From 8c6afc14e09df355a6da61c1600f33c64ef1558e Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Mon, 30 Jul 2018 21:31:33 +0800 Subject: [PATCH 1/2] =?UTF-8?q?commit=20changes=20from=20=E4=B9=9D?= =?UTF-8?q?=E4=B8=87=E9=87=8C=E8=80=8C=E5=8D=97=E4=B8=BA,=20Jul=2018?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cocos/1.x/CocosArmatureComponent-new.ts | 631 + Cocos/1.x/out/dragonBones.d.ts | 13101 +++---- Cocos/1.x/out/dragonBones.js | 32626 ++++++++-------- Cocos/1.x/out/dragonBones.min.js | 2 +- Cocos/1.x/package-lock.json | 36 + .../cocos/CocosArmatureComponent.ts | 116 +- Cocos/Demos/assets/DragonBones.meta | 5 + Cocos/Demos/assets/DragonBones/Dragon.meta | 5 + .../DragonBones/Dragon/Dragon_1_ske.json | 1 + .../DragonBones/Dragon/Dragon_1_ske.json.meta | 5 + .../DragonBones/Dragon/Dragon_1_tex.json | 1 + .../DragonBones/Dragon/Dragon_1_tex.json.meta | 7 + .../DragonBones/Dragon/Dragon_1_tex.png | Bin 0 -> 159196 bytes .../DragonBones/Dragon/Dragon_1_tex.png.meta | 30 + Cocos/Demos/assets/Prefab.meta | 5 + Cocos/Demos/assets/Prefab/Canvas.prefab | 216 + Cocos/Demos/assets/Prefab/Canvas.prefab.meta | 6 + Cocos/Demos/assets/Scene/Own.meta | 5 + Cocos/Demos/assets/Scene/Own/TestScene.fire | 4704 +++ .../assets/Scene/Own/TestScene.fire.meta | 7 + Cocos/Demos/assets/Script/Own.meta | 5 + .../Demos/assets/Script/Own/ReplaceNotify.ts | 101 + .../assets/Script/Own/ReplaceNotify.ts.meta | 9 + .../dragonbones/assets/dragonBones.js | 578 +- Cocos/README.md | 6 - 25 files changed, 29156 insertions(+), 23052 deletions(-) create mode 100755 Cocos/1.x/CocosArmatureComponent-new.ts mode change 100644 => 100755 Cocos/1.x/out/dragonBones.d.ts mode change 100644 => 100755 Cocos/1.x/out/dragonBones.js mode change 100644 => 100755 Cocos/1.x/out/dragonBones.min.js create mode 100755 Cocos/1.x/package-lock.json mode change 100644 => 100755 Cocos/1.x/src/dragonBones/cocos/CocosArmatureComponent.ts create mode 100755 Cocos/Demos/assets/DragonBones.meta create mode 100755 Cocos/Demos/assets/DragonBones/Dragon.meta create mode 100755 Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json create mode 100755 Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json.meta create mode 100755 Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json create mode 100755 Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json.meta create mode 100755 Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.png create mode 100755 Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.png.meta create mode 100755 Cocos/Demos/assets/Prefab.meta create mode 100755 Cocos/Demos/assets/Prefab/Canvas.prefab create mode 100755 Cocos/Demos/assets/Prefab/Canvas.prefab.meta create mode 100755 Cocos/Demos/assets/Scene/Own.meta create mode 100755 Cocos/Demos/assets/Scene/Own/TestScene.fire create mode 100755 Cocos/Demos/assets/Scene/Own/TestScene.fire.meta create mode 100755 Cocos/Demos/assets/Script/Own.meta create mode 100755 Cocos/Demos/assets/Script/Own/ReplaceNotify.ts create mode 100755 Cocos/Demos/assets/Script/Own/ReplaceNotify.ts.meta delete mode 100644 Cocos/README.md diff --git a/Cocos/1.x/CocosArmatureComponent-new.ts b/Cocos/1.x/CocosArmatureComponent-new.ts new file mode 100755 index 00000000..2806d03d --- /dev/null +++ b/Cocos/1.x/CocosArmatureComponent-new.ts @@ -0,0 +1,631 @@ +/** + * 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 DefaultArmaturesEnum = cc.Enum({ 'default': -1 }); +var DefaultAnimsEnum = cc.Enum({ '': 0 }); + +function setEnumAttr(obj, propName, enumDef) { + cc.Class.attr(obj, propName, { + type: 'Enum', + enumList: cc.Enum.getList(enumDef) + }); +} + +namespace dragonBones { + // const _defaultItems = cc.Enum({ "None": -1 }); + // function _setItems(object: any, key: string, items: any) { + // (cc.Class as any).attr( // creator.d.ts error. + // object, + // key, + // { + // type: "Enum", + // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. + // } + // ); + // } + + const { + ccclass, + property, + executeInEditMode, + disallowMultiple, + playOnFocus, + menu, + help, + } = cc._decorator; + /** + * @see dragonBones.IArmatureProxy + */ + @ccclass("CocosArmatureComponent") + @executeInEditMode + @disallowMultiple + @playOnFocus + @menu("DragonBones/Armature") + @executeInEditMode + @help("https://github.com/DragonBones/") + export class CocosArmatureComponent extends cc._RendererUnderSG { //implements IArmatureProxy + @property({ + type: dragonBones.CocosFactory, + serializable: false, + }) + _factory: dragonBones.CocosFactory | null = null; + + @property({ + type: dragonBones.DragonBonesData, + serializable: false, + }) + _dragonBonesData: dragonBones.DragonBonesData | null = null, + + /** + * !#en + * The DragonBones data contains the armatures information (bind pose bones, slots, draw order, + * attachments, skins, etc) and animations but does not hold any state.
+ * Multiple ArmatureDisplay can share the same DragonBones data. + * !#zh + * 骨骼数据包含了骨骼信息(绑定骨骼动作,slots,渲染顺序, + * attachments,皮肤等等)和动画但不持有任何状态。
+ * 多个 ArmatureDisplay 可以共用相同的骨骼数据。 + * @property {DragonBonesAsset} dragonAsset + */ + @property({ + type: dragonBones.DragonBonesAsset, + notify: function () { + // parse the asset data + this._parseDragonAsset(); + + this._refresh(); + if (CC_EDITOR) { + this._defaultArmatureIndex = 0; + this._animationIndex = 0; + } + }, + tooltip: 'dragonAsset' + }) + dragonAsset: dragonBones.DragonBonesAsset = null; + + /** + * !#en + * The atlas asset for the DragonBones. + * !#zh + * 骨骼数据所需的 Atlas Texture 数据。 + * @property {DragonBonesAtlasAsset} dragonAtlasAsset + */ + @property({ + type: dragonBones.DragonBonesAtlasAsset, + notify: function () { + // parse the atlas asset data + this._parseDragonAtlasAsset(); + this._refreshSgNode(); + }, + tooltip: 'dragonAtlasAsset' + }) + dragonAtlasAsset: dragonBones.DragonBonesAtlasAsset = null; + + @property + _armatureName: ''; + /** + * !#en The name of current armature. + * !#zh 当前的 Armature 名称。 + * @property {String} armatureName + */ + @property({ + type: cc.String, + visible: false + }) + get armatureName() { + return this._armatureName; + } + set armatureName(value) { + this._armatureName = value; + var animNames = this.getAnimationNames(this._armatureName); + if (!this.animationName || animNames.indexOf(this.animationName) < 0) { + if (CC_EDITOR) { + this.animationName = animNames[0]; + } + else { + // Not use default animation name at runtime + this.animationName = ''; + } + } + this._refresh(); + } + + @property(cc.String) + _animationName: string = ''; + /** + * !#en The name of current playing animation. + * !#zh 当前播放的动画名称。 + * @property {String} animationName + */ + @property({ + type: cc.String, + visible: false + }) + get animationName() { + return this._animationName; + } + set animationName(value: string) { + this._animationName = value; + } + + /** + * @property {Number} _defaultArmatureIndex + */ + @property + _defaultArmatureIndex: number = 0; + @property({ + type: DefaultArmaturesEnum, + visible: true, + editorOnly: true, + displayName: "Armature", + tooltip: 'Armature Enum' + }) + get defaultArmatureIndex() { + return this._defaultArmatureIndex; + } + set defaultArmatureIndex(value: number) { + this._defaultArmatureIndex = value; + var armatureName = ''; + if (this.dragonAsset) { + var armaturesEnum; + if (this.dragonAsset) { + armaturesEnum = this.dragonAsset.getArmatureEnum(); + } + if (!armaturesEnum) { + return cc.errorID(7400, this.name); + } + + armatureName = armaturesEnum[this._defaultArmatureIndex]; + } + + if (armatureName !== undefined) { + this.armatureName = armatureName; + } + else { + cc.errorID(7401, this.name); + } + } + + // value of 0 represents no animation + @property + _animationIndex: number = 0; + @property({ + type: DefaultAnimsEnum, + visible: true, + editorOnly: true, + displayName: 'Animation', + tooltip: 'Animation Enum' + }) + get animationIndex() { + return this._animationIndex; + } + set animationIndex(value: number) { + this._animationIndex = value; + if (this._animationIndex === 0) { + this.animationName = ''; + return; + } + + var animsEnum; + if (this.dragonAsset) { + animsEnum = this.dragonAsset.getAnimsEnum(this.armatureName); + } + + if (!animsEnum) { + return; + } + + var animName = animsEnum[this._animationIndex]; + if (animName !== undefined) { + this.animationName = animName; + } + else { + cc.errorID(7402, this.name); + } + } + + /** + * !#en The time scale of this armature. + * !#zh 当前骨骼中所有动画的时间缩放率。 + * @property {Number} timeScale + * @default 1 + */ + @property + _timeScale: number = 1; + @property({ + type: Number, + tooltip: 'Time Scale' + }) + get timeScale() { + return this._timeScale; + } + set timeScale(value: number) { + this._timeScale = value; + if (this._sgNode) { + this._sgNode.animation().timeScale = this.timeScale; + } + } + + /** + * !#en The play times of the default animation. + * -1 means using the value of config file; + * 0 means repeat for ever + * >0 means repeat times + * !#zh 播放默认动画的循环次数 + * -1 表示使用配置文件中的默认值; + * 0 表示无限循环 + * >0 表示循环次数 + * @property {Number} playTimes + * @default -1 + */ + @property({ + type: Number, + tooltip: 'Play Times' + }) + playTimes: number = -1; + + /** + * !#en Indicates whether open debug bones. + * !#zh 是否显示 bone 的 debug 信息。 + * @property {Boolean} debugBones + * @default false + */ + @property + _debugBones: boolean = false; + @property({ + editorOnly: true, + tooltip: 'DebugBones' + }) + get debugBones() { + return this._debugBones; + } + set debugBones(value: boolean) { + this._debugBones = value; + if (this._sgNode) { + this._sgNode.setDebugBones(this.debugBones); + } + } + + + + // IMPLEMENT + ctor() { + if (CC_JSB) { + // TODO Fix me + // If using the getFactory in JSB. + // There may be throw errors when close the application. + this._factory = new dragonBones.CocosFactory(); + } else { + this._factory = dragonBones.CocosFactory.factory; + } + } + + __preload() { + this._parseDragonAsset(); + this._parseDragonAtlasAsset(); + this._refresh(); + } + + _createSgNode() { + if (this.dragonAsset && this.dragonAtlasAsset && this.armatureName) { + return this._factory.buildArmatureDisplay(this.armatureName, this._dragonBonesData.name); + } + return null; + } + + _initSgNode() { + // set the time scale + var sgNode = this._sgNode; + sgNode.animation().timeScale = this.timeScale; + + if (this.animationName) { + this.playAnimation(this.animationName, this.playTimes); + } + + if (CC_EDITOR) { + sgNode.setDebugBones(this.debugBones); + } + } + + _removeSgNode() { + var sgNode = this._sgNode; + this._super(); + if (sgNode) { + sgNode.armature().dispose(); + } + } + + _parseDragonAsset() { + if (this.dragonAsset) { + if (CC_JSB) { + // The '_factory' create a new one every time in JSB, they can't use getDragonBonesData + // to get cached data, and only parse data every time + this._dragonBonesData = this._factory.parseDragonBonesData(this.dragonAsset.dragonBonesJson); + } + else { + var jsonObj = JSON.parse(this.dragonAsset.dragonBonesJson); + var data = this._factory.getDragonBonesData(jsonObj.name); + if (data) { + // already added asset + var armature, dragonBonesData; + for (var i = 0, len = jsonObj.armature.length; i < len; i++) { + armature = jsonObj.armature[i]; + if (!data.armatures[armature.name]) { + //add new armature + if (!dragonBonesData) { + dragonBonesData = this._factory._dataParser.parseDragonBonesData(jsonObj); + } + data.addArmature(dragonBonesData.armatures[armature.name]); + } + } + this._dragonBonesData = data; + return; + } + this._dragonBonesData = this._factory.parseDragonBonesData(jsonObj); + } + } + } + + _parseDragonAtlasAsset() { + if (this.dragonAtlasAsset) { + if (CC_JSB) { + // TODO parse the texture atlas data from json string & texture path + this._factory.parseTextureAtlasData(this.dragonAtlasAsset.atlasJson, this.dragonAtlasAsset.texture); + } + else { + var atlasJsonObj = JSON.parse(this.dragonAtlasAsset.atlasJson); + var atlasName = atlasJsonObj.name; + var existedAtlasData = null; + var atlasDataList = this._factory.getTextureAtlasData(atlasName); + var texturePath = this.dragonAtlasAsset.texture; + if (atlasDataList && atlasDataList.length > 0) { + for (var idx in atlasDataList) { + var data = atlasDataList[idx]; + if (data && data.texture && data.texture.url === texturePath) { + existedAtlasData = data; + break; + } + } + } + + var texture = cc.textureCache.getTextureForKey(texturePath); + if (existedAtlasData) { + existedAtlasData.texture = texture; + } + else { + this._factory.parseTextureAtlasData(atlasJsonObj, texture); + } + } + } + } + + _refreshSgNode() { + var self = this; + + // discard exists sgNode + var listenersBefore = null, listenersCacheBefore = null; + if (self._sgNode) { + listenersBefore = self._sgNode._bubblingListeners; // get the listeners added before + listenersCacheBefore = self._sgNode._hasListenerCache; + if (self.node._sizeProvider === self._sgNode) { + self.node._sizeProvider = null; + } + self._removeSgNode(); + self._sgNode = null; + } + + // recreate sgNode... + var sgNode = self._sgNode = self._createSgNode(); + if (sgNode) { + if (CC_JSB) { + sgNode.retain(); + } + if (!self.enabledInHierarchy) { + sgNode.setVisible(false); + } + + if (listenersBefore) { + sgNode._bubblingListeners = listenersBefore; // using the listeners added before + sgNode._hasListenerCache = listenersCacheBefore; + if (CC_JSB && !sgNode.hasEventCallback()) { + // In JSB, should set event callback of the new sgNode + // to make the listeners work well. + sgNode.setEventCallback(function (eventObject) { + sgNode.emit(eventObject.type, eventObject); + }); + } + } + + self._initSgNode(); + self._appendSgNode(sgNode); + self._registSizeProvider(); + } + } + + _refresh() { + this._refreshSgNode(); + + if (CC_EDITOR) { + // update inspector + this._updateArmatureEnum(); + this._updateAnimEnum(); + Editor.Utils.refreshSelectedInspector('node', this.node.uuid); + } + } + + // update animation list for editor + _updateAnimEnum() { + var animEnum; + if (this.dragonAsset) { + animEnum = this.dragonAsset.getAnimsEnum(this.armatureName); + } + // change enum + setEnumAttr(this, '_animationIndex', animEnum || DefaultAnimsEnum); + } + + // update armature list for editor + _updateArmatureEnum() { + var armatureEnum; + if (this.dragonAsset) { + armatureEnum = this.dragonAsset.getArmatureEnum(); + } + // change enum + setEnumAttr(this, '_defaultArmatureIndex', armatureEnum || DefaultArmaturesEnum); + } + + /** + * !#en + * Play the specified animation. + * Parameter animName specify the animation name. + * Parameter playTimes specify the repeat times of the animation. + * -1 means use the value of the config file. + * 0 means play the animation for ever. + * >0 means repeat times. + * !#zh + * 播放指定的动画. + * animName 指定播放动画的名称。 + * playTimes 指定播放动画的次数。 + * -1 为使用配置文件中的次数。 + * 0 为无限循环播放。 + * >0 为动画的重复次数。 + * @method playAnimation + * @param {String} animName + * @param {Number} playTimes + * @return {dragonBones.AnimationState} + */ + playAnimation(animName, playTimes) { + if (this._sgNode) { + this.playTimes = (playTimes === undefined) ? -1 : playTimes; + this.animationName = animName; + return this._sgNode.animation().play(animName, this.playTimes); + } + + return null; + } + + /** + * !#en + * Get the all armature names in the DragonBones Data. + * !#zh + * 获取 DragonBones 数据中所有的 armature 名称 + * @method getArmatureNames + * @returns {Array} + */ + getArmatureNames() { + if (this._dragonBonesData) { + return this._dragonBonesData.armatureNames; + } + + return []; + } + + /** + * !#en + * Get the all animation names of specified armature. + * !#zh + * 获取指定的 armature 的所有动画名称。 + * @method getAnimationNames + * @param {String} armatureName + * @returns {Array} + */ + getAnimationNames(armatureName) { + var ret = []; + if (this._dragonBonesData) { + var armatureData = this._dragonBonesData.getArmature(armatureName); + if (armatureData) { + for (var animName in armatureData.animations) { + if (armatureData.animations.hasOwnProperty(animName)) { + ret.push(animName); + } + } + } + } + + return ret; + } + + /** + * !#en + * Add event listener for the DragonBones Event. + * !#zh + * 添加 DragonBones 事件监听器。 + * @method addEventListener + * @param {dragonBones.EventObject} eventType + * @param {function} listener + * @param {Object} target + */ + addEventListener(eventType, listener, target) { + if (this._sgNode) { + this._sgNode.addEvent(eventType, listener, target); + } + } + + /** + * !#en + * Remove the event listener for the DragonBones Event. + * !#zh + * 移除 DragonBones 事件监听器。 + * @method removeEventListener + * @param {dragonBones.EventObject} eventType + * @param {function} listener + * @param {Object} target + */ + removeEventListener(eventType, listener, target) { + if (this._sgNode) { + this._sgNode.removeEvent(eventType, listener, target); + } + } + + /** + * !#en + * Build the armature for specified name. + * !#zh + * 构建指定名称的 armature 对象 + * @method buildArmature + * @param {String} armatureName + * @return {dragonBones.Armature} + */ + buildArmatures(armatureName) { + if (this._factory) { + return this._factory.buildArmature(armatureName); + } + + return null; + } + /** + * !#en + * Get the current armature object of the ArmatureDisplay. + * !#zh + * 获取 ArmatureDisplay 当前使用的 Armature 对象 + * @method armature + * @returns {Object} + */ + armature() { + if (this._sgNode) { + return this._sgNode.armature(); + } + + return null; + } + } +} \ No newline at end of file diff --git a/Cocos/1.x/out/dragonBones.d.ts b/Cocos/1.x/out/dragonBones.d.ts old mode 100644 new mode 100755 index 4bbb97be..a4919c90 --- a/Cocos/1.x/out/dragonBones.d.ts +++ b/Cocos/1.x/out/dragonBones.d.ts @@ -1,6547 +1,6554 @@ -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - const enum BinaryOffset { - WeigthBoneCount = 0, - WeigthFloatOffset = 1, - WeigthBoneIndices = 2, - GeometryVertexCount = 0, - GeometryTriangleCount = 1, - GeometryFloatOffset = 2, - GeometryWeightOffset = 3, - GeometryVertexIndices = 4, - TimelineScale = 0, - TimelineOffset = 1, - TimelineKeyFrameCount = 2, - TimelineFrameValueCount = 3, - TimelineFrameValueOffset = 4, - TimelineFrameOffset = 5, - FramePosition = 0, - FrameTweenType = 1, - FrameTweenEasingOrCurveSampleCount = 2, - FrameCurveSamples = 3, - DeformVertexOffset = 0, - DeformCount = 1, - DeformValueCount = 2, - DeformValueOffset = 3, - DeformFloatOffset = 4, - } - /** - * @private - */ - const enum ArmatureType { - Armature = 0, - MovieClip = 1, - Stage = 2, - } - /** - * @private - */ - const enum BoneType { - Bone = 0, - Surface = 1, - } - /** - * @private - */ - const enum DisplayType { - Image = 0, - Armature = 1, - Mesh = 2, - BoundingBox = 3, - Path = 4, - } - /** - * - Bounding box type. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框类型。 - * @version DragonBones 5.0 - * @language zh_CN - */ - const enum BoundingBoxType { - Rectangle = 0, - Ellipse = 1, - Polygon = 2, - } - /** - * @private - */ - const enum ActionType { - Play = 0, - Frame = 10, - Sound = 11, - } - /** - * @private - */ - const enum BlendMode { - Normal = 0, - Add = 1, - Alpha = 2, - Darken = 3, - Difference = 4, - Erase = 5, - HardLight = 6, - Invert = 7, - Layer = 8, - Lighten = 9, - Multiply = 10, - Overlay = 11, - Screen = 12, - Subtract = 13, - } - /** - * @private - */ - const enum TweenType { - None = 0, - Line = 1, - Curve = 2, - QuadIn = 3, - QuadOut = 4, - QuadInOut = 5, - } - /** - * @private - */ - const enum TimelineType { - Action = 0, - ZOrder = 1, - BoneAll = 10, - BoneTranslate = 11, - BoneRotate = 12, - BoneScale = 13, - Surface = 50, - BoneAlpha = 60, - SlotDisplay = 20, - SlotColor = 21, - SlotDeform = 22, - SlotZIndex = 23, - SlotAlpha = 24, - IKConstraint = 30, - AnimationProgress = 40, - AnimationWeight = 41, - AnimationParameter = 42, - } - /** - * - Offset mode. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 偏移模式。 - * @version DragonBones 5.5 - * @language zh_CN - */ - const enum OffsetMode { - None = 0, - Additive = 1, - Override = 2, - } - /** - * - Animation fade out mode. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出模式。 - * @version DragonBones 4.5 - * @language zh_CN - */ - const enum AnimationFadeOutMode { - /** - * - Fade out the animation states of the same layer. - * @language en_US - */ - /** - * - 淡出同层的动画状态。 - * @language zh_CN - */ - SameLayer = 1, - /** - * - Fade out the animation states of the same group. - * @language en_US - */ - /** - * - 淡出同组的动画状态。 - * @language zh_CN - */ - SameGroup = 2, - /** - * - Fade out the animation states of the same layer and group. - * @language en_US - */ - /** - * - 淡出同层并且同组的动画状态。 - * @language zh_CN - */ - SameLayerAndGroup = 3, - /** - * - Fade out of all animation states. - * @language en_US - */ - /** - * - 淡出所有的动画状态。 - * @language zh_CN - */ - All = 4, - /** - * - Does not replace the animation state with the same name. - * @language en_US - */ - /** - * - 不替换同名的动画状态。 - * @language zh_CN - */ - Single = 5, - } - /** - * @private - */ - const enum AnimationBlendType { - None = 0, - E1D = 1, - } - /** - * @private - */ - const enum AnimationBlendMode { - Additive = 0, - Override = 1, - } - /** - * @private - */ - const enum ConstraintType { - IK = 0, - Path = 1, - } - /** - * @private - */ - const enum PositionMode { - Fixed = 0, - Percent = 1, - } - /** - * @private - */ - const enum SpacingMode { - Length = 0, - Fixed = 1, - Percent = 2, - } - /** - * @private - */ - const enum RotateMode { - Tangent = 0, - Chain = 1, - ChainScale = 2, - } - /** - * @private - */ - interface Map { - [key: string]: T; - } - /** - * @private - */ - class DragonBones { - static readonly VERSION: string; - static yDown: boolean; - static debug: boolean; - static debugDraw: boolean; - private readonly _clock; - private readonly _events; - private readonly _objects; - private _eventManager; - constructor(eventManager: IEventDispatcher); - advanceTime(passedTime: number): void; - bufferEvent(value: EventObject): void; - bufferObject(object: BaseObject): void; - readonly clock: WorldClock; - readonly eventManager: IEventDispatcher; - } -} -declare var __extends: any; -declare var exports: any; -declare var module: any; -declare var define: any; -/** - * 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. - */ -declare namespace 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 - */ - abstract class BaseObject { - private static _hashCode; - private static _defaultMaxCount; - private static readonly _maxCountMap; - private static readonly _poolsMap; - private static _returnObject(object); - static toString(): string; - /** - * - 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 - */ - static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; - /** - * - 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 - */ - static clearPool(objectConstructor?: (typeof BaseObject) | null): void; - /** - * - 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 - */ - static borrowObject(objectConstructor: { - new (): T; - }): T; - /** - * - A unique identification number assigned to the object. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分配给此实例的唯一标识号。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly hashCode: number; - private _isInPool; - protected abstract _onClear(): void; - /** - * - Clear the object and return it back to object pool。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除该实例的所有数据并将其返还对象池。 - * @version DragonBones 4.5 - * @language zh_CN - */ - returnToPool(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - 2D Transform matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 转换矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Matrix { - /** - * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - a: number; - /** - * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - b: number; - /** - * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - c: number; - /** - * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - d: number; - /** - * - The distance by which to translate each point along the x axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 x 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - tx: number; - /** - * - The distance by which to translate each point along the y axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 y 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - ty: number; - /** - * @private - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Matrix): Matrix; - /** - * @private - */ - copyFromArray(value: Array, offset?: number): Matrix; - /** - * - 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 - */ - identity(): Matrix; - /** - * - 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 - */ - concat(value: Matrix): Matrix; - /** - * - Convert to inverse matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为逆矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - invert(): Matrix; - /** - * - 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 - */ - transformPoint(x: number, y: number, result: { - x: number; - y: number; - }, delta?: boolean): void; - /** - * @private - */ - transformRectangle(rectangle: { - x: number; - y: number; - width: number; - height: number; - }, delta?: boolean): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - 2D Transform. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 变换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Transform { - /** - * @private - */ - static readonly PI: number; - /** - * @private - */ - static readonly PI_D: number; - /** - * @private - */ - static readonly PI_H: number; - /** - * @private - */ - static readonly PI_Q: number; - /** - * @private - */ - static readonly RAD_DEG: number; - /** - * @private - */ - static readonly DEG_RAD: number; - /** - * @private - */ - static normalizeRadian(value: number): number; - /** - * - Horizontal translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - Vertical translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - Skew. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 倾斜。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - skew: number; - /** - * - rotation. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - rotation: number; - /** - * - Horizontal Scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleX: number; - /** - * - Vertical scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleY: number; - /** - * @private - */ - constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Transform): Transform; - /** - * @private - */ - identity(): Transform; - /** - * @private - */ - add(value: Transform): Transform; - /** - * @private - */ - minus(value: Transform): Transform; - /** - * @private - */ - fromMatrix(matrix: Matrix): Transform; - /** - * @private - */ - toMatrix(matrix: Matrix): Transform; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class ColorTransform { - alphaMultiplier: number; - redMultiplier: number; - greenMultiplier: number; - blueMultiplier: number; - alphaOffset: number; - redOffset: number; - greenOffset: number; - blueOffset: number; - constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); - copyFrom(value: ColorTransform): void; - identity(): void; - } -} -/** - * 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. - */ -declare namespace 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 - */ - class Point { - /** - * - The horizontal coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的水平坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The vertical coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的垂直坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - 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 - */ - constructor(x?: number, y?: number); - /** - * @private - */ - copyFrom(value: Point): void; - /** - * @private - */ - clear(): void; - } -} -/** - * 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. - */ -declare namespace 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.
- * 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) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Rectangle { - /** - * - The x coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 x 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The y coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 y 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - The width of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形的宽度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - width: number; - /** - * - 矩形的高度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - The height of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - height: number; - /** - * @private - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * @private - */ - copyFrom(value: Rectangle): void; - /** - * @private - */ - clear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The user custom data. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 用户自定义数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - class UserData extends BaseObject { - static toString(): string; - /** - * - The custom int numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly ints: Array; - /** - * - The custom float numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly floats: Array; - /** - * - The custom strings. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly strings: Array; - protected _onClear(): void; - /** - * - Get the custom int number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getInt(index?: number): number; - /** - * - Get the custom float number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getFloat(index?: number): number; - /** - * - Get the custom string. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getString(index?: number): string; - } - /** - * @private - */ - class ActionData extends BaseObject { - static toString(): string; - type: ActionType; - name: string; - bone: BoneData | null; - slot: SlotData | null; - data: UserData | null; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace 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 - */ - class DragonBonesData extends BaseObject { - static toString(): string; - /** - * @private - */ - autoSearch: boolean; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧频。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * - The data version. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 数据版本。 - * @version DragonBones 3.0 - * @language zh_CN - */ - version: string; - /** - * - The DragonBones data name. - * The name is consistent with the DragonBones project name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据名称。 - * 该名称与龙骨项目名保持一致。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - stage: ArmatureData | null; - /** - * - All armature data names. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armatureNames: Array; - /** - * @private - */ - readonly armatures: Map; - /** - * @private - */ - userData: UserData | null; - protected _onClear(): void; - /** - * - 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 - */ - getArmature(armatureName: string): ArmatureData | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class ArmatureData extends BaseObject { - static toString(): string; - /** - * @private - */ - type: ArmatureType; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧率。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * @private - */ - scale: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly aabb: Rectangle; - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationNames: Array; - /** - * @private - */ - readonly sortedBones: Array; - /** - * @private - */ - readonly sortedSlots: Array; - /** - * @private - */ - readonly defaultActions: Array; - /** - * @private - */ - readonly actions: Array; - /** - * @private - */ - readonly bones: Map; - /** - * @private - */ - readonly slots: Map; - /** - * @private - */ - readonly constraints: Map; - /** - * @private - */ - readonly skins: Map; - /** - * @private - */ - readonly animations: Map; - /** - * - The default skin data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认插槽数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultSkin: SkinData | null; - /** - * - The default animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultAnimation: AnimationData | null; - /** - * @private - */ - canvas: CanvasData | null; - /** - * @private - */ - userData: UserData | null; - /** - * @private - */ - parent: DragonBonesData; - protected _onClear(): void; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(boneName: string): BoneData | null; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(slotName: string): SlotData | null; - /** - * @private - */ - getConstraint(constraintName: string): ConstraintData | null; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSkin(skinName: string): SkinData | null; - /** - * @private - */ - getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getAnimation(animationName: string): AnimationData | null; - } - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class BoneData extends BaseObject { - static toString(): string; - /** - * @private - */ - inheritTranslation: boolean; - /** - * @private - */ - inheritRotation: boolean; - /** - * @private - */ - inheritScale: boolean; - /** - * @private - */ - inheritReflection: boolean; - /** - * @private - */ - type: BoneType; - /** - * - The bone length. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼长度。 - * @version DragonBones 3.0 - * @language zh_CN - */ - length: number; - /** - * @private - */ - alpha: number; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly transform: Transform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData | null; - protected _onClear(): void; - } - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SlotData extends BaseObject { - static toString(): string; - /** - * @private - */ - blendMode: BlendMode; - /** - * @private - */ - displayIndex: number; - /** - * @private - */ - zOrder: number; - /** - * @private - */ - zIndex: number; - /** - * @private - */ - alpha: number; - /** - * - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - color: ColorTransform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class CanvasData extends BaseObject { - static toString(): string; - hasBackground: boolean; - color: number; - x: number; - y: number; - width: number; - height: number; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SkinData extends BaseObject { - static toString(): string; - /** - * - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly displays: Map>; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @private - */ - getDisplay(slotName: string, displayName: string): DisplayData | null; - /** - * @private - */ - getDisplays(slotName: string): Array | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - abstract class ConstraintData extends BaseObject { - order: number; - name: string; - type: ConstraintType; - target: BoneData; - root: BoneData; - bone: BoneData | null; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class GeometryData { - isShared: boolean; - inheritDeform: boolean; - offset: number; - data: DragonBonesData; - weight: WeightData | null; - clear(): void; - shareFrom(value: GeometryData): void; - readonly vertexCount: number; - readonly triangleCount: number; - } - /** - * @private - */ - abstract class DisplayData extends BaseObject { - type: DisplayType; - name: string; - path: string; - readonly transform: Transform; - parent: SkinData; - protected _onClear(): void; - } - /** - * @private - */ - class ImageDisplayData extends DisplayData { - static toString(): string; - readonly pivot: Point; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @private - */ - class ArmatureDisplayData extends DisplayData { - static toString(): string; - inheritAnimation: boolean; - readonly actions: Array; - armature: ArmatureData | null; - protected _onClear(): void; - /** - * @private - */ - addAction(value: ActionData): void; - } - /** - * @private - */ - class MeshDisplayData extends DisplayData { - static toString(): string; - readonly geometry: GeometryData; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @private - */ - class BoundingBoxDisplayData extends DisplayData { - static toString(): string; - boundingBox: BoundingBoxData | null; - protected _onClear(): void; - } - /** - * @private - */ - class PathDisplayData extends DisplayData { - static toString(): string; - closed: boolean; - constantSpeed: boolean; - readonly geometry: GeometryData; - readonly curveLengths: Array; - protected _onClear(): void; - } - /** - * @private - */ - class WeightData extends BaseObject { - static toString(): string; - count: number; - offset: number; - readonly bones: Array; - protected _onClear(): void; - addBone(value: BoneData): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract class BoundingBoxData extends BaseObject { - /** - * - The bounding box type. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框类型。 - * @version DragonBones 5.0 - * @language zh_CN - */ - type: BoundingBoxType; - /** - * @private - */ - color: number; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - protected _onClear(): void; - /** - * - Check whether the bounding box contains a specific point. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否包含特定点。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract containsPoint(pX: number, pY: number): boolean; - /** - * - Check whether the bounding box intersects a specific segment. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否与特定线段相交。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { - x: number; - y: number; - } | null, intersectionPointB: { - x: number; - y: number; - } | null, normalRadians: { - x: number; - y: number; - } | null): number; - } - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class RectangleBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - private static _computeOutCode(x, y, xMin, yMin, xMax, yMax); - /** - * @private - */ - static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class EllipseBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class PolygonBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * @private - */ - x: number; - /** - * @private - */ - y: number; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly vertices: Array; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationData extends BaseObject { - static toString(): string; - /** - * @private - */ - blendType: AnimationBlendType; - /** - * - The frame count of the animation. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的帧数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameCount: number; - /** - * - The play times of the animation. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The duration of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的持续时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - duration: number; - /** - * @private - */ - scale: number; - /** - * - The fade in time of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的淡入时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * - The animation name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly cachedFrames: Array; - /** - * @private - */ - readonly boneTimelines: Map>; - /** - * @private - */ - readonly slotTimelines: Map>; - /** - * @private - */ - readonly constraintTimelines: Map>; - /** - * @private - */ - readonly animationTimelines: Map>; - /** - * @private - */ - readonly boneCachedFrameIndices: Map>; - /** - * @private - */ - readonly slotCachedFrameIndices: Map>; - /** - * @private - */ - actionTimeline: TimelineData | null; - /** - * @private - */ - zOrderTimeline: TimelineData | null; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @private - */ - addBoneTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - addSlotTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - addConstraintTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - addAnimationTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - getBoneTimelines(timelineName: string): Array | null; - /** - * @private - */ - getSlotTimelines(timelineName: string): Array | null; - /** - * @private - */ - getConstraintTimelines(timelineName: string): Array | null; - /** - * @private - */ - getAnimationTimelines(timelineName: string): Array | null; - /** - * @private - */ - getBoneCachedFrameIndices(boneName: string): Array | null; - /** - * @private - */ - getSlotCachedFrameIndices(slotName: string): Array | null; - } - /** - * @private - */ - class TimelineData extends BaseObject { - static toString(): string; - type: TimelineType; - offset: number; - frameIndicesOffset: number; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - class AnimationConfig extends BaseObject { - static toString(): string; - /** - * @private - */ - pauseFadeOut: boolean; - /** - * - Fade out the pattern of other animation states when the animation state is fade in. - * This property is typically used to specify the substitution of multiple animation states blend. - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入动画状态时淡出其他动画状态的模式。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeOutMode: AnimationFadeOutMode; - /** - * @private - */ - fadeOutTweenType: TweenType; - /** - * @private - */ - fadeOutTime: number; - /** - * @private - */ - pauseFadeIn: boolean; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additive: boolean; - /** - * - Whether the animation state has control over the display property of the slots. - * Sometimes blend a animation state does not want it to control the display properties of the slots, - * especially if other animation state are controlling the display properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * @private - */ - fadeInTweenType: TweenType; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The start time of play. (In seconds) - * @default 0.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的开始时间。 (以秒为单位) - * @default 0.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - position: number; - /** - * - The duration of play. - * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的持续时间。 - * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - duration: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - weight: number; - /** - * - The fade in time. - * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入时间。 - * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The animation data name. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画数据名称。 - * @version DragonBones 5.0 - * @language zh_CN - */ - animation: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - /** - * @private - */ - readonly boneMask: Array; - protected _onClear(): void; - /** - * @private - */ - clear(): void; - /** - * @private - */ - copyFrom(value: AnimationConfig): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class TextureAtlasData extends BaseObject { - /** - * @private - */ - autoSearch: boolean; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - /** - * @private - */ - scale: number; - /** - * - The texture atlas name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * - The image path of the texture atlas. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集图片路径。 - * @version DragonBones 3.0 - * @language zh_CN - */ - imagePath: string; - /** - * @private - */ - readonly textures: Map; - protected _onClear(): void; - /** - * @private - */ - copyFrom(value: TextureAtlasData): void; - /** - * @private - */ - getTexture(textureName: string): TextureData | null; - } - /** - * @private - */ - abstract class TextureData extends BaseObject { - static createRectangle(): Rectangle; - rotated: boolean; - name: string; - readonly region: Rectangle; - parent: TextureAtlasData; - frame: Rectangle | null; - protected _onClear(): void; - copyFrom(value: TextureData): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The armature proxy interface, the docking engine needs to implement it concretely. - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 骨架代理接口,对接的引擎需要对其进行具体实现。 - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language zh_CN - */ - interface IArmatureProxy extends IEventDispatcher { - /** - * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 释放该实例和骨架。 (骨架会回收到对象池) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - dispose(disposeProxy: boolean): void; - /** - * - The armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armature: Armature; - /** - * - The animation player. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - class Armature extends BaseObject implements IAnimatable { - static toString(): string; - private static _onSortSlots(a, b); - /** - * - Whether to inherit the animation control of the parent armature. - * True to try to have the child armature play an animation with the same name when the parent armature play the animation. - * @default true - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 是否继承父骨架的动画控制。 - * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 - * @default true - * @version DragonBones 4.5 - * @language zh_CN - */ - inheritAnimation: boolean; - /** - * @private - */ - userData: any; - private _slotsDirty; - private _zOrderDirty; - private _flipX; - private _flipY; - private _alpha; - private readonly _bones; - private readonly _slots; - private readonly _actions; - private _animation; - private _proxy; - private _display; - private _replacedTexture; - private _clock; - protected _onClear(): void; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - dispose(): void; - /** - * @inheritDoc - */ - advanceTime(passedTime: number): void; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): Slot | null; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): Slot | null; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(name: string): Bone | null; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBoneByDisplay(display: any): Bone | null; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(name: string): Slot | null; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlotByDisplay(display: any): Slot | null; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBones(): Array; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlots(): Array; - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipX: boolean; - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipY: boolean; - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - cacheFrameRate: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armatureData: ArmatureData; - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - /** - * @pivate - */ - readonly proxy: IArmatureProxy; - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly eventDispatcher: IEventDispatcher; - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly display: any; - /** - * @private - */ - replacedTexture: any; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly parent: Slot | null; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - abstract class TransformObject extends BaseObject { - protected static readonly _helpMatrix: Matrix; - protected static readonly _helpTransform: Transform; - protected static readonly _helpPoint: Point; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly globalTransformMatrix: Matrix; - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly global: Transform; - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly offset: Transform; - /** - * @private - */ - origin: Transform | null; - /** - * @private - */ - userData: any; - protected _globalDirty: boolean; - /** - */ - protected _onClear(): void; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - updateGlobalTransform(): void; - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armature: Armature; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - class Bone extends TransformObject { - static toString(): string; - /** - * - The offset mode. - * @see #offset - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 偏移模式。 - * @see #offset - * @version DragonBones 5.5 - * @language zh_CN - */ - offsetMode: OffsetMode; - protected _localDirty: boolean; - protected _visible: boolean; - protected _cachedFrameIndex: number; - /** - * @private - */ - protected _parent: Bone | null; - protected _onClear(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: Bone): boolean; - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly boneData: BoneData; - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - visible: boolean; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone | null; - } -} -/** - * 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. - */ -declare namespace 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class DisplayFrame extends BaseObject { - static toString(): string; - rawDisplayData: DisplayData | null; - displayData: DisplayData | null; - textureData: TextureData | null; - display: any | Armature | null; - readonly deformVertices: Array; - protected _onClear(): void; - updateDeformVertices(): void; - getGeometryData(): GeometryData | null; - getBoundingBox(): BoundingBoxData | null; - getTextureData(): TextureData | null; - } - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class Slot extends TransformObject { - /** - * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language zh_CN - */ - displayController: string | null; - protected _displayDataDirty: boolean; - protected _displayDirty: boolean; - protected _geometryDirty: boolean; - protected _textureDirty: boolean; - protected _visibleDirty: boolean; - protected _blendModeDirty: boolean; - protected _zOrderDirty: boolean; - protected _transformDirty: boolean; - protected _visible: boolean; - protected _blendMode: BlendMode; - protected _displayIndex: number; - protected _animationDisplayIndex: number; - protected _cachedFrameIndex: number; - protected readonly _localMatrix: Matrix; - protected _boundingBoxData: BoundingBoxData | null; - protected _textureData: TextureData | null; - protected _rawDisplay: any; - protected _meshDisplay: any; - protected _display: any | null; - protected _childArmature: Armature | null; - /** - * @private - */ - protected _parent: Bone; - protected _onClear(): void; - protected abstract _initDisplay(value: any, isRetain: boolean): void; - protected abstract _disposeDisplay(value: any, isRelease: boolean): void; - protected abstract _onUpdateDisplay(): void; - protected abstract _addDisplay(): void; - protected abstract _replaceDisplay(value: any): void; - protected abstract _removeDisplay(): void; - protected abstract _updateZOrder(): void; - protected abstract _updateBlendMode(): void; - protected abstract _updateColor(): void; - protected abstract _updateFrame(): void; - protected abstract _updateMesh(): void; - protected abstract _updateTransform(): void; - protected abstract _identityTransform(): void; - protected _hasDisplay(display: any): boolean; - protected _updateDisplayData(): void; - protected _updateDisplay(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * @private - */ - updateTransformAndMatrix(): void; - /** - * @private - */ - replaceRawDisplayData(displayData: DisplayData | null, index?: number): void; - /** - * @private - */ - replaceDisplayData(displayData: DisplayData | null, index?: number): void; - /** - * @private - */ - replaceTextureData(textureData: TextureData | null, index?: number): void; - /** - * @private - */ - replaceDisplay(value: any | Armature | null, index?: number): void; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): boolean; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * @private - */ - getDisplayFrameAt(index: number): DisplayFrame; - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - visible: boolean; - /** - * @private - */ - displayFrameCount: number; - /** - * - The index of the display object displayed in the display list. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - displayIndex: number; - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - displayList: Array; - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly slotData: SlotData; - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly boundingBoxData: BoundingBoxData | null; - /** - * @private - */ - readonly rawDisplay: any; - /** - * @private - */ - readonly meshDisplay: any; - /** - * - The display object that the slot displays at this time. - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - display: any; - /** - * - The child armature that the slot displayed at current time. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     let prevChildArmature = slot.childArmature;
-         *     if (prevChildArmature) {
-         *         prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     let prevChildArmature = slot.childArmature;
-         *     if (prevChildArmature) {
-         *         prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - childArmature: Armature | null; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - setDisplay(value: any): void; - } -} -/** - * 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. - */ -declare namespace 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. - */ -declare namespace dragonBones { - /** - * - Play animation interface. (Both Armature and Wordclock implement the interface) - * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) - * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - interface IAnimatable { - /** - * - Advance time. - * @param passedTime - Passed time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 更新时间。 - * @param passedTime - 前进的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - The Wordclock instance to which the current belongs. - * @example - *
-         *     armature.clock = factory.clock; // Add armature to clock.
-         *     armature.clock = null; // Remove armature from clock.
-         * 
- * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 当前所属的 WordClock 实例。 - * @example - *
-         *     armature.clock = factory.clock; // 将骨架添加到时钟。
-         *     armature.clock = null; // 将骨架从时钟移除。
-         * 
- * @version DragonBones 5.0 - * @language zh_CN - */ - clock: WorldClock | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - class WorldClock implements IAnimatable { - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - time: number; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - private _systemTime; - private readonly _animatebles; - private _clock; - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(time?: number); - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: IAnimatable): boolean; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - add(value: IAnimatable): void; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - remove(value: IAnimatable): void; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - clear(): void; - /** - * @inheritDoc - */ - clock: WorldClock | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - class Animation extends BaseObject { - static toString(): string; - /** - * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * Update bones and slots cachedFrameIndices. - */ - private _animationDirty; - private _inheritTimeScale; - private readonly _animationNames; - private readonly _animationStates; - private readonly _animations; - private readonly _blendStates; - private _armature; - private _animationConfig; - private _lastAnimationState; - protected _onClear(): void; - private _fadeOut(animationConfig); - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - reset(): void; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(animationName?: string | null): void; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - playConfig(animationConfig: AnimationConfig): AnimationState | null; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - play(animationName?: string | null, playTimes?: number): AnimationState | null; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态。 - * @param animationName - 动画状态名称。 - * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - getState(animationName: string, layer?: number): AnimationState | null; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - hasAnimation(animationName: string): boolean; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - getStates(): ReadonlyArray; - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationName: string; - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly animationNames: ReadonlyArray; - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - animations: Map; - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly animationConfig: AnimationConfig; - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationState: AnimationState | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationState extends BaseObject { - static toString(): string; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additive: boolean; - /** - * - Whether the animation state has control over the display object properties of the slots. - * Sometimes blend a animation state does not want it to control the display object properties of the slots, - * especially if other animation state are controlling the display object properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * @private - */ - blendType: AnimationBlendType; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * @private - */ - parameterX: number; - /** - * @private - */ - parameterY: number; - /** - * @private - */ - positionX: number; - /** - * @private - */ - positionY: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * @private - */ - fadeTotalTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - private _timelineDirty; - private _weight; - private _fadeTime; - private _time; - private readonly _boneMask; - private readonly _boneTimelines; - private readonly _boneBlendTimelines; - private readonly _slotTimelines; - private readonly _slotBlendTimelines; - private readonly _constraintTimelines; - private readonly _animationTimelines; - private readonly _poseTimelines; - private _animationData; - private _armature; - private _zOrderTimeline; - private _activeChildA; - private _activeChildB; - protected _onClear(): void; - private _updateTimelines(); - private _updateBoneAndSlotTimelines(); - private _advanceFadeTime(passedTime); - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - play(): void; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(): void; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - containsBoneMask(boneName: string): boolean; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - addBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeAllBoneMask(): void; - /** - * @private - */ - addState(animationState: AnimationState, timelineDatas?: TimelineData[] | null): void; - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeIn: boolean; - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeOut: boolean; - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeComplete: boolean; - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly currentPlayTimes: number; - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly totalTime: number; - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - currentTime: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - weight: number; - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationData: AnimationData; - } -} -/** - * 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. - */ -declare namespace 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. - */ -declare namespace 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. - */ -declare namespace dragonBones { - /** - * - The properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - class EventObject extends BaseObject { - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly START: string; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly LOOP_COMPLETE: string; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly COMPLETE: string; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN: string; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN_COMPLETE: string; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT: string; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT_COMPLETE: string; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FRAME_EVENT: string; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly SOUND_EVENT: string; - static toString(): string; - /** - * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) - * @version DragonBones 4.5 - * @language zh_CN - */ - time: number; - /** - * - The event type。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - type: EventStringType; - /** - * - The event name. (The frame event name or the frame sound name) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件名称。 (帧事件的名称或帧声音的名称) - * @version DragonBones 4.5 - * @language zh_CN - */ - name: string; - /** - * - The armature that dispatch the event. - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨架。 - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language zh_CN - */ - armature: Armature; - /** - * - The bone that dispatch the event. - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language zh_CN - */ - bone: Bone | null; - /** - * - The slot that dispatch the event. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - slot: Slot | null; - /** - * - The animation state that dispatch the event. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - animationState: AnimationState; - /** - * @private - */ - actionData: ActionData | null; - /** - * @private - */ - /** - * - The custom data. - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义数据。 - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language zh_CN - */ - data: UserData | null; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; - /** - * - The event dispatcher interface. - * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件派发接口。 - * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 - * @version DragonBones 4.5 - * @language zh_CN - */ - interface IEventDispatcher { - /** - * - Checks whether the object has any listeners registered for a specific type of event。 - * @param type - Event type. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 检查是否为特定的事件类型注册了任何侦听器。 - * @param type - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - hasDBEventListener(type: EventStringType): boolean; - /** - * - Dispatches an event into the event flow. - * @param type - Event type. - * @param eventObject - Event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分派特定的事件到事件流中。 - * @param type - 事件类型。 - * @param eventObject - 事件数据。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - /** - * - Add an event listener object so that the listener receives notification of an event. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Removes a listener from the object. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 删除特定事件类型的侦听器。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - abstract class DataParser { - protected static readonly DATA_VERSION_2_3: string; - protected static readonly DATA_VERSION_3_0: string; - protected static readonly DATA_VERSION_4_0: string; - protected static readonly DATA_VERSION_4_5: string; - protected static readonly DATA_VERSION_5_0: string; - protected static readonly DATA_VERSION_5_5: string; - protected static readonly DATA_VERSION_5_6: string; - protected static readonly DATA_VERSION: string; - protected static readonly DATA_VERSIONS: Array; - protected static readonly TEXTURE_ATLAS: string; - protected static readonly SUB_TEXTURE: string; - protected static readonly FORMAT: string; - protected static readonly IMAGE_PATH: string; - protected static readonly WIDTH: string; - protected static readonly HEIGHT: string; - protected static readonly ROTATED: string; - protected static readonly FRAME_X: string; - protected static readonly FRAME_Y: string; - protected static readonly FRAME_WIDTH: string; - protected static readonly FRAME_HEIGHT: string; - protected static readonly DRADON_BONES: string; - protected static readonly USER_DATA: string; - protected static readonly ARMATURE: string; - protected static readonly CANVAS: string; - protected static readonly BONE: string; - protected static readonly SURFACE: string; - protected static readonly SLOT: string; - protected static readonly CONSTRAINT: string; - protected static readonly SKIN: string; - protected static readonly DISPLAY: string; - protected static readonly FRAME: string; - protected static readonly IK: string; - protected static readonly PATH_CONSTRAINT: string; - protected static readonly ANIMATION: string; - protected static readonly TIMELINE: string; - protected static readonly FFD: string; - protected static readonly TRANSLATE_FRAME: string; - protected static readonly ROTATE_FRAME: string; - protected static readonly SCALE_FRAME: string; - protected static readonly DISPLAY_FRAME: string; - protected static readonly COLOR_FRAME: string; - protected static readonly DEFAULT_ACTIONS: string; - protected static readonly ACTIONS: string; - protected static readonly EVENTS: string; - protected static readonly INTS: string; - protected static readonly FLOATS: string; - protected static readonly STRINGS: string; - protected static readonly TRANSFORM: string; - protected static readonly PIVOT: string; - protected static readonly AABB: string; - protected static readonly COLOR: string; - protected static readonly VERSION: string; - protected static readonly COMPATIBLE_VERSION: string; - protected static readonly FRAME_RATE: string; - protected static readonly TYPE: string; - protected static readonly SUB_TYPE: string; - protected static readonly NAME: string; - protected static readonly PARENT: string; - protected static readonly TARGET: string; - protected static readonly STAGE: string; - protected static readonly SHARE: string; - protected static readonly PATH: string; - protected static readonly LENGTH: string; - protected static readonly DISPLAY_INDEX: string; - protected static readonly Z_ORDER: string; - protected static readonly Z_INDEX: string; - protected static readonly BLEND_MODE: string; - protected static readonly INHERIT_TRANSLATION: string; - protected static readonly INHERIT_ROTATION: string; - protected static readonly INHERIT_SCALE: string; - protected static readonly INHERIT_REFLECTION: string; - protected static readonly INHERIT_ANIMATION: string; - protected static readonly INHERIT_DEFORM: string; - protected static readonly SEGMENT_X: string; - protected static readonly SEGMENT_Y: string; - protected static readonly BEND_POSITIVE: string; - protected static readonly CHAIN: string; - protected static readonly WEIGHT: string; - protected static readonly BLEND_TYPE: string; - protected static readonly FADE_IN_TIME: string; - protected static readonly PLAY_TIMES: string; - protected static readonly SCALE: string; - protected static readonly OFFSET: string; - protected static readonly POSITION: string; - protected static readonly DURATION: string; - protected static readonly TWEEN_EASING: string; - protected static readonly TWEEN_ROTATE: string; - protected static readonly TWEEN_SCALE: string; - protected static readonly CLOCK_WISE: string; - protected static readonly CURVE: string; - protected static readonly SOUND: string; - protected static readonly EVENT: string; - protected static readonly ACTION: string; - protected static readonly X: string; - protected static readonly Y: string; - protected static readonly SKEW_X: string; - protected static readonly SKEW_Y: string; - protected static readonly SCALE_X: string; - protected static readonly SCALE_Y: string; - protected static readonly VALUE: string; - protected static readonly ROTATE: string; - protected static readonly SKEW: string; - protected static readonly ALPHA: string; - protected static readonly ALPHA_OFFSET: string; - protected static readonly RED_OFFSET: string; - protected static readonly GREEN_OFFSET: string; - protected static readonly BLUE_OFFSET: string; - protected static readonly ALPHA_MULTIPLIER: string; - protected static readonly RED_MULTIPLIER: string; - protected static readonly GREEN_MULTIPLIER: string; - protected static readonly BLUE_MULTIPLIER: string; - protected static readonly UVS: string; - protected static readonly VERTICES: string; - protected static readonly TRIANGLES: string; - protected static readonly WEIGHTS: string; - protected static readonly SLOT_POSE: string; - protected static readonly BONE_POSE: string; - protected static readonly BONES: string; - protected static readonly POSITION_MODE: string; - protected static readonly SPACING_MODE: string; - protected static readonly ROTATE_MODE: string; - protected static readonly SPACING: string; - protected static readonly ROTATE_OFFSET: string; - protected static readonly ROTATE_MIX: string; - protected static readonly TRANSLATE_MIX: string; - protected static readonly TARGET_DISPLAY: string; - protected static readonly CLOSED: string; - protected static readonly CONSTANT_SPEED: string; - protected static readonly VERTEX_COUNT: string; - protected static readonly LENGTHS: string; - protected static readonly GOTO_AND_PLAY: string; - protected static readonly DEFAULT_NAME: string; - protected static _getArmatureType(value: string): ArmatureType; - protected static _getBoneType(value: string): BoneType; - protected static _getPositionMode(value: string): PositionMode; - protected static _getSpacingMode(value: string): SpacingMode; - protected static _getRotateMode(value: string): RotateMode; - protected static _getDisplayType(value: string): DisplayType; - protected static _getBoundingBoxType(value: string): BoundingBoxType; - protected static _getBlendMode(value: string): BlendMode; - protected static _getAnimationBlendType(value: string): AnimationBlendType; - protected static _getActionType(value: string): ActionType; - abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; - abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - const enum FrameValueType { - Step = 0, - Int = 1, - Float = 2, - } - /** - * @private - */ - class ObjectDataParser extends DataParser { - protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; - protected static _getNumber(rawData: any, key: string, defaultValue: number): number; - protected static _getString(rawData: any, key: string, defaultValue: string): string; - protected _rawTextureAtlasIndex: number; - protected readonly _rawBones: Array; - protected _data: DragonBonesData; - protected _armature: ArmatureData; - protected _bone: BoneData; - protected _geometry: GeometryData; - protected _slot: SlotData; - protected _skin: SkinData; - protected _mesh: MeshDisplayData; - protected _animation: AnimationData; - protected _timeline: TimelineData; - protected _rawTextureAtlases: Array | null; - private _frameValueType; - private _defaultColorOffset; - private _prevClockwise; - private _prevRotation; - private _frameDefaultValue; - private _frameValueScale; - private readonly _helpMatrixA; - private readonly _helpMatrixB; - private readonly _helpTransform; - private readonly _helpColorTransform; - private readonly _helpPoint; - private readonly _helpArray; - private readonly _intArray; - private readonly _floatArray; - private readonly _frameIntArray; - private readonly _frameFloatArray; - private readonly _frameArray; - private readonly _timelineArray; - private readonly _colorArray; - private readonly _cacheRawMeshes; - private readonly _cacheMeshes; - private readonly _actionFrames; - private readonly _weightSlotPose; - private readonly _weightBonePoses; - private readonly _cacheBones; - private readonly _slotChildActions; - private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); - private _samplingEasingCurve(curve, samples); - private _parseActionDataInFrame(rawData, frameStart, bone, slot); - private _mergeActionFrame(rawData, frameStart, type, bone, slot); - protected _parseArmature(rawData: any, scale: number): ArmatureData; - protected _parseBone(rawData: any): BoneData; - protected _parseIKConstraint(rawData: any): ConstraintData | null; - protected _parsePathConstraint(rawData: any): ConstraintData | null; - protected _parseSlot(rawData: any, zOrder: number): SlotData; - protected _parseSkin(rawData: any): SkinData; - protected _parseDisplay(rawData: any): DisplayData | null; - protected _parsePath(rawData: any, display: PathDisplayData): void; - protected _parsePivot(rawData: any, display: ImageDisplayData): void; - protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; - protected _parseBoundingBox(rawData: any): BoundingBoxData | null; - protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, timelineType: TimelineType, frameValueType: FrameValueType, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number, timeline?: TimelineData | null): TimelineData | null; - protected _parseBoneTimeline(rawData: any): void; - protected _parseSlotTimeline(rawData: any): void; - protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSingleValueFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseDoubleValueFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; - protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotDeformFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; - protected _parseDeformFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseTransform(rawData: any, transform: Transform, scale: number): void; - protected _parseColorTransform(rawData: any, color: ColorTransform): void; - protected _parseGeometry(rawData: any, geometry: GeometryData): void; - protected _parseArray(rawData: any): void; - protected _modifyArray(): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; - private static _objectDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): ObjectDataParser; - } - /** - * @private - */ - class ActionFrame { - frameStart: number; - readonly actions: Array; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class BinaryDataParser extends ObjectDataParser { - private _binaryOffset; - private _binary; - private _intArrayBuffer; - private _frameArrayBuffer; - private _timelineArrayBuffer; - private _inRange(a, min, max); - private _decodeUTF8(data); - private _parseBinaryTimeline(type, offset, timelineData?); - protected _parseAnimation(rawData: any): AnimationData; - protected _parseGeometry(rawData: any, geometry: GeometryData): void; - protected _parseArray(rawData: any): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - private static _binaryDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): BinaryDataParser; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class BaseFactory { - protected static _objectParser: ObjectDataParser; - protected static _binaryParser: BinaryDataParser; - /** - * @private - */ - autoSearch: boolean; - protected readonly _dragonBonesDataMap: Map; - protected readonly _textureAtlasDataMap: Map>; - protected _dragonBones: DragonBones; - protected _dataParser: DataParser; - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; - protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; - protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; - /** - * @private - */ - protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, _slot: Slot, displayData: ArmatureDisplayData): Armature | null; - protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, slot: Slot): any; - protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; - protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; - /** - * - Update texture atlases. - * @param textureAtlases - The texture atlas objects. - * @param name - The texture atlas name. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 更新贴图集对象。 - * @param textureAtlases - 多个贴图集对象。 - * @param name - 贴图集名称。 - * @version DragonBones 5.7 - * @language zh_CN - */ - updateTextureAtlases(textureAtlases: Array, name: string): void; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - getDragonBonesData(name: string): DragonBonesData | null; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - addDragonBonesData(data: DragonBonesData, name?: string | null): void; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeDragonBonesData(name: string, disposeData?: boolean): void; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureAtlasData(name: string): Array | null; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeTextureAtlasData(name: string, disposeData?: boolean): void; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - clear(disposeData?: boolean): void; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; - /** - * @private - */ - replaceDisplay(slot: Slot, displayData: DisplayData | null, displayIndex?: number): void; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; - /** - * @private - */ - replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; - /** - * @private - */ - getAllDragonBonesData(): Map; - /** - * @private - */ - getAllTextureAtlasData(): Map>; - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - readonly clock: WorldClock; - /** - * @private - */ - readonly dragonBones: DragonBones; - } - /** - * @private - */ - class BuildArmaturePackage { - dataName: string; - textureAtlasName: string; - data: DragonBonesData; - armature: ArmatureData; - skin: SkinData | null; - } -} -/** - * 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. - */ -declare var _Scene: any; -declare namespace dragonBones { - class DragonBonesAsset extends cc.Asset { - readonly dragonBonesData: string | ArrayBuffer; - readonly textureAtlases: string[]; - readonly textures: cc.Texture2D[]; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The Cocos texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class CocosTextureAtlasData extends TextureAtlasData { - static toString(): string; - private _renderTexture; - protected _onClear(): void; - createTexture(): TextureData; - /** - * - The Cocos texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - renderTexture: cc.Texture2D | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @see dragonBones.IArmatureProxy - */ - class CocosArmatureComponent extends cc.Component implements IArmatureProxy { - /** - * @private - */ - debugDraw: boolean; - private _debugDraw; - dbInit(armature: Armature): void; - dbClear(): void; - dbUpdate(): void; - dispose(_isposeProxy?: boolean): void; - destroy(): true; - /** - * @private - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - hasDBEventListener(type: EventStringType): boolean; - addDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; - removeDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; - readonly armature: Armature; - readonly animation: Animation; - start(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The Cocos slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class CocosSlot extends Slot { - static toString(): string; - private _ccMeshDirty; - private _textureScale; - private _renderDisplay; - protected _onClear(): void; - protected _initDisplay(_value: any, _isRetain: boolean): void; - protected _disposeDisplay(value: any, isRelease: boolean): void; - protected _onUpdateDisplay(): void; - protected _addDisplay(): void; - protected _replaceDisplay(value: any): void; - protected _removeDisplay(): void; - protected _updateZOrder(): void; - protected _updateBlendMode(): void; - protected _updateColor(): void; - protected _updateFrame(): void; - protected _updateMesh(): void; - protected _updateTransform(): void; - protected _identityTransform(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The Cocos factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class CocosFactory extends BaseFactory { - private static _dragonBonesInstance; - private static _factory; - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static readonly factory: CocosFactory; - protected _node: cc.Node | null; - protected _armatureNode: cc.Node | null; - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _buildTextureAtlasData(textureAtlasData: CocosTextureAtlasData | null, textureAtlas: cc.Texture2D | null): CocosTextureAtlasData; - protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: ArmatureDisplayData): Armature | null; - protected _buildSlot(_dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature component. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 - * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架组件。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - buildArmatureComponent(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string, node?: cc.Node | null): CocosArmatureComponent | null; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureDisplay(textureName: string, textureAtlasName?: string | null): cc.Sprite | null; - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly soundEventManager: cc.Node; - } -} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + GeometryVertexCount = 0, + GeometryTriangleCount = 1, + GeometryFloatOffset = 2, + GeometryWeightOffset = 3, + GeometryVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformVertexOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4 + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2 + } + /** + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1 + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + Path = 4 + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2 + } + /** + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11 + } + /** + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13 + } + /** + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5 + } + /** + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + BoneAlpha = 60, + SlotDisplay = 20, + SlotColor = 21, + SlotDeform = 22, + SlotZIndex = 23, + SlotAlpha = 24, + IKConstraint = 30, + AnimationProgress = 40, + AnimationWeight = 41, + AnimationParameter = 42 + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2 + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5 + } + /** + * @private + */ + const enum AnimationBlendType { + None = 0, + E1D = 1 + } + /** + * @private + */ + const enum AnimationBlendMode { + Additive = 0, + Override = 1 + } + /** + * @private + */ + const enum ConstraintType { + IK = 0, + Path = 1 + } + /** + * @private + */ + const enum PositionMode { + Fixed = 0, + Percent = 1 + } + /** + * @private + */ + const enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + /** + * @private + */ + const enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +declare var __extends: any; +declare var exports: any; +declare var module: any; +declare var define: any; +/** + * 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. + */ +declare namespace 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 + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject; + static toString(): string; + /** + * - 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 + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - 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 + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - 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 + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - 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 + */ + identity(): Matrix; + /** + * - 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 + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - 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 + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * 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. + */ +declare namespace 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 + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - 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 + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * 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. + */ +declare namespace 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.
+ * 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) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + protected _onClear(): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace 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 + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @private + */ + userData: UserData | null; + protected _onClear(): void; + /** + * - 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 + */ + getArmature(armatureName: string): ArmatureData | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + protected _onClear(): void; + /** + * - Get a specific done data. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(boneName: string): BoneData | null; + /** + * - Get a specific slot data. + * @param slotName - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param slotName - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(slotName: string): SlotData | null; + /** + * @private + */ + getConstraint(constraintName: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param skinName - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param skinName - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(skinName: string): SkinData | null; + /** + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param animationName - The animation animationName. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param animationName - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(animationName: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * @private + */ + alpha: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * @private + */ + zIndex: number; + /** + * @private + */ + alpha: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + protected _onClear(): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + type: ConstraintType; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class GeometryData { + isShared: boolean; + inheritDeform: boolean; + offset: number; + data: DragonBonesData; + weight: WeightData | null; + clear(): void; + shareFrom(value: GeometryData): void; + readonly vertexCount: number; + readonly triangleCount: number; + } + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: SkinData; + protected _onClear(): void; + } + /** + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + readonly geometry: GeometryData; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class PathDisplayData extends DisplayData { + static toString(): string; + closed: boolean; + constantSpeed: boolean; + readonly geometry: GeometryData; + readonly curveLengths: Array; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode; + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * @private + */ + blendType: AnimationBlendType; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + protected _onClear(): void; + /** + * @private + */ + addBoneTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(timelineName: string): Array | null; + /** + * @private + */ + getSlotTimelines(timelineName: string): Array | null; + /** + * @private + */ + getConstraintTimelines(timelineName: string): Array | null; + /** + * @private + */ + getAnimationTimelines(timelineName: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(boneName: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(slotName: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additive: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + getTexture(textureName: string): TextureData | null; + } + /** + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots; + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + private _alpha; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + private _replacedTexture; + private _clock; + protected _onClear(): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + protected _globalDirty: boolean; + /** + */ + protected _onClear(): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + protected _localDirty: boolean; + protected _visible: boolean; + protected _cachedFrameIndex: number; + /** + * @private + */ + protected _parent: Bone | null; + protected _onClear(): void; + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: Bone): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone | null; + } +} +/** + * 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. + */ +declare namespace 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class DisplayFrame extends BaseObject { + static toString(): string; + rawDisplayData: DisplayData | null; + displayData: DisplayData | null; + textureData: TextureData | null; + display: any | Armature | null; + readonly deformVertices: Array; + protected _onClear(): void; + updateDeformVertices(): void; + getGeometryData(): GeometryData | null; + getBoundingBox(): BoundingBoxData | null; + getTextureData(): TextureData | null; + } + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + protected _displayDataDirty: boolean; + protected _displayDirty: boolean; + protected _geometryDirty: boolean; + protected _textureDirty: boolean; + protected _visibleDirty: boolean; + protected _blendModeDirty: boolean; + protected _zOrderDirty: boolean; + protected _transformDirty: boolean; + protected _visible: boolean; + protected _blendMode: BlendMode; + protected _displayIndex: number; + protected _animationDisplayIndex: number; + protected _cachedFrameIndex: number; + protected readonly _localMatrix: Matrix; + protected _boundingBoxData: BoundingBoxData | null; + protected _textureData: TextureData | null; + protected _rawDisplay: any; + protected _meshDisplay: any; + protected _display: any | null; + protected _childArmature: Armature | null; + /** + * @private + */ + protected _parent: Bone; + protected _onClear(): void; + protected abstract _initDisplay(value: any, isRetain: boolean): void; + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + protected abstract _onUpdateDisplay(): void; + protected abstract _addDisplay(): void; + protected abstract _replaceDisplay(value: any): void; + protected abstract _removeDisplay(): void; + protected abstract _updateZOrder(): void; + protected abstract _updateBlendMode(): void; + protected abstract _updateColor(): void; + protected abstract _updateFrame(): void; + protected abstract _updateMesh(): void; + protected abstract _updateTransform(): void; + protected abstract _identityTransform(): void; + protected _hasDisplay(display: any): boolean; + protected _updateDisplayData(): void; + protected _updateDisplay(): void; + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceRawDisplayData(displayData: DisplayData | null, index?: number): void; + /** + * @private + */ + replaceDisplayData(displayData: DisplayData | null, index?: number): void; + /** + * @private + */ + replaceTextureData(textureData: TextureData | null, index?: number): void; + /** + * @private + */ + replaceDisplay(value: any | Armature | null, index?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + getDisplayFrameAt(index: number): DisplayFrame; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * @private + */ + displayFrameCount: number; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     let prevChildArmature = slot.childArmature;
+         *     if (prevChildArmature) {
+         *         prevChildArmature.dispose();
+         *     }
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     let prevChildArmature = slot.childArmature;
+         *     if (prevChildArmature) {
+         *         prevChildArmature.dispose();
+         *     }
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * 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. + */ +declare namespace 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. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _systemTime; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * Update bones and slots cachedFrameIndices. + */ + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private readonly _blendStates; + private _armature; + private _animationConfig; + private _lastAnimationState; + protected _onClear(): void; + private _fadeOut; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态。 + * @param animationName - 动画状态名称。 + * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string, layer?: number): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): ReadonlyArray; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: ReadonlyArray; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additive: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + blendType: AnimationBlendType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * @private + */ + parameterX: number; + /** + * @private + */ + parameterY: number; + /** + * @private + */ + positionX: number; + /** + * @private + */ + positionY: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + private _weight; + private _fadeTime; + private _time; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _boneBlendTimelines; + private readonly _slotTimelines; + private readonly _slotBlendTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private _animationData; + private _armature; + private _zOrderTimeline; + private _activeChildA; + private _activeChildB; + protected _onClear(): void; + private _updateTimelines; + private _updateBoneAndSlotTimelines; + private _advanceFadeTime; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(boneName: string): boolean; + /** + * - Add a specific bone mask. + * @param boneName - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(boneName: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param boneName - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(boneName: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * @private + */ + addState(animationState: AnimationState, timelineDatas?: TimelineData[] | null): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + weight: number; + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } +} +/** + * 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. + */ +declare namespace 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. + */ +declare namespace 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. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * @private + */ + actionData: ActionData | null; + /** + * @private + */ + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION_5_6: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly CANVAS: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly FRAME: string; + protected static readonly IK: string; + protected static readonly PATH_CONSTRAINT: string; + protected static readonly ANIMATION: string; + protected static readonly TIMELINE: string; + protected static readonly FFD: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly Z_ORDER: string; + protected static readonly Z_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly BLEND_TYPE: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly BONES: string; + protected static readonly POSITION_MODE: string; + protected static readonly SPACING_MODE: string; + protected static readonly ROTATE_MODE: string; + protected static readonly SPACING: string; + protected static readonly ROTATE_OFFSET: string; + protected static readonly ROTATE_MIX: string; + protected static readonly TRANSLATE_MIX: string; + protected static readonly TARGET_DISPLAY: string; + protected static readonly CLOSED: string; + protected static readonly CONSTANT_SPEED: string; + protected static readonly VERTEX_COUNT: string; + protected static readonly LENGTHS: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getPositionMode(value: string): PositionMode; + protected static _getSpacingMode(value: string): SpacingMode; + protected static _getRotateMode(value: string): RotateMode; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getBlendMode(value: string): BlendMode; + protected static _getAnimationBlendType(value: string): AnimationBlendType; + protected static _getActionType(value: string): ActionType; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + const enum FrameValueType { + Step = 0, + Int = 1, + Float = 2 + } + /** + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _geometry: GeometryData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _frameValueType; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private _frameDefaultValue; + private _frameValueScale; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _colorArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint; + private _samplingEasingCurve; + private _parseActionDataInFrame; + private _mergeActionFrame; + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parsePathConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePath(rawData: any, display: PathDisplayData): void; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, timelineType: TimelineType, frameValueType: FrameValueType, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number, timeline?: TimelineData | null): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSingleValueFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseDoubleValueFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDeformFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseDeformFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseGeometry(rawData: any, geometry: GeometryData): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange; + private _decodeUTF8; + private _parseBinaryTimeline; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseGeometry(rawData: any, geometry: GeometryData): void; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + protected static _objectParser: ObjectDataParser; + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + protected readonly _dragonBonesDataMap: Map; + protected readonly _textureAtlasDataMap: Map>; + protected _dragonBones: DragonBones; + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + protected _isSupportMesh(): boolean; + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, _slot: Slot, displayData: ArmatureDisplayData): Armature | null; + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, slot: Slot): any; + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * - Update texture atlases. + * @param textureAtlases - The texture atlas objects. + * @param name - The texture atlas name. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 更新贴图集对象。 + * @param textureAtlases - 多个贴图集对象。 + * @param name - 贴图集名称。 + * @version DragonBones 5.7 + * @language zh_CN + */ + updateTextureAtlases(textureAtlases: Array, name: string): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData | null, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + } + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} +/** + * 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. + */ +declare var _Scene: any; +declare namespace dragonBones { + class DragonBonesAsset extends cc.Asset { + readonly dragonBonesData: string | ArrayBuffer; + readonly textureAtlases: string[]; + readonly textures: cc.Texture2D[]; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The Cocos texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class CocosTextureAtlasData extends TextureAtlasData { + static toString(): string; + private _renderTexture; + protected _onClear(): void; + createTexture(): TextureData; + /** + * - The Cocos texture. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + renderTexture: cc.Texture2D | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @see dragonBones.IArmatureProxy + */ + class CocosArmatureComponent extends cc.Component implements IArmatureProxy { + /** + * @private + */ + debugDraw: boolean; + private _debugDraw; + dbInit(armature: Armature): void; + dbClear(): void; + dbUpdate(): void; + dispose(_isposeProxy?: boolean): void; + destroy(): true; + /** + * @private + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + hasDBEventListener(type: EventStringType): boolean; + addDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; + removeDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; + readonly armature: Armature; + readonly animation: Animation; + dragonBonesName: string; + dragonBonesAsset: DragonBonesAsset | null; + _loadAndDisplayDragonBones(): void; + _parseDragonAsset(): void; + _parseDragonAtlasAsset(): void; + _dragonBonesNode: cc.Node; + display(): void; + onLoad(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The Cocos slot. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class CocosSlot extends Slot { + static toString(): string; + private _ccMeshDirty; + private _textureScale; + private _renderDisplay; + protected _onClear(): void; + protected _initDisplay(_value: any, _isRetain: boolean): void; + protected _disposeDisplay(value: any, isRelease: boolean): void; + protected _onUpdateDisplay(): void; + protected _addDisplay(): void; + protected _replaceDisplay(value: any): void; + protected _removeDisplay(): void; + protected _updateZOrder(): void; + protected _updateBlendMode(): void; + protected _updateColor(): void; + protected _updateFrame(): void; + protected _updateMesh(): void; + protected _updateTransform(): void; + protected _identityTransform(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The Cocos factory. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class CocosFactory extends BaseFactory { + private static _dragonBonesInstance; + private static _factory; + /** + * - A global factory instance that can be used directly. + * @version DragonBones 4.7 + * @language en_US + */ + /** + * - 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + static readonly factory: CocosFactory; + protected _node: cc.Node | null; + protected _armatureNode: cc.Node | null; + constructor(dataParser?: DataParser | null); + protected _isSupportMesh(): boolean; + protected _buildTextureAtlasData(textureAtlasData: CocosTextureAtlasData | null, textureAtlas: cc.Texture2D | null): CocosTextureAtlasData; + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: ArmatureDisplayData): Armature | null; + protected _buildSlot(_dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; + /** + * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. + * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. + * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature component. + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 + * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 + * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架组件。 + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language zh_CN + */ + buildArmatureComponent(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string, node?: cc.Node | null): CocosArmatureComponent | null; + /** + * - Create the display object with the specified texture. + * @param textureName - The texture data name. + * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建带有指定贴图的显示对象。 + * @param textureName - 贴图数据名称。 + * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureDisplay(textureName: string, textureAtlasName?: string | null): cc.Sprite | null; + /** + * - A global sound event manager. + * Sound events can be listened to uniformly from the manager. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 全局声音事件管理器。 + * 声音事件可以从该管理器统一侦听。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly soundEventManager: cc.Node; + } +} diff --git a/Cocos/1.x/out/dragonBones.js b/Cocos/1.x/out/dragonBones.js old mode 100644 new mode 100755 index 803475e7..d95dfa76 --- a/Cocos/1.x/out/dragonBones.js +++ b/Cocos/1.x/out/dragonBones.js @@ -1,16258 +1,16368 @@ -"use strict"; -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 __decorate = (this && this.__decorate) || function (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; -}; -/** - * 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 = (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) { - 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 = (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) { - 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 = (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 = (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 = (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 = (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.
- * 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) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var Rectangle = (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 = (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 = (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 = (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, 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 armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var ArmatureData = (function (_super) { - __extends(ArmatureData, _super); - function ArmatureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.aabb = new dragonBones.Rectangle(); - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.animationNames = []; - /** - * @private - */ - _this.sortedBones = []; - /** - * @private - */ - _this.sortedSlots = []; - /** - * @private - */ - _this.defaultActions = []; - /** - * @private - */ - _this.actions = []; - /** - * @private - */ - _this.bones = {}; - /** - * @private - */ - _this.slots = {}; - /** - * @private - */ - _this.constraints = {}; - /** - * @private - */ - _this.skins = {}; - /** - * @private - */ - _this.animations = {}; - /** - * @private - */ - _this.canvas = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - ArmatureData.toString = function () { - return "[class dragonBones.ArmatureData]"; - }; - ArmatureData.prototype._onClear = function () { - for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { - var action = _c[_b]; - action.returnToPool(); - } - for (var k in this.bones) { - this.bones[k].returnToPool(); - delete this.bones[k]; - } - for (var k in this.slots) { - this.slots[k].returnToPool(); - delete this.slots[k]; - } - for (var k in this.constraints) { - this.constraints[k].returnToPool(); - delete this.constraints[k]; - } - for (var k in this.skins) { - this.skins[k].returnToPool(); - delete this.skins[k]; - } - for (var k in this.animations) { - this.animations[k].returnToPool(); - delete this.animations[k]; - } - if (this.canvas !== null) { - this.canvas.returnToPool(); - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.type = 0 /* Armature */; - this.frameRate = 0; - this.cacheFrameRate = 0; - this.scale = 1.0; - this.name = ""; - this.aabb.clear(); - this.animationNames.length = 0; - this.sortedBones.length = 0; - this.sortedSlots.length = 0; - this.defaultActions.length = 0; - this.actions.length = 0; - // this.bones.clear(); - // this.slots.clear(); - // this.constraints.clear(); - // this.skins.clear(); - // this.animations.clear(); - this.defaultSkin = null; - this.defaultAnimation = null; - this.canvas = null; - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - ArmatureData.prototype.sortBones = function () { - var total = this.sortedBones.length; - if (total <= 0) { - return; - } - var sortHelper = this.sortedBones.concat(); - var index = 0; - var count = 0; - this.sortedBones.length = 0; - while (count < total) { - var bone = sortHelper[index++]; - if (index >= total) { - index = 0; - } - if (this.sortedBones.indexOf(bone) >= 0) { - continue; - } - var flag = false; - for (var k in this.constraints) { - var constraint = this.constraints[k]; - if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { - flag = true; - break; - } - } - if (flag) { - continue; - } - if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { - continue; - } - this.sortedBones.push(bone); - count++; - } - }; - /** - * @internal - */ - ArmatureData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0) { - return; - } - this.cacheFrameRate = frameRate; - for (var k in this.animations) { - this.animations[k].cacheFrames(this.cacheFrameRate); - } - }; - /** - * @internal - */ - ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { - var dataArray = this.parent.cachedFrames; - var arrayOffset = dataArray.length; - dataArray.length += 10; - dataArray[arrayOffset] = globalTransformMatrix.a; - dataArray[arrayOffset + 1] = globalTransformMatrix.b; - dataArray[arrayOffset + 2] = globalTransformMatrix.c; - dataArray[arrayOffset + 3] = globalTransformMatrix.d; - dataArray[arrayOffset + 4] = globalTransformMatrix.tx; - dataArray[arrayOffset + 5] = globalTransformMatrix.ty; - dataArray[arrayOffset + 6] = transform.rotation; - dataArray[arrayOffset + 7] = transform.skew; - dataArray[arrayOffset + 8] = transform.scaleX; - dataArray[arrayOffset + 9] = transform.scaleY; - return arrayOffset; - }; - /** - * @internal - */ - ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { - var dataArray = this.parent.cachedFrames; - globalTransformMatrix.a = dataArray[arrayOffset]; - globalTransformMatrix.b = dataArray[arrayOffset + 1]; - globalTransformMatrix.c = dataArray[arrayOffset + 2]; - globalTransformMatrix.d = dataArray[arrayOffset + 3]; - globalTransformMatrix.tx = dataArray[arrayOffset + 4]; - globalTransformMatrix.ty = dataArray[arrayOffset + 5]; - transform.rotation = dataArray[arrayOffset + 6]; - transform.skew = dataArray[arrayOffset + 7]; - transform.scaleX = dataArray[arrayOffset + 8]; - transform.scaleY = dataArray[arrayOffset + 9]; - transform.x = globalTransformMatrix.tx; - transform.y = globalTransformMatrix.ty; - }; - /** - * @internal - */ - ArmatureData.prototype.addBone = function (value) { - if (value.name in this.bones) { - console.warn("Same bone: " + value.name); - return; - } - this.bones[value.name] = value; - this.sortedBones.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addSlot = function (value) { - if (value.name in this.slots) { - console.warn("Same slot: " + value.name); - return; - } - this.slots[value.name] = value; - this.sortedSlots.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addConstraint = function (value) { - if (value.name in this.constraints) { - console.warn("Same constraint: " + value.name); - return; - } - this.constraints[value.name] = value; - }; - /** - * @internal - */ - ArmatureData.prototype.addSkin = function (value) { - if (value.name in this.skins) { - console.warn("Same skin: " + value.name); - return; - } - value.parent = this; - this.skins[value.name] = value; - if (this.defaultSkin === null) { - this.defaultSkin = value; - } - if (value.name === "default") { - this.defaultSkin = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAnimation = function (value) { - if (value.name in this.animations) { - console.warn("Same animation: " + value.name); - return; - } - value.parent = this; - this.animations[value.name] = value; - this.animationNames.push(value.name); - if (this.defaultAnimation === null) { - this.defaultAnimation = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAction = function (value, isDefault) { - if (isDefault) { - this.defaultActions.push(value); - } - else { - this.actions.push(value); - } - }; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getBone = function (boneName) { - return boneName in this.bones ? this.bones[boneName] : null; - }; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSlot = function (slotName) { - return slotName in this.slots ? this.slots[slotName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getConstraint = function (constraintName) { - return constraintName in this.constraints ? this.constraints[constraintName] : null; - }; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSkin = function (skinName) { - return skinName in this.skins ? this.skins[skinName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { - var skin = this.getSkin(skinName); - if (skin === null) { - return null; - } - return skin.getDisplay(slotName, meshName); - }; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getAnimation = function (animationName) { - return animationName in this.animations ? this.animations[animationName] : null; - }; - return ArmatureData; - }(dragonBones.BaseObject)); - dragonBones.ArmatureData = ArmatureData; - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var BoneData = (function (_super) { - __extends(BoneData, _super); - function BoneData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.transform = new dragonBones.Transform(); - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - BoneData.toString = function () { - return "[class dragonBones.BoneData]"; - }; - BoneData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.inheritTranslation = false; - this.inheritRotation = false; - this.inheritScale = false; - this.inheritReflection = false; - this.type = 0 /* Bone */; - this.length = 0.0; - this.alpha = 1.0; - this.name = ""; - this.transform.identity(); - this.userData = null; - this.parent = null; - }; - return BoneData; - }(dragonBones.BaseObject)); - dragonBones.BoneData = BoneData; - /** - * @internal - */ - var SurfaceData = (function (_super) { - __extends(SurfaceData, _super); - function SurfaceData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new dragonBones.GeometryData(); - return _this; - } - SurfaceData.toString = function () { - return "[class dragonBones.SurfaceData]"; - }; - SurfaceData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Surface */; - this.segmentX = 0; - this.segmentY = 0; - this.geometry.clear(); - }; - return SurfaceData; - }(BoneData)); - dragonBones.SurfaceData = SurfaceData; - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SlotData = (function (_super) { - __extends(SlotData, _super); - function SlotData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.color = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - /** - * @internal - */ - SlotData.createColor = function () { - return new dragonBones.ColorTransform(); - }; - SlotData.toString = function () { - return "[class dragonBones.SlotData]"; - }; - SlotData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.blendMode = 0 /* Normal */; - this.displayIndex = 0; - this.zOrder = 0; - this.zIndex = 0; - this.alpha = 1.0; - this.name = ""; - this.color = null; // - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotData; - }(dragonBones.BaseObject)); - dragonBones.SlotData = SlotData; -})(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 CanvasData = (function (_super) { - __extends(CanvasData, _super); - function CanvasData() { - return _super !== null && _super.apply(this, arguments) || this; - } - CanvasData.toString = function () { - return "[class dragonBones.CanvasData]"; - }; - CanvasData.prototype._onClear = function () { - this.hasBackground = false; - this.color = 0x000000; - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - return CanvasData; - }(dragonBones.BaseObject)); - dragonBones.CanvasData = CanvasData; -})(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 skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SkinData = (function (_super) { - __extends(SkinData, _super); - function SkinData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.displays = {}; - return _this; - } - SkinData.toString = function () { - return "[class dragonBones.SkinData]"; - }; - SkinData.prototype._onClear = function () { - for (var k in this.displays) { - var slotDisplays = this.displays[k]; - for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { - var display = slotDisplays_1[_i]; - if (display !== null) { - display.returnToPool(); - } - } - delete this.displays[k]; - } - this.name = ""; - // this.displays.clear(); - this.parent = null; // - }; - /** - * @internal - */ - SkinData.prototype.addDisplay = function (slotName, value) { - if (!(slotName in this.displays)) { - this.displays[slotName] = []; - } - if (value !== null) { - value.parent = this; - } - var slotDisplays = this.displays[slotName]; // TODO clear prev - slotDisplays.push(value); - }; - /** - * @private - */ - SkinData.prototype.getDisplay = function (slotName, displayName) { - var slotDisplays = this.getDisplays(slotName); - if (slotDisplays !== null) { - for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { - var display = slotDisplays_2[_i]; - if (display !== null && display.name === displayName) { - return display; - } - } - } - return null; - }; - /** - * @private - */ - SkinData.prototype.getDisplays = function (slotName) { - if (!(slotName in this.displays)) { - return null; - } - return this.displays[slotName]; - }; - return SkinData; - }(dragonBones.BaseObject)); - dragonBones.SkinData = SkinData; -})(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 ConstraintData = (function (_super) { - __extends(ConstraintData, _super); - function ConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintData.prototype._onClear = function () { - this.order = 0; - this.name = ""; - this.type = 0 /* IK */; - this.target = null; // - this.root = null; // - this.bone = null; - }; - return ConstraintData; - }(dragonBones.BaseObject)); - dragonBones.ConstraintData = ConstraintData; - /** - * @internal - */ - var IKConstraintData = (function (_super) { - __extends(IKConstraintData, _super); - function IKConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintData.toString = function () { - return "[class dragonBones.IKConstraintData]"; - }; - IKConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.scaleEnabled = false; - this.bendPositive = false; - this.weight = 1.0; - }; - return IKConstraintData; - }(ConstraintData)); - dragonBones.IKConstraintData = IKConstraintData; - /** - * @internal - */ - var PathConstraintData = (function (_super) { - __extends(PathConstraintData, _super); - function PathConstraintData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - PathConstraintData.toString = function () { - return "[class dragonBones.PathConstraintData]"; - }; - PathConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.pathSlot = null; - this.pathDisplayData = null; - this.bones.length = 0; - this.positionMode = 0 /* Fixed */; - this.spacingMode = 1 /* Fixed */; - this.rotateMode = 1 /* Chain */; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 0.0; - this.translateMix = 0.0; - }; - PathConstraintData.prototype.AddBone = function (value) { - this.bones.push(value); - }; - return PathConstraintData; - }(ConstraintData)); - dragonBones.PathConstraintData = PathConstraintData; -})(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 GeometryData = (function () { - function GeometryData() { - this.weight = null; // Initial value. - } - GeometryData.prototype.clear = function () { - if (!this.isShared && this.weight !== null) { - this.weight.returnToPool(); - } - this.isShared = false; - this.inheritDeform = false; - this.offset = 0; - this.data = null; - this.weight = null; - }; - GeometryData.prototype.shareFrom = function (value) { - this.isShared = true; - this.offset = value.offset; - this.weight = value.weight; - }; - Object.defineProperty(GeometryData.prototype, "vertexCount", { - get: function () { - var intArray = this.data.intArray; - return intArray[this.offset + 0 /* GeometryVertexCount */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GeometryData.prototype, "triangleCount", { - get: function () { - var intArray = this.data.intArray; - return intArray[this.offset + 1 /* GeometryTriangleCount */]; - }, - enumerable: true, - configurable: true - }); - return GeometryData; - }()); - dragonBones.GeometryData = GeometryData; - /** - * @private - */ - var DisplayData = (function (_super) { - __extends(DisplayData, _super); - function DisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.transform = new dragonBones.Transform(); - return _this; - } - DisplayData.prototype._onClear = function () { - this.name = ""; - this.path = ""; - this.transform.identity(); - this.parent = null; // - }; - return DisplayData; - }(dragonBones.BaseObject)); - dragonBones.DisplayData = DisplayData; - /** - * @private - */ - var ImageDisplayData = (function (_super) { - __extends(ImageDisplayData, _super); - function ImageDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.pivot = new dragonBones.Point(); - return _this; - } - ImageDisplayData.toString = function () { - return "[class dragonBones.ImageDisplayData]"; - }; - ImageDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Image */; - this.pivot.clear(); - this.texture = null; - }; - return ImageDisplayData; - }(DisplayData)); - dragonBones.ImageDisplayData = ImageDisplayData; - /** - * @private - */ - var ArmatureDisplayData = (function (_super) { - __extends(ArmatureDisplayData, _super); - function ArmatureDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.actions = []; - return _this; - } - ArmatureDisplayData.toString = function () { - return "[class dragonBones.ArmatureDisplayData]"; - }; - ArmatureDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - this.type = 1 /* Armature */; - this.inheritAnimation = false; - this.actions.length = 0; - this.armature = null; - }; - /** - * @private - */ - ArmatureDisplayData.prototype.addAction = function (value) { - this.actions.push(value); - }; - return ArmatureDisplayData; - }(DisplayData)); - dragonBones.ArmatureDisplayData = ArmatureDisplayData; - /** - * @private - */ - var MeshDisplayData = (function (_super) { - __extends(MeshDisplayData, _super); - function MeshDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new GeometryData(); - return _this; - } - MeshDisplayData.toString = function () { - return "[class dragonBones.MeshDisplayData]"; - }; - MeshDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Mesh */; - this.geometry.clear(); - this.texture = null; - }; - return MeshDisplayData; - }(DisplayData)); - dragonBones.MeshDisplayData = MeshDisplayData; - /** - * @private - */ - var BoundingBoxDisplayData = (function (_super) { - __extends(BoundingBoxDisplayData, _super); - function BoundingBoxDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.boundingBox = null; // Initial value. - return _this; - } - BoundingBoxDisplayData.toString = function () { - return "[class dragonBones.BoundingBoxDisplayData]"; - }; - BoundingBoxDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.boundingBox !== null) { - this.boundingBox.returnToPool(); - } - this.type = 3 /* BoundingBox */; - this.boundingBox = null; - }; - return BoundingBoxDisplayData; - }(DisplayData)); - dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; - /** - * @private - */ - var PathDisplayData = (function (_super) { - __extends(PathDisplayData, _super); - function PathDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new GeometryData(); - _this.curveLengths = []; - return _this; - } - PathDisplayData.toString = function () { - return "[class dragonBones.PathDisplayData]"; - }; - PathDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 4 /* Path */; - this.closed = false; - this.constantSpeed = false; - this.geometry.clear(); - this.curveLengths.length = 0; - }; - return PathDisplayData; - }(DisplayData)); - dragonBones.PathDisplayData = PathDisplayData; - /** - * @private - */ - var WeightData = (function (_super) { - __extends(WeightData, _super); - function WeightData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - WeightData.toString = function () { - return "[class dragonBones.WeightData]"; - }; - WeightData.prototype._onClear = function () { - this.count = 0; - this.offset = 0; - this.bones.length = 0; - }; - WeightData.prototype.addBone = function (value) { - this.bones.push(value); - }; - return WeightData; - }(dragonBones.BaseObject)); - dragonBones.WeightData = WeightData; -})(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 base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - var BoundingBoxData = (function (_super) { - __extends(BoundingBoxData, _super); - function BoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoundingBoxData.prototype._onClear = function () { - this.color = 0x000000; - this.width = 0.0; - this.height = 0.0; - }; - return BoundingBoxData; - }(dragonBones.BaseObject)); - dragonBones.BoundingBoxData = BoundingBoxData; - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var RectangleBoundingBoxData = (function (_super) { - __extends(RectangleBoundingBoxData, _super); - function RectangleBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - RectangleBoundingBoxData.toString = function () { - return "[class dragonBones.RectangleBoundingBoxData]"; - }; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { - var code = 0 /* InSide */; // initialised as being inside of [[clip window]] - if (x < xMin) { - code |= 1 /* Left */; - } - else if (x > xMax) { - code |= 2 /* Right */; - } - if (y < yMin) { - code |= 4 /* Top */; - } - else if (y > yMax) { - code |= 8 /* Bottom */; - } - return code; - }; - /** - * @private - */ - RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; - var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; - if (inSideA && inSideB) { - return -1; - } - var intersectionCount = 0; - var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - while (true) { - if ((outcode0 | outcode1) === 0) { - intersectionCount = 2; - break; - } - else if ((outcode0 & outcode1) !== 0) { - break; - } - // failed both tests, so calculate the line segment to clip - // from an outside point to an intersection with clip edge - var x = 0.0; - var y = 0.0; - var normalRadian = 0.0; - // At least one endpoint is outside the clip rectangle; pick it. - var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; - // Now find the intersection point; - if ((outcodeOut & 4 /* Top */) !== 0) { - x = xA + (xB - xA) * (yMin - yA) / (yB - yA); - y = yMin; - if (normalRadians !== null) { - normalRadian = -Math.PI * 0.5; - } - } - else if ((outcodeOut & 8 /* Bottom */) !== 0) { - x = xA + (xB - xA) * (yMax - yA) / (yB - yA); - y = yMax; - if (normalRadians !== null) { - normalRadian = Math.PI * 0.5; - } - } - else if ((outcodeOut & 2 /* Right */) !== 0) { - y = yA + (yB - yA) * (xMax - xA) / (xB - xA); - x = xMax; - if (normalRadians !== null) { - normalRadian = 0; - } - } - else if ((outcodeOut & 1 /* Left */) !== 0) { - y = yA + (yB - yA) * (xMin - xA) / (xB - xA); - x = xMin; - if (normalRadians !== null) { - normalRadian = Math.PI; - } - } - // Now we move outside point to intersection point to clip - // and get ready for next pass. - if (outcodeOut === outcode0) { - xA = x; - yA = y; - outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.x = normalRadian; - } - } - else { - xB = x; - yB = y; - outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.y = normalRadian; - } - } - } - if (intersectionCount) { - if (inSideA) { - intersectionCount = 2; // 10 - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = xB; - } - if (normalRadians !== null) { - normalRadians.x = normalRadians.y + Math.PI; - } - } - else if (inSideB) { - intersectionCount = 1; // 01 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - } - } - return intersectionCount; - }; - RectangleBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Rectangle */; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - return true; - } - } - return false; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var widthH = this.width * 0.5; - var heightH = this.height * 0.5; - var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return RectangleBoundingBoxData; - }(BoundingBoxData)); - dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var EllipseBoundingBoxData = (function (_super) { - __extends(EllipseBoundingBoxData, _super); - function EllipseBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - EllipseBoundingBoxData.toString = function () { - return "[class dragonBones.EllipseData]"; - }; - /** - * @private - */ - EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var d = widthH / heightH; - var dd = d * d; - yA *= d; - yB *= d; - var dX = xB - xA; - var dY = yB - yA; - var lAB = Math.sqrt(dX * dX + dY * dY); - var xD = dX / lAB; - var yD = dY / lAB; - var a = (xC - xA) * xD + (yC - yA) * yD; - var aa = a * a; - var ee = xA * xA + yA * yA; - var rr = widthH * widthH; - var dR = rr - ee + aa; - var intersectionCount = 0; - if (dR >= 0.0) { - var dT = Math.sqrt(dR); - var sA = a - dT; - var sB = a + dT; - var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); - var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); - var sideAB = inSideA * inSideB; - if (sideAB < 0) { - return -1; - } - else if (sideAB === 0) { - if (inSideA === -1) { - intersectionCount = 2; // 10 - xB = xA + sB * xD; - yB = (yA + sB * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (inSideB === 1) { - intersectionCount = 1; // 01 - xA = xA + sA * xD; - yA = (yA + sA * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA + sA * xD; - intersectionPointA.y = (yA + sA * yD) / d; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); - } - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA + sB * xD; - intersectionPointB.y = (yA + sB * yD) / d; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); - } - } - } - } - } - return intersectionCount; - }; - EllipseBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Ellipse */; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - pY *= widthH / heightH; - return Math.sqrt(pX * pX + pY * pY) <= widthH; - } - } - return false; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return EllipseBoundingBoxData; - }(BoundingBoxData)); - dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var PolygonBoundingBoxData = (function (_super) { - __extends(PolygonBoundingBoxData, _super); - function PolygonBoundingBoxData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - _this.vertices = []; - return _this; - } - PolygonBoundingBoxData.toString = function () { - return "[class dragonBones.PolygonBoundingBoxData]"; - }; - /** - * @private - */ - PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (xA === xB) { - xA = xB + 0.000001; - } - if (yA === yB) { - yA = yB + 0.000001; - } - var count = vertices.length; - var dXAB = xA - xB; - var dYAB = yA - yB; - var llAB = xA * yB - yA * xB; - var intersectionCount = 0; - var xC = vertices[count - 2]; - var yC = vertices[count - 1]; - var dMin = 0.0; - var dMax = 0.0; - var xMin = 0.0; - var yMin = 0.0; - var xMax = 0.0; - var yMax = 0.0; - for (var i = 0; i < count; i += 2) { - var xD = vertices[i]; - var yD = vertices[i + 1]; - if (xC === xD) { - xC = xD + 0.0001; - } - if (yC === yD) { - yC = yD + 0.0001; - } - var dXCD = xC - xD; - var dYCD = yC - yD; - var llCD = xC * yD - yC * xD; - var ll = dXAB * dYCD - dYAB * dXCD; - var x = (llAB * dXCD - dXAB * llCD) / ll; - if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { - var y = (llAB * dYCD - dYAB * llCD) / ll; - if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { - if (intersectionPointB !== null) { - var d = x - xA; - if (d < 0.0) { - d = -d; - } - if (intersectionCount === 0) { - dMin = d; - dMax = d; - xMin = x; - yMin = y; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - } - else { - if (d < dMin) { - dMin = d; - xMin = x; - yMin = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - if (d > dMax) { - dMax = d; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - } - intersectionCount++; - } - else { - xMin = x; - yMin = y; - xMax = x; - yMax = y; - intersectionCount++; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - break; - } - } - } - xC = xD; - yC = yD; - } - if (intersectionCount === 1) { - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMin; - intersectionPointB.y = yMin; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (intersectionCount > 1) { - intersectionCount++; - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMax; - intersectionPointB.y = yMax; - } - } - return intersectionCount; - }; - PolygonBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Polygon */; - this.x = 0.0; - this.y = 0.0; - this.vertices.length = 0; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var isInSide = false; - if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { - for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { - var yA = this.vertices[iP + 1]; - var yB = this.vertices[i + 1]; - if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { - var xA = this.vertices[iP]; - var xB = this.vertices[i]; - if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { - isInSide = !isInSide; - } - } - iP = i; - } - } - return isInSide; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = 0; - if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { - intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); - } - return intersectionCount; - }; - return PolygonBoundingBoxData; - }(BoundingBoxData)); - dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; -})(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 animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationData = (function (_super) { - __extends(AnimationData, _super); - function AnimationData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.cachedFrames = []; - /** - * @private - */ - _this.boneTimelines = {}; - /** - * @private - */ - _this.slotTimelines = {}; - /** - * @private - */ - _this.constraintTimelines = {}; - /** - * @private - */ - _this.animationTimelines = {}; - /** - * @private - */ - _this.boneCachedFrameIndices = {}; - /** - * @private - */ - _this.slotCachedFrameIndices = {}; - /** - * @private - */ - _this.actionTimeline = null; // Initial value. - /** - * @private - */ - _this.zOrderTimeline = null; // Initial value. - return _this; - } - AnimationData.toString = function () { - return "[class dragonBones.AnimationData]"; - }; - AnimationData.prototype._onClear = function () { - for (var k in this.boneTimelines) { - for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - delete this.boneTimelines[k]; - } - for (var k in this.slotTimelines) { - for (var _b = 0, _c = this.slotTimelines[k]; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - delete this.slotTimelines[k]; - } - for (var k in this.constraintTimelines) { - for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - delete this.constraintTimelines[k]; - } - for (var k in this.animationTimelines) { - for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - delete this.animationTimelines[k]; - } - for (var k in this.boneCachedFrameIndices) { - delete this.boneCachedFrameIndices[k]; - } - for (var k in this.slotCachedFrameIndices) { - delete this.slotCachedFrameIndices[k]; - } - if (this.actionTimeline !== null) { - this.actionTimeline.returnToPool(); - } - if (this.zOrderTimeline !== null) { - this.zOrderTimeline.returnToPool(); - } - this.frameIntOffset = 0; - this.frameFloatOffset = 0; - this.frameOffset = 0; - this.blendType = 0 /* None */; - this.frameCount = 0; - this.playTimes = 0; - this.duration = 0.0; - this.scale = 1.0; - this.fadeInTime = 0.0; - this.cacheFrameRate = 0.0; - this.name = ""; - this.cachedFrames.length = 0; - // this.boneTimelines.clear(); - // this.slotTimelines.clear(); - // this.constraintTimelines.clear(); - // this.animationTimelines.clear(); - // this.boneCachedFrameIndices.clear(); - // this.slotCachedFrameIndices.clear(); - this.actionTimeline = null; - this.zOrderTimeline = null; - this.parent = null; // - }; - /** - * @internal - */ - AnimationData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0.0) { - return; - } - this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); - var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. - this.cachedFrames.length = cacheFrameCount; - for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { - this.cachedFrames[i] = false; - } - for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { - var bone = _a[_i]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.boneCachedFrameIndices[bone.name] = indices; - } - for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { - var slot = _c[_b]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.slotCachedFrameIndices[slot.name] = indices; - } - }; - /** - * @private - */ - AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : (this.constraintTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.getBoneTimelines = function (timelineName) { - return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotTimelines = function (timelineName) { - return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getConstraintTimelines = function (timelineName) { - return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getAnimationTimelines = function (timelineName) { - return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { - return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { - return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; - }; - return AnimationData; - }(dragonBones.BaseObject)); - dragonBones.AnimationData = AnimationData; - /** - * @private - */ - var TimelineData = (function (_super) { - __extends(TimelineData, _super); - function TimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineData.toString = function () { - return "[class dragonBones.TimelineData]"; - }; - TimelineData.prototype._onClear = function () { - this.type = 10 /* BoneAll */; - this.offset = 0; - this.frameIndicesOffset = -1; - }; - return TimelineData; - }(dragonBones.BaseObject)); - dragonBones.TimelineData = TimelineData; - /** - * @internal - */ - var AnimationTimelineData = (function (_super) { - __extends(AnimationTimelineData, _super); - function AnimationTimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationTimelineData.toString = function () { - return "[class dragonBones.AnimationTimelineData]"; - }; - AnimationTimelineData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.x = 0.0; - this.y = 0.0; - }; - return AnimationTimelineData; - }(TimelineData)); - dragonBones.AnimationTimelineData = AnimationTimelineData; -})(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 animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - var AnimationConfig = (function (_super) { - __extends(AnimationConfig, _super); - function AnimationConfig() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.boneMask = []; - return _this; - } - AnimationConfig.toString = function () { - return "[class dragonBones.AnimationConfig]"; - }; - AnimationConfig.prototype._onClear = function () { - this.pauseFadeOut = true; - this.fadeOutMode = 4 /* All */; - this.fadeOutTweenType = 1 /* Line */; - this.fadeOutTime = -1.0; - this.actionEnabled = true; - this.additive = false; - this.displayControl = true; - this.pauseFadeIn = true; - this.resetToPose = true; - this.fadeInTweenType = 1 /* Line */; - this.playTimes = -1; - this.layer = 0; - this.position = 0.0; - this.duration = -1.0; - this.timeScale = -100.0; - this.weight = 1.0; - this.fadeInTime = -1.0; - this.autoFadeOutTime = -1.0; - this.name = ""; - this.animation = ""; - this.group = ""; - this.boneMask.length = 0; - }; - /** - * @private - */ - AnimationConfig.prototype.clear = function () { - this._onClear(); - }; - /** - * @private - */ - AnimationConfig.prototype.copyFrom = function (value) { - this.pauseFadeOut = value.pauseFadeOut; - this.fadeOutMode = value.fadeOutMode; - this.autoFadeOutTime = value.autoFadeOutTime; - this.fadeOutTweenType = value.fadeOutTweenType; - this.actionEnabled = value.actionEnabled; - this.additive = value.additive; - this.displayControl = value.displayControl; - this.pauseFadeIn = value.pauseFadeIn; - this.resetToPose = value.resetToPose; - this.playTimes = value.playTimes; - this.layer = value.layer; - this.position = value.position; - this.duration = value.duration; - this.timeScale = value.timeScale; - this.fadeInTime = value.fadeInTime; - this.fadeOutTime = value.fadeOutTime; - this.fadeInTweenType = value.fadeInTweenType; - this.weight = value.weight; - this.name = value.name; - this.animation = value.animation; - this.group = value.group; - this.boneMask.length = value.boneMask.length; - for (var i = 0, l = this.boneMask.length; i < l; ++i) { - this.boneMask[i] = value.boneMask[i]; - } - }; - return AnimationConfig; - }(dragonBones.BaseObject)); - dragonBones.AnimationConfig = AnimationConfig; -})(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 texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var TextureAtlasData = (function (_super) { - __extends(TextureAtlasData, _super); - function TextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.textures = {}; - return _this; - } - TextureAtlasData.prototype._onClear = function () { - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - this.autoSearch = false; - this.width = 0; - this.height = 0; - this.scale = 1.0; - // this.textures.clear(); - this.name = ""; - this.imagePath = ""; - }; - /** - * @private - */ - TextureAtlasData.prototype.copyFrom = function (value) { - this.autoSearch = value.autoSearch; - this.scale = value.scale; - this.width = value.width; - this.height = value.height; - this.name = value.name; - this.imagePath = value.imagePath; - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - // this.textures.clear(); - for (var k in value.textures) { - var texture = this.createTexture(); - texture.copyFrom(value.textures[k]); - this.textures[k] = texture; - } - }; - /** - * @internal - */ - TextureAtlasData.prototype.addTexture = function (value) { - if (value.name in this.textures) { - console.warn("Same texture: " + value.name); - return; - } - value.parent = this; - this.textures[value.name] = value; - }; - /** - * @private - */ - TextureAtlasData.prototype.getTexture = function (textureName) { - return textureName in this.textures ? this.textures[textureName] : null; - }; - return TextureAtlasData; - }(dragonBones.BaseObject)); - dragonBones.TextureAtlasData = TextureAtlasData; - /** - * @private - */ - var TextureData = (function (_super) { - __extends(TextureData, _super); - function TextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.region = new dragonBones.Rectangle(); - _this.frame = null; // Initial value. - return _this; - } - TextureData.createRectangle = function () { - return new dragonBones.Rectangle(); - }; - TextureData.prototype._onClear = function () { - this.rotated = false; - this.name = ""; - this.region.clear(); - this.parent = null; // - this.frame = null; - }; - TextureData.prototype.copyFrom = function (value) { - this.rotated = value.rotated; - this.name = value.name; - this.region.copyFrom(value.region); - this.parent = value.parent; - if (this.frame === null && value.frame !== null) { - this.frame = TextureData.createRectangle(); - } - else if (this.frame !== null && value.frame === null) { - this.frame = null; - } - if (this.frame !== null && value.frame !== null) { - this.frame.copyFrom(value.frame); - } - }; - return TextureData; - }(dragonBones.BaseObject)); - dragonBones.TextureData = TextureData; -})(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_1) { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - var Armature = (function (_super) { - __extends(Armature, _super); - function Armature() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._slots = []; - /** - * @internal - */ - _this._constraints = []; - _this._actions = []; - _this._animation = null; // Initial value. - _this._proxy = null; // Initial value. - /** - * @internal - */ - _this._replaceTextureAtlasData = null; // Initial value. - _this._clock = null; // Initial value. - return _this; - } - Armature.toString = function () { - return "[class dragonBones.Armature]"; - }; - Armature._onSortSlots = function (a, b) { - return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; - }; - Armature.prototype._onClear = function () { - if (this._clock !== null) { - this._clock.remove(this); - } - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone.returnToPool(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot.returnToPool(); - } - for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { - var constraint = _e[_d]; - constraint.returnToPool(); - } - for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { - var action = _g[_f]; - action.returnToPool(); - } - if (this._animation !== null) { - this._animation.returnToPool(); - } - if (this._proxy !== null) { - this._proxy.dbClear(); - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - } - this.inheritAnimation = true; - this.userData = null; - this._lockUpdate = false; - this._slotsDirty = true; - this._zOrderDirty = false; - this._zIndexDirty = false; - this._alphaDirty = true; - this._flipX = false; - this._flipY = false; - this._cacheFrameIndex = -1; - this._alpha = 1.0; - this._globalAlpha = 1.0; - this._bones.length = 0; - this._slots.length = 0; - this._constraints.length = 0; - this._actions.length = 0; - this._armatureData = null; // - this._animation = null; // - this._proxy = null; // - this._display = null; - this._replaceTextureAtlasData = null; - this._replacedTexture = null; - this._dragonBones = null; // - this._clock = null; - this._parent = null; - }; - /** - * @internal - */ - Armature.prototype._sortZOrder = function (slotIndices, offset) { - var slotDatas = this._armatureData.sortedSlots; - var isOriginal = slotIndices === null; - if (this._zOrderDirty || !isOriginal) { - for (var i = 0, l = slotDatas.length; i < l; ++i) { - var slotIndex = isOriginal ? i : slotIndices[offset + i]; - if (slotIndex < 0 || slotIndex >= l) { - continue; - } - var slotData = slotDatas[slotIndex]; - var slot = this.getSlot(slotData.name); - if (slot !== null) { - slot._setZOrder(i); - } - } - this._slotsDirty = true; - this._zOrderDirty = !isOriginal; - } - }; - /** - * @internal - */ - Armature.prototype._addBone = function (value) { - if (this._bones.indexOf(value) < 0) { - this._bones.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addSlot = function (value) { - if (this._slots.indexOf(value) < 0) { - this._slots.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addConstraint = function (value) { - if (this._constraints.indexOf(value) < 0) { - this._constraints.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._bufferAction = function (action, append) { - if (this._actions.indexOf(action) < 0) { - if (append) { - this._actions.push(action); - } - else { - this._actions.unshift(action); - } - } - }; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.dispose = function () { - if (this._armatureData !== null) { - this._lockUpdate = true; - this._dragonBones.bufferObject(this); - } - }; - /** - * @internal - */ - Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { - if (this._armatureData !== null) { - return; - } - this._armatureData = armatureData; - this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); - this._proxy = proxy; - this._display = display; - this._dragonBones = dragonBones; - this._proxy.dbInit(this); - this._animation.init(this); - this._animation.animations = this._armatureData.animations; - }; - /** - * @inheritDoc - */ - Armature.prototype.advanceTime = function (passedTime) { - if (this._lockUpdate) { - return; - } - this._lockUpdate = true; - if (this._armatureData === null) { - console.warn("The armature has been disposed."); - return; - } - else if (this._armatureData.parent === null) { - console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); - return; - } - var prevCacheFrameIndex = this._cacheFrameIndex; - // Update animation. - this._animation.advanceTime(passedTime); - // Sort slots. - if (this._slotsDirty || this._zIndexDirty) { - this._slots.sort(Armature._onSortSlots); - if (this._zIndexDirty) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i]._setZOrder(i); // - } - } - this._slotsDirty = false; - this._zIndexDirty = false; - } - // Update alpha. - if (this._alphaDirty) { - this._alphaDirty = false; - this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone._updateAlpha(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot._updateAlpha(); - } - } - // Update bones and slots. - if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { - var i = 0, l = 0; - for (i = 0, l = this._bones.length; i < l; ++i) { - this._bones[i].update(this._cacheFrameIndex); - } - for (i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].update(this._cacheFrameIndex); - } - } - // Do actions. - if (this._actions.length > 0) { - for (var _d = 0, _e = this._actions; _d < _e.length; _d++) { - var action = _e[_d]; - var actionData = action.actionData; - if (actionData !== null) { - if (actionData.type === 0 /* Play */) { - if (action.slot !== null) { - var childArmature = action.slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - else if (action.bone !== null) { - for (var _f = 0, _g = this.getSlots(); _f < _g.length; _f++) { - var slot = _g[_f]; - if (slot.parent === action.bone) { - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - } - } - else { - this._animation.fadeIn(actionData.name); - } - } - } - action.returnToPool(); - } - this._actions.length = 0; - } - this._lockUpdate = false; - this._proxy.dbUpdate(); - }; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.invalidUpdate = function (boneName, updateSlot) { - if (boneName === void 0) { boneName = null; } - if (updateSlot === void 0) { updateSlot = false; } - if (boneName !== null && boneName.length > 0) { - var bone = this.getBone(boneName); - if (bone !== null) { - bone.invalidUpdate(); - if (updateSlot) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === bone) { - slot.invalidUpdate(); - } - } - } - } - } - else { - for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { - var bone = _c[_b]; - bone.invalidUpdate(); - } - if (updateSlot) { - for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { - var slot = _e[_d]; - slot.invalidUpdate(); - } - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.containsPoint = function (x, y) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.containsPoint(x, y)) { - return slot; - } - } - return null; - }; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var isV = xA === xB; - var dMin = 0.0; - var dMax = 0.0; - var intXA = 0.0; - var intYA = 0.0; - var intXB = 0.0; - var intYB = 0.0; - var intAN = 0.0; - var intBN = 0.0; - var intSlotA = null; - var intSlotB = null; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionPointA !== null || intersectionPointB !== null) { - if (intersectionPointA !== null) { - var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotA === null || d < dMin) { - dMin = d; - intXA = intersectionPointA.x; - intYA = intersectionPointA.y; - intSlotA = slot; - if (normalRadians) { - intAN = normalRadians.x; - } - } - } - if (intersectionPointB !== null) { - var d = intersectionPointB.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotB === null || d > dMax) { - dMax = d; - intXB = intersectionPointB.x; - intYB = intersectionPointB.y; - intSlotB = slot; - if (normalRadians !== null) { - intBN = normalRadians.y; - } - } - } - } - else { - intSlotA = slot; - break; - } - } - } - if (intSlotA !== null && intersectionPointA !== null) { - intersectionPointA.x = intXA; - intersectionPointA.y = intYA; - if (normalRadians !== null) { - normalRadians.x = intAN; - } - } - if (intSlotB !== null && intersectionPointB !== null) { - intersectionPointB.x = intXB; - intersectionPointB.y = intYB; - if (normalRadians !== null) { - normalRadians.y = intBN; - } - } - return intSlotA; - }; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBone = function (name) { - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.name === name) { - return bone; - } - } - return null; - }; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBoneByDisplay = function (display) { - var slot = this.getSlotByDisplay(display); - return slot !== null ? slot.parent : null; - }; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlot = function (name) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.name === name) { - return slot; - } - } - return null; - }; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlotByDisplay = function (display) { - if (display !== null) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.display === display) { - return slot; - } - } - } - return null; - }; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBones = function () { - return this._bones; - }; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlots = function () { - return this._slots; - }; - Object.defineProperty(Armature.prototype, "flipX", { - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipX; - }, - set: function (value) { - if (this._flipX === value) { - return; - } - this._flipX = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "flipY", { - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipY; - }, - set: function (value) { - if (this._flipY === value) { - return; - } - this._flipY = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "cacheFrameRate", { - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData.cacheFrameRate; - }, - set: function (value) { - if (this._armatureData.cacheFrameRate !== value) { - this._armatureData.cacheFrames(value); - // Set child armature frameRate. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.cacheFrameRate = value; - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "name", { - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armatureData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "armatureData", { - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "animation", { - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "proxy", { - /** - * @pivate - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "eventDispatcher", { - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "display", { - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "replacedTexture", { - /** - * @private - */ - get: function () { - return this._replacedTexture; - }, - set: function (value) { - if (this._replacedTexture === value) { - return; - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - this._replaceTextureAtlasData = null; - } - this._replacedTexture = value; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - slot.invalidUpdate(); - slot.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - // Update childArmature clock. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.clock = this._clock; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "parent", { - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.getDisplay = function () { - return this._display; - }; - return Armature; - }(dragonBones_1.BaseObject)); - dragonBones_1.Armature = Armature; -})(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 base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - var TransformObject = (function (_super) { - __extends(TransformObject, _super); - function TransformObject() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.globalTransformMatrix = new dragonBones.Matrix(); - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.global = new dragonBones.Transform(); - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.offset = new dragonBones.Transform(); - return _this; - } - /** - */ - TransformObject.prototype._onClear = function () { - this.globalTransformMatrix.identity(); - this.global.identity(); - this.offset.identity(); - this.origin = null; - this.userData = null; - this._globalDirty = false; - this._alpha = 1.0; - this._globalAlpha = 1.0; - this._armature = null; // - }; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - TransformObject.prototype.updateGlobalTransform = function () { - if (this._globalDirty) { - this._globalDirty = false; - this.global.fromMatrix(this.globalTransformMatrix); - } - }; - Object.defineProperty(TransformObject.prototype, "armature", { - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - TransformObject._helpMatrix = new dragonBones.Matrix(); - TransformObject._helpTransform = new dragonBones.Transform(); - TransformObject._helpPoint = new dragonBones.Point(); - return TransformObject; - }(dragonBones.BaseObject)); - dragonBones.TransformObject = TransformObject; -})(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) { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - var Bone = (function (_super) { - __extends(Bone, _super); - function Bone() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.animationPose = new dragonBones.Transform(); - return _this; - } - Bone.toString = function () { - return "[class dragonBones.Bone]"; - }; - Bone.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.offsetMode = 1 /* Additive */; - this.animationPose.identity(); - this._transformDirty = false; - this._childrenTransformDirty = false; - this._localDirty = true; - this._hasConstraint = false; - this._visible = true; - this._cachedFrameIndex = -1; - this._boneData = null; // - this._parent = null; // - this._cachedFrameIndices = null; - }; - Bone.prototype._updateGlobalTransformMatrix = function (isCache) { - // For typescript. - var boneData = this._boneData; - var global = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - var origin = this.origin; - var offset = this.offset; - var animationPose = this.animationPose; - var parent = this._parent; // - var flipX = this._armature.flipX; - var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; - var inherit = parent !== null; - var rotation = 0.0; - if (this.offsetMode === 1 /* Additive */) { - if (origin !== null) { - // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); - global.x = origin.x + offset.x + animationPose.x; - global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; - global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; - if (dragonBones.DragonBones.yDown) { - global.y = origin.y + offset.y + animationPose.y; - global.skew = origin.skew + offset.skew + animationPose.skew; - global.rotation = origin.rotation + offset.rotation + animationPose.rotation; - } - else { - global.y = origin.y - offset.y + animationPose.y; - global.skew = origin.skew - offset.skew + animationPose.skew; - global.rotation = origin.rotation - offset.rotation + animationPose.rotation; - } - } - else { - global.copyFrom(offset); - if (!dragonBones.DragonBones.yDown) { - global.y = -global.y; - global.skew = -global.skew; - global.rotation = -global.rotation; - } - global.add(animationPose); - } - } - else if (this.offsetMode === 0 /* None */) { - if (origin !== null) { - global.copyFrom(origin).add(animationPose); - } - else { - global.copyFrom(animationPose); - } - } - else { - inherit = false; - global.copyFrom(offset); - if (!dragonBones.DragonBones.yDown) { - global.y = -global.y; - global.skew = -global.skew; - global.rotation = -global.rotation; - } - } - if (inherit) { - var isSurface = parent._boneData.type === 1 /* Surface */; - var surfaceBone = isSurface ? parent._bone : null; - var parentMatrix = isSurface ? parent._getGlobalTransformMatrix(global.x, global.y) : parent.globalTransformMatrix; - if (boneData.inheritScale && (!isSurface || surfaceBone !== null)) { - if (isSurface) { - if (boneData.inheritRotation) { - global.rotation += parent.global.rotation; - } - surfaceBone.updateGlobalTransform(); - global.scaleX *= surfaceBone.global.scaleX; - global.scaleY *= surfaceBone.global.scaleY; - parentMatrix.transformPoint(global.x, global.y, global); - global.toMatrix(globalTransformMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - } - else { - if (!boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (flipX && flipY) { - rotation = global.rotation - (parent.global.rotation + Math.PI); - } - else if (flipX) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else if (flipY) { - rotation = global.rotation + parent.global.rotation; - } - else { - rotation = global.rotation - parent.global.rotation; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - globalTransformMatrix.concat(parentMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - if (isCache) { - global.fromMatrix(globalTransformMatrix); - } - else { - this._globalDirty = true; - } - } - } - else { - if (boneData.inheritTranslation) { - var x = global.x; - var y = global.y; - global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - else { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - } - if (boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (parent.global.scaleX < 0.0) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else { - rotation = global.rotation + parent.global.rotation; - } - if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { - rotation -= global.rotation * 2.0; - if (flipX !== flipY || boneData.inheritReflection) { - global.skew += Math.PI; - } - if (!dragonBones.DragonBones.yDown) { - global.skew = -global.skew; - } - } - global.rotation = rotation; - } - else if (flipX || flipY) { - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - } - else { - if (flipX || flipY) { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - }; - /** - * @internal - */ - Bone.prototype._updateAlpha = function () { - if (this._parent !== null) { - this._globalAlpha = this._alpha * this._parent._globalAlpha; - } - else { - this._globalAlpha = this._alpha * this._armature._globalAlpha; - } - }; - /** - * @internal - */ - Bone.prototype.init = function (boneData, armatureValue) { - if (this._boneData !== null) { - return; - } - this._boneData = boneData; - this._armature = armatureValue; - this._alpha = this._boneData.alpha; - if (this._boneData.parent !== null) { - this._parent = this._armature.getBone(this._boneData.parent.name); - } - this._armature._addBone(this); - // - this.origin = this._boneData.transform; - }; - /** - * @internal - */ - Bone.prototype.update = function (cacheFrameIndex) { - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - /** - * @internal - */ - Bone.prototype.updateByConstraint = function () { - if (this._localDirty) { - this._localDirty = false; - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - this._updateGlobalTransformMatrix(true); - } - this._transformDirty = true; - } - }; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.invalidUpdate = function () { - this._transformDirty = true; - }; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.parent; - } - return ancestor === this; - }; - Object.defineProperty(Bone.prototype, "boneData", { - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._boneData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "visible", { - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slot._updateVisible(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "name", { - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._boneData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - return Bone; - }(dragonBones.TransformObject)); - dragonBones.Bone = Bone; -})(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) { - /** - * @internal - */ - var Surface = (function (_super) { - __extends(Surface, _super); - function Surface() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._vertices = []; - _this._deformVertices = []; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - _this._hullCache = []; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - _this._matrixCahce = []; - return _this; - } - Surface.toString = function () { - return "[class dragonBones.Surface]"; - }; - Surface.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dX = 0.0; - this._dY = 0.0; - this._k = 0.0; - this._kX = 0.0; - this._kY = 0.0; - this._vertices.length = 0; - this._deformVertices.length = 0; - this._matrixCahce.length = 0; - this._hullCache.length = 0; - this._bone = null; - }; - Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { - var dabX = bX - aX; - var dabY = bY - aY; - var dacX = cX - aX; - var dacY = cY - aY; - transform.rotation = Math.atan2(dabY, dabX); - transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; - if (isDown) { - transform.rotation += Math.PI; - } - transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; - transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; - transform.toMatrix(matrix); - transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); - transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); - }; - Surface.prototype._updateVertices = function () { - var data = this._armature.armatureData.parent; - var geometry = this._boneData.geometry; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; - var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; - var vertices = this._vertices; - var animationVertices = this._deformVertices; - if (this._parent !== null) { - if (this._parent._boneData.type === 1 /* Surface */) { - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - var matrix = this._parent._getGlobalTransformMatrix(x, y); - // - vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; - vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - } - else { - var parentMatrix = this._parent.globalTransformMatrix; - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - // - vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - } - } - else { - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; - vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - } - } - }; - Surface.prototype._updateGlobalTransformMatrix = function (isCache) { - // tslint:disable-next-line:no-unused-expression - isCache; - var segmentXD = this._boneData.segmentX * 2; - var lastIndex = this._vertices.length - 2; - var lA = 200.0; - // - var raX = this._vertices[0]; - var raY = this._vertices[1]; - var rbX = this._vertices[segmentXD]; - var rbY = this._vertices[segmentXD + 1]; - var rcX = this._vertices[lastIndex]; - var rcY = this._vertices[lastIndex + 1]; - var rdX = this._vertices[lastIndex - segmentXD]; - var rdY = this._vertices[lastIndex - segmentXD + 1]; - // - var dacX = raX + (rcX - raX) * 0.5; - var dacY = raY + (rcY - raY) * 0.5; - var dbdX = rbX + (rdX - rbX) * 0.5; - var dbdY = rbY + (rdY - rbY) * 0.5; - var aX = dacX + (dbdX - dacX) * 0.5; - var aY = dacY + (dbdY - dacY) * 0.5; - var bX = rbX + (rcX - rbX) * 0.5; - var bY = rbY + (rcY - rbY) * 0.5; - var cX = rdX + (rcX - rdX) * 0.5; - var cY = rdY + (rcY - rdY) * 0.5; - // TODO interpolation - this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); - this._globalDirty = false; - }; - Surface.prototype._getGlobalTransformMatrix = function (x, y) { - var lA = 200.0; - var lB = 1000.0; - if (x < -lB || lB < x || y < -lB || lB < y) { - return this.globalTransformMatrix; - } - var isDown = false; - var surfaceData = this._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var segmentXD = surfaceData.segmentX * 2; - var dX = this._dX; - var dY = this._dY; - var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 - var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 - var matrixIndex = 0; - var pX = indexX * dX - lA; - var pY = indexY * dY - lA; - // - var matrices = this._matrixCahce; - var helpMatrix = Surface._helpMatrix; - if (x < -lA) { - if (y < -lA || y >= lA) { - return this.globalTransformMatrix; - } - // Left. - isDown = y > this._kX * (x + lA) + pY; - matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexY * (segmentXD + 2); - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[2] - (segmentY - indexY) * ddX; - var sY = this._hullCache[3] - (segmentY - indexY) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (x >= lA) { - if (y < -lA || y >= lA) { - return this.globalTransformMatrix; - } - // Right. - isDown = y > this._kX * (x - lB) + pY; - matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[0] + indexY * ddX; - var sY = this._hullCache[1] + indexY * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y < -lA) { - if (x < -lA || x >= lA) { - return this.globalTransformMatrix; - } - // Up. - isDown = y > this._kY * (x - pX - dX) - lB; - matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[8] + indexX * ddX; - var sY = this._hullCache[9] + indexX * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y >= lA) { - if (x < -lA || x >= lA) { - return this.globalTransformMatrix; - } - // Down - isDown = y > this._kY * (x - pX - dX) + lA; - matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[6] - (segmentX - indexX) * ddX; - var sY = this._hullCache[7] - (segmentX - indexX) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else { - isDown = y > this._k * (x - pX - dX) + pY; - matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - return helpMatrix; - }; - /** - * @internal - * @private - */ - Surface.prototype.init = function (surfaceData, armatureValue) { - if (this._boneData !== null) { - return; - } - _super.prototype.init.call(this, surfaceData, armatureValue); - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; - var lB = 1000.0; - var lA = 200.0; - // - this._dX = lA * 2.0 / segmentX; - this._dY = lA * 2.0 / segmentY; - this._k = -this._dY / this._dX; - this._kX = -this._dY / (lB - lA); - this._kY = -(lB - lA) / this._dX; - this._vertices.length = vertexCount * 2; - this._deformVertices.length = vertexCount * 2; - this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; - this._hullCache.length = 10; - for (var i = 0; i < vertexCount * 2; ++i) { - this._deformVertices[i] = 0.0; - } - if (this._parent !== null) { - if (this._parent.boneData.type === 0 /* Bone */) { - this._bone = this._parent; - } - else { - this._bone = this._parent._bone; - } - } - }; - /** - * @internal - */ - Surface.prototype.update = function (cacheFrameIndex) { - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { - this._matrixCahce[i] = -1.0; - } - // - this._updateVertices(); - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // Update hull vertices. - var lB = 1000.0; - var lA = 200.0; - var ddX = 2 * this.global.x; - var ddY = 2 * this.global.y; - // - var helpPoint = Surface._helpPoint; - this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); - this._hullCache[0] = helpPoint.x; - this._hullCache[1] = helpPoint.y; - this._hullCache[2] = ddX - helpPoint.x; - this._hullCache[3] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); - this._hullCache[4] = helpPoint.x; - this._hullCache[5] = helpPoint.y; - // - this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); - this._hullCache[6] = helpPoint.x; - this._hullCache[7] = helpPoint.y; - this._hullCache[8] = ddX - helpPoint.x; - this._hullCache[9] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); - this._hullCache[10] = helpPoint.x; - this._hullCache[11] = helpPoint.y; - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - return Surface; - }(dragonBones.Bone)); - dragonBones.Surface = Surface; -})(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 DisplayFrame = (function (_super) { - __extends(DisplayFrame, _super); - function DisplayFrame() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.deformVertices = []; - return _this; - } - DisplayFrame.toString = function () { - return "[class dragonBones.DisplayFrame]"; - }; - DisplayFrame.prototype._onClear = function () { - this.rawDisplayData = null; - this.displayData = null; - this.textureData = null; - this.display = null; - this.deformVertices.length = 0; - }; - DisplayFrame.prototype.updateDeformVertices = function () { - if (this.rawDisplayData === null || this.deformVertices.length !== 0) { - return; - } - var rawGeometryData; - if (this.rawDisplayData.type === 2 /* Mesh */) { - rawGeometryData = this.rawDisplayData.geometry; - } - else if (this.rawDisplayData.type === 4 /* Path */) { - rawGeometryData = this.rawDisplayData.geometry; - } - else { - return; - } - var vertexCount = 0; - if (rawGeometryData.weight !== null) { - vertexCount = rawGeometryData.weight.count * 2; - } - else { - vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; - } - this.deformVertices.length = vertexCount; - for (var i = 0, l = this.deformVertices.length; i < l; ++i) { - this.deformVertices[i] = 0.0; - } - }; - DisplayFrame.prototype.getGeometryData = function () { - if (this.displayData !== null) { - if (this.displayData.type === 2 /* Mesh */) { - return this.displayData.geometry; - } - if (this.displayData.type === 4 /* Path */) { - return this.displayData.geometry; - } - } - if (this.rawDisplayData !== null) { - if (this.rawDisplayData.type === 2 /* Mesh */) { - return this.rawDisplayData.geometry; - } - if (this.rawDisplayData.type === 4 /* Path */) { - return this.rawDisplayData.geometry; - } - } - return null; - }; - DisplayFrame.prototype.getBoundingBox = function () { - if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { - return this.displayData.boundingBox; - } - if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { - return this.rawDisplayData.boundingBox; - } - return null; - }; - DisplayFrame.prototype.getTextureData = function () { - if (this.displayData !== null) { - if (this.displayData.type === 0 /* Image */) { - return this.displayData.texture; - } - if (this.displayData.type === 2 /* Mesh */) { - return this.displayData.texture; - } - } - if (this.textureData !== null) { - return this.textureData; - } - if (this.rawDisplayData !== null) { - if (this.rawDisplayData.type === 0 /* Image */) { - return this.rawDisplayData.texture; - } - if (this.rawDisplayData.type === 2 /* Mesh */) { - return this.rawDisplayData.texture; - } - } - return null; - }; - return DisplayFrame; - }(dragonBones.BaseObject)); - dragonBones.DisplayFrame = DisplayFrame; - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - var Slot = (function (_super) { - __extends(Slot, _super); - function Slot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._localMatrix = new dragonBones.Matrix(); - /** - * @internal - */ - _this._colorTransform = new dragonBones.ColorTransform(); - /** - * @internal - */ - _this._displayFrames = []; - /** - * @internal - */ - _this._geometryBones = []; - _this._rawDisplay = null; // Initial value. - _this._meshDisplay = null; // Initial value. - _this._display = null; - return _this; - } - Slot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - var disposeDisplayList = []; - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var dispayFrame = _a[_i]; - var display = dispayFrame.display; - if (display !== this._rawDisplay && display !== this._meshDisplay && - disposeDisplayList.indexOf(display) < 0) { - disposeDisplayList.push(display); - } - dispayFrame.returnToPool(); - } - for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { - var eachDisplay = disposeDisplayList_1[_b]; - if (eachDisplay instanceof dragonBones.Armature) { - eachDisplay.dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { - this._disposeDisplay(this._meshDisplay, false); - } - if (this._rawDisplay !== null) { - this._disposeDisplay(this._rawDisplay, false); - } - this.displayController = null; - this._displayDataDirty = false; - this._displayDirty = false; - this._geometryDirty = false; - this._textureDirty = false; - this._visibleDirty = false; - this._blendModeDirty = false; - this._zOrderDirty = false; - this._colorDirty = false; - this._verticesDirty = false; - this._transformDirty = false; - this._visible = true; - this._blendMode = 0 /* Normal */; - this._displayIndex = -1; - this._animationDisplayIndex = -1; - this._zOrder = 0; - this._zIndex = 0; - this._cachedFrameIndex = -1; - this._pivotX = 0.0; - this._pivotY = 0.0; - this._localMatrix.identity(); - this._colorTransform.identity(); - this._displayFrames.length = 0; - this._geometryBones.length = 0; - this._slotData = null; // - this._displayFrame = null; - this._geometryData = null; - this._boundingBoxData = null; - this._textureData = null; - this._rawDisplay = null; - this._meshDisplay = null; - this._display = null; - this._childArmature = null; - this._parent = null; // - this._cachedFrameIndices = null; - }; - Slot.prototype._hasDisplay = function (display) { - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var displayFrame = _a[_i]; - if (displayFrame.display === display) { - return true; - } - } - return false; - }; - /** - * @internal - */ - Slot.prototype._isBonesUpdate = function () { - for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone !== null && bone._childrenTransformDirty) { - return true; - } - } - return false; - }; - /** - * @internal - */ - Slot.prototype._updateAlpha = function () { - var globalAlpha = this._alpha * this._parent._globalAlpha; - if (this._globalAlpha !== globalAlpha) { - this._globalAlpha = globalAlpha; - this._colorDirty = true; - } - }; - Slot.prototype._updateDisplayData = function () { - var prevDisplayFrame = this._displayFrame; - var prevGeometryData = this._geometryData; - var prevTextureData = this._textureData; - var rawDisplayData = null; - var displayData = null; - this._displayFrame = null; - this._geometryData = null; - this._boundingBoxData = null; - this._textureData = null; - if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { - this._displayFrame = this._displayFrames[this._displayIndex]; - rawDisplayData = this._displayFrame.rawDisplayData; - displayData = this._displayFrame.displayData; - this._geometryData = this._displayFrame.getGeometryData(); - this._boundingBoxData = this._displayFrame.getBoundingBox(); - this._textureData = this._displayFrame.getTextureData(); - } - if (this._displayFrame !== prevDisplayFrame || - this._geometryData !== prevGeometryData || this._textureData !== prevTextureData) { - // Update pivot offset. - if (this._geometryData === null && this._textureData !== null) { - var imageDisplayData = ((displayData !== null && displayData.type === 0 /* Image */) ? displayData : rawDisplayData); // - var scale = this._textureData.parent.scale * this._armature._armatureData.scale; - var frame = this._textureData.frame; - this._pivotX = imageDisplayData.pivot.x; - this._pivotY = imageDisplayData.pivot.y; - var rect = frame !== null ? frame : this._textureData.region; - var width = rect.width; - var height = rect.height; - if (this._textureData.rotated && frame === null) { - width = rect.height; - height = rect.width; - } - this._pivotX *= width * scale; - this._pivotY *= height * scale; - if (frame !== null) { - this._pivotX += frame.x * scale; - this._pivotY += frame.y * scale; - } - // Update replace pivot. TODO - if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) { - rawDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX -= Slot._helpPoint.x; - this._pivotY -= Slot._helpPoint.y; - imageDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX += Slot._helpPoint.x; - this._pivotY += Slot._helpPoint.y; - } - if (!dragonBones.DragonBones.yDown) { - this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; - } - } - else { - this._pivotX = 0.0; - this._pivotY = 0.0; - } - // Update original transform. - if (rawDisplayData !== null) { - this.origin = rawDisplayData.transform; - } - else if (displayData !== null) { - this.origin = displayData.transform; - } - else { - this.origin = null; - } - // TODO remove slot offset. - if (this.origin !== null) { - this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); - } - else { - this.global.copyFrom(this.offset).toMatrix(this._localMatrix); - } - // Update geometry. - if (this._geometryData !== prevGeometryData) { - this._geometryDirty = true; - this._verticesDirty = true; - if (this._geometryData !== null) { - this._geometryBones.length = 0; - if (this._geometryData.weight !== null) { - for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { - var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); - this._geometryBones.push(bone); - } - } - } - else { - this._geometryBones.length = 0; - this._geometryData = null; - } - } - this._textureDirty = this._textureData !== prevTextureData; - this._transformDirty = true; - } - }; - Slot.prototype._updateDisplay = function () { - var prevDisplay = this._display !== null ? this._display : this._rawDisplay; - var prevChildArmature = this._childArmature; - // Update display and child armature. - if (this._displayFrame !== null) { - this._display = this._displayFrame.display; - if (this._display !== null && this._display instanceof dragonBones.Armature) { - this._childArmature = this._display; - this._display = this._childArmature.display; - } - else { - this._childArmature = null; - } - } - else { - this._display = null; - this._childArmature = null; - } - // Update display. - var currentDisplay = this._display !== null ? this._display : this._rawDisplay; - if (currentDisplay !== prevDisplay) { - this._textureDirty = true; - this._visibleDirty = true; - this._blendModeDirty = true; - // this._zOrderDirty = true; - this._colorDirty = true; - this._transformDirty = true; - this._onUpdateDisplay(); - this._replaceDisplay(prevDisplay); - } - // Update child armature. - if (this._childArmature !== prevChildArmature) { - if (prevChildArmature !== null) { - prevChildArmature._parent = null; // Update child armature parent. - prevChildArmature.clock = null; - if (prevChildArmature.inheritAnimation) { - prevChildArmature.animation.reset(); - } - } - if (this._childArmature !== null) { - this._childArmature._parent = this; // Update child armature parent. - this._childArmature.clock = this._armature.clock; - if (this._childArmature.inheritAnimation) { - if (this._childArmature.cacheFrameRate === 0) { - var cacheFrameRate = this._armature.cacheFrameRate; - if (cacheFrameRate !== 0) { - this._childArmature.cacheFrameRate = cacheFrameRate; - } - } - // Child armature action. - if (this._displayFrame !== null) { - var actions = null; - var displayData = this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; - if (displayData !== null && displayData.type === 1 /* Armature */) { - actions = displayData.actions; - } - if (actions !== null && actions.length > 0) { - for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { - var action = actions_1[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - eventObject.slot = this; - this._armature._bufferAction(eventObject, false); - } - } - else { - this._childArmature.animation.play(); - } - } - } - } - } - }; - Slot.prototype._updateGlobalTransformMatrix = function (isCache) { - var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); - this.globalTransformMatrix.copyFrom(this._localMatrix); - this.globalTransformMatrix.concat(parentMatrix); - if (isCache) { - this.global.fromMatrix(this.globalTransformMatrix); - } - else { - this._globalDirty = true; - } - }; - /** - * @internal - */ - Slot.prototype._setDisplayIndex = function (value, isAnimation) { - if (isAnimation === void 0) { isAnimation = false; } - if (isAnimation) { - if (this._animationDisplayIndex === value) { - return; - } - this._animationDisplayIndex = value; - } - if (this._displayIndex === value) { - return; - } - this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; - this._displayDataDirty = true; - this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; - }; - /** - * @internal - */ - Slot.prototype._setZOrder = function (value) { - if (this._zOrder === value) { - // return false; - } - this._zOrder = value; - this._zOrderDirty = true; - return this._zOrderDirty; - }; - /** - * @internal - */ - Slot.prototype._setColor = function (value) { - this._colorTransform.copyFrom(value); - return this._colorDirty = true; - }; - /** - * @internal - */ - Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - if (this._slotData !== null) { - return; - } - this._slotData = slotData; - this._colorDirty = true; // - this._blendModeDirty = true; // - this._blendMode = this._slotData.blendMode; - this._zOrder = this._slotData.zOrder; - this._zIndex = this._slotData.zIndex; - this._alpha = this._slotData.alpha; - this._colorTransform.copyFrom(this._slotData.color); - this._rawDisplay = rawDisplay; - this._meshDisplay = meshDisplay; - // - this._armature = armatureValue; - var slotParent = this._armature.getBone(this._slotData.parent.name); - if (slotParent !== null) { - this._parent = slotParent; - } - else { - // Never; - } - this._armature._addSlot(this); - // - this._initDisplay(this._rawDisplay, false); - if (this._rawDisplay !== this._meshDisplay) { - this._initDisplay(this._meshDisplay, false); - } - this._onUpdateDisplay(); - this._addDisplay(); - }; - /** - * @internal - */ - Slot.prototype.update = function (cacheFrameIndex) { - if (this._displayDataDirty) { - this._updateDisplayData(); - this._displayDataDirty = false; - } - if (this._displayDirty) { - this._updateDisplay(); - this._displayDirty = false; - } - if (this._geometryDirty || this._textureDirty) { - if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { - this._updateFrame(); - } - this._geometryDirty = false; - this._textureDirty = false; - } - if (this._display === null) { - return; - } - if (this._visibleDirty) { - this._updateVisible(); - this._visibleDirty = false; - } - if (this._blendModeDirty) { - this._updateBlendMode(); - this._blendModeDirty = false; - } - if (this._colorDirty) { - this._updateColor(); - this._colorDirty = false; - } - if (this._zOrderDirty) { - this._updateZOrder(); - this._zOrderDirty = false; - } - if (this._geometryData !== null && this._display === this._meshDisplay) { - var isSkinned = this._geometryData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (this._verticesDirty || - (isSkinned && this._isBonesUpdate()) || - (isSurface && this._parent._childrenTransformDirty)) { - this._verticesDirty = false; // Allow update mesh to reset the dirty value. - this._updateMesh(); - } - if (isSkinned || isSurface) { - return; - } - } - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - if (this._transformDirty) { - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - this._updateGlobalTransformMatrix(isCache); - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - this._updateTransform(); - this._transformDirty = false; - } - }; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Slot.prototype.invalidUpdate = function () { - this._displayDataDirty = true; - this._displayDirty = true; - // - this._transformDirty = true; - }; - /** - * @private - */ - Slot.prototype.updateTransformAndMatrix = function () { - if (this._transformDirty) { - this._updateGlobalTransformMatrix(false); - this._transformDirty = false; - } - }; - /** - * @private - */ - Slot.prototype.replaceRawDisplayData = function (displayData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.rawDisplayData !== displayData) { - displayFrame.deformVertices.length = 0; - displayFrame.rawDisplayData = displayData; - if (displayFrame.rawDisplayData === null) { - var defaultSkin = this._armature._armatureData.defaultSkin; - if (defaultSkin !== null) { - var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); - if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { - displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; - } - } - } - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplayData = function (displayData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { - displayFrame.displayData = displayData; - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceTextureData = function (textureData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.textureData !== textureData) { - displayFrame.textureData = textureData; - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplay = function (value, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.display !== value) { - var prevDisplay = displayFrame.display; - displayFrame.display = value; - if (prevDisplay !== null && - prevDisplay !== this._rawDisplay && prevDisplay !== this._meshDisplay && - !this._hasDisplay(prevDisplay)) { - if (prevDisplay instanceof dragonBones.Armature) { - // (eachDisplay as Armature).dispose(); - } - else { - this._disposeDisplay(prevDisplay, true); - } - } - if (value !== null && - value !== this._rawDisplay && value !== this._meshDisplay && - !this._hasDisplay(prevDisplay) && - !(value instanceof dragonBones.Armature)) { - this._initDisplay(value, true); - } - if (index === this._displayIndex) { - this._displayDirty = true; - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.containsPoint = function (x, y) { - if (this._boundingBoxData === null) { - return false; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); - return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); - }; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (this._boundingBoxData === null) { - return 0; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); - xA = Slot._helpPoint.x; - yA = Slot._helpPoint.y; - Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); - xB = Slot._helpPoint.x; - yB = Slot._helpPoint.y; - var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionCount === 1 || intersectionCount === 2) { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - if (intersectionPointB !== null) { - intersectionPointB.x = intersectionPointA.x; - intersectionPointB.y = intersectionPointA.y; - } - } - else if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - else { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - } - if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - if (normalRadians !== null) { - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); - normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); - normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - } - } - return intersectionCount; - }; - /** - * @private - */ - Slot.prototype.getDisplayFrameAt = function (index) { - return this._displayFrames[index]; - }; - Object.defineProperty(Slot.prototype, "visible", { - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - this._updateVisible(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayFrameCount", { - /** - * @private - */ - get: function () { - return this._displayFrames.length; - }, - set: function (value) { - var prevCount = this._displayFrames.length; - if (prevCount < value) { - this._displayFrames.length = value; - for (var i = prevCount; i < value; ++i) { - this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); - } - } - else if (prevCount > value) { - for (var i = prevCount - 1; i < value; --i) { - this.replaceDisplay(null, i); - this._displayFrames[i].returnToPool(); - } - this._displayFrames.length = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayIndex", { - /** - * - The index of the display object displayed in the display list. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._displayIndex; - }, - set: function (value) { - this._setDisplayIndex(value); - this.update(-1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "name", { - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._slotData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayList", { - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - var displays = new Array(); - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var displayFrame = _a[_i]; - displays.push(displayFrame.display); - } - return displays; - }, - set: function (value) { - this.displayFrameCount = value.length; - var index = 0; - for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { - var eachDisplay = value_1[_i]; - this.replaceDisplay(eachDisplay, index++); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "slotData", { - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._slotData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "boundingBoxData", { - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - return this._boundingBoxData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplay", { - /** - * @private - */ - get: function () { - return this._rawDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "meshDisplay", { - /** - * @private - */ - get: function () { - return this._meshDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "display", { - /** - * - The display object that the slot displays at this time. - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - set: function (value) { - if (this._display === value) { - return; - } - if (this._displayFrames.length === 0) { - this.displayFrameCount = 1; - this._displayIndex = 0; - } - this.replaceDisplay(value, this._displayIndex); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "childArmature", { - /** - * - The child armature that the slot displayed at current time. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     let prevChildArmature = slot.childArmature;
-             *     if (prevChildArmature) {
-             *         prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     let prevChildArmature = slot.childArmature;
-             *     if (prevChildArmature) {
-             *         prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._childArmature; - }, - set: function (value) { - if (this._childArmature === value) { - return; - } - this.display = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.getDisplay = function () { - return this._display; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.setDisplay = function (value) { - this.display = value; - }; - return Slot; - }(dragonBones.TransformObject)); - dragonBones.Slot = Slot; -})(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) { - /** - * @internal - */ - var Constraint = (function (_super) { - __extends(Constraint, _super); - function Constraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - Constraint.prototype._onClear = function () { - this._armature = null; // - this._target = null; // - this._root = null; // - this._bone = null; - }; - Object.defineProperty(Constraint.prototype, "name", { - get: function () { - return this._constraintData.name; - }, - enumerable: true, - configurable: true - }); - Constraint._helpMatrix = new dragonBones.Matrix(); - Constraint._helpTransform = new dragonBones.Transform(); - Constraint._helpPoint = new dragonBones.Point(); - return Constraint; - }(dragonBones.BaseObject)); - dragonBones.Constraint = Constraint; - /** - * @internal - */ - var IKConstraint = (function (_super) { - __extends(IKConstraint, _super); - function IKConstraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraint.toString = function () { - return "[class dragonBones.IKConstraint]"; - }; - IKConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._scaleEnabled = false; - this._bendPositive = false; - this._weight = 1.0; - this._constraintData = null; - }; - IKConstraint.prototype._computeA = function () { - var ikGlobal = this._target.global; - var global = this._root.global; - var globalTransformMatrix = this._root.globalTransformMatrix; - var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radian += Math.PI; - } - global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype._computeB = function () { - var boneLength = this._bone._boneData.length; - var parent = this._root; - var ikGlobal = this._target.global; - var parentGlobal = parent.global; - var global = this._bone.global; - var globalTransformMatrix = this._bone.globalTransformMatrix; - var x = globalTransformMatrix.a * boneLength; - var y = globalTransformMatrix.b * boneLength; - var lLL = x * x + y * y; - var lL = Math.sqrt(lLL); - var dX = global.x - parentGlobal.x; - var dY = global.y - parentGlobal.y; - var lPP = dX * dX + dY * dY; - var lP = Math.sqrt(lPP); - var rawRadian = global.rotation; - var rawParentRadian = parentGlobal.rotation; - var rawRadianA = Math.atan2(dY, dX); - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - var lTT = dX * dX + dY * dY; - var lT = Math.sqrt(lTT); - var radianA = 0.0; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); - if (lL + lP <= lT) { - } - else if (lP < lL) { - radianA += Math.PI; - } - } - else { - var h = (lPP - lLL + lTT) / (2.0 * lTT); - var r = Math.sqrt(lPP - h * h * lTT) / lT; - var hX = parentGlobal.x + (dX * h); - var hY = parentGlobal.y + (dY * h); - var rX = -dY * r; - var rY = dX * r; - var isPPR = false; - var parentParent = parent.parent; - if (parentParent !== null) { - var parentParentMatrix = parentParent.globalTransformMatrix; - isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; - } - if (isPPR !== this._bendPositive) { - global.x = hX - rX; - global.y = hY - rY; - } - else { - global.x = hX + rX; - global.y = hY + rY; - } - radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); - } - var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); - parentGlobal.rotation = rawParentRadian + dR * this._weight; - parentGlobal.toMatrix(parent.globalTransformMatrix); - // - var currentRadianA = rawRadianA + dR * this._weight; - global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; - global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; - // - var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radianB += Math.PI; - } - global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype.init = function (constraintData, armature) { - if (this._constraintData !== null) { - return; - } - this._constraintData = constraintData; - this._armature = armature; - this._target = this._armature.getBone(this._constraintData.target.name); - this._root = this._armature.getBone(this._constraintData.root.name); - this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; - { - var ikConstraintData = this._constraintData; - this._scaleEnabled = ikConstraintData.scaleEnabled; - this._bendPositive = ikConstraintData.bendPositive; - this._weight = ikConstraintData.weight; - } - this._root._hasConstraint = true; - }; - IKConstraint.prototype.update = function () { - this._root.updateByConstraint(); - if (this._bone !== null) { - this._bone.updateByConstraint(); - this._computeB(); - } - else { - this._computeA(); - } - }; - IKConstraint.prototype.invalidUpdate = function () { - this._root.invalidUpdate(); - if (this._bone !== null) { - this._bone.invalidUpdate(); - } - }; - return IKConstraint; - }(Constraint)); - dragonBones.IKConstraint = IKConstraint; - /** - * @internal - */ - var PathConstraint = (function (_super) { - __extends(PathConstraint, _super); - function PathConstraint() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._spaces = []; - _this._positions = []; - _this._curves = []; - _this._boneLengths = []; - _this._pathGlobalVertices = []; - _this._segments = [10]; - return _this; - } - PathConstraint.toString = function () { - return "[class dragonBones.PathConstraint]"; - }; - PathConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.dirty = false; - this.pathOffset = 0; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 1.0; - this.translateMix = 1.0; - this._pathSlot = null; - this._bones.length = 0; - this._spaces.length = 0; - this._positions.length = 0; - this._curves.length = 0; - this._boneLengths.length = 0; - this._pathGlobalVertices.length = 0; - }; - PathConstraint.prototype._updatePathVertices = function (verticesData) { - //计算曲线的节点数据 - var armature = this._armature; - var dragonBonesData = armature.armatureData.parent; - var scale = armature.armatureData.scale; - var intArray = dragonBonesData.intArray; - var floatArray = dragonBonesData.floatArray; - var pathOffset = verticesData.offset; - var pathVertexCount = intArray[pathOffset + 0 /* GeometryVertexCount */]; - var pathVertexOffset = intArray[pathOffset + 2 /* GeometryFloatOffset */]; - this._pathGlobalVertices.length = pathVertexCount * 2; - var weightData = verticesData.weight; - //没有骨骼约束我,那节点只受自己的Bone控制 - if (weightData === null) { - var parentBone = this._pathSlot.parent; - parentBone.updateByConstraint(); - var matrix = parentBone.globalTransformMatrix; - for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { - var vx = floatArray[iV_1++] * scale; - var vy = floatArray[iV_1++] * scale; - var x = matrix.a * vx + matrix.c * vy + matrix.tx; - var y = matrix.b * vx + matrix.d * vy + matrix.ty; - // - this._pathGlobalVertices[i] = x; - this._pathGlobalVertices[i + 1] = y; - } - return; - } - //有骨骼约束我,那我的节点受骨骼权重控制 - var bones = this._pathSlot._geometryBones; - var weightBoneCount = weightData.bones.length; - var weightOffset = weightData.offset; - var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; - var iV = floatOffset; - var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; - for (var i = 0, iW = 0; i < pathVertexCount; i++) { - var vertexBoneCount = intArray[iB++]; // - var xG = 0.0, yG = 0.0; - for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone === null) { - continue; - } - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var vx = floatArray[iV++] * scale; - var vy = floatArray[iV++] * scale; - xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; - yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; - } - this._pathGlobalVertices[iW++] = xG; - this._pathGlobalVertices[iW++] = yG; - } - }; - PathConstraint.prototype._computeVertices = function (start, count, offset, out) { - //TODO优化 - for (var i = offset, iW = start; i < count; i += 2) { - out[i] = this._pathGlobalVertices[iW++]; - out[i + 1] = this._pathGlobalVertices[iW++]; - } - }; - PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { - //计算当前的骨骼在曲线上的位置 - var armature = this._armature; - var intArray = armature.armatureData.parent.intArray; - var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; - var positions = this._positions; - var spaces = this._spaces; - var isClosed = pathDisplayDta.closed; - var curveVertices = Array(); - var verticesLength = vertexCount * 2; - var curveCount = verticesLength / 6; - var preCurve = -1; - var position = this.position; - positions.length = spaceCount * 3 + 2; - var pathLength = 0.0; - //不需要匀速运动,效率高些 - if (!pathDisplayDta.constantSpeed) { - var lenghts = pathDisplayDta.curveLengths; - curveCount -= isClosed ? 1 : 2; - pathLength = lenghts[curveCount]; - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - curveVertices.length = 8; - for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - if (isClosed) { - position %= pathLength; - if (position < 0) { - position += pathLength; - } - curve = 0; - } - else if (position < 0) { - //TODO - continue; - } - else if (position > pathLength) { - //TODO - continue; - } - var percent = 0.0; - for (;; curve++) { - var len = lenghts[curve]; - if (position > len) { - continue; - } - if (curve === 0) { - percent = position / len; - } - else { - var preLen = lenghts[curve - 1]; - percent = (position - preLen) / (len - preLen); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - if (isClosed && curve === curveCount) { - //计算曲线 - this._computeVertices(verticesLength - 4, 4, 0, curveVertices); - this._computeVertices(0, 4, 4, curveVertices); - } - else { - this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); - } - } - // - this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); - } - return; - } - //匀速的 - if (isClosed) { - verticesLength += 2; - curveVertices.length = vertexCount; - this._computeVertices(2, verticesLength - 4, 0, curveVertices); - this._computeVertices(0, 2, verticesLength - 4, curveVertices); - curveVertices[verticesLength - 2] = curveVertices[0]; - curveVertices[verticesLength - 1] = curveVertices[1]; - } - else { - curveCount--; - verticesLength -= 4; - curveVertices.length = verticesLength; - this._computeVertices(2, verticesLength, 0, curveVertices); - } - // - var curves = new Array(curveCount); - pathLength = 0; - var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = curveVertices[w]; - cy1 = curveVertices[w + 1]; - cx2 = curveVertices[w + 2]; - cy2 = curveVertices[w + 3]; - x2 = curveVertices[w + 4]; - y2 = curveVertices[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - var segments = this._segments; - var curveLength = 0; - for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (isClosed) { - p %= pathLength; - if (p < 0) - p += pathLength; - curve = 0; - } - else if (p < 0) { - continue; - } - else if (p > pathLength) { - continue; - } - // Determine curve containing position. - for (;; curve++) { - var length_1 = curves[curve]; - if (p > length_1) - continue; - if (curve === 0) - p /= length_1; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_1 - prev); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - var ii = curve * 6; - x1 = curveVertices[ii]; - y1 = curveVertices[ii + 1]; - cx1 = curveVertices[ii + 2]; - cy1 = curveVertices[ii + 3]; - cx2 = curveVertices[ii + 4]; - cy2 = curveVertices[ii + 5]; - x2 = curveVertices[ii + 6]; - y2 = curveVertices[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - // Weight by segment length. - p *= curveLength; - for (;; segment++) { - var length_2 = segments[segment]; - if (p > length_2) - continue; - if (segment === 0) - p /= length_2; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_2 - prev); - } - break; - } - this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); - } - }; - //Calculates a point on the curve, for a given t value between 0 and 1. - PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { - if (t === 0) { - out[offset] = x1; - out[offset + 1] = y1; - out[offset + 2] = 0; - return; - } - if (t === 1) { - out[offset] = x2; - out[offset + 1] = y2; - out[offset + 2] = 0; - return; - } - var mt = 1 - t; - var mt2 = mt * mt; - var t2 = t * t; - var a = mt2 * mt; - var b = mt2 * t * 3; - var c = mt * t2 * 3; - var d = t * t2; - var x = a * x1 + b * cx1 + c * cx2 + d * x2; - var y = a * y1 + b * cy1 + c * cy2 + d * y2; - out[offset] = x; - out[offset + 1] = y; - if (tangents) { - //Calculates the curve tangent at the specified t value - out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); - } - else { - out[offset + 2] = 0; - } - }; - PathConstraint.prototype.init = function (constraintData, armature) { - this._constraintData = constraintData; - this._armature = armature; - var data = constraintData; - this.pathOffset = data.pathDisplayData.geometry.offset; - // - this.position = data.position; - this.spacing = data.spacing; - this.rotateOffset = data.rotateOffset; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - // - this._root = this._armature.getBone(data.root.name); - this._target = this._armature.getBone(data.target.name); - this._pathSlot = this._armature.getSlot(data.pathSlot.name); - for (var i = 0, l = data.bones.length; i < l; i++) { - var bone = this._armature.getBone(data.bones[i].name); - if (bone !== null) { - this._bones.push(bone); - } - } - if (data.rotateMode === 2 /* ChainScale */) { - this._boneLengths.length = this._bones.length; - } - this._root._hasConstraint = true; - }; - PathConstraint.prototype.update = function () { - var pathSlot = this._pathSlot; - if (pathSlot._geometryData === null || - pathSlot._geometryData.offset !== this.pathOffset) { - return; - } - var constraintData = this._constraintData; - // - //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 - var isPathVerticeDirty = false; - if (this._root._childrenTransformDirty) { - this._updatePathVertices(pathSlot._geometryData); - isPathVerticeDirty = true; - } - else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) { - this._updatePathVertices(pathSlot._geometryData); - pathSlot._verticesDirty = false; - isPathVerticeDirty = true; - } - if (!isPathVerticeDirty && !this.dirty) { - return; - } - // - var positionMode = constraintData.positionMode; - var spacingMode = constraintData.spacingMode; - var rotateMode = constraintData.rotateMode; - var bones = this._bones; - var isLengthMode = spacingMode === 0 /* Length */; - var isChainScaleMode = rotateMode === 2 /* ChainScale */; - var isTangentMode = rotateMode === 0 /* Tangent */; - var boneCount = bones.length; - var spacesCount = isTangentMode ? boneCount : boneCount + 1; - var spacing = this.spacing; - var spaces = this._spaces; - spaces.length = spacesCount; - //计曲线间隔和长度 - if (isChainScaleMode || isLengthMode) { - //Bone改变和spacing改变触发 - spaces[0] = 0; - for (var i = 0, l = spacesCount - 1; i < l; i++) { - var bone = bones[i]; - bone.updateByConstraint(); - var boneLength = bone._boneData.length; - var matrix = bone.globalTransformMatrix; - var x = boneLength * matrix.a; - var y = boneLength * matrix.b; - var len = Math.sqrt(x * x + y * y); - if (isChainScaleMode) { - this._boneLengths[i] = len; - } - spaces[i + 1] = (boneLength + spacing) * len / boneLength; - } - } - else { - for (var i = 0; i < spacesCount; i++) { - spaces[i] = spacing; - } - } - // - this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); - //根据新的节点数据重新采样 - var positions = this._positions; - var rotateOffset = this.rotateOffset; - var boneX = positions[0], boneY = positions[1]; - var tip; - if (rotateOffset === 0) { - tip = rotateMode === 1 /* Chain */; - } - else { - tip = false; - var bone = pathSlot.parent; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; - } - } - // - var rotateMix = this.rotateMix; - var translateMix = this.translateMix; - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - matrix.tx += (boneX - matrix.tx) * translateMix; - matrix.ty += (boneY - matrix.ty) * translateMix; - var x = positions[p], y = positions[p + 1]; - var dx = x - boneX, dy = y - boneY; - if (isChainScaleMode) { - var lenght = this._boneLengths[i]; - var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; - matrix.a *= s; - matrix.b *= s; - } - boneX = x; - boneY = y; - if (rotateMix > 0) { - var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; - if (isTangentMode) { - r = positions[p - 1]; - } - else { - r = Math.atan2(dy, dx); - } - r -= Math.atan2(b, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone._boneData.length; - boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; - } - else { - r += rotateOffset; - } - if (r > dragonBones.Transform.PI) { - r -= dragonBones.Transform.PI_D; - } - else if (r < -dragonBones.Transform.PI) { - r += dragonBones.Transform.PI_D; - } - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - matrix.a = cos * a - sin * b; - matrix.b = sin * a + cos * b; - matrix.c = cos * c - sin * d; - matrix.d = sin * c + cos * d; - } - bone.global.fromMatrix(matrix); - } - this.dirty = false; - }; - PathConstraint.prototype.invalidUpdate = function () { - }; - return PathConstraint; - }(Constraint)); - dragonBones.PathConstraint = PathConstraint; -})(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) { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var WorldClock = (function () { - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function WorldClock(time) { - if (time === void 0) { time = 0.0; } - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - this.time = 0.0; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - this.timeScale = 1.0; - this._systemTime = 0.0; - this._animatebles = []; - this._clock = null; - this.time = time; - this._systemTime = new Date().getTime() * 0.001; - } - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.advanceTime = function (passedTime) { - if (passedTime !== passedTime) { - passedTime = 0.0; - } - var currentTime = Date.now() * 0.001; - if (passedTime < 0.0) { - passedTime = currentTime - this._systemTime; - } - this._systemTime = currentTime; - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - if (passedTime === 0.0) { - return; - } - if (passedTime < 0.0) { - this.time -= passedTime; - } - else { - this.time += passedTime; - } - var i = 0, r = 0, l = this._animatebles.length; - for (; i < l; ++i) { - var animatable = this._animatebles[i]; - if (animatable !== null) { - if (r > 0) { - this._animatebles[i - r] = animatable; - this._animatebles[i] = null; - } - animatable.advanceTime(passedTime); - } - else { - r++; - } - } - if (r > 0) { - l = this._animatebles.length; - for (; i < l; ++i) { - var animateble = this._animatebles[i]; - if (animateble !== null) { - this._animatebles[i - r] = animateble; - } - else { - r++; - } - } - this._animatebles.length -= r; - } - }; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.clock; - } - return ancestor === this; - }; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.add = function (value) { - if (this._animatebles.indexOf(value) < 0) { - this._animatebles.push(value); - value.clock = this; - } - }; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.remove = function (value) { - var index = this._animatebles.indexOf(value); - if (index >= 0) { - this._animatebles[index] = null; - value.clock = null; - } - }; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.clear = function () { - for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { - var animatable = _a[_i]; - if (animatable !== null) { - animatable.clock = null; - } - } - }; - Object.defineProperty(WorldClock.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock !== null) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - return WorldClock; - }()); - dragonBones.WorldClock = WorldClock; -})(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 animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - var Animation = (function (_super) { - __extends(Animation, _super); - function Animation() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._animationNames = []; - _this._animationStates = []; - _this._animations = {}; - _this._blendStates = {}; - _this._animationConfig = null; // Initial value. - return _this; - } - Animation.toString = function () { - return "[class dragonBones.Animation]"; - }; - Animation.prototype._onClear = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in this._blendStates) { - var blendStates = this._blendStates[k]; - for (var kB in blendStates) { - blendStates[kB].returnToPool(); - } - delete this._blendStates[k]; - } - if (this._animationConfig !== null) { - this._animationConfig.returnToPool(); - } - this.timeScale = 1.0; - this._animationDirty = false; - this._inheritTimeScale = 1.0; - this._animationNames.length = 0; - this._animationStates.length = 0; - //this._animations.clear(); - this._armature = null; // - this._animationConfig = null; // - this._lastAnimationState = null; - }; - Animation.prototype._fadeOut = function (animationConfig) { - switch (animationConfig.fadeOutMode) { - case 1 /* SameLayer */: - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 2 /* SameGroup */: - for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { - var animationState = _c[_b]; - if (animationState._parent !== null) { - continue; - } - if (animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 3 /* SameLayerAndGroup */: - for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { - var animationState = _e[_d]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer && - animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 4 /* All */: - for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { - var animationState = _g[_f]; - if (animationState._parent !== null) { - continue; - } - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - break; - case 5 /* Single */: // TODO - default: - break; - } - }; - /** - * @internal - */ - Animation.prototype.init = function (armature) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); - }; - /** - * @internal - */ - Animation.prototype.advanceTime = function (passedTime) { - if (passedTime < 0.0) { - passedTime = -passedTime; - } - if (this._armature.inheritAnimation && this._armature._parent !== null) { - this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; - } - else { - this._inheritTimeScale = this.timeScale; - } - if (this._inheritTimeScale !== 1.0) { - passedTime *= this._inheritTimeScale; - } - for (var k in this._blendStates) { - var blendStates = this._blendStates[k]; - for (var kB in blendStates) { - blendStates[kB].reset(); - } - } - var animationStateCount = this._animationStates.length; - if (animationStateCount === 1) { - var animationState = this._animationStates[0]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - this._armature._dragonBones.bufferObject(animationState); - this._animationStates.length = 0; - this._lastAnimationState = null; - } - else { - var animationData = animationState.animationData; - var cacheFrameRate = animationData.cacheFrameRate; - if (this._animationDirty && cacheFrameRate > 0.0) { - this._animationDirty = false; - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - if (slot.displayFrameCount > 0) { - var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; - if (rawDisplayData !== null && - rawDisplayData.parent === this._armature.armatureData.defaultSkin) { - slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); - continue; - } - } - slot._cachedFrameIndices = null; - } - } - animationState.advanceTime(passedTime, cacheFrameRate); - } - } - else if (animationStateCount > 1) { - for (var i = 0, r = 0; i < animationStateCount; ++i) { - var animationState = this._animationStates[i]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - r++; - this._armature._dragonBones.bufferObject(animationState); - this._animationDirty = true; - if (this._lastAnimationState === animationState) { - this._lastAnimationState = null; - } - } - else { - if (r > 0) { - this._animationStates[i - r] = animationState; - } - animationState.advanceTime(passedTime, 0.0); - } - if (i === animationStateCount - 1 && r > 0) { - this._animationStates.length -= r; - if (this._lastAnimationState === null && this._animationStates.length > 0) { - this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; - } - } - } - this._armature._cacheFrameIndex = -1; - } - else { - this._armature._cacheFrameIndex = -1; - } - }; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.reset = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - this._animationDirty = false; - this._animationConfig.clear(); - this._animationStates.length = 0; - this._lastAnimationState = null; - }; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.stop = function (animationName) { - if (animationName === void 0) { animationName = null; } - if (animationName !== null) { - var animationState = this.getState(animationName); - if (animationState !== null) { - animationState.stop(); - } - } - else { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.stop(); - } - } - }; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - Animation.prototype.playConfig = function (animationConfig) { - var animationName = animationConfig.animation; - if (!(animationName in this._animations)) { - console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); - return null; - } - var animationData = this._animations[animationName]; - if (animationConfig.fadeOutMode === 5 /* Single */) { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState_1 = _a[_i]; - if (animationState_1._fadeState < 1 && - animationState_1.layer === animationConfig.layer && - animationState_1.animationData === animationData) { - return animationState_1; - } - } - } - if (this._animationStates.length === 0) { - animationConfig.fadeInTime = 0.0; - } - else if (animationConfig.fadeInTime < 0.0) { - animationConfig.fadeInTime = animationData.fadeInTime; - } - if (animationConfig.fadeOutTime < 0.0) { - animationConfig.fadeOutTime = animationConfig.fadeInTime; - } - if (animationConfig.timeScale <= -100.0) { - animationConfig.timeScale = 1.0 / animationData.scale; - } - if (animationData.frameCount > 0) { - if (animationConfig.position < 0.0) { - animationConfig.position %= animationData.duration; - animationConfig.position = animationData.duration - animationConfig.position; - } - else if (animationConfig.position === animationData.duration) { - animationConfig.position -= 0.000001; // Play a little time before end. - } - else if (animationConfig.position > animationData.duration) { - animationConfig.position %= animationData.duration; - } - if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { - animationConfig.duration = animationData.duration - animationConfig.position; - } - if (animationConfig.playTimes < 0) { - animationConfig.playTimes = animationData.playTimes; - } - } - else { - animationConfig.playTimes = 1; - animationConfig.position = 0.0; - if (animationConfig.duration > 0.0) { - animationConfig.duration = 0.0; - } - } - if (animationConfig.duration === 0.0) { - animationConfig.duration = -1.0; - } - this._fadeOut(animationConfig); - // - var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); - animationState.init(this._armature, animationData, animationConfig); - this._animationDirty = true; - this._armature._cacheFrameIndex = -1; - if (this._animationStates.length > 0) { - var added = false; - for (var i = 0, l = this._animationStates.length; i < l; ++i) { - if (animationState.layer > this._animationStates[i].layer) { - added = true; - this._animationStates.splice(i, 0, animationState); - break; - } - else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { - added = true; - this._animationStates.splice(i + 1, 0, animationState); - break; - } - } - if (!added) { - this._animationStates.push(animationState); - } - } - else { - this._animationStates.push(animationState); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - var childArmature = slot.childArmature; - if (childArmature !== null && childArmature.inheritAnimation && - childArmature.animation.hasAnimation(animationName) && - childArmature.animation.getState(animationName) === null) { - childArmature.animation.fadeIn(animationName); // - } - } - for (var k in animationData.animationTimelines) { - var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); - if (childAnimationState === null) { - continue; - } - var timelines = animationData.animationTimelines[k]; - childAnimationState.actionEnabled = false; - childAnimationState.resetToPose = false; - childAnimationState.stop(); - animationState.addState(childAnimationState, timelines); - // - var index = this._animationStates.indexOf(animationState); - var childIndex = this._animationStates.indexOf(childAnimationState); - if (childIndex < index) { - this._animationStates.splice(index, 1); - this._animationStates.splice(childIndex, 0, animationState); - } - } - // if (!this._armature._lockUpdate && animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. - // this._armature.advanceTime(0.0); - // } - this._lastAnimationState = animationState; - return animationState; - }; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.play = function (animationName, playTimes) { - if (animationName === void 0) { animationName = null; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName !== null ? animationName : ""; - if (animationName !== null && animationName.length > 0) { - this.playConfig(this._animationConfig); - } - else if (this._lastAnimationState === null) { - var defaultAnimation = this._armature.armatureData.defaultAnimation; - if (defaultAnimation !== null) { - this._animationConfig.animation = defaultAnimation.name; - this.playConfig(this._animationConfig); - } - } - else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { - this._lastAnimationState.play(); - } - else { - this._animationConfig.animation = this._lastAnimationState.name; - this.playConfig(this._animationConfig); - } - return this._lastAnimationState; - }; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { - if (fadeInTime === void 0) { fadeInTime = -1.0; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - this._animationConfig.clear(); - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { - if (time === void 0) { time = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.position = time; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { - if (frame === void 0) { frame = 0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.frameCount > 0 ? animationData.duration * frame / animationData.frameCount : 0.0; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { - if (progress === void 0) { progress = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); - } - return this.playConfig(this._animationConfig); - }; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByTime = function (animationName, time) { - if (time === void 0) { time = 0.0; } - var animationState = this.gotoAndPlayByTime(animationName, time, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { - if (frame === void 0) { frame = 0; } - var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { - if (progress === void 0) { progress = 0.0; } - var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * @internal - */ - Animation.prototype.getBlendState = function (type, name, target) { - if (!(type in this._blendStates)) { - this._blendStates[type] = {}; - } - var blendStates = this._blendStates[type]; - if (!(name in blendStates)) { - var blendState = blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState); - blendState.target = target; - } - return blendStates[name]; - }; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态。 - * @param animationName - 动画状态名称。 - * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.getState = function (animationName, layer) { - if (layer === void 0) { layer = -1; } - var i = this._animationStates.length; - while (i--) { - var animationState = this._animationStates[i]; - if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { - return animationState; - } - } - return null; - }; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.hasAnimation = function (animationName) { - return animationName in this._animations; - }; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - Animation.prototype.getStates = function () { - return this._animationStates; - }; - Object.defineProperty(Animation.prototype, "isPlaying", { - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState.isPlaying) { - return true; - } - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "isCompleted", { - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (!animationState.isCompleted) { - return false; - } - } - return this._animationStates.length > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationName", { - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationNames", { - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animations", { - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animations; - }, - set: function (value) { - if (this._animations === value) { - return; - } - this._animationNames.length = 0; - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in value) { - this._animationNames.push(k); - this._animations[k] = value[k]; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationConfig", { - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - this._animationConfig.clear(); - return this._animationConfig; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationState", { - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState; - }, - enumerable: true, - configurable: true - }); - return Animation; - }(dragonBones.BaseObject)); - dragonBones.Animation = Animation; -})(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 animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationState = (function (_super) { - __extends(AnimationState, _super); - function AnimationState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._boneMask = []; - _this._boneTimelines = []; - _this._boneBlendTimelines = []; - _this._slotTimelines = []; - _this._slotBlendTimelines = []; - _this._constraintTimelines = []; - _this._animationTimelines = []; - _this._poseTimelines = []; - /** - * @internal - */ - _this._actionTimeline = null; // Initial value. - _this._zOrderTimeline = null; // Initial value. - return _this; - } - AnimationState.toString = function () { - return "[class dragonBones.AnimationState]"; - }; - AnimationState.prototype._onClear = function () { - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { - var timeline = _l[_k]; - var animationState = timeline.target; - if (animationState._parent === this) { - animationState._fadeState = 1; - animationState._subFadeState = 1; - animationState._parent = null; - } - timeline.returnToPool(); - } - if (this._actionTimeline !== null) { - this._actionTimeline.returnToPool(); - } - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.returnToPool(); - } - this.actionEnabled = false; - this.additive = false; - this.displayControl = false; - this.resetToPose = false; - this.blendType = 0 /* None */; - this.playTimes = 1; - this.layer = 0; - this.timeScale = 1.0; - this._weight = 1.0; - this.parameterX = 0.0; - this.parameterY = 0.0; - this.positionX = 0.0; - this.positionY = 0.0; - this.autoFadeOutTime = 0.0; - this.fadeTotalTime = 0.0; - this.name = ""; - this.group = ""; - this._timelineDirty = 2; - this._playheadState = 0; - this._fadeState = -1; - this._subFadeState = -1; - this._position = 0.0; - this._duration = 0.0; - this._fadeTime = 0.0; - this._time = 0.0; - this._fadeProgress = 0.0; - this._weightResult = 0.0; - this._boneMask.length = 0; - this._boneTimelines.length = 0; - this._boneBlendTimelines.length = 0; - this._slotTimelines.length = 0; - this._slotBlendTimelines.length = 0; - this._constraintTimelines.length = 0; - this._animationTimelines.length = 0; - this._poseTimelines.length = 0; - // this._bonePoses.clear(); - this._animationData = null; // - this._armature = null; // - this._actionTimeline = null; // - this._zOrderTimeline = null; - this._activeChildA = null; - this._activeChildB = null; - this._parent = null; - }; - AnimationState.prototype._updateTimelines = function () { - { - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); - if (timelineDatas !== null) { - for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { - var timelineData = timelineDatas_1[_b]; - switch (timelineData.type) { - case 30 /* IKConstraint */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.target = constraint; - timeline.init(this._armature, this, timelineData); - this._constraintTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.target = constraint; - timeline.init(this._armature, this, null); - this._constraintTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - }; - AnimationState.prototype._updateBoneAndSlotTimelines = function () { - { - var boneTimelines = {}; - // Create bone timelines map. - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var timelineName = timeline.target.target.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - var timelineName = timeline.target.target.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - // - for (var _d = 0, _e = this._armature.getBones(); _d < _e.length; _d++) { - var bone = _e[_d]; - var timelineName = bone.name; - if (!this.containsBoneMask(timelineName)) { - continue; - } - if (timelineName in boneTimelines) { - delete boneTimelines[timelineName]; - } - else { - var timelineDatas = this._animationData.getBoneTimelines(timelineName); - var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); - if (timelineDatas !== null) { - for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { - var timelineData = timelineDatas_2[_f]; - switch (timelineData.type) { - case 10 /* BoneAll */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 11 /* BoneTranslate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 12 /* BoneRotate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 13 /* BoneScale */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 60 /* BoneAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); - timeline.init(this._armature, this, timelineData); - this._boneBlendTimelines.push(timeline); - break; - } - case 50 /* Surface */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); - timeline.init(this._armature, this, timelineData); - this._boneBlendTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { - if (bone._boneData.type === 0 /* Bone */) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, null); - this._boneTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - else { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); - timeline.init(this._armature, this, null); - this._boneBlendTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - for (var k in boneTimelines) { - for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { - var timeline = _h[_g]; - var index = this._boneTimelines.indexOf(timeline); - if (index >= 0) { - this._boneTimelines.splice(index, 1); - timeline.returnToPool(); - } - index = this._boneBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._boneBlendTimelines.splice(index, 1); - timeline.returnToPool(); - } - } - } - } - { - var slotTimelines = {}; - var ffdFlags = []; - // Create slot timelines map. - for (var _j = 0, _k = this._slotTimelines; _j < _k.length; _j++) { - var timeline = _k[_j]; - var timelineName = timeline.target.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - for (var _l = 0, _m = this._slotBlendTimelines; _l < _m.length; _l++) { - var timeline = _m[_l]; - var timelineName = timeline.target.target.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - // - for (var _o = 0, _p = this._armature.getSlots(); _o < _p.length; _o++) { - var slot = _p[_o]; - var boneName = slot.parent.name; - if (!this.containsBoneMask(boneName)) { - continue; - } - var timelineName = slot.name; - if (timelineName in slotTimelines) { - delete slotTimelines[timelineName]; - } - else { - var displayIndexFlag = false; - var colorFlag = false; - ffdFlags.length = 0; - var timelineDatas = this._animationData.getSlotTimelines(timelineName); - if (timelineDatas !== null) { - for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { - var timelineData = timelineDatas_3[_q]; - switch (timelineData.type) { - case 20 /* SlotDisplay */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - displayIndexFlag = true; - break; - } - case 23 /* SlotZIndex */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); - timeline.init(this._armature, this, timelineData); - this._slotBlendTimelines.push(timeline); - break; - } - case 21 /* SlotColor */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - colorFlag = true; - break; - } - case 22 /* SlotDeform */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); - timeline.init(this._armature, this, timelineData); - if (timeline.target !== null) { - this._slotBlendTimelines.push(timeline); - ffdFlags.push(timeline.geometryOffset); - } - else { - timeline.returnToPool(); - } - break; - } - case 24 /* SlotAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); - timeline.init(this._armature, this, timelineData); - this._slotBlendTimelines.push(timeline); - break; - } - default: - break; - } - } - } - if (this.resetToPose) { - if (!displayIndexFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (!colorFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayFrame = slot.getDisplayFrameAt(i); - if (displayFrame.deformVertices.length === 0) { - continue; - } - var geometryData = displayFrame.getGeometryData(); - if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.geometryOffset = geometryData.offset; // - timeline.displayFrame = displayFrame; // - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); - timeline.init(this._armature, this, null); - this._slotBlendTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - } - for (var k in slotTimelines) { - for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { - var timeline = _s[_r]; - var index = this._slotTimelines.indexOf(timeline); - if (index >= 0) { - this._slotTimelines.splice(index, 1); - timeline.returnToPool(); - } - index = this._slotBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._slotBlendTimelines.splice(index, 1); - timeline.returnToPool(); - } - } - } - } - }; - AnimationState.prototype._advanceFadeTime = function (passedTime) { - var isFadeOut = this._fadeState > 0; - if (this._subFadeState < 0) { - this._subFadeState = 0; - var eventActive = this._parent === null && this.actionEnabled; - if (eventActive) { - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - if (passedTime < 0.0) { - passedTime = -passedTime; - } - this._fadeTime += passedTime; - if (this._fadeTime >= this.fadeTotalTime) { - this._subFadeState = 1; - this._fadeProgress = isFadeOut ? 0.0 : 1.0; - } - else if (this._fadeTime > 0.0) { - this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); - } - else { - this._fadeProgress = isFadeOut ? 1.0 : 0.0; - } - if (this._subFadeState > 0) { - if (!isFadeOut) { - this._playheadState |= 1; // x1 - this._fadeState = 0; - } - var eventActive = this._parent === null && this.actionEnabled; - if (eventActive) { - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - }; - /** - * @internal - */ - AnimationState.prototype.init = function (armature, animationData, animationConfig) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationData = animationData; - // - this.resetToPose = animationConfig.resetToPose; - this.additive = animationConfig.additive; - this.displayControl = animationConfig.displayControl; - this.actionEnabled = animationConfig.actionEnabled; - this.blendType = animationData.blendType; - this.layer = animationConfig.layer; - this.playTimes = animationConfig.playTimes; - this.timeScale = animationConfig.timeScale; - this.fadeTotalTime = animationConfig.fadeInTime; - this.autoFadeOutTime = animationConfig.autoFadeOutTime; - this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; - this.group = animationConfig.group; - // - this._weight = animationConfig.weight; - if (animationConfig.pauseFadeIn) { - this._playheadState = 2; // 10 - } - else { - this._playheadState = 3; // 11 - } - if (animationConfig.duration < 0.0) { - this._position = 0.0; - this._duration = this._animationData.duration; - if (animationConfig.position !== 0.0) { - if (this.timeScale >= 0.0) { - this._time = animationConfig.position; - } - else { - this._time = animationConfig.position - this._duration; - } - } - else { - this._time = 0.0; - } - } - else { - this._position = animationConfig.position; - this._duration = animationConfig.duration; - this._time = 0.0; - } - if (this.timeScale < 0.0 && this._time === 0.0) { - this._time = -0.000001; // Turn to end. - } - if (this.fadeTotalTime <= 0.0) { - this._fadeProgress = 0.999999; // Make different. - } - if (animationConfig.boneMask.length > 0) { - this._boneMask.length = animationConfig.boneMask.length; - for (var i = 0, l = this._boneMask.length; i < l; ++i) { - this._boneMask[i] = animationConfig.boneMask[i]; - } - } - this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); - this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); - this._actionTimeline.currentTime = this._time; - if (this._actionTimeline.currentTime < 0.0) { - this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; - } - if (this._animationData.zOrderTimeline !== null) { - this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); - this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); - } - }; - /** - * @internal - */ - AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { - // Update fade time. - if (this._fadeState !== 0 || this._subFadeState !== 0) { - this._advanceFadeTime(passedTime); - } - // Update time. - if (this._playheadState === 3) { - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - this._time += passedTime; - } - // Update timeline. - if (this._timelineDirty !== 0) { - if (this._timelineDirty === 2) { - this._updateTimelines(); - } - this._timelineDirty = 0; - this._updateBoneAndSlotTimelines(); - } - var isBlendDirty = this._fadeState !== 0 || this._subFadeState === 0; - var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; - var isUpdateTimeline = true; - var isUpdateBoneTimeline = true; - var time = this._time; - this._weightResult = this._weight * this._fadeProgress; - if (this._parent !== null) { - this._weightResult *= this._parent._weightResult; - } - if (this._actionTimeline.playState <= 0) { - this._actionTimeline.update(time); - } - if (this._weight === 0.0) { - return; - } - if (isCacheEnabled) { - var internval = cacheFrameRate * 2.0; - this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; - } - if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { - this._zOrderTimeline.update(time); - } - if (isCacheEnabled) { - var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint - if (this._armature._cacheFrameIndex === cacheFrameIndex) { - isUpdateTimeline = false; - isUpdateBoneTimeline = false; - } - else { - this._armature._cacheFrameIndex = cacheFrameIndex; - if (this._animationData.cachedFrames[cacheFrameIndex]) { - isUpdateBoneTimeline = false; - } - else { - this._animationData.cachedFrames[cacheFrameIndex] = true; - } - } - } - if (isUpdateTimeline) { - var isBlend = false; - var prevTarget = null; // - if (isUpdateBoneTimeline) { - for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { - var timeline = this._boneTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (timeline.target !== prevTarget) { - var blendState = timeline.target; - isBlend = blendState.update(this); - prevTarget = blendState; - if (blendState.dirty === 1) { - var pose = blendState.target.animationPose; - pose.x = 0.0; - pose.y = 0.0; - pose.rotation = 0.0; - pose.skew = 0.0; - pose.scaleX = 1.0; - pose.scaleY = 1.0; - } - } - if (isBlend) { - timeline.blend(isBlendDirty); - } - } - } - for (var i = 0, l = this._boneBlendTimelines.length; i < l; ++i) { - var timeline = this._boneBlendTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (timeline.target.update(this)) { - timeline.blend(isBlendDirty); - } - } - if (this.displayControl) { - for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { - var timeline = this._slotTimelines[i]; - if (timeline.playState <= 0) { - var slot = timeline.target; - var displayController = slot.displayController; - if (displayController === null || - displayController === this.name || - displayController === this.group) { - timeline.update(time); - } - } - } - } - for (var i = 0, l = this._slotBlendTimelines.length; i < l; ++i) { - var timeline = this._slotBlendTimelines[i]; - if (timeline.playState <= 0) { - var blendState = timeline.target; - timeline.update(time); - if (blendState.update(this)) { - timeline.blend(isBlendDirty); - } - } - } - for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { - var timeline = this._constraintTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - } - if (this._animationTimelines.length > 0) { - var dL = 100.0; - var dR = 100.0; - var leftState = null; - var rightState = null; - for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { - var timeline = this._animationTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (this.blendType === 1 /* E1D */) { - var animationState = timeline.target; - var d = this.parameterX - animationState.positionX; - if (d >= 0.0) { - if (d < dL) { - dL = d; - leftState = animationState; - } - } - else { - if (-d < dR) { - dR = -d; - rightState = animationState; - } - } - } - } - if (leftState !== null) { - if (this._activeChildA !== leftState) { - if (this._activeChildA !== null) { - this._activeChildA.weight = 0.0; - } - this._activeChildA = leftState; - this._activeChildA.activeTimeline(); - } - if (this._activeChildB !== rightState) { - if (this._activeChildB !== null) { - this._activeChildB.weight = 0.0; - } - this._activeChildB = rightState; - } - leftState.weight = dR / (dL + dR); - if (rightState) { - rightState.weight = 1.0 - leftState.weight; - } - } - } - } - if (this._fadeState === 0) { - if (this._subFadeState > 0) { - this._subFadeState = 0; - if (this._poseTimelines.length > 0) { - for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var index = this._boneTimelines.indexOf(timeline); - if (index >= 0) { - this._boneTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._boneBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._boneBlendTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._slotTimelines.indexOf(timeline); - if (index >= 0) { - this._slotTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._slotBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._slotBlendTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._constraintTimelines.indexOf(timeline); - if (index >= 0) { - this._constraintTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - } - this._poseTimelines.length = 0; - } - } - if (this._actionTimeline.playState > 0) { - if (this.autoFadeOutTime >= 0.0) { - this.fadeOut(this.autoFadeOutTime); - } - } - } - }; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.play = function () { - this._playheadState = 3; // 11 - }; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.stop = function () { - this._playheadState &= 1; // 0x - }; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { - if (pausePlayhead === void 0) { pausePlayhead = true; } - if (fadeOutTime < 0.0) { - fadeOutTime = 0.0; - } - if (pausePlayhead) { - this._playheadState &= 2; // x0 - } - if (this._fadeState > 0) { - if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { - return; - } - } - else { - this._fadeState = 1; - this._subFadeState = -1; - if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { - this._fadeProgress = 0.000001; // Modify fade progress to different value. - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.fadeOut(); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.fadeOut(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.fadeOut(); - } - for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.fadeOut(); - } - for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.fadeOut(); - } - for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { - var timeline = _l[_k]; - timeline.fadeOut(); - // - var animaitonState = timeline.target; - animaitonState.fadeOut(999999.0, true); - } - } - this.displayControl = false; // - this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; - this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); - }; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.containsBoneMask = function (boneName) { - return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; - }; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.addBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = this._armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this._boneMask.indexOf(boneName) < 0) { - this._boneMask.push(boneName); - } - if (recursive) { - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this._boneMask.indexOf(boneName); - if (index >= 0) { - this._boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = this._armature.getBone(boneName); - if (currentBone !== null) { - var bones = this._armature.getBones(); - if (this._boneMask.length > 0) { - for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { - var bone = bones_1[_i]; - var index_1 = this._boneMask.indexOf(bone.name); - if (index_1 >= 0 && currentBone.contains(bone)) { - this._boneMask.splice(index_1, 1); - } - } - } - else { - for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { - var bone = bones_2[_a]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeAllBoneMask = function () { - this._boneMask.length = 0; - this._timelineDirty = 1; - }; - /** - * @private - */ - AnimationState.prototype.addState = function (animationState, timelineDatas) { - if (timelineDatas === void 0) { timelineDatas = null; } - if (timelineDatas !== null) { - for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { - var timelineData = timelineDatas_4[_i]; - switch (timelineData.type) { - case 40 /* AnimationProgress */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - if (this.blendType !== 0 /* None */) { - var animaitonTimelineData = timelineData; - animationState.positionX = animaitonTimelineData.x; - animationState.positionY = animaitonTimelineData.y; - animationState.weight = 0.0; - } - animationState._parent = this; - this.resetToPose = false; - break; - } - case 41 /* AnimationWeight */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - case 42 /* AnimationParameter */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - default: - break; - } - } - } - if (animationState._parent === null) { - animationState._parent = this; - } - }; - /** - * @internal - */ - AnimationState.prototype.activeTimeline = function () { - for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.dirty = true; - timeline.currentTime = -1.0; - } - }; - Object.defineProperty(AnimationState.prototype, "isFadeIn", { - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState < 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeOut", { - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeComplete", { - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState === 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isPlaying", { - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isCompleted", { - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.playState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "totalTime", { - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentTime", { - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentTime; - }, - set: function (value) { - var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); - if (value < 0 || this._duration < value) { - value = (value % this._duration) + currentPlayTimes * this._duration; - if (value < 0) { - value += this._duration; - } - } - if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && - value === this._duration && this._parent === null) { - value = this._duration - 0.000001; // - } - if (this._time === value) { - return; - } - this._time = value; - this._actionTimeline.setCurrentTime(this._time); - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.playState = -1; - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.playState = -1; - } - for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.playState = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "weight", { - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - get: function () { - return this._weight; - }, - set: function (value) { - if (this._weight === value) { - return; - } - this._weight = value; - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.dirty = true; - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.dirty = true; - } - for (var _d = 0, _e = this._slotBlendTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.dirty = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "animationData", { - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animationData; - }, - enumerable: true, - configurable: true - }); - return AnimationState; - }(dragonBones.BaseObject)); - dragonBones.AnimationState = AnimationState; - /** - * @internal - */ - var BlendState = (function (_super) { - __extends(BlendState, _super); - function BlendState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BlendState.toString = function () { - return "[class dragonBones.BlendState]"; - }; - BlendState.prototype._onClear = function () { - this.reset(); - this.target = null; - }; - BlendState.prototype.update = function (animationState) { - var animationLayer = animationState.layer; - var animationWeight = animationState._weightResult; - if (this.dirty > 0) { - if (this.leftWeight > 0.0) { - if (this.layer !== animationLayer) { - if (this.layerWeight >= this.leftWeight) { - this.dirty++; - this.layer = animationLayer; - this.leftWeight = 0.0; - this.blendWeight = 0.0; - return false; - } - this.layer = animationLayer; - this.leftWeight -= this.layerWeight; - this.layerWeight = 0.0; - } - animationWeight *= this.leftWeight; - this.dirty++; - this.blendWeight = animationWeight; - this.layerWeight += this.blendWeight; - return true; - } - return false; - } - this.dirty++; - this.layer = animationLayer; - this.leftWeight = 1.0; - this.blendWeight = animationWeight; - this.layerWeight = animationWeight; - return true; - }; - BlendState.prototype.reset = function () { - this.dirty = 0; - this.layer = 0; - this.leftWeight = 0.0; - this.layerWeight = 0.0; - this.blendWeight = 0.0; - }; - BlendState.BONE_TRANSFORM = "boneTransform"; - BlendState.BONE_ALPHA = "boneAlpha"; - BlendState.SURFACE = "surface"; - BlendState.SLOT_DEFORM = "slotDeform"; - BlendState.SLOT_ALPHA = "slotAlpha"; - BlendState.SLOT_Z_INDEX = "slotZIndex"; - return BlendState; - }(dragonBones.BaseObject)); - dragonBones.BlendState = BlendState; -})(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) { - /** - * @internal - */ - var TimelineState = (function (_super) { - __extends(TimelineState, _super); - function TimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineState.prototype._onClear = function () { - this.dirty = false; - this.playState = -1; - this.currentPlayTimes = -1; - this.currentTime = -1.0; - this.target = null; - this._isTween = false; - this._valueOffset = 0; - this._frameValueOffset = 0; - this._frameOffset = 0; - this._frameRate = 0; - this._frameCount = 0; - this._frameIndex = -1; - this._frameRateR = 0.0; - this._position = 0.0; - this._duration = 0.0; - this._timeScale = 1.0; - this._timeOffset = 0.0; - this._animationData = null; // - this._timelineData = null; // - this._armature = null; // - this._animationState = null; // - this._actionTimeline = null; // - this._frameArray = null; // - this._valueArray = null; // - this._timelineArray = null; // - this._frameIndices = null; // - }; - TimelineState.prototype._setCurrentTime = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._actionTimeline !== null && this._frameCount <= 1) { - this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; - this.currentPlayTimes = 1; - this.currentTime = this._actionTimeline.currentTime; - } - else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { - var playTimes = this._animationState.playTimes; - var totalTime = playTimes * this._duration; - passedTime *= this._timeScale; - if (this._timeOffset !== 0.0) { - passedTime += this._timeOffset * this._animationData.duration; - } - if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { - if (this.playState <= 0 && this._animationState._playheadState === 3) { - this.playState = 1; - } - this.currentPlayTimes = playTimes; - if (passedTime < 0.0) { - this.currentTime = 0.0; - } - else { - this.currentTime = this.playState === 1 ? this._duration + 0.000001 : this._duration; // Precision problem - } - } - else { - if (this.playState !== 0 && this._animationState._playheadState === 3) { - this.playState = 0; - } - if (passedTime < 0.0) { - passedTime = -passedTime; - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = this._duration - (passedTime % this._duration); - } - else { - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = passedTime % this._duration; - } - } - this.currentTime += this._position; - } - else { - this.playState = this._actionTimeline.playState; - this.currentPlayTimes = this._actionTimeline.currentPlayTimes; - this.currentTime = this._actionTimeline.currentTime; - } - if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { - return false; - } - // Clear frame flag when timeline start or loopComplete. - if ((prevState < 0 && this.playState !== prevState) || - (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { - this._frameIndex = -1; - } - return true; - }; - TimelineState.prototype.init = function (armature, animationState, timelineData) { - this._armature = armature; - this._animationState = animationState; - this._timelineData = timelineData; - this._actionTimeline = this._animationState._actionTimeline; - if (this === this._actionTimeline) { - this._actionTimeline = null; // - } - this._animationData = this._animationState.animationData; - // - this._frameRate = this._animationData.parent.frameRate; - this._frameRateR = 1.0 / this._frameRate; - this._position = this._animationState._position; - this._duration = this._animationState._duration; - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. - this._frameArray = dragonBonesData.frameArray; - this._timelineArray = dragonBonesData.timelineArray; - this._frameIndices = dragonBonesData.frameIndices; - // - this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; - this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; - this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; - this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; - } - }; - TimelineState.prototype.fadeOut = function () { - this.dirty = false; - }; - TimelineState.prototype.update = function (passedTime) { - if (this._setCurrentTime(passedTime)) { - if (this._frameCount > 1) { - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - this._frameIndex = frameIndex; - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - this._onArriveAtFrame(); - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - } - this._onArriveAtFrame(); - } - if (this._isTween || this.dirty) { - this._onUpdateFrame(); - } - } - }; - TimelineState.prototype.blend = function (_isDirty) { - }; - return TimelineState; - }(dragonBones.BaseObject)); - dragonBones.TimelineState = TimelineState; - /** - * @internal - */ - var TweenTimelineState = (function (_super) { - __extends(TweenTimelineState, _super); - function TweenTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { - var value = progress; - switch (tweenType) { - case 3 /* QuadIn */: - value = Math.pow(progress, 2.0); - break; - case 4 /* QuadOut */: - value = 1.0 - Math.pow(1.0 - progress, 2.0); - break; - case 5 /* QuadInOut */: - value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); - break; - } - return (value - progress) * easing + progress; - }; - TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { - if (progress <= 0.0) { - return 0.0; - } - else if (progress >= 1.0) { - return 1.0; - } - var isOmited = count > 0; - var segmentCount = count + 1; // + 2 - 1 - var valueIndex = Math.floor(progress * segmentCount); - var fromValue = 0.0; - var toValue = 0.0; - if (isOmited) { - fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; - toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; - } - else { - fromValue = samples[offset + valueIndex - 1]; - toValue = samples[offset + valueIndex]; - } - return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; - }; - TweenTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._tweenType = 0 /* None */; - this._curveCount = 0; - this._framePosition = 0.0; - this._frameDurationR = 0.0; - this._tweenEasing = 0.0; - this._tweenProgress = 0.0; - this._valueScale = 1.0; - }; - TweenTimelineState.prototype._onArriveAtFrame = function () { - if (this._frameCount > 1 && - (this._frameIndex !== this._frameCount - 1 || - this._animationState.playTimes === 0 || - this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { - this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; - this._isTween = this._tweenType !== 0 /* None */; - if (this._isTween) { - if (this._tweenType === 2 /* Curve */) { - this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; - } - else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { - this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; - } - } - else { - this.dirty = true; - } - this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; - if (this._frameIndex === this._frameCount - 1) { - this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); - } - else { - var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; - var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; - if (frameDuration > 0) { - this._frameDurationR = 1.0 / frameDuration; - } - else { - this._frameDurationR = 0.0; - } - } - } - else { - this.dirty = true; - this._isTween = false; - } - }; - TweenTimelineState.prototype._onUpdateFrame = function () { - if (this._isTween) { - this.dirty = true; - this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; - if (this._tweenType === 2 /* Curve */) { - this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); - } - else if (this._tweenType !== 1 /* Line */) { - this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); - } - } - }; - return TweenTimelineState; - }(TimelineState)); - dragonBones.TweenTimelineState = TweenTimelineState; - /** - * @internal - */ - var SingleValueTimelineState = (function (_super) { - __extends(SingleValueTimelineState, _super); - function SingleValueTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SingleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._current = 0.0; - this._difference = 0.0; - this._result = 0.0; - }; - SingleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + 1; - if (valueScale === 1.0) { - this._current = valueArray[valueOffset]; - this._difference = valueArray[nextValueOffset] - this._current; - } - else { - this._current = valueArray[valueOffset] * valueScale; - this._difference = valueArray[nextValueOffset] * valueScale - this._current; - } - } - else { - this._result = valueArray[valueOffset] * valueScale; - } - } - else { - this._result = 0.0; - } - }; - SingleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._result = this._current + this._difference * this._tweenProgress; - } - }; - return SingleValueTimelineState; - }(TweenTimelineState)); - dragonBones.SingleValueTimelineState = SingleValueTimelineState; - /** - * @internal - */ - var DoubleValueTimelineState = (function (_super) { - __extends(DoubleValueTimelineState, _super); - function DoubleValueTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - DoubleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._currentA = 0.0; - this._currentB = 0.0; - this._differenceA = 0.0; - this._differenceB = 0.0; - this._resultA = 0.0; - this._resultB = 0.0; - }; - DoubleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + 2; - if (valueScale === 1.0) { - this._currentA = valueArray[valueOffset]; - this._currentB = valueArray[valueOffset + 1]; - this._differenceA = valueArray[nextValueOffset] - this._currentA; - this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; - } - else { - this._currentA = valueArray[valueOffset] * valueScale; - this._currentB = valueArray[valueOffset + 1] * valueScale; - this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; - this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; - } - } - else { - this._resultA = valueArray[valueOffset] * valueScale; - this._resultB = valueArray[valueOffset + 1] * valueScale; - } - } - else { - this._resultA = 0.0; - this._resultB = 0.0; - } - }; - DoubleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._resultA = this._currentA + this._differenceA * this._tweenProgress; - this._resultB = this._currentB + this._differenceB * this._tweenProgress; - } - }; - return DoubleValueTimelineState; - }(TweenTimelineState)); - dragonBones.DoubleValueTimelineState = DoubleValueTimelineState; - /** - * @internal - */ - var MutilpleValueTimelineState = (function (_super) { - __extends(MutilpleValueTimelineState, _super); - function MutilpleValueTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rd = []; - return _this; - } - MutilpleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._valueCount = 0; - this._rd.length = 0; - }; - MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - var valueCount = this._valueCount; - var rd = this._rd; - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + valueCount; - if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; - } - } - } - else if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i]; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] * valueScale; - } - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = 0.0; - } - } - }; - MutilpleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - var valueCount = this._valueCount; - var valueScale = this._valueScale; - var tweenProgress = this._tweenProgress; - var valueArray = this._valueArray; - var rd = this._rd; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; - if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; - } - } - } - }; - return MutilpleValueTimelineState; - }(TweenTimelineState)); - dragonBones.MutilpleValueTimelineState = MutilpleValueTimelineState; -})(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) { - /** - * @internal - */ - var ActionTimelineState = (function (_super) { - __extends(ActionTimelineState, _super); - function ActionTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ActionTimelineState.toString = function () { - return "[class dragonBones.ActionTimelineState]"; - }; - ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { - var eventDispatcher = this._armature.eventDispatcher; - if (this._animationState.actionEnabled) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; - var actionCount = this._frameArray[frameOffset + 1]; - var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. - for (var i = 0; i < actionCount; ++i) { - var actionIndex = this._frameArray[frameOffset + 2 + i]; - var action = actions[actionIndex]; - if (action.type === 0 /* Play */) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._bufferAction(eventObject, true); - } - else { - var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; - if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - } - }; - ActionTimelineState.prototype._onArriveAtFrame = function () { }; - ActionTimelineState.prototype._onUpdateFrame = function () { }; - ActionTimelineState.prototype.update = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._setCurrentTime(passedTime)) { - var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; - var eventDispatcher = this._armature.eventDispatcher; - if (prevState < 0) { - if (this.playState !== prevState) { - if (this._animationState.displayControl && this._animationState.resetToPose) { - this._armature._sortZOrder(null, 0); - } - prevPlayTimes = this.currentPlayTimes; - if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = dragonBones.EventObject.START; - eventObject.armature = this._armature; - eventObject.animationState = this._animationState; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - else { - return; - } - } - var isReverse = this._animationState.timeScale < 0.0; - var loopCompleteEvent = null; - var completeEvent = null; - if (eventActive && this.currentPlayTimes !== prevPlayTimes) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { - loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; - loopCompleteEvent.armature = this._armature; - loopCompleteEvent.animationState = this._animationState; - } - if (this.playState > 0) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { - completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - completeEvent.type = dragonBones.EventObject.COMPLETE; - completeEvent.armature = this._armature; - completeEvent.animationState = this._animationState; - } - } - } - if (this._frameCount > 1) { - var timelineData = this._timelineData; - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - var crossedFrameIndex = this._frameIndex; - this._frameIndex = frameIndex; - if (this._timelineArray !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - if (isReverse) { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - if (this.currentPlayTimes === prevPlayTimes) { - if (crossedFrameIndex === frameIndex) { - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - else { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - } - else if (crossedFrameIndex === frameIndex) { - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - if (crossedFrameIndex < this._frameCount - 1) { - crossedFrameIndex++; - } - else { - crossedFrameIndex = 0; - } - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration // - ) { - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - } - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - // Arrive at frame. - var framePosition = this._frameArray[this._frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { - this._onCrossFrame(this._frameIndex); - } - } - else if (this._position <= framePosition) { - if (!isReverse && loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - this._onCrossFrame(this._frameIndex); - } - } - } - if (loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - } - if (completeEvent !== null) { - this._armature._dragonBones.bufferEvent(completeEvent); - } - } - }; - ActionTimelineState.prototype.setCurrentTime = function (value) { - this._setCurrentTime(value); - this._frameIndex = -1; - }; - return ActionTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ActionTimelineState = ActionTimelineState; - /** - * @internal - */ - var ZOrderTimelineState = (function (_super) { - __extends(ZOrderTimelineState, _super); - function ZOrderTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ZOrderTimelineState.toString = function () { - return "[class dragonBones.ZOrderTimelineState]"; - }; - ZOrderTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var count = this._frameArray[this._frameOffset + 1]; - if (count > 0) { - this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); - } - else { - this._armature._sortZOrder(null, 0); - } - } - }; - ZOrderTimelineState.prototype._onUpdateFrame = function () { }; - return ZOrderTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ZOrderTimelineState = ZOrderTimelineState; - /** - * @internal - */ - var BoneAllTimelineState = (function (_super) { - __extends(BoneAllTimelineState, _super); - function BoneAllTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneAllTimelineState.toString = function () { - return "[class dragonBones.BoneAllTimelineState]"; - }; - BoneAllTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); - this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); - } - if (this._timelineData === null) { - this._rd[4] = 1.0; - this._rd[5] = 1.0; - } - }; - BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = 6; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneAllTimelineState.prototype.fadeOut = function () { - this.dirty = false; - this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); - this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); - }; - BoneAllTimelineState.prototype.blend = function (isDirty) { - var valueScale = this._armature.armatureData.scale; - var rd = this._rd; - // - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.x += rd[0] * blendWeight * valueScale; - result.y += rd[1] * blendWeight * valueScale; - result.rotation += rd[2] * blendWeight; - result.skew += rd[3] * blendWeight; - result.scaleX += (rd[4] - 1.0) * blendWeight; - result.scaleY += (rd[5] - 1.0) * blendWeight; - } - else { - result.x = rd[0] * blendWeight * valueScale; - result.y = rd[1] * blendWeight * valueScale; - result.rotation = rd[2] * blendWeight; - result.skew = rd[3] * blendWeight; - result.scaleX = (rd[4] - 1.0) * blendWeight + 1.0; // - result.scaleY = (rd[5] - 1.0) * blendWeight + 1.0; // - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneAllTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.BoneAllTimelineState = BoneAllTimelineState; - /** - * @internal - */ - var BoneTranslateTimelineState = (function (_super) { - __extends(BoneTranslateTimelineState, _super); - function BoneTranslateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTranslateTimelineState.toString = function () { - return "[class dragonBones.BoneTranslateTimelineState]"; - }; - BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneTranslateTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.x += this._resultA * blendWeight; - result.y += this._resultB * blendWeight; - } - else if (blendWeight !== 1.0) { - result.x = this._resultA * blendWeight; - result.y = this._resultB * blendWeight; - } - else { - result.x = this._resultA; - result.y = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneTranslateTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; - /** - * @internal - */ - var BoneRotateTimelineState = (function (_super) { - __extends(BoneRotateTimelineState, _super); - function BoneRotateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneRotateTimelineState.toString = function () { - return "[class dragonBones.BoneRotateTimelineState]"; - }; - BoneRotateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); - this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); - } - }; - BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneRotateTimelineState.prototype.fadeOut = function () { - this.dirty = false; - this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); - this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); - }; - BoneRotateTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.rotation += this._resultA * blendWeight; - result.skew += this._resultB * blendWeight; - } - else if (blendWeight !== 1.0) { - result.rotation = this._resultA * blendWeight; - result.skew = this._resultB * blendWeight; - } - else { - result.rotation = this._resultA; - result.skew = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneRotateTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; - /** - * @internal - */ - var BoneScaleTimelineState = (function (_super) { - __extends(BoneScaleTimelineState, _super); - function BoneScaleTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneScaleTimelineState.toString = function () { - return "[class dragonBones.BoneScaleTimelineState]"; - }; - BoneScaleTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { - this._resultA = 1.0; - this._resultB = 1.0; - } - }; - BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneScaleTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.scaleX += (this._resultA - 1.0) * blendWeight; - result.scaleY += (this._resultB - 1.0) * blendWeight; - } - else if (blendWeight !== 1.0) { - result.scaleX = (this._resultA - 1.0) * blendWeight + 1.0; - result.scaleY = (this._resultB - 1.0) * blendWeight + 1.0; - } - else { - result.scaleX = this._resultA; - result.scaleY = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneScaleTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; - /** - * @internal - */ - var SurfaceTimelineState = (function (_super) { - __extends(SurfaceTimelineState, _super); - function SurfaceTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SurfaceTimelineState.toString = function () { - return "[class dragonBones.SurfaceTimelineState]"; - }; - SurfaceTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._deformCount = 0; - this._deformOffset = 0; - this._sameValueOffset = 0; - }; - SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; - var frameIntArray = dragonBonesData.frameIntArray; - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = dragonBonesData.frameFloatArray; - this._rd.length = this._valueCount * 2; - } - else { - this._deformCount = this.target.target._deformVertices.length; - } - }; - SurfaceTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var surface = blendState.target; - var blendWeight = blendState.blendWeight; - var result = surface._deformVertices; - var valueArray = this._valueArray; - if (valueArray !== null) { - var valueCount = this._valueCount; - var deformOffset = this._deformOffset; - var sameValueOffset = this._sameValueOffset; - var rd = this._rd; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < deformOffset) { - value = valueArray[sameValueOffset + i]; - } - else if (i < deformOffset + valueCount) { - value = rd[i - deformOffset]; - } - else { - value = valueArray[sameValueOffset + i - valueCount]; - } - if (blendState.dirty > 1) { - result[i] += value * blendWeight; - } - else { - result[i] = value * blendWeight; - } - } - } - else if (blendState.dirty === 1) { - for (var i = 0; i < this._deformCount; ++i) { - result[i] = 0.0; - } - } - if (isDirty || this.dirty) { - this.dirty = false; - surface._transformDirty = true; - } - }; - return SurfaceTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.SurfaceTimelineState = SurfaceTimelineState; - /** - * @internal - */ - var AlphaTimelineState = (function (_super) { - __extends(AlphaTimelineState, _super); - function AlphaTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AlphaTimelineState.toString = function () { - return "[class dragonBones.AlphaTimelineState]"; - }; - AlphaTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { - this._result = 1.0; - } - }; - AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.01; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - AlphaTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var alphaTarget = blendState.target; - var blendWeight = blendState.blendWeight; - if (blendState.dirty > 1) { - alphaTarget._alpha += this._result * blendWeight; - if (alphaTarget._alpha > 1.0) { - alphaTarget._alpha = 1.0; - } - } - else { - alphaTarget._alpha = this._result * blendWeight; - } - if (isDirty || this.dirty) { - this.dirty = false; - this._armature._alphaDirty = true; - } - }; - return AlphaTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AlphaTimelineState = AlphaTimelineState; - /** - * @internal - */ - var SlotDisplayTimelineState = (function (_super) { - __extends(SlotDisplayTimelineState, _super); - function SlotDisplayTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotDisplayTimelineState.toString = function () { - return "[class dragonBones.SlotDisplayTimelineState]"; - }; - SlotDisplayTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var slot = this.target; - var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; - if (slot.displayIndex !== displayIndex) { - slot._setDisplayIndex(displayIndex, true); - } - } - }; - SlotDisplayTimelineState.prototype._onUpdateFrame = function () { - }; - return SlotDisplayTimelineState; - }(dragonBones.TimelineState)); - dragonBones.SlotDisplayTimelineState = SlotDisplayTimelineState; - /** - * @internal - */ - var SlotColorTimelineState = (function (_super) { - __extends(SlotColorTimelineState, _super); - function SlotColorTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._difference = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - SlotColorTimelineState.toString = function () { - return "[class dragonBones.SlotColorTimelineState]"; - }; - SlotColorTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; - var colorArray = dragonBonesData.colorArray; - var frameIntArray = dragonBonesData.frameIntArray; - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; - var colorOffset = frameIntArray[valueOffset]; - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bounds bug. - } - if (this._isTween) { - this._current[0] = colorArray[colorOffset++]; - this._current[1] = colorArray[colorOffset++]; - this._current[2] = colorArray[colorOffset++]; - this._current[3] = colorArray[colorOffset++]; - this._current[4] = colorArray[colorOffset++]; - this._current[5] = colorArray[colorOffset++]; - this._current[6] = colorArray[colorOffset++]; - this._current[7] = colorArray[colorOffset++]; - if (this._frameIndex === this._frameCount - 1) { - colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; - } - else { - colorOffset = frameIntArray[valueOffset + 1]; - } - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bounds bug. - } - this._difference[0] = colorArray[colorOffset++] - this._current[0]; - this._difference[1] = colorArray[colorOffset++] - this._current[1]; - this._difference[2] = colorArray[colorOffset++] - this._current[2]; - this._difference[3] = colorArray[colorOffset++] - this._current[3]; - this._difference[4] = colorArray[colorOffset++] - this._current[4]; - this._difference[5] = colorArray[colorOffset++] - this._current[5]; - this._difference[6] = colorArray[colorOffset++] - this._current[6]; - this._difference[7] = colorArray[colorOffset++] - this._current[7]; - } - else { - this._result[0] = colorArray[colorOffset++] * 0.01; - this._result[1] = colorArray[colorOffset++] * 0.01; - this._result[2] = colorArray[colorOffset++] * 0.01; - this._result[3] = colorArray[colorOffset++] * 0.01; - this._result[4] = colorArray[colorOffset++]; - this._result[5] = colorArray[colorOffset++]; - this._result[6] = colorArray[colorOffset++]; - this._result[7] = colorArray[colorOffset++]; - } - } - else { - var slot = this.target; - var color = slot.slotData.color; - this._result[0] = color.alphaMultiplier; - this._result[1] = color.redMultiplier; - this._result[2] = color.greenMultiplier; - this._result[3] = color.blueMultiplier; - this._result[4] = color.alphaOffset; - this._result[5] = color.redOffset; - this._result[6] = color.greenOffset; - this._result[7] = color.blueOffset; - } - }; - SlotColorTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; - this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; - this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; - this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; - this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; - this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; - this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; - this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; - } - }; - SlotColorTimelineState.prototype.fadeOut = function () { - this._isTween = false; - }; - SlotColorTimelineState.prototype.update = function (passedTime) { - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._isTween || this.dirty) { - var slot = this.target; - var result = slot._colorTransform; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); - result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; - result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; - result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; - result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; - result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; - result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; - result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; - result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; - slot._colorDirty = true; - } - } - else if (this.dirty) { - this.dirty = false; - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - result.alphaMultiplier = this._result[0]; - result.redMultiplier = this._result[1]; - result.greenMultiplier = this._result[2]; - result.blueMultiplier = this._result[3]; - result.alphaOffset = this._result[4]; - result.redOffset = this._result[5]; - result.greenOffset = this._result[6]; - result.blueOffset = this._result[7]; - slot._colorDirty = true; - } - } - } - }; - return SlotColorTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.SlotColorTimelineState = SlotColorTimelineState; - /** - * @internal - */ - var SlotZIndexTimelineState = (function (_super) { - __extends(SlotZIndexTimelineState, _super); - function SlotZIndexTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotZIndexTimelineState.toString = function () { - return "[class dragonBones.SlotZIndexTimelineState]"; - }; - SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { - var blendState = this.target; - var slot = blendState.target; - this._result = slot.slotData.zIndex; - } - }; - SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - SlotZIndexTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var slot = blendState.target; - var blendWeight = blendState.blendWeight; - if (blendState.dirty > 1) { - slot._zIndex += this._result * blendWeight; - } - else { - slot._zIndex = this._result * blendWeight; - } - if (isDirty || this.dirty) { - this.dirty = false; - this._armature._zIndexDirty = true; - } - }; - return SlotZIndexTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.SlotZIndexTimelineState = SlotZIndexTimelineState; - /** - * @internal - */ - var DeformTimelineState = (function (_super) { - __extends(DeformTimelineState, _super); - function DeformTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - DeformTimelineState.toString = function () { - return "[class dragonBones.DeformTimelineState]"; - }; - DeformTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.geometryOffset = 0; - this.displayFrame = null; - this._deformCount = 0; - this._deformOffset = 0; - this._sameValueOffset = 0; - }; - DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - var dragonBonesData = this._animationData.parent.parent; - var frameIntArray = dragonBonesData.frameIntArray; - var slot = this.target.target; - this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; - if (this.geometryOffset < 0) { - this.geometryOffset += 65536; // Fixed out of bounds bug. - } - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayFrame = slot.getDisplayFrameAt(i); - var geometryData = displayFrame.getGeometryData(); - if (geometryData === null) { - continue; - } - if (geometryData.offset === this.geometryOffset) { - this.displayFrame = displayFrame; - this.displayFrame.updateDeformVertices(); - break; - } - } - if (this.displayFrame === null) { - this.returnToPool(); // - return; - } - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = dragonBonesData.frameFloatArray; - this._rd.length = this._valueCount * 2; - } - else { - this._deformCount = this.displayFrame.deformVertices.length; - } - }; - DeformTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var slot = blendState.target; - var blendWeight = blendState.blendWeight; - var result = this.displayFrame.deformVertices; - var valueArray = this._valueArray; - if (valueArray !== null) { - var valueCount = this._valueCount; - var deformOffset = this._deformOffset; - var sameValueOffset = this._sameValueOffset; - var rd = this._rd; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < deformOffset) { - value = valueArray[sameValueOffset + i]; - } - else if (i < deformOffset + valueCount) { - value = rd[i - deformOffset]; - } - else { - value = valueArray[sameValueOffset + i - valueCount]; - } - if (blendState.dirty > 1) { - result[i] += value * blendWeight; - } - else { - result[i] = value * blendWeight; - } - } - } - else if (blendState.dirty === 1) { - for (var i = 0; i < this._deformCount; ++i) { - result[i] = 0.0; - } - } - if (isDirty || this.dirty) { - this.dirty = false; - if (slot._geometryData === this.displayFrame.getGeometryData()) { - slot._verticesDirty = true; - } - } - }; - return DeformTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.DeformTimelineState = DeformTimelineState; - /** - * @internal - */ - var IKConstraintTimelineState = (function (_super) { - __extends(IKConstraintTimelineState, _super); - function IKConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintTimelineState.toString = function () { - return "[class dragonBones.IKConstraintTimelineState]"; - }; - IKConstraintTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var ikConstraint = this.target; - if (this._timelineData !== null) { - ikConstraint._bendPositive = this._currentA > 0.0; - ikConstraint._weight = this._currentB; - } - else { - var ikConstraintData = ikConstraint._constraintData; - ikConstraint._bendPositive = ikConstraintData.bendPositive; - ikConstraint._weight = ikConstraintData.weight; - } - ikConstraint.invalidUpdate(); - this.dirty = false; - }; - IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.01; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return IKConstraintTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; - /** - * @internal - */ - var AnimationProgressTimelineState = (function (_super) { - __extends(AnimationProgressTimelineState, _super); - function AnimationProgressTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationProgressTimelineState.toString = function () { - return "[class dragonBones.AnimationProgressTimelineState]"; - }; - AnimationProgressTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.currentTime = this._result * animationState.totalTime; - } - this.dirty = false; - }; - AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationProgressTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AnimationProgressTimelineState = AnimationProgressTimelineState; - /** - * @internal - */ - var AnimationWeightTimelineState = (function (_super) { - __extends(AnimationWeightTimelineState, _super); - function AnimationWeightTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationWeightTimelineState.toString = function () { - return "[class dragonBones.AnimationWeightTimelineState]"; - }; - AnimationWeightTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.weight = this._result; - } - this.dirty = false; - }; - AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationWeightTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AnimationWeightTimelineState = AnimationWeightTimelineState; - /** - * @internal - */ - var AnimationParametersTimelineState = (function (_super) { - __extends(AnimationParametersTimelineState, _super); - function AnimationParametersTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationParametersTimelineState.toString = function () { - return "[class dragonBones.AnimationParametersTimelineState]"; - }; - AnimationParametersTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.parameterX = this._resultA; - animationState.parameterY = this._resultB; - } - this.dirty = false; - }; - AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationParametersTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.AnimationParametersTimelineState = AnimationParametersTimelineState; -})(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 properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EventObject = (function (_super) { - __extends(EventObject, _super); - function EventObject() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @internal - * @private - */ - EventObject.actionDataToInstance = function (data, instance, armature) { - if (data.type === 0 /* Play */) { - instance.type = EventObject.FRAME_EVENT; - } - else { - instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; - } - instance.name = data.name; - instance.armature = armature; - instance.actionData = data; - instance.data = data.data; - if (data.bone !== null) { - instance.bone = armature.getBone(data.bone.name); - } - if (data.slot !== null) { - instance.slot = armature.getSlot(data.slot.name); - } - }; - EventObject.toString = function () { - return "[class dragonBones.EventObject]"; - }; - EventObject.prototype._onClear = function () { - this.time = 0.0; - this.type = ""; - this.name = ""; - this.armature = null; - this.bone = null; - this.slot = null; - this.animationState = null; - this.actionData = null; - this.data = null; - }; - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.START = "start"; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.LOOP_COMPLETE = "loopComplete"; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.COMPLETE = "complete"; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN = "fadeIn"; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN_COMPLETE = "fadeInComplete"; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT = "fadeOut"; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FRAME_EVENT = "frameEvent"; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.SOUND_EVENT = "soundEvent"; - return EventObject; - }(dragonBones.BaseObject)); - dragonBones.EventObject = EventObject; -})(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 DataParser = (function () { - function DataParser() { - } - DataParser._getArmatureType = function (value) { - switch (value.toLowerCase()) { - case "stage": - return 2 /* Stage */; - case "armature": - return 0 /* Armature */; - case "movieclip": - return 1 /* MovieClip */; - default: - return 0 /* Armature */; - } - }; - DataParser._getBoneType = function (value) { - switch (value.toLowerCase()) { - case "bone": - return 0 /* Bone */; - case "surface": - return 1 /* Surface */; - default: - return 0 /* Bone */; - } - }; - DataParser._getPositionMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "percent": - return 1 /* Percent */; - case "fixed": - return 0 /* Fixed */; - default: - return 1 /* Percent */; - } - }; - DataParser._getSpacingMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "length": - return 0 /* Length */; - case "percent": - return 2 /* Percent */; - case "fixed": - return 1 /* Fixed */; - default: - return 0 /* Length */; - } - }; - DataParser._getRotateMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "tangent": - return 0 /* Tangent */; - case "chain": - return 1 /* Chain */; - case "chainscale": - return 2 /* ChainScale */; - default: - return 0 /* Tangent */; - } - }; - DataParser._getDisplayType = function (value) { - switch (value.toLowerCase()) { - case "image": - return 0 /* Image */; - case "mesh": - return 2 /* Mesh */; - case "armature": - return 1 /* Armature */; - case "boundingbox": - return 3 /* BoundingBox */; - case "path": - return 4 /* Path */; - default: - return 0 /* Image */; - } - }; - DataParser._getBoundingBoxType = function (value) { - switch (value.toLowerCase()) { - case "rectangle": - return 0 /* Rectangle */; - case "ellipse": - return 1 /* Ellipse */; - case "polygon": - return 2 /* Polygon */; - default: - return 0 /* Rectangle */; - } - }; - DataParser._getBlendMode = function (value) { - switch (value.toLowerCase()) { - case "normal": - return 0 /* Normal */; - case "add": - return 1 /* Add */; - case "alpha": - return 2 /* Alpha */; - case "darken": - return 3 /* Darken */; - case "difference": - return 4 /* Difference */; - case "erase": - return 5 /* Erase */; - case "hardlight": - return 6 /* HardLight */; - case "invert": - return 7 /* Invert */; - case "layer": - return 8 /* Layer */; - case "lighten": - return 9 /* Lighten */; - case "multiply": - return 10 /* Multiply */; - case "overlay": - return 11 /* Overlay */; - case "screen": - return 12 /* Screen */; - case "subtract": - return 13 /* Subtract */; - default: - return 0 /* Normal */; - } - }; - DataParser._getAnimationBlendType = function (value) { - switch (value.toLowerCase()) { - case "none": - return 0 /* None */; - case "1d": - return 1 /* E1D */; - default: - return 0 /* None */; - } - }; - DataParser._getActionType = function (value) { - switch (value.toLowerCase()) { - case "play": - return 0 /* Play */; - case "frame": - return 10 /* Frame */; - case "sound": - return 11 /* Sound */; - default: - return 0 /* Play */; - } - }; - DataParser.DATA_VERSION_2_3 = "2.3"; - DataParser.DATA_VERSION_3_0 = "3.0"; - DataParser.DATA_VERSION_4_0 = "4.0"; - DataParser.DATA_VERSION_4_5 = "4.5"; - DataParser.DATA_VERSION_5_0 = "5.0"; - DataParser.DATA_VERSION_5_5 = "5.5"; - DataParser.DATA_VERSION_5_6 = "5.6"; - DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_6; - DataParser.DATA_VERSIONS = [ - DataParser.DATA_VERSION_4_0, - DataParser.DATA_VERSION_4_5, - DataParser.DATA_VERSION_5_0, - DataParser.DATA_VERSION_5_5, - DataParser.DATA_VERSION_5_6 - ]; - DataParser.TEXTURE_ATLAS = "textureAtlas"; - DataParser.SUB_TEXTURE = "SubTexture"; - DataParser.FORMAT = "format"; - DataParser.IMAGE_PATH = "imagePath"; - DataParser.WIDTH = "width"; - DataParser.HEIGHT = "height"; - DataParser.ROTATED = "rotated"; - DataParser.FRAME_X = "frameX"; - DataParser.FRAME_Y = "frameY"; - DataParser.FRAME_WIDTH = "frameWidth"; - DataParser.FRAME_HEIGHT = "frameHeight"; - DataParser.DRADON_BONES = "dragonBones"; - DataParser.USER_DATA = "userData"; - DataParser.ARMATURE = "armature"; - DataParser.CANVAS = "canvas"; - DataParser.BONE = "bone"; - DataParser.SURFACE = "surface"; - DataParser.SLOT = "slot"; - DataParser.CONSTRAINT = "constraint"; - DataParser.SKIN = "skin"; - DataParser.DISPLAY = "display"; - DataParser.FRAME = "frame"; - DataParser.IK = "ik"; - DataParser.PATH_CONSTRAINT = "path"; - DataParser.ANIMATION = "animation"; - DataParser.TIMELINE = "timeline"; - DataParser.FFD = "ffd"; - DataParser.TRANSLATE_FRAME = "translateFrame"; - DataParser.ROTATE_FRAME = "rotateFrame"; - DataParser.SCALE_FRAME = "scaleFrame"; - DataParser.DISPLAY_FRAME = "displayFrame"; - DataParser.COLOR_FRAME = "colorFrame"; - DataParser.DEFAULT_ACTIONS = "defaultActions"; - DataParser.ACTIONS = "actions"; - DataParser.EVENTS = "events"; - DataParser.INTS = "ints"; - DataParser.FLOATS = "floats"; - DataParser.STRINGS = "strings"; - DataParser.TRANSFORM = "transform"; - DataParser.PIVOT = "pivot"; - DataParser.AABB = "aabb"; - DataParser.COLOR = "color"; - DataParser.VERSION = "version"; - DataParser.COMPATIBLE_VERSION = "compatibleVersion"; - DataParser.FRAME_RATE = "frameRate"; - DataParser.TYPE = "type"; - DataParser.SUB_TYPE = "subType"; - DataParser.NAME = "name"; - DataParser.PARENT = "parent"; - DataParser.TARGET = "target"; - DataParser.STAGE = "stage"; - DataParser.SHARE = "share"; - DataParser.PATH = "path"; - DataParser.LENGTH = "length"; - DataParser.DISPLAY_INDEX = "displayIndex"; - DataParser.Z_ORDER = "zOrder"; - DataParser.Z_INDEX = "zIndex"; - DataParser.BLEND_MODE = "blendMode"; - DataParser.INHERIT_TRANSLATION = "inheritTranslation"; - DataParser.INHERIT_ROTATION = "inheritRotation"; - DataParser.INHERIT_SCALE = "inheritScale"; - DataParser.INHERIT_REFLECTION = "inheritReflection"; - DataParser.INHERIT_ANIMATION = "inheritAnimation"; - DataParser.INHERIT_DEFORM = "inheritDeform"; - DataParser.SEGMENT_X = "segmentX"; - DataParser.SEGMENT_Y = "segmentY"; - DataParser.BEND_POSITIVE = "bendPositive"; - DataParser.CHAIN = "chain"; - DataParser.WEIGHT = "weight"; - DataParser.BLEND_TYPE = "blendType"; - DataParser.FADE_IN_TIME = "fadeInTime"; - DataParser.PLAY_TIMES = "playTimes"; - DataParser.SCALE = "scale"; - DataParser.OFFSET = "offset"; - DataParser.POSITION = "position"; - DataParser.DURATION = "duration"; - DataParser.TWEEN_EASING = "tweenEasing"; - DataParser.TWEEN_ROTATE = "tweenRotate"; - DataParser.TWEEN_SCALE = "tweenScale"; - DataParser.CLOCK_WISE = "clockwise"; - DataParser.CURVE = "curve"; - DataParser.SOUND = "sound"; - DataParser.EVENT = "event"; - DataParser.ACTION = "action"; - DataParser.X = "x"; - DataParser.Y = "y"; - DataParser.SKEW_X = "skX"; - DataParser.SKEW_Y = "skY"; - DataParser.SCALE_X = "scX"; - DataParser.SCALE_Y = "scY"; - DataParser.VALUE = "value"; - DataParser.ROTATE = "rotate"; - DataParser.SKEW = "skew"; - DataParser.ALPHA = "alpha"; - DataParser.ALPHA_OFFSET = "aO"; - DataParser.RED_OFFSET = "rO"; - DataParser.GREEN_OFFSET = "gO"; - DataParser.BLUE_OFFSET = "bO"; - DataParser.ALPHA_MULTIPLIER = "aM"; - DataParser.RED_MULTIPLIER = "rM"; - DataParser.GREEN_MULTIPLIER = "gM"; - DataParser.BLUE_MULTIPLIER = "bM"; - DataParser.UVS = "uvs"; - DataParser.VERTICES = "vertices"; - DataParser.TRIANGLES = "triangles"; - DataParser.WEIGHTS = "weights"; - DataParser.SLOT_POSE = "slotPose"; - DataParser.BONE_POSE = "bonePose"; - DataParser.BONES = "bones"; - DataParser.POSITION_MODE = "positionMode"; - DataParser.SPACING_MODE = "spacingMode"; - DataParser.ROTATE_MODE = "rotateMode"; - DataParser.SPACING = "spacing"; - DataParser.ROTATE_OFFSET = "rotateOffset"; - DataParser.ROTATE_MIX = "rotateMix"; - DataParser.TRANSLATE_MIX = "translateMix"; - DataParser.TARGET_DISPLAY = "targetDisplay"; - DataParser.CLOSED = "closed"; - DataParser.CONSTANT_SPEED = "constantSpeed"; - DataParser.VERTEX_COUNT = "vertexCount"; - DataParser.LENGTHS = "lengths"; - DataParser.GOTO_AND_PLAY = "gotoAndPlay"; - DataParser.DEFAULT_NAME = "default"; - return DataParser; - }()); - dragonBones.DataParser = DataParser; -})(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 ObjectDataParser = (function (_super) { - __extends(ObjectDataParser, _super); - function ObjectDataParser() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rawTextureAtlasIndex = 0; - _this._rawBones = []; - _this._data = null; // - _this._armature = null; // - _this._bone = null; // - _this._geometry = null; // - _this._slot = null; // - _this._skin = null; // - _this._mesh = null; // - _this._animation = null; // - _this._timeline = null; // - _this._rawTextureAtlases = null; - _this._frameValueType = 0 /* Step */; - _this._defaultColorOffset = -1; - _this._prevClockwise = 0; - _this._prevRotation = 0.0; - _this._frameDefaultValue = 0.0; - _this._frameValueScale = 1.0; - _this._helpMatrixA = new dragonBones.Matrix(); - _this._helpMatrixB = new dragonBones.Matrix(); - _this._helpTransform = new dragonBones.Transform(); - _this._helpColorTransform = new dragonBones.ColorTransform(); - _this._helpPoint = new dragonBones.Point(); - _this._helpArray = []; - _this._intArray = []; - _this._floatArray = []; - _this._frameIntArray = []; - _this._frameFloatArray = []; - _this._frameArray = []; - _this._timelineArray = []; - _this._colorArray = []; - _this._cacheRawMeshes = []; - _this._cacheMeshes = []; - _this._actionFrames = []; - _this._weightSlotPose = {}; - _this._weightBonePoses = {}; - _this._cacheBones = {}; - _this._slotChildActions = {}; - return _this; - } - ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "boolean") { - return value; - } - else if (type === "string") { - switch (value) { - case "0": - case "NaN": - case "": - case "false": - case "null": - case "undefined": - return false; - default: - return true; - } - } - else { - return !!value; - } - } - return defaultValue; - }; - ObjectDataParser._getNumber = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - if (value === null || value === "NaN") { - return defaultValue; - } - return +value || 0; - } - return defaultValue; - }; - ObjectDataParser._getString = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "string") { - return value; - } - return String(value); - } - return defaultValue; - }; - ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { - var l_t = 1.0 - t; - var powA = l_t * l_t; - var powB = t * t; - var kA = l_t * powA; - var kB = 3.0 * t * powA; - var kC = 3.0 * l_t * powB; - var kD = t * powB; - result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; - result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; - }; - ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { - var curveCount = curve.length; - if (curveCount % 3 === 1) { - var stepIndex = -2; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { - stepIndex += 6; - } - var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; - var x1 = isInCurve ? curve[stepIndex] : 0.0; - var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; - var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - return true; - } - else { - var stepIndex = 0; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while (curve[stepIndex + 6] < t) { - stepIndex += 6; - } - var x1 = curve[stepIndex]; - var y1 = curve[stepIndex + 1]; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = curve[stepIndex + 6]; - var y4 = curve[stepIndex + 7]; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - return false; - } - }; - ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { - if (dragonBones.DataParser.EVENT in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.SOUND in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); - } - if (dragonBones.DataParser.ACTION in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); - } - if (dragonBones.DataParser.EVENTS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); - } - }; - ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { - var actionOffset = this._armature.actions.length; - var actions = this._parseActionData(rawData, type, bone, slot); - var frameIndex = 0; - var frame = null; - for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { - var action = actions_2[_i]; - this._armature.addAction(action, false); - } - if (this._actionFrames.length === 0) { - frame = new ActionFrame(); - frame.frameStart = 0; - this._actionFrames.push(frame); - frame = null; - } - for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { - var eachFrame = _b[_a]; - if (eachFrame.frameStart === frameStart) { - frame = eachFrame; - break; - } - else if (eachFrame.frameStart > frameStart) { - break; - } - frameIndex++; - } - if (frame === null) { - frame = new ActionFrame(); - frame.frameStart = frameStart; - this._actionFrames.splice(frameIndex, 0, frame); - } - for (var i = 0; i < actions.length; ++i) { - frame.actions.push(actionOffset + i); - } - }; - ObjectDataParser.prototype._parseArmature = function (rawData, scale) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); - armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); - armature.scale = scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); - } - else { - armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); - } - if (armature.frameRate === 0) { - armature.frameRate = 24; - } - this._armature = armature; - if (dragonBones.DataParser.CANVAS in rawData) { - var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; - var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); - if (dragonBones.DataParser.COLOR in rawCanvas) { - canvas.hasBackground = true; - } - else { - canvas.hasBackground = false; - } - canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); - canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; - canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; - canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; - canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; - armature.canvas = canvas; - } - if (dragonBones.DataParser.AABB in rawData) { - var rawAABB = rawData[dragonBones.DataParser.AABB]; - armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; - armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; - armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; - armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; - } - if (dragonBones.DataParser.BONE in rawData) { - var rawBones = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { - var rawBone = rawBones_1[_i]; - var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); - var bone = this._parseBone(rawBone); - if (parentName.length > 0) { - var parent_1 = armature.getBone(parentName); - if (parent_1 !== null) { - bone.parent = parent_1; - } - else { - if (!(parentName in this._cacheBones)) { - this._cacheBones[parentName] = []; - } - this._cacheBones[parentName].push(bone); - } - } - if (bone.name in this._cacheBones) { - for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { - var child = _b[_a]; - child.parent = bone; - } - delete this._cacheBones[bone.name]; - } - armature.addBone(bone); - this._rawBones.push(bone); // Cache raw bones sort. - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawIKS = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { - var rawIK = rawIKS_1[_c]; - var constraint = this._parseIKConstraint(rawIK); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - armature.sortBones(); - if (dragonBones.DataParser.SLOT in rawData) { - var zOrder = 0; - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { - var rawSlot = rawSlots_1[_d]; - armature.addSlot(this._parseSlot(rawSlot, zOrder++)); - } - } - if (dragonBones.DataParser.SKIN in rawData) { - var rawSkins = rawData[dragonBones.DataParser.SKIN]; - for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { - var rawSkin = rawSkins_1[_e]; - armature.addSkin(this._parseSkin(rawSkin)); - } - } - if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { - var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; - for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { - var rawPath = rawPaths_1[_f]; - var constraint = this._parsePathConstraint(rawPath); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { - var rawData_1 = this._cacheRawMeshes[i]; - var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); - if (shareName.length === 0) { - continue; - } - var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - if (skinName.length === 0) { - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; - if (shareMesh === null) { - continue; // Error. - } - var mesh = this._cacheMeshes[i]; - mesh.geometry.shareFrom(shareMesh.geometry); - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; - for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { - var rawAnimation = rawAnimations_1[_g]; - var animation = this._parseAnimation(rawAnimation); - armature.addAnimation(animation); - } - } - if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); - for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { - var action = actions_3[_h]; - armature.addAction(action, true); - if (action.type === 0 /* Play */) { - var animation = armature.getAnimation(action.name); - if (animation !== null) { - armature.defaultAnimation = animation; - } - } - } - } - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { - var action = actions_4[_j]; - armature.addAction(action, false); - } - } - // Clear helper. - this._rawBones.length = 0; - this._cacheRawMeshes.length = 0; - this._cacheMeshes.length = 0; - this._armature = null; - for (var k in this._weightSlotPose) { - delete this._weightSlotPose[k]; - } - for (var k in this._weightBonePoses) { - delete this._weightBonePoses[k]; - } - for (var k in this._cacheBones) { - delete this._cacheBones[k]; - } - for (var k in this._slotChildActions) { - delete this._slotChildActions[k]; - } - return armature; - }; - ObjectDataParser.prototype._parseBone = function (rawData) { - var type = 0 /* Bone */; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); - } - if (type === 0 /* Bone */) { - var scale = this._armature.scale; - var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); - bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); - bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); - bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); - bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); - bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; - bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); - } - return bone; - } - var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); - surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); - surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); - this._parseGeometry(rawData, surface.geometry); - return surface; - }; - ObjectDataParser.prototype._parseIKConstraint = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); - if (bone === null) { - return null; - } - var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); - constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); - constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); - constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 0 /* IK */; - constraint.target = target; - if (chain > 0 && bone.parent !== null) { - constraint.root = bone.parent; - constraint.bone = bone; - } - else { - constraint.root = bone; - constraint.bone = null; - } - return constraint; - }; - ObjectDataParser.prototype._parsePathConstraint = function (rawData) { - var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var defaultSkin = this._armature.defaultSkin; - if (defaultSkin === null) { - return null; - } - //TODO - var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); - if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { - return null; - } - var bones = rawData[dragonBones.DataParser.BONES]; - if (bones === null || bones.length === 0) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 1 /* Path */; - constraint.pathSlot = target; - constraint.pathDisplayData = targetDisplay; - constraint.target = target.parent; - constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); - constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); - constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); - constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); - constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); - constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); - constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); - constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); - // - for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { - var boneName = bones_3[_i]; - var bone = this._armature.getBone(boneName); - if (bone !== null) { - constraint.AddBone(bone); - if (constraint.root === null) { - constraint.root = bone; - } - } - } - return constraint; - }; - ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - slot.zOrder = zOrder; - slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); - slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // - if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { - slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); - } - else { - slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); - } - if (dragonBones.DataParser.COLOR in rawData) { - slot.color = dragonBones.SlotData.createColor(); - this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - } - return slot; - }; - ObjectDataParser.prototype._parseSkin = function (rawData) { - var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); - skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (skin.name.length === 0) { - skin.name = dragonBones.DataParser.DEFAULT_NAME; - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - this._skin = skin; - for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { - var rawSlot = rawSlots_2[_i]; - var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); - var slot = this._armature.getSlot(slotName); - if (slot !== null) { - this._slot = slot; - if (dragonBones.DataParser.DISPLAY in rawSlot) { - var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; - for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { - var rawDisplay = rawDisplays_1[_a]; - if (rawDisplay) { - skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); - } - else { - skin.addDisplay(slotName, null); - } - } - } - this._slot = null; // - } - } - this._skin = null; // - } - return skin; - }; - ObjectDataParser.prototype._parseDisplay = function (rawData) { - var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); - var type = 0 /* Image */; - var display = null; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); - } - switch (type) { - case 0 /* Image */: { - var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); - imageDisplay.name = name; - imageDisplay.path = path.length > 0 ? path : name; - this._parsePivot(rawData, imageDisplay); - break; - } - case 1 /* Armature */: { - var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); - armatureDisplay.name = name; - armatureDisplay.path = path.length > 0 ? path : name; - armatureDisplay.inheritAnimation = true; - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { - var action = actions_5[_i]; - armatureDisplay.addAction(action); - } - } - else if (this._slot.name in this._slotChildActions) { - var displays = this._skin.getDisplays(this._slot.name); - if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { - for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { - var action = _b[_a]; - armatureDisplay.addAction(action); - } - delete this._slotChildActions[this._slot.name]; - } - } - break; - } - case 2 /* Mesh */: { - var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); - meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); - meshDisplay.name = name; - meshDisplay.path = path.length > 0 ? path : name; - if (dragonBones.DataParser.SHARE in rawData) { - meshDisplay.geometry.data = this._data; - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - else { - this._parseMesh(rawData, meshDisplay); - } - break; - } - case 3 /* BoundingBox */: { - var boundingBox = this._parseBoundingBox(rawData); - if (boundingBox !== null) { - var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); - boundingBoxDisplay.name = name; - boundingBoxDisplay.path = path.length > 0 ? path : name; - boundingBoxDisplay.boundingBox = boundingBox; - } - break; - } - case 4 /* Path */: { - var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; - var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); - pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); - pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); - pathDisplay.name = name; - pathDisplay.path = path.length > 0 ? path : name; - pathDisplay.curveLengths.length = rawCurveLengths.length; - for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { - pathDisplay.curveLengths[i] = rawCurveLengths[i]; - } - this._parsePath(rawData, pathDisplay); - break; - } - } - if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); - } - return display; - }; - ObjectDataParser.prototype._parsePath = function (rawData, display) { - this._parseGeometry(rawData, display.geometry); - }; - ObjectDataParser.prototype._parsePivot = function (rawData, display) { - if (dragonBones.DataParser.PIVOT in rawData) { - var rawPivot = rawData[dragonBones.DataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); - display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); - } - else { - display.pivot.x = 0.5; - display.pivot.y = 0.5; - } - }; - ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { - this._parseGeometry(rawData, mesh.geometry); - if (dragonBones.DataParser.WEIGHTS in rawData) { - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; - this._weightSlotPose[meshName] = rawSlotPose; - this._weightBonePoses[meshName] = rawBonePoses; - } - }; - ObjectDataParser.prototype._parseBoundingBox = function (rawData) { - var boundingBox = null; - var type = 0 /* Rectangle */; - if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { - type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); - } - switch (type) { - case 0 /* Rectangle */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); - break; - case 1 /* Ellipse */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); - break; - case 2 /* Polygon */: - boundingBox = this._parsePolygonBoundingBox(rawData); - break; - } - if (boundingBox !== null) { - boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); - if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { - boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); - boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); - } - } - return boundingBox; - }; - ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { - var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); - if (dragonBones.DataParser.VERTICES in rawData) { - var scale = this._armature.scale; - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertices = polygonBoundingBox.vertices; - vertices.length = rawVertices.length; - for (var i = 0, l = rawVertices.length; i < l; i += 2) { - var x = rawVertices[i] * scale; - var y = rawVertices[i + 1] * scale; - vertices[i] = x; - vertices[i + 1] = y; - // AABB. - if (i === 0) { - polygonBoundingBox.x = x; - polygonBoundingBox.y = y; - polygonBoundingBox.width = x; - polygonBoundingBox.height = y; - } - else { - if (x < polygonBoundingBox.x) { - polygonBoundingBox.x = x; - } - else if (x > polygonBoundingBox.width) { - polygonBoundingBox.width = x; - } - if (y < polygonBoundingBox.y) { - polygonBoundingBox.y = y; - } - else if (y > polygonBoundingBox.height) { - polygonBoundingBox.height = y; - } - } - } - polygonBoundingBox.width -= polygonBoundingBox.x; - polygonBoundingBox.height -= polygonBoundingBox.y; - } - else { - console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); - } - return polygonBoundingBox; - }; - ObjectDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.blendType = dragonBones.DataParser._getAnimationBlendType(ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); - animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); - animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - animation.frameIntOffset = this._frameIntArray.length; - animation.frameFloatOffset = this._frameFloatArray.length; - animation.frameOffset = this._frameArray.length; - this._animation = animation; - if (dragonBones.DataParser.FRAME in rawData) { - var rawFrames = rawData[dragonBones.DataParser.FRAME]; - var keyFrameCount = rawFrames.length; - if (keyFrameCount > 0) { - for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { - var rawFrame = rawFrames[i]; - this._parseActionDataInFrame(rawFrame, frameStart, null, null); - frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, 0 /* Step */, 0, this._parseZOrderFrame); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { - var rawTimeline = rawTimelines_1[_i]; - this._parseBoneTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SLOT]; - for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { - var rawTimeline = rawTimelines_2[_a]; - this._parseSlotTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.FFD in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.FFD]; - for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { - var rawTimeline = rawTimelines_3[_b]; - var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); - var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - if (skinName.length === 0) { - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - this._slot = this._armature.getSlot(slotName); - this._mesh = this._armature.getMesh(skinName, slotName, displayName); - if (this._slot === null || this._mesh === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, 2 /* Float */, 0, this._parseSlotDeformFrame); - if (timeline !== null) { - this._animation.addSlotTimeline(slotName, timeline); - } - this._slot = null; // - this._mesh = null; // - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { - var rawTimeline = rawTimelines_4[_c]; - var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var constraint = this._armature.getConstraint(constraintName); - if (constraint === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, 1 /* Int */, 2, this._parseIKConstraintFrame); - if (timeline !== null) { - this._animation.addConstraintTimeline(constraintName, timeline); - } - } - } - if (this._actionFrames.length > 0) { - this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, 0 /* Step */, 0, this._parseActionFrame); - this._actionFrames.length = 0; - } - if (dragonBones.DataParser.TIMELINE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { - var rawTimeline = rawTimelines_5[_d]; - var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); - var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = null; - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 20 /* SlotDisplay */: // TODO - case 23 /* SlotZIndex */: - case 60 /* BoneAlpha */: - case 24 /* SlotAlpha */: - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - if (timelineType === 20 /* SlotDisplay */) { - this._frameValueType = 0 /* Step */; - this._frameValueScale = 1.0; - } - else { - this._frameValueType = 1 /* Int */; - if (timelineType === 23 /* SlotZIndex */) { - this._frameValueScale = 1.0; - } - else if (timelineType === 40 /* AnimationProgress */ || - timelineType === 41 /* AnimationWeight */) { - this._frameValueScale = 10000.0; - } - else { - this._frameValueScale = 100.0; - } - } - if (timelineType === 60 /* BoneAlpha */ || - timelineType === 24 /* SlotAlpha */ || - timelineType === 41 /* AnimationWeight */) { - this._frameDefaultValue = 1.0; - } - else { - this._frameDefaultValue = 0.0; - } - if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); - var animaitonTimeline = timeline; - animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); - animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 1, this._parseSingleValueFrame, timeline); - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 30 /* IKConstraint */: - case 42 /* AnimationParameter */: - if (timelineType === 30 /* IKConstraint */ || - timelineType === 42 /* AnimationParameter */) { - this._frameValueType = 1 /* Int */; - if (timelineType === 42 /* AnimationParameter */) { - this._frameValueScale = 10000.0; - } - else { - this._frameValueScale = 100.0; - } - } - else { - if (timelineType === 12 /* BoneRotate */) { - this._frameValueScale = dragonBones.Transform.DEG_RAD; - } - else { - this._frameValueScale = 1.0; - } - this._frameValueType = 2 /* Float */; - } - if (timelineType === 13 /* BoneScale */ || - timelineType === 30 /* IKConstraint */) { - this._frameDefaultValue = 1.0; - } - else { - this._frameDefaultValue = 0.0; - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 2, this._parseDoubleValueFrame); - break; - case 1 /* ZOrder */: - // TODO - break; - case 50 /* Surface */: { - var surface = this._armature.getBone(timelineName); - if (surface === null) { - continue; - } - this._geometry = surface.geometry; - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); - this._geometry = null; // - break; - } - case 22 /* SlotDeform */: { - this._geometry = null; // - for (var skinName in this._armature.skins) { - var skin = this._armature.skins[skinName]; - for (var slontName in skin.displays) { - var displays = skin.displays[slontName]; - for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { - var display = displays_1[_e]; - if (display !== null && display.name === timelineName) { - this._geometry = display.geometry; - break; - } - } - } - } - if (this._geometry === null) { - continue; - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); - this._geometry = null; // - break; - } - case 21 /* SlotColor */: - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 1 /* Int */, 1, this._parseSlotColorFrame); - break; - } - if (timeline !== null) { - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 1 /* ZOrder */: - // TODO - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 50 /* Surface */: - case 60 /* BoneAlpha */: - this._animation.addBoneTimeline(timelineName, timeline); - break; - case 20 /* SlotDisplay */: - case 21 /* SlotColor */: - case 22 /* SlotDeform */: - case 23 /* SlotZIndex */: - case 24 /* SlotAlpha */: - this._animation.addSlotTimeline(timelineName, timeline); - break; - case 30 /* IKConstraint */: - this._animation.addConstraintTimeline(timelineName, timeline); - break; - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - case 42 /* AnimationParameter */: - this._animation.addAnimationTimeline(timelineName, timeline); - break; - } - } - } - } - this._animation = null; // - return animation; - }; - ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, timelineType, frameValueType, frameValueCount, frameParser, timeline) { - if (timeline === void 0) { timeline = null; } - if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { - rawFrames = rawData[framesKey]; - } - if (rawFrames === null) { - return null; - } - var keyFrameCount = rawFrames.length; - if (keyFrameCount === 0) { - return null; - } - var frameIntArrayLength = this._frameIntArray.length; - var frameFloatArrayLength = this._frameFloatArray.length; - var timelineOffset = this._timelineArray.length; - if (timeline === null) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - } - timeline.type = timelineType; - timeline.offset = timelineOffset; - this._frameValueType = frameValueType; - this._timeline = timeline; - this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; - if (rawData !== null) { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); - } - else { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; - } - this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; - this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; - switch (this._frameValueType) { - case 0 /* Step */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; - break; - case 1 /* Int */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; - break; - case 2 /* Float */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; - break; - } - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; - } - else { - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - var frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - var rawFrame = rawFrames[iK]; - frameStart = i; // frame.frameStart; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - if (rawFrame instanceof ActionFrame) { - frameCount = this._actionFrames[iK + 1].frameStart - frameStart; - } - else { - frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; - iK++; - } - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - this._timeline = null; // - return timeline; - }; - ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (bone === null) { - return; - } - this._bone = bone; - this._slot = this._armature.getSlot(this._bone.name); - if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { - this._frameDefaultValue = 0.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, 2 /* Float */, 2, this._parseDoubleValueFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.ROTATE_FRAME in rawData) { - this._frameDefaultValue = 0.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, 2 /* Float */, 2, this._parseBoneRotateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.SCALE_FRAME in rawData) { - this._frameDefaultValue = 1.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, 2 /* Float */, 2, this._parseBoneScaleFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, 2 /* Float */, 6, this._parseBoneAllFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - this._bone = null; // - this._slot = null; // - }; - ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { - var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (slot === null) { - return; - } - var displayTimeline = null; - var colorTimeline = null; - this._slot = slot; - if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); - } - else { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); - } - if (dragonBones.DataParser.COLOR_FRAME in rawData) { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); - } - else { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); - } - if (displayTimeline !== null) { - this._animation.addSlotTimeline(slot.name, displayTimeline); - } - if (colorTimeline !== null) { - this._animation.addSlotTimeline(slot.name, colorTimeline); - } - this._slot = null; // - }; - ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - rawData; - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - this._frameArray.length += 1; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - return frameOffset; - }; - ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (frameCount > 0) { - if (dragonBones.DataParser.CURVE in rawData) { - var sampleCount = frameCount + 1; - this._helpArray.length = sampleCount; - var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); - this._frameArray.length += 1 + 1 + this._helpArray.length; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited ? sampleCount : -sampleCount; - for (var i = 0; i < sampleCount; ++i) { - this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); - } - } - else { - var noTween = -2.0; - var tweenEasing = noTween; - if (dragonBones.DataParser.TWEEN_EASING in rawData) { - tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); - } - if (tweenEasing === noTween) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - else if (tweenEasing === 0.0) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; - } - else if (tweenEasing < 0.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); - } - else if (tweenEasing <= 1.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); - } - else { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); - } - } - } - else { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { - var frameOffset = 0; - switch (this._frameValueType) { - case 0: { - frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue); - break; - } - case 1: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale); - break; - } - case 2: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 1; - this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale; - break; - } - } - return frameOffset; - }; - ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { - var frameOffset = 0; - switch (this._frameValueType) { - case 0: { - frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 2; - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue); - this._frameArray[frameOffset + 2] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue); - break; - } - case 1: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale); - this._frameIntArray[frameValueOffset + 1] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale); - break; - } - case 2: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale; - this._frameFloatArray[frameValueOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale; - break; - } - } - return frameOffset; - }; - ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - var actionCount = frame.actions.length; - this._frameArray.length += 1 + 1 + actionCount; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. - for (var i = 0; i < actionCount; ++i) { - this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (dragonBones.DataParser.Z_ORDER in rawData) { - var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; - if (rawZOrder.length > 0) { - var slotCount = this._armature.sortedSlots.length; - var unchanged = new Array(slotCount - rawZOrder.length / 2); - var zOrders = new Array(slotCount); - for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { - unchanged[i_1] = 0; - } - for (var i_2 = 0; i_2 < slotCount; ++i_2) { - zOrders[i_2] = -1; - } - var originalIndex = 0; - var unchangedIndex = 0; - for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { - var slotIndex = rawZOrder[i_3]; - var zOrderOffset = rawZOrder[i_3 + 1]; - while (originalIndex !== slotIndex) { - unchanged[unchangedIndex++] = originalIndex++; - } - var index = originalIndex + zOrderOffset; - zOrders[index] = originalIndex++; - } - while (originalIndex < slotCount) { - unchanged[unchangedIndex++] = originalIndex++; - } - this._frameArray.length += 1 + slotCount; - this._frameArray[frameOffset + 1] = slotCount; - var i = slotCount; - while (i--) { - if (zOrders[i] === -1) { - this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; - } - else { - this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; - } - } - return frameOffset; - } - } - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = 0; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { - this._helpTransform.identity(); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); - } - // Modify rotation. - var rotation = this._helpTransform.rotation; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 6; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; - this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { - // Modify rotation. - var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - if (dragonBones.DataParser.VALUE in rawData) { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - } - else { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - } - this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var colorOffset = -1; - if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { - var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; - for (var k in rawColor) { - // tslint:disable-next-line:no-unused-expression - k; - this._parseColorTransform(rawColor, this._helpColorTransform); - colorOffset = this._colorArray.length; - this._colorArray.length += 8; - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); - colorOffset -= 8; - break; - } - } - if (colorOffset < 0) { - if (this._defaultColorOffset < 0) { - this._defaultColorOffset = colorOffset = this._colorArray.length; - this._colorArray.length += 8; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - } - colorOffset = this._defaultColorOffset; - } - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameIntOffset] = colorOffset; - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; - var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; - var weight = this._mesh.geometry.weight; - var x = 0.0; - var y = 0.0; - var iB = 0; - var iV = 0; - if (weight !== null) { - var rawSlotPose = this._weightSlotPose[meshName]; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - this._frameFloatArray.length += weight.count * 2; - iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; - } - else { - this._frameFloatArray.length += vertexCount * 2; - } - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices === null) { - x = 0.0; - y = 0.0; - } - else { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - if (weight !== null) { - var rawBonePoses = this._weightBonePoses[meshName]; - var vertexBoneCount = this._intArray[iB++]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var boneIndex = this._intArray[iB++]; - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; - } - } - else { - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { - var actions = new Array(); - if (typeof rawData === "string") { - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - action.type = type; - action.name = rawData; - action.bone = bone; - action.slot = slot; - actions.push(action); - } - else if (rawData instanceof Array) { - for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { - var rawAction = rawData_2[_i]; - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { - action.type = 0 /* Play */; - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); - } - else { - if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { - action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); - } - else { - action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); - } - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); - } - if (dragonBones.DataParser.BONE in rawAction) { - var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); - action.bone = this._armature.getBone(boneName); - } - else { - action.bone = bone; - } - if (dragonBones.DataParser.SLOT in rawAction) { - var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); - action.slot = this._armature.getSlot(slotName); - } - else { - action.slot = slot; - } - var userData = null; - if (dragonBones.DataParser.INTS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawInts = rawAction[dragonBones.DataParser.INTS]; - for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { - var rawValue = rawInts_1[_a]; - userData.addInt(rawValue); - } - } - if (dragonBones.DataParser.FLOATS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; - for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { - var rawValue = rawFloats_1[_b]; - userData.addFloat(rawValue); - } - } - if (dragonBones.DataParser.STRINGS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; - for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { - var rawValue = rawStrings_1[_c]; - userData.addString(rawValue); - } - } - action.data = userData; - actions.push(action); - } - } - return actions; - }; - ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? - rawData[dragonBones.DataParser.VERTICES] : - (dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null); - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; - var weight = this._geometry.weight; - var x = 0.0; - var y = 0.0; - if (weight !== null) { - // TODO - } - else { - this._frameFloatArray.length += vertexCount * 2; - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices !== null) { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - else { - x = 0.0; - y = 0.0; - } - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { - transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; - transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; - if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); - } - else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; - } - transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); - transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); - }; - ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { - color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; - color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; - color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; - color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); - color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); - color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); - color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); - }; - ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertexCount = Math.floor(rawVertices.length / 2); // uint - var triangleCount = 0; - var geometryOffset = this._intArray.length; - var verticesOffset = this._floatArray.length; - // - geometry.offset = geometryOffset; - geometry.data = this._data; - // - this._intArray.length += 1 + 1 + 1 + 1; - this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; - this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; - this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // - // - this._floatArray.length += vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[verticesOffset + i] = rawVertices[i]; - } - if (dragonBones.DataParser.TRIANGLES in rawData) { - var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; - triangleCount = Math.floor(rawTriangles.length / 3); // uint - // - this._intArray.length += triangleCount * 3; - for (var i = 0, l = triangleCount * 3; i < l; ++i) { - this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; - } - } - // Fill triangle count. - this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; - if (dragonBones.DataParser.UVS in rawData) { - var rawUVs = rawData[dragonBones.DataParser.UVS]; - var uvOffset = verticesOffset + vertexCount * 2; - this._floatArray.length += vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[uvOffset + i] = rawUVs[i]; - } - } - if (dragonBones.DataParser.WEIGHTS in rawData) { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var floatOffset = this._floatArray.length; - var weightBoneCount = 0; - var sortedBones = this._armature.sortedBones; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - if (dragonBones.DataParser.BONE_POSE in rawData) { - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var weightBoneIndices = new Array(); - weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint - weightBoneIndices.length = weightBoneCount; - for (var i = 0; i < weightBoneCount; ++i) { - var rawBoneIndex = rawBonePoses[i * 7]; // uint - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - weightBoneIndices[i] = rawBoneIndex; - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { - var iD = i * 2; - var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint - var x = this._floatArray[verticesOffset + iD]; - var y = this._floatArray[verticesOffset + iD + 1]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var rawBoneIndex = rawWeights[iW++]; // uint - var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint); - this._intArray[iB++] = boneIndex; - this._floatArray[iV++] = rawWeights[iW++]; - this._floatArray[iV++] = this._helpPoint.x; - this._floatArray[iV++] = this._helpPoint.y; - } - } - } - else { - var rawBones = rawData[dragonBones.DataParser.BONES]; - weightBoneCount = rawBones.length; - for (var i = 0; i < weightBoneCount; i++) { - var rawBoneIndex = rawBones[i]; - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { - var vertexBoneCount = rawWeights[iW++]; - this._intArray[iB++] = vertexBoneCount; - for (var j = 0; j < vertexBoneCount; j++) { - var boneIndex = rawWeights[iW++]; - var boneWeight = rawWeights[iW++]; - var x = rawVertices[iV++]; - var y = rawVertices[iV++]; - this._intArray[iB++] = rawBones.indexOf(boneIndex); - this._floatArray[iF++] = boneWeight; - this._floatArray[iF++] = x; - this._floatArray[iF++] = y; - } - } - } - geometry.weight = weight; - } - }; - ObjectDataParser.prototype._parseArray = function (rawData) { - // tslint:disable-next-line:no-unused-expression - rawData; - this._intArray.length = 0; - this._floatArray.length = 0; - this._frameIntArray.length = 0; - this._frameFloatArray.length = 0; - this._frameArray.length = 0; - this._timelineArray.length = 0; - this._colorArray.length = 0; - }; - ObjectDataParser.prototype._modifyArray = function () { - // Align. - if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._intArray.push(0); - } - if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameIntArray.push(0); - } - if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameArray.push(0); - } - if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { - this._timelineArray.push(0); - } - if ((this._timelineArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._colorArray.push(0); - } - var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; - var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; - var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; - var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; - var l7 = this._colorArray.length * Int16Array.BYTES_PER_ELEMENT; - var lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7; - // - var binary = new ArrayBuffer(lTotal); - var intArray = new Int16Array(binary, 0, this._intArray.length); - var floatArray = new Float32Array(binary, l1, this._floatArray.length); - var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - for (var i = 0, l = this._colorArray.length; i < l; ++i) { - colorArray[i] = this._colorArray[i]; - } - this._data.binary = binary; - this._data.intArray = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = frameArray; - this._data.timelineArray = timelineArray; - this._data.colorArray = colorArray; - this._defaultColorOffset = -1; - }; - ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined, "Data error."); - var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); - var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); - if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || - dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { - var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); - data.version = version; - data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); - if (data.frameRate === 0) { - data.frameRate = 24; - } - if (dragonBones.DataParser.ARMATURE in rawData) { - this._data = data; - this._parseArray(rawData); - var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; - for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { - var rawArmature = rawArmatures_1[_i]; - data.addArmature(this._parseArmature(rawArmature, scale)); - } - if (!this._data.binary) { - this._modifyArray(); - } - if (dragonBones.DataParser.STAGE in rawData) { - data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); - } - else if (data.armatureNames.length > 0) { - data.stage = data.getArmature(data.armatureNames[0]); - } - this._data = null; - } - if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { - this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; - } - return data; - } - else { - console.assert(false, "Nonsupport data version: " + version + "\n" + - "Please convert DragonBones data to support version.\n" + - "Read more: https://github.com/DragonBones/Tools/"); - } - return null; - }; - ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { - if (scale === void 0) { scale = 1.0; } - console.assert(rawData !== undefined); - if (rawData === null) { - if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { - return false; - } - var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; - this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); - if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { - this._rawTextureAtlasIndex = 0; - this._rawTextureAtlases = null; - } - return true; - } - // Texture format. - textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); - textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); - textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; - textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); - if (dragonBones.DataParser.SUB_TEXTURE in rawData) { - var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; - for (var i = 0, l = rawTextures.length; i < l; ++i) { - var rawTexture = rawTextures[i]; - var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); - var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); - var textureData = textureAtlasData.createTexture(); - textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); - textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); - textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); - textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); - textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); - textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); - if (frameWidth > 0.0 && frameHeight > 0.0) { - textureData.frame = dragonBones.TextureData.createRectangle(); - textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); - textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); - textureData.frame.width = frameWidth; - textureData.frame.height = frameHeight; - } - textureAtlasData.addTexture(textureData); - } - } - return true; - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - ObjectDataParser.getInstance = function () { - if (ObjectDataParser._objectDataParserInstance === null) { - ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); - } - return ObjectDataParser._objectDataParserInstance; - }; - ObjectDataParser._objectDataParserInstance = null; - return ObjectDataParser; - }(dragonBones.DataParser)); - dragonBones.ObjectDataParser = ObjectDataParser; - /** - * @private - */ - var ActionFrame = (function () { - function ActionFrame() { - this.frameStart = 0; - this.actions = []; - } - return ActionFrame; - }()); - dragonBones.ActionFrame = ActionFrame; -})(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 BinaryDataParser = (function (_super) { - __extends(BinaryDataParser, _super); - function BinaryDataParser() { - return _super !== null && _super.apply(this, arguments) || this; - } - BinaryDataParser.prototype._inRange = function (a, min, max) { - return min <= a && a <= max; - }; - BinaryDataParser.prototype._decodeUTF8 = function (data) { - var EOF_byte = -1; - var EOF_code_point = -1; - var FATAL_POINT = 0xFFFD; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte === EOF_byte) { - if (utf8_bytes_needed !== 0) { - code_point = FATAL_POINT; - } - else { - code_point = EOF_code_point; - } - } - else { - if (utf8_bytes_needed === 0) { - if (this._inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this._inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this._inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this._inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this._inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = _byte; - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = _byte; - } - } - } - } - //Decode string - if (code_point !== null && code_point !== EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { - if (timelineData === void 0) { timelineData = null; } - var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - timeline.type = type; - timeline.offset = offset; - this._timeline = timeline; - var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - } - else { - var frameIndicesOffset = 0; - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; - } - iK++; - } - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - this._timeline = null; // - return timeline; - }; - BinaryDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.blendType = dragonBones.DataParser._getAnimationBlendType(dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); - animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); - animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - // Offsets. - var offsets = rawData[dragonBones.DataParser.OFFSET]; - animation.frameIntOffset = offsets[0]; - animation.frameFloatOffset = offsets[1]; - animation.frameOffset = offsets[2]; - this._animation = animation; - if (dragonBones.DataParser.ACTION in rawData) { - animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.BONE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var bone = this._armature.getBone(k); - if (bone === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addBoneTimeline(bone.name, timeline); - } - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var slot = this._armature.getSlot(k); - if (slot === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSlotTimeline(slot.name, timeline); - } - } - } - if (dragonBones.DataParser.CONSTRAINT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var constraint = this._armature.getConstraint(k); - if (constraint === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addConstraintTimeline(constraint.name, timeline); - } - } - } - if (dragonBones.DataParser.TIMELINE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { - var rawTimeline = rawTimelines_6[_i]; - var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); - if (timelineOffset >= 0) { - var timelineType = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); - var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = null; - if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); - var animaitonTimeline = timeline; - animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); - animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); - } - timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 1 /* ZOrder */: - // TODO - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 50 /* Surface */: - case 60 /* BoneAlpha */: - this._animation.addBoneTimeline(timelineName, timeline); - break; - case 20 /* SlotDisplay */: - case 21 /* SlotColor */: - case 22 /* SlotDeform */: - case 23 /* SlotZIndex */: - case 24 /* SlotAlpha */: - this._animation.addSlotTimeline(timelineName, timeline); - break; - case 30 /* IKConstraint */: - this._animation.addConstraintTimeline(timelineName, timeline); - break; - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - case 42 /* AnimationParameter */: - this._animation.addAnimationTimeline(timelineName, timeline); - break; - } - } - } - } - this._animation = null; - return animation; - }; - BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { - geometry.offset = rawData[dragonBones.DataParser.OFFSET]; - geometry.data = this._data; - var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; - if (weightOffset >= 0) { - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; - var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; - weight.offset = weightOffset; - for (var i = 0; i < boneCount; ++i) { - var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; - weight.addBone(this._rawBones[boneIndex]); - } - var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; - var weightCount = 0; - for (var i = 0, l = vertexCount; i < l; ++i) { - var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; - weightCount += vertexBoneCount; - boneIndicesOffset += vertexBoneCount; - } - weight.count = weightCount; - geometry.weight = weight; - } - }; - BinaryDataParser.prototype._parseArray = function (rawData) { - var offsets = rawData[dragonBones.DataParser.OFFSET]; - var l1 = offsets[1]; - var l2 = offsets[3]; - var l3 = offsets[5]; - var l4 = offsets[7]; - var l5 = offsets[9]; - var l6 = offsets[11]; - var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. - var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); - var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); - var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); - var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); - var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); - var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); - var colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. - this._data.binary = this._binary; - this._data.intArray = this._intArrayBuffer = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = this._frameArrayBuffer = frameArray; - this._data.timelineArray = this._timelineArrayBuffer = timelineArray; - this._data.colorArray = colorArray; - }; - BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); - var tag = new Uint8Array(rawData, 0, 8); - if (tag[0] !== "D".charCodeAt(0) || - tag[1] !== "B".charCodeAt(0) || - tag[2] !== "D".charCodeAt(0) || - tag[3] !== "T".charCodeAt(0)) { - console.assert(false, "Nonsupport data."); - return null; - } - var headerLength = new Uint32Array(rawData, 8, 1)[0]; - var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); - var headerString = this._decodeUTF8(headerBytes); - var header = JSON.parse(headerString); - // - this._binaryOffset = 8 + 4 + headerLength; - this._binary = rawData; - return _super.prototype.parseDragonBonesData.call(this, header, scale); - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - BinaryDataParser.getInstance = function () { - if (BinaryDataParser._binaryDataParserInstance === null) { - BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); - } - return BinaryDataParser._binaryDataParserInstance; - }; - BinaryDataParser._binaryDataParserInstance = null; - return BinaryDataParser; - }(dragonBones.ObjectDataParser)); - dragonBones.BinaryDataParser = BinaryDataParser; -})(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) { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var BaseFactory = (function () { - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - function BaseFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - /** - * @private - */ - this.autoSearch = false; - this._dragonBonesDataMap = {}; - this._textureAtlasDataMap = {}; - this._dragonBones = null; - this._dataParser = null; - if (BaseFactory._objectParser === null) { - BaseFactory._objectParser = new dragonBones.ObjectDataParser(); - } - if (BaseFactory._binaryParser === null) { - BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); - } - this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; - } - BaseFactory.prototype._isSupportMesh = function () { - return true; - }; - BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { - if (textureAtlasName in this._textureAtlasDataMap) { - for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { - var textureAtlasData = _a[_i]; - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - if (this.autoSearch) { - for (var k in this._textureAtlasDataMap) { - for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { - var textureAtlasData = _c[_b]; - if (textureAtlasData.autoSearch) { - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - } - } - return null; - }; - BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { - var dragonBonesData = null; - var armatureData = null; - if (dragonBonesName.length > 0) { - if (dragonBonesName in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - armatureData = dragonBonesData.getArmature(armatureName); - } - } - if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { - for (var k in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[k]; - if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { - armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData !== null) { - dragonBonesName = k; - break; - } - } - } - } - if (armatureData !== null) { - dataPackage.dataName = dragonBonesName; - dataPackage.textureAtlasName = textureAtlasName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = null; - if (skinName.length > 0) { - dataPackage.skin = armatureData.getSkin(skinName); - if (dataPackage.skin === null && this.autoSearch) { - for (var k in this._dragonBonesDataMap) { - var skinDragonBonesData = this._dragonBonesDataMap[k]; - var skinArmatureData = skinDragonBonesData.getArmature(skinName); - if (skinArmatureData !== null) { - dataPackage.skin = skinArmatureData.defaultSkin; - break; - } - } - } - } - if (dataPackage.skin === null) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - return false; - }; - BaseFactory.prototype._buildBones = function (dataPackage, armature) { - for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { - var boneData = _a[_i]; - var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); - bone.init(boneData, armature); - } - }; - /** - * @private - */ - BaseFactory.prototype._buildSlots = function (dataPackage, armature) { - var currentSkin = dataPackage.skin; - var defaultSkin = dataPackage.armature.defaultSkin; - if (currentSkin === null || defaultSkin === null) { - return; - } - var skinSlots = {}; - for (var k in defaultSkin.displays) { - var displays = defaultSkin.getDisplays(k); - skinSlots[k] = displays; - } - if (currentSkin !== defaultSkin) { - for (var k in currentSkin.displays) { - var displays = currentSkin.getDisplays(k); - skinSlots[k] = displays; - } - } - for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { - var slotData = _a[_i]; - var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; - var slot = this._buildSlot(dataPackage, slotData, armature); - if (displayDatas !== null) { - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - slot.replaceRawDisplayData(displayData, i); - if (displayData !== null) { - if (dataPackage.textureAtlasName.length > 0) { - var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); - slot.replaceTextureData(textureData, i); - } - var display = this._getSlotDisplay(dataPackage, displayData, slot); - slot.replaceDisplay(display, i); - } - else { - slot.replaceDisplay(null); - } - } - } - slot._setDisplayIndex(slotData.displayIndex, true); - } - }; - BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { - var constraints = dataPackage.armature.constraints; - for (var k in constraints) { - var constraintData = constraints[k]; - // TODO more constraint type. - switch (constraintData.type) { - case 0 /* IK */: - var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - ikConstraint.init(constraintData, armature); - armature._addConstraint(ikConstraint); - break; - case 1 /* Path */: - var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); - pathConstraint.init(constraintData, armature); - armature._addConstraint(pathConstraint); - break; - default: - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - constraint.init(constraintData, armature); - armature._addConstraint(constraint); - break; - } - } - }; - BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { - return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); - }; - BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { - var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; - var display = null; - switch (displayData.type) { - case 0 /* Image */: { - var imageDisplayData = displayData; - if (imageDisplayData.texture === null) { - imageDisplayData.texture = this._getTextureData(dataName, displayData.path); - } - display = slot.rawDisplay; - break; - } - case 2 /* Mesh */: { - var meshDisplayData = displayData; - if (meshDisplayData.texture === null) { - meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); - } - if (this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 1 /* Armature */: { - var armatureDisplayData = displayData; - var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); - if (childArmature !== null) { - childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; - if (!childArmature.inheritAnimation) { - var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; - if (actions.length > 0) { - for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { - var action = actions_6[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); - eventObject.slot = slot; - slot.armature._bufferAction(eventObject, false); - } - } - else { - childArmature.animation.play(); - } - } - armatureDisplayData.armature = childArmature.armatureData; // - } - display = childArmature; - break; - } - case 3 /* BoundingBox */: - break; - default: - break; - } - return display; - }; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; - var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); - while (true) { - var textureAtlasData = this._buildTextureAtlasData(null, null); - if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { - this.addTextureAtlasData(textureAtlasData, name); - } - else { - textureAtlasData.returnToPool(); - break; - } - } - if (dragonBonesData !== null) { - this.addDragonBonesData(dragonBonesData, name); - } - return dragonBonesData; - }; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var textureAtlasData = this._buildTextureAtlasData(null, null); - this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); - this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); - this.addTextureAtlasData(textureAtlasData, name); - return textureAtlasData; - }; - /** - * - Update texture atlases. - * @param textureAtlases - The texture atlas objects. - * @param name - The texture atlas name. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 更新贴图集对象。 - * @param textureAtlases - 多个贴图集对象。 - * @param name - 贴图集名称。 - * @version DragonBones 5.7 - * @language zh_CN - */ - BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { - var textureAtlasDatas = this.getTextureAtlasData(name); - if (textureAtlasDatas !== null) { - for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { - if (i < textureAtlases.length) { - this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); - } - } - } - }; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getDragonBonesData = function (name) { - return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; - }; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addDragonBonesData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - if (name in this._dragonBonesDataMap) { - if (this._dragonBonesDataMap[name] === data) { - return; - } - console.warn("Can not add same name data: " + name); - return; - } - this._dragonBonesDataMap[name] = data; - }; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); - } - delete this._dragonBonesDataMap[name]; - } - }; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getTextureAtlasData = function (name) { - return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; - }; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addTextureAtlasData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); - if (textureAtlasList.indexOf(data) < 0) { - textureAtlasList.push(data); - } - }; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._textureAtlasDataMap) { - var textureAtlasDataList = this._textureAtlasDataMap[name]; - if (disposeData) { - for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { - var textureAtlasData = textureAtlasDataList_1[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[name]; - } - }; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { - return null; - } - return dataPackage.armature; - }; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.clear = function (disposeData) { - if (disposeData === void 0) { disposeData = true; } - for (var k in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); - } - delete this._dragonBonesDataMap[k]; - } - for (var k in this._textureAtlasDataMap) { - if (disposeData) { - var textureAtlasDataList = this._textureAtlasDataMap[k]; - for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { - var textureAtlasData = textureAtlasDataList_2[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[k]; - } - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { - console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); - return null; - } - var armature = this._buildArmature(dataPackage); - this._buildBones(dataPackage, armature); - this._buildSlots(dataPackage, armature); - this._buildConstraints(dataPackage, armature); - armature.invalidUpdate(null, true); - armature.advanceTime(0.0); // Update armature pose. - return armature; - }; - /** - * @private - */ - BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - displayIndex = slot.displayIndex; - } - if (displayIndex < 0) { - displayIndex = 0; - } - slot.replaceDisplayData(displayData, displayIndex); - if (displayData !== null) { - var display = this._getSlotDisplay(null, displayData, slot); - if (displayData.type === 0 /* Image */) { - var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; - if (rawDisplayData !== null && - rawDisplayData.type === 2 /* Mesh */) { - display = slot.meshDisplay; - } - } - slot.replaceDisplay(display, displayIndex); - } - else { - slot.replaceDisplay(null, displayIndex); - } - }; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (armatureData === null || armatureData.defaultSkin === null) { - return false; - } - var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); - this.replaceDisplay(slot, displayData, displayIndex); - return true; - }; - /** - * @private - */ - BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displayDatas = armatureData.defaultSkin.getDisplays(slotName); - if (!displayDatas) { - return false; - } - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - this.replaceDisplay(slot, displayData, i); - } - return true; - }; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { - if (isOverride === void 0) { isOverride = false; } - if (exclude === void 0) { exclude = null; } - var success = false; - var defaultSkin = skin.parent.defaultSkin; - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (exclude !== null && exclude.indexOf(slot.name) >= 0) { - continue; - } - var displayDatas = skin.getDisplays(slot.name); - if (displayDatas === null) { - if (defaultSkin !== null && skin !== defaultSkin) { - displayDatas = defaultSkin.getDisplays(slot.name); - } - if (displayDatas === null) { - if (isOverride) { - slot.displayFrameCount = 0; - } - continue; - } - } - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - slot.replaceRawDisplayData(displayData, i); - if (displayData !== null) { - slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); - } - else { - slot.replaceDisplay(null, i); - } - } - success = true; - } - return success; - }; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { - if (isOverride === void 0) { isOverride = true; } - var skinData = armatureData.defaultSkin; - if (skinData === null) { - return false; - } - if (isOverride) { - armature.animation.animations = armatureData.animations; - } - else { - var rawAnimations = armature.animation.animations; - var animations = {}; - for (var k in rawAnimations) { - animations[k] = rawAnimations[k]; - } - for (var k in armatureData.animations) { - animations[k] = armatureData.animations[k]; - } - armature.animation.animations = animations; - } - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var index = 0; - for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { - var display = _c[_b]; - if (display instanceof dragonBones.Armature) { - var displayDatas = skinData.getDisplays(slot.name); - if (displayDatas !== null && index < displayDatas.length) { - var displayData = displayDatas[index]; - if (displayData !== null && displayData.type === 1 /* Armature */) { - var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); - if (childArmatureData) { - this.replaceAnimation(display, childArmatureData, isOverride); - } - } - } - } - index++; - } - } - return true; - }; - /** - * @private - */ - BaseFactory.prototype.getAllDragonBonesData = function () { - return this._dragonBonesDataMap; - }; - /** - * @private - */ - BaseFactory.prototype.getAllTextureAtlasData = function () { - return this._textureAtlasDataMap; - }; - Object.defineProperty(BaseFactory.prototype, "clock", { - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - get: function () { - return this._dragonBones.clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseFactory.prototype, "dragonBones", { - /** - * @private - */ - get: function () { - return this._dragonBones; - }, - enumerable: true, - configurable: true - }); - BaseFactory._objectParser = null; - BaseFactory._binaryParser = null; - return BaseFactory; - }()); - dragonBones.BaseFactory = BaseFactory; - /** - * @private - */ - var BuildArmaturePackage = (function () { - function BuildArmaturePackage() { - this.dataName = ""; - this.textureAtlasName = ""; - this.skin = null; - } - return BuildArmaturePackage; - }()); - dragonBones.BuildArmaturePackage = BuildArmaturePackage; -})(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. - */ -if (CC_EDITOR) { - _Scene.Sandbox._globalsVerifier_loadPluginScript.ignoreNames['dragonBones'] = true; -} -var dragonBones; -(function (dragonBones) { - var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; - var DragonBonesAsset = (function (_super) { - __extends(DragonBonesAsset, _super); - function DragonBonesAsset() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.dragonBonesData = ""; - _this.textureAtlases = []; - _this.textures = []; - return _this; - } - __decorate([ - property - ], DragonBonesAsset.prototype, "dragonBonesData", void 0); - __decorate([ - property([cc.String]) - ], DragonBonesAsset.prototype, "textureAtlases", void 0); - __decorate([ - property([cc.Texture2D]) - ], DragonBonesAsset.prototype, "textures", void 0); - DragonBonesAsset = __decorate([ - ccclass("DragonBones.DragonBonesAsset") - ], DragonBonesAsset); - return DragonBonesAsset; - }(cc.Asset)); - dragonBones.DragonBonesAsset = DragonBonesAsset; -})(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 Cocos texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosTextureAtlasData = (function (_super) { - __extends(CocosTextureAtlasData, _super); - function CocosTextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._renderTexture = null; // Initial value. - return _this; - } - CocosTextureAtlasData.toString = function () { - return "[class dragonBones.CocosTextureAtlasData]"; - }; - CocosTextureAtlasData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this._renderTexture !== null) { - // this._renderTexture.dispose(); - } - this._renderTexture = null; - }; - CocosTextureAtlasData.prototype.createTexture = function () { - return dragonBones.BaseObject.borrowObject(CocosTextureData); - }; - Object.defineProperty(CocosTextureAtlasData.prototype, "renderTexture", { - /** - * - The Cocos texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._renderTexture; - }, - set: function (value) { - if (this._renderTexture === value) { - return; - } - this._renderTexture = value; - if (this._renderTexture !== null) { - for (var k in this.textures) { - var textureData = this.textures[k]; - if (textureData.renderTexture !== null) { - textureData.renderTexture.destroy(); - } - var reat = cc.rect(textureData.region.x, textureData.region.y, textureData.rotated ? textureData.region.height : textureData.region.width, textureData.rotated ? textureData.region.width : textureData.region.height); - var offset = cc.v2(); - var originSize = cc.size(reat.size.width, reat.size.height); - textureData.renderTexture = new cc.SpriteFrame(this._renderTexture, reat, textureData.rotated, offset, originSize); - } - } - else { - for (var k in this.textures) { - var textureData = this.textures[k]; - if (textureData.renderTexture !== null) { - textureData.renderTexture.destroy(); - } - textureData.renderTexture = null; - } - } - }, - enumerable: true, - configurable: true - }); - return CocosTextureAtlasData; - }(dragonBones.TextureAtlasData)); - dragonBones.CocosTextureAtlasData = CocosTextureAtlasData; - /** - * @internal - */ - var CocosTextureData = (function (_super) { - __extends(CocosTextureData, _super); - function CocosTextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.renderTexture = null; // Initial value. - return _this; - } - CocosTextureData.toString = function () { - return "[class dragonBones.CocosTextureData]"; - }; - CocosTextureData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.renderTexture !== null) { - this.renderTexture.destroy(); - } - this.renderTexture = null; - }; - return CocosTextureData; - }(dragonBones.TextureData)); - dragonBones.CocosTextureData = CocosTextureData; -})(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) { - // const _defaultItems = cc.Enum({ "None": -1 }); - // function _setItems(object: any, key: string, items: any) { - // (cc.Class as any).attr( // creator.d.ts error. - // object, - // key, - // { - // type: "Enum", - // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. - // } - // ); - // } - var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, executeInEditMode = _a.executeInEditMode, disallowMultiple = _a.disallowMultiple, playOnFocus = _a.playOnFocus, menu = _a.menu, help = _a.help; - /** - * @see dragonBones.IArmatureProxy - */ - var CocosArmatureComponent = (function (_super) { - __extends(CocosArmatureComponent, _super); - function CocosArmatureComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.debugDraw = false; - _this._debugDraw = false; - /** - * @internal - */ - _this._armature = null; - // Editor. - /** - * @internal - */ - _this._armatureName = ""; - /** - * @internal - */ - _this._animationName = ""; - // Visibie. - /** - * @internal - */ - _this._dragonBonesAsset = null; - /** - * @internal - */ - _this._armatureNames = []; - /** - * @internal - */ - _this._animationNames = []; - /** - * @internal - */ - _this._playTimes = -1; - /** - * @internal - */ - _this._timeScale = 1.0; - return _this; - } - CocosArmatureComponent.prototype.dbInit = function (armature) { - this._armature = armature; - }; - CocosArmatureComponent.prototype.dbClear = function () { - this._armature = null; - _super.prototype.destroy.call(this); - }; - CocosArmatureComponent.prototype.dbUpdate = function () { - var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; - if (drawed || this._debugDraw) { - this._debugDraw = drawed; - } - }; - CocosArmatureComponent.prototype.dispose = function (_isposeProxy) { - if (_isposeProxy === void 0) { _isposeProxy = true; } - if (this._armature !== null) { - this._armature.dispose(); - this._armature = null; - } - }; - CocosArmatureComponent.prototype.destroy = function () { - this.dispose(); - if (false) { - _super.prototype.destroy.call(this); - } - return true; - }; - /** - * @private - */ - CocosArmatureComponent.prototype.dispatchDBEvent = function (type, eventObject) { - var event = new cc.Event.EventCustom(type, false); - event.setUserData(eventObject); - this.node.dispatchEvent(event); - }; - CocosArmatureComponent.prototype.hasDBEventListener = function (type) { - return this.node.hasEventListener(type, false); // creator.d.ts error. - }; - CocosArmatureComponent.prototype.addDBEventListener = function (type, listener, target) { - this.node.on(type, listener, target); - }; - CocosArmatureComponent.prototype.removeDBEventListener = function (type, listener, target) { - this.node.off(type, listener, target); - }; - Object.defineProperty(CocosArmatureComponent.prototype, "armature", { - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CocosArmatureComponent.prototype, "animation", { - get: function () { - return this._armature.animation; - }, - enumerable: true, - configurable: true - }); - CocosArmatureComponent.prototype.start = function () { - }; - __decorate([ - property - ], CocosArmatureComponent.prototype, "_armatureName", void 0); - __decorate([ - property - ], CocosArmatureComponent.prototype, "_animationName", void 0); - __decorate([ - property({ - type: dragonBones.DragonBonesAsset, - displayName: "DragonBones", - tooltip: "DragonBones Asset", - visible: true, - }) - ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); - __decorate([ - property({ - type: [cc.String], - displayName: "Armature", - tooltip: "The armature name.", - visible: true, - editorOnly: true, - serializable: false, - }) - ], CocosArmatureComponent.prototype, "_armatureNames", void 0); - __decorate([ - property({ - type: [cc.String], - displayName: "Animation", - tooltip: "The animation name.", - visible: true, - editorOnly: true, - serializable: false, - }) - ], CocosArmatureComponent.prototype, "_animationNames", void 0); - __decorate([ - property({ - type: cc.Integer, - displayName: "Play times", - tooltip: "The animation play times.", - visible: true, - slide: true, - range: [-1, 99, 1], - }) - ], CocosArmatureComponent.prototype, "_playTimes", void 0); - __decorate([ - property({ - type: cc.Float, - displayName: "TimeScale", - tooltip: "The animation play speed.", - visible: true, - slide: true, - range: [-2, 2, 0.01], - }) - ], CocosArmatureComponent.prototype, "_timeScale", void 0); - CocosArmatureComponent = __decorate([ - ccclass("CocosArmatureComponent"), - executeInEditMode, - disallowMultiple, - playOnFocus, - menu("DragonBones/Armature"), - executeInEditMode, - help("https://github.com/DragonBones/") - ], CocosArmatureComponent); - return CocosArmatureComponent; - }(cc.Component)); - dragonBones.CocosArmatureComponent = CocosArmatureComponent; -})(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 Cocos slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosSlot = (function (_super) { - __extends(CocosSlot, _super); - function CocosSlot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._ccMeshDirty = false; - return _this; - } - CocosSlot.toString = function () { - return "[class dragonBones.CocosSlot]"; - }; - CocosSlot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._textureScale = 1.0; - this._renderDisplay = null; - }; - CocosSlot.prototype._initDisplay = function (_value, _isRetain) { - }; - CocosSlot.prototype._disposeDisplay = function (value, isRelease) { - if (!isRelease) { - value.destroy(); - } - }; - CocosSlot.prototype._onUpdateDisplay = function () { - this._renderDisplay = (this._display ? this._display : this._rawDisplay); - }; - CocosSlot.prototype._addDisplay = function () { - var container = this._armature.display; - container.addChild(this._renderDisplay, this._zOrder); - }; - CocosSlot.prototype._replaceDisplay = function (value) { - var container = this._armature.display; - var prevDisplay = value; - if (this._renderDisplay.parent !== container) { - container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder()); - } - // container.removeChild(prevDisplay, false); - this._renderDisplay.active = true; - prevDisplay.active = false; - this._textureScale = 1.0; - }; - CocosSlot.prototype._removeDisplay = function () { - this._renderDisplay.parent.removeChild(this._renderDisplay, false); - }; - CocosSlot.prototype._updateZOrder = function () { - if (this._renderDisplay.getLocalZOrder() === this._zOrder) { - return; - } - this._renderDisplay.setLocalZOrder(this._zOrder); - }; - /** - * @internal - */ - CocosSlot.prototype._updateVisible = function () { - this._renderDisplay.active = this._parent.visible && this._visible; - }; - CocosSlot.prototype._updateBlendMode = function () { - var sprite = this._renderDisplay.getComponent(cc.Sprite); - if (sprite) { - switch (this._blendMode) { - case 0 /* Normal */: - break; - case 1 /* Add */: - var texture = sprite.spriteFrame.getTexture(); - var BlendFunc = cc.BlendFunc; // creator.d.ts error. - if (texture && texture.hasPremultipliedAlpha()) { - sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.ONE, BlendFunc.BlendFactor.ONE); // creator.d.ts error. - } - else { - sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.SRC_ALPHA, BlendFunc.BlendFactor.ONE); // creator.d.ts error. - } - break; - case 3 /* Darken */: - break; - case 4 /* Difference */: - break; - case 6 /* HardLight */: - break; - case 9 /* Lighten */: - break; - case 10 /* Multiply */: - break; - case 11 /* Overlay */: - break; - case 12 /* Screen */: - break; - default: - break; - } - } - else if (this._childArmature !== null) { - for (var _i = 0, _a = this._childArmature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - slot._blendMode = this._blendMode; - slot._updateBlendMode(); - } - } - }; - CocosSlot.prototype._updateColor = function () { - var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha * 255; - var color = this._renderDisplay.color; - this._renderDisplay.opacity = alpha; - color.setR(this._colorTransform.redMultiplier * 0xFF); - color.setG(this._colorTransform.greenMultiplier * 0xFF); - color.setB(this._colorTransform.blueMultiplier * 0xFF); - this._renderDisplay.setColor(color); // creator.d.ts error. - }; - CocosSlot.prototype._updateFrame = function () { - var currentTextureData = this._textureData; - var sprite = this._renderDisplay.getComponent(cc.Sprite); - if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { - var currentTextureAtlasData = currentTextureData.parent; - if (this._armature.replacedTexture !== null) { - if (this._armature._replaceTextureAtlasData === null) { - currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); - currentTextureAtlasData.copyFrom(currentTextureData.parent); - currentTextureAtlasData.renderTexture = this._armature.replacedTexture; - this._armature._replaceTextureAtlasData = currentTextureAtlasData; - } - else { - currentTextureAtlasData = this._armature._replaceTextureAtlasData; - } - currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); - } - var renderTexture = currentTextureData.renderTexture; - if (renderTexture !== null) { - if (this._geometryData !== null) { - var data = this._geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; - var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; - var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - var uvOffset = vertexOffset + vertexCount * 2; - var scale = this._armature._armatureData.scale; - var textureAtlasSize = renderTexture.getTexture().getContentSizeInPixels(); - var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : textureAtlasSize.width; - var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : textureAtlasSize.height; - var region = currentTextureData.region; - var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); - var polygonInfo = { - triangles: { - verts: [], - indices: [] - }, - rect: boundsRect - }; - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var vertex = { - x: floatArray[vertexOffset + i] * scale, - y: -floatArray[vertexOffset + i + 1] * scale, - u: floatArray[uvOffset + i], - v: floatArray[uvOffset + i + 1] - }; - if (currentTextureData.rotated) { - var backU = vertex.u; - vertex.u = (region.x + (1.0 - vertex.v) * region.width) / textureAtlasWidth; - vertex.v = (region.y + backU * region.height) / textureAtlasHeight; - } - else { - vertex.u = (region.x + vertex.u * region.width) / textureAtlasWidth; - vertex.v = (region.y + vertex.v * region.height) / textureAtlasHeight; - } - polygonInfo.triangles.verts[i / 2] = vertex; - if (boundsRect.x > vertex.x) { - boundsRect.x = vertex.x; - } - if (boundsRect.width < vertex.x) { - boundsRect.width = vertex.x; - } - if (boundsRect.y > vertex.y) { - boundsRect.y = vertex.y; - } - if (boundsRect.height < vertex.y) { - boundsRect.height = vertex.y; - } - } - for (var i = 0; i < triangleCount * 3; ++i) { - polygonInfo.triangles.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; - } - this._textureScale = 1.0; - sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.MESH); // creator.d.ts error. - sprite.spriteFrame = renderTexture; - sprite._sgNode.setMeshPolygonInfo(polygonInfo); // creator.d.ts error. - sprite._sgNode.setContentSize(cc.size(boundsRect.width, boundsRect.height)); // creator.d.ts error. - var isSkinned = this._geometryData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (isSkinned || isSurface) { - this._identityTransform(); - } - // Delay to update cocos mesh. (some cocos bug.) - this._ccMeshDirty = true; - } - else { - this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; - sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. - sprite.spriteFrame = renderTexture; - sprite._sgNode.setContentSize(renderTexture.getOriginalSize()); // creator.d.ts error. - } - this._visibleDirty = true; - // this._blendModeDirty = true; - // this._colorDirty = true; - return; - } - } - this._renderDisplay.active = false; - this._renderDisplay.setPosition(0.0, 0.0); - }; - CocosSlot.prototype._updateMesh = function () { - var scale = this._armature._armatureData.scale; - var deformVertices = this._displayFrame.deformVertices; - var bones = this._geometryBones; - var geometryData = this._geometryData; - var weightData = geometryData.weight; - var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform; - var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite; - var polygonInfo = meshDisplay.getMeshPolygonInfo(); - if (!polygonInfo) { - return; - } - var verticesAndUVs = polygonInfo.triangles.verts; - var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); - if (weightData !== null) { - var data = geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; - if (weightFloatOffset < 0) { - weightFloatOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { - var boneCount = intArray[iB++]; - var xG = 0.0, yG = 0.0; - for (var j = 0; j < boneCount; ++j) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var xL = floatArray[iV++] * scale; - var yL = floatArray[iV++] * scale; - if (hasDeform) { - xL += deformVertices[iF++]; - yL += deformVertices[iF++]; - } - xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; - yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; - } - } - var vertex = verticesAndUVs[i]; - vertex.x = xG; - vertex.y = yG; - if (boundsRect.x > xG) { - boundsRect.x = xG; - } - if (boundsRect.width < xG) { - boundsRect.width = xG; - } - if (boundsRect.y > yG) { - boundsRect.y = yG; - } - if (boundsRect.height < yG) { - boundsRect.height = yG; - } - } - } - else { - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - var data = geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var iH = i / 2; // int. - var x = floatArray[vertexOffset + i] * scale; - var y = floatArray[vertexOffset + i + 1] * scale; - if (hasDeform) { - x += deformVertices[i]; - y += deformVertices[i + 1]; - } - var vertex = verticesAndUVs[iH]; - if (isSurface) { - var matrix = this._parent._getGlobalTransformMatrix(x, y); - vertex.x = matrix.a * x + matrix.c * y + matrix.tx; - vertex.y = matrix.b * x + matrix.d * y + matrix.ty; - // - x = vertex.x; - y = vertex.y; - } - else { - vertex.x = x; - y = vertex.y = -y; - } - if (boundsRect.x > x) { - boundsRect.x = x; - } - if (boundsRect.width < x) { - boundsRect.width = x; - } - if (boundsRect.y > y) { - boundsRect.y = y; - } - if (boundsRect.height < y) { - boundsRect.height = y; - } - } - } - boundsRect.width -= boundsRect.x; - boundsRect.height -= boundsRect.y; - polygonInfo.rect = boundsRect; - meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height)); - meshDisplay.setMeshPolygonInfo(polygonInfo); - if (weightData !== null) { - this._identityTransform(); - } - else { - var transform = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); - this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); - this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; - this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; - this._renderDisplay.scaleX = transform.scaleX * this._textureScale; - this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; - } - if (this._ccMeshDirty) { - this._ccMeshDirty = false; - this._verticesDirty = true; - } - }; - CocosSlot.prototype._updateTransform = function () { - // const globalTransformMatrix = this.globalTransformMatrix; - // const helpMatrix = TransformObject._helpMatrix; - // helpMatrix.a = globalTransformMatrix.a; - // helpMatrix.b = globalTransformMatrix.b; - // helpMatrix.c = -globalTransformMatrix.c; - // helpMatrix.d = -globalTransformMatrix.d; - // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { - // helpMatrix.tx = globalTransformMatrix.tx - (globalTransformMatrix.a * this._pivotX + globalTransformMatrix.c * this._pivotY); - // helpMatrix.ty = (globalTransformMatrix.ty - (globalTransformMatrix.b * this._pivotX + globalTransformMatrix.d * this._pivotY)); - // } - // else { - // helpMatrix.tx = globalTransformMatrix.tx; - // helpMatrix.ty = globalTransformMatrix.ty; - // } - // (this._renderDisplay as any)._sgNode._renderCmd.setNodeToParentTransform(helpMatrix); // creator.d.ts error. - this.updateGlobalTransform(); - var transform = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { - this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); - this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); - } - else { - this._renderDisplay.x = transform.x; - this._renderDisplay.y = transform.y; - } - this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; - this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; - this._renderDisplay.scaleX = transform.scaleX * this._textureScale; - this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; - }; - CocosSlot.prototype._identityTransform = function () { - // const helpMatrix = TransformObject._helpMatrix; - // helpMatrix.a = 1.0; - // helpMatrix.b = 0.0; - // helpMatrix.c = -0.0; - // helpMatrix.d = -1.0; - // helpMatrix.tx = 0.0; - // helpMatrix.ty = 0.0; - // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix); - this._renderDisplay.x = 0.0; - this._renderDisplay.y = 0.0; - this._renderDisplay.rotationX = 0.0; - this._renderDisplay.rotationY = 0.0; - this._renderDisplay.scaleX = 1.0; - this._renderDisplay.scaleY = 1.0; - }; - return CocosSlot; - }(dragonBones.Slot)); - dragonBones.CocosSlot = CocosSlot; -})(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) { - var ccclass = cc._decorator.ccclass; - var ClockHandler = (function (_super) { - __extends(ClockHandler, _super); - function ClockHandler() { - return _super !== null && _super.apply(this, arguments) || this; - } - ClockHandler.prototype.update = function (passedTime) { - CocosFactory.factory.dragonBones.advanceTime(passedTime); - }; - ClockHandler = __decorate([ - ccclass - ], ClockHandler); - return ClockHandler; - }(cc.Component)); - /** - * - The Cocos factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosFactory = (function (_super) { - __extends(CocosFactory, _super); - function CocosFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - var _this = _super.call(this, dataParser) || this; - _this._node = null; - _this._armatureNode = null; - if (!CC_EDITOR) { - if (_this._node === null) { - var nodeName = "DragonBones Node"; - _this._node = cc.find(nodeName); - if (_this._node === null) { - _this._node = new cc.Node(nodeName); - cc.game.addPersistRootNode(_this._node); - } - } - if (!_this._node.getComponent(ClockHandler)) { - _this._node.addComponent(ClockHandler); - } - var eventManager = _this._node.getComponent(dragonBones.CocosArmatureComponent) || _this._node.addComponent(dragonBones.CocosArmatureComponent); - if (CocosFactory._dragonBonesInstance === null) { - CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); - // - dragonBones.DragonBones.yDown = false; - } - } - else { - if (CocosFactory._dragonBonesInstance === null) { - CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(null); - // - dragonBones.DragonBones.yDown = false; - } - } - _this._dragonBones = CocosFactory._dragonBonesInstance; - return _this; - } - Object.defineProperty(CocosFactory, "factory", { - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - if (this._factory === null) { - this._factory = new CocosFactory(); - } - return this._factory; - }, - enumerable: true, - configurable: true - }); - CocosFactory.prototype._isSupportMesh = function () { - if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { - console.warn("Only webgl mode can support mesh."); - return false; - } - return true; - }; - CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { - if (textureAtlasData !== null) { - textureAtlasData.renderTexture = textureAtlas; - } - else { - textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); - } - return textureAtlasData; - }; - CocosFactory.prototype._buildArmature = function (dataPackage) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); - var armatureDisplay = this._armatureNode === null ? new cc.Node(dataPackage.armature.name) : this._armatureNode; - var armatureComponent = armatureDisplay.getComponent(dragonBones.CocosArmatureComponent) || armatureDisplay.addComponent(dragonBones.CocosArmatureComponent); - armatureDisplay.setOpacityModifyRGB(false); - armatureDisplay.setCascadeOpacityEnabled(true); - armatureDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. - this._armatureNode = null; - armatureComponent._armature = armature; - armature.init(dataPackage.armature, armatureComponent, armatureDisplay, this._dragonBones); - return armature; - }; - CocosFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { - var childDisplayName = slot.slotData.name + " (" + displayData.path.replace("/", "_") + ")"; // - var proxy = slot.armature.proxy; - var childNode = cc.find(childDisplayName, proxy.node); - var childArmature = null; - if (!childNode) { - if (dataPackage !== null) { - childArmature = this.buildArmature(displayData.path, dataPackage.dataName); - } - else { - childArmature = this.buildArmature(displayData.path, displayData.parent.parent.parent.name); - } - } - else { - var childArmatureComponent = childNode.getComponent(dragonBones.CocosArmatureComponent) || null; - if (childArmatureComponent === null) { - if (dataPackage !== null) { - childArmatureComponent = this.buildArmatureComponent(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage.textureAtlasName, childNode); - } - else { - childArmatureComponent = this.buildArmatureComponent(displayData.path, "", "", "", childNode); - } - } - if (childArmatureComponent !== null) { - childArmature = childArmatureComponent.armature; - } - } - if (childArmature === null) { - return null; - } - var childArmatureDisplay = childArmature.display; - childArmatureDisplay.name = childDisplayName; - if (childArmatureDisplay.parent !== proxy.node) { - proxy.node.addChild(childArmatureDisplay, slot._zOrder); - } - childArmatureDisplay.active = false; - return childArmature; - }; - CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.CocosSlot); - var armatureDisplay = armature.display; - var rawSlotDisplay = cc.find(slotData.name, armatureDisplay) || new cc.Node(slotData.name); - rawSlotDisplay.addComponent(cc.Sprite); - rawSlotDisplay.setAnchorPoint(0.0, 0.0); - rawSlotDisplay.setOpacityModifyRGB(false); - rawSlotDisplay.setCascadeOpacityEnabled(true); - rawSlotDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. - slot.init(slotData, armature, rawSlotDisplay, rawSlotDisplay); - return slot; - }; - /** - * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature component. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 - * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架组件。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - CocosFactory.prototype.buildArmatureComponent = function (armatureName, dragonBonesName, skinName, textureAtlasName, node) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - if (node === void 0) { node = null; } - this._armatureNode = node; - var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); - if (armature !== null) { - this._dragonBones.clock.add(armature); - return armature.proxy; - } - return null; - }; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { - if (textureAtlasName === void 0) { textureAtlasName = null; } - var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); - if (textureData !== null && textureData.renderTexture !== null) { - var texture = textureData.renderTexture; - var sprite = new cc.Sprite(); - sprite.spriteFrame = texture; - return sprite; - } - return null; - }; - Object.defineProperty(CocosFactory.prototype, "soundEventManager", { - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._dragonBones.eventManager.node; - }, - enumerable: true, - configurable: true - }); - CocosFactory._dragonBonesInstance = null; - CocosFactory._factory = null; - return CocosFactory; - }(dragonBones.BaseFactory)); - dragonBones.CocosFactory = CocosFactory; -})(dragonBones || (dragonBones = {})); +"use strict"; +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 __decorate = (this && this.__decorate) || function (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; +}; +/** + * 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("YuPeng 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.
+ * 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) 确定)以及宽度和高度定义的区域。
+ * 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, 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 armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var ArmatureData = /** @class */ (function (_super) { + __extends(ArmatureData, _super); + function ArmatureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.aabb = new dragonBones.Rectangle(); + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * @private + */ + _this.bones = {}; + /** + * @private + */ + _this.slots = {}; + /** + * @private + */ + _this.constraints = {}; + /** + * @private + */ + _this.skins = {}; + /** + * @private + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + ArmatureData.prototype._onClear = function () { + for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { + var action = _c[_b]; + action.returnToPool(); + } + for (var k in this.bones) { + this.bones[k].returnToPool(); + delete this.bones[k]; + } + for (var k in this.slots) { + this.slots[k].returnToPool(); + delete this.slots[k]; + } + for (var k in this.constraints) { + this.constraints[k].returnToPool(); + delete this.constraints[k]; + } + for (var k in this.skins) { + this.skins[k].returnToPool(); + delete this.skins[k]; + } + for (var k in this.animations) { + this.animations[k].returnToPool(); + delete this.animations[k]; + } + if (this.canvas !== null) { + this.canvas.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.type = 0 /* Armature */; + this.frameRate = 0; + this.cacheFrameRate = 0; + this.scale = 1.0; + this.name = ""; + this.aabb.clear(); + this.animationNames.length = 0; + this.sortedBones.length = 0; + this.sortedSlots.length = 0; + this.defaultActions.length = 0; + this.actions.length = 0; + // this.bones.clear(); + // this.slots.clear(); + // this.constraints.clear(); + // this.skins.clear(); + // this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @internal + */ + ArmatureData.prototype.sortBones = function () { + var total = this.sortedBones.length; + if (total <= 0) { + return; + } + var sortHelper = this.sortedBones.concat(); + var index = 0; + var count = 0; + this.sortedBones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this.sortedBones.indexOf(bone) >= 0) { + continue; + } + var flag = false; + for (var k in this.constraints) { // Wait constraint. + var constraint = this.constraints[k]; + if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @internal + */ + ArmatureData.prototype.cacheFrames = function (frameRate) { + if (this.cacheFrameRate > 0) { // TODO clear cache. + return; + } + this.cacheFrameRate = frameRate; + for (var k in this.animations) { + this.animations[k].cacheFrames(this.cacheFrameRate); + } + }; + /** + * @internal + */ + ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { + var dataArray = this.parent.cachedFrames; + var arrayOffset = dataArray.length; + dataArray.length += 10; + dataArray[arrayOffset] = globalTransformMatrix.a; + dataArray[arrayOffset + 1] = globalTransformMatrix.b; + dataArray[arrayOffset + 2] = globalTransformMatrix.c; + dataArray[arrayOffset + 3] = globalTransformMatrix.d; + dataArray[arrayOffset + 4] = globalTransformMatrix.tx; + dataArray[arrayOffset + 5] = globalTransformMatrix.ty; + dataArray[arrayOffset + 6] = transform.rotation; + dataArray[arrayOffset + 7] = transform.skew; + dataArray[arrayOffset + 8] = transform.scaleX; + dataArray[arrayOffset + 9] = transform.scaleY; + return arrayOffset; + }; + /** + * @internal + */ + ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { + var dataArray = this.parent.cachedFrames; + globalTransformMatrix.a = dataArray[arrayOffset]; + globalTransformMatrix.b = dataArray[arrayOffset + 1]; + globalTransformMatrix.c = dataArray[arrayOffset + 2]; + globalTransformMatrix.d = dataArray[arrayOffset + 3]; + globalTransformMatrix.tx = dataArray[arrayOffset + 4]; + globalTransformMatrix.ty = dataArray[arrayOffset + 5]; + transform.rotation = dataArray[arrayOffset + 6]; + transform.skew = dataArray[arrayOffset + 7]; + transform.scaleX = dataArray[arrayOffset + 8]; + transform.scaleY = dataArray[arrayOffset + 9]; + transform.x = globalTransformMatrix.tx; + transform.y = globalTransformMatrix.ty; + }; + /** + * @internal + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Same bone: " + value.name); + return; + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @internal + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Same slot: " + value.name); + return; + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @internal + */ + ArmatureData.prototype.addConstraint = function (value) { + if (value.name in this.constraints) { + console.warn("Same constraint: " + value.name); + return; + } + this.constraints[value.name] = value; + }; + /** + * @internal + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Same skin: " + value.name); + return; + } + value.parent = this; + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + if (value.name === "default") { + this.defaultSkin = value; + } + }; + /** + * @internal + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Same animation: " + value.name); + return; + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * @internal + */ + ArmatureData.prototype.addAction = function (value, isDefault) { + if (isDefault) { + this.defaultActions.push(value); + } + else { + this.actions.push(value); + } + }; + /** + * - Get a specific done data. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (boneName) { + return boneName in this.bones ? this.bones[boneName] : null; + }; + /** + * - Get a specific slot data. + * @param slotName - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param slotName - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (slotName) { + return slotName in this.slots ? this.slots[slotName] : null; + }; + /** + * @private + */ + ArmatureData.prototype.getConstraint = function (constraintName) { + return constraintName in this.constraints ? this.constraints[constraintName] : null; + }; + /** + * - Get a specific skin data. + * @param skinName - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param skinName - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (skinName) { + return skinName in this.skins ? this.skins[skinName] : null; + }; + /** + * @private + */ + ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { + var skin = this.getSkin(skinName); + if (skin === null) { + return null; + } + return skin.getDisplay(slotName, meshName); + }; + /** + * - Get a specific animation data. + * @param animationName - The animation animationName. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param animationName - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (animationName) { + return animationName in this.animations ? this.animations[animationName] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var BoneData = /** @class */ (function (_super) { + __extends(BoneData, _super); + function BoneData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.transform = new dragonBones.Transform(); + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + BoneData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.type = 0 /* Bone */; + this.length = 0.0; + this.alpha = 1.0; + this.name = ""; + this.transform.identity(); + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * @internal + */ + var SurfaceData = /** @class */ (function (_super) { + __extends(SurfaceData, _super); + function SurfaceData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new dragonBones.GeometryData(); + return _this; + } + SurfaceData.toString = function () { + return "[class dragonBones.SurfaceData]"; + }; + SurfaceData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Surface */; + this.segmentX = 0; + this.segmentY = 0; + this.geometry.clear(); + }; + return SurfaceData; + }(BoneData)); + dragonBones.SurfaceData = SurfaceData; + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var SlotData = /** @class */ (function (_super) { + __extends(SlotData, _super); + function SlotData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.color = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @internal + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.zIndex = 0; + this.alpha = 1.0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @internal + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; +})(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 CanvasData = /** @class */ (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + CanvasData.prototype._onClear = function () { + this.hasBackground = false; + this.color = 0x000000; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + }; + return CanvasData; + }(dragonBones.BaseObject)); + dragonBones.CanvasData = CanvasData; +})(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 skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var SkinData = /** @class */ (function (_super) { + __extends(SkinData, _super); + function SkinData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.displays = {}; + return _this; + } + SkinData.toString = function () { + return "[class dragonBones.SkinData]"; + }; + SkinData.prototype._onClear = function () { + for (var k in this.displays) { + var slotDisplays = this.displays[k]; + for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { + var display = slotDisplays_1[_i]; + if (display !== null) { + display.returnToPool(); + } + } + delete this.displays[k]; + } + this.name = ""; + // this.displays.clear(); + this.parent = null; // + }; + /** + * @internal + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + if (value !== null) { + value.parent = this; + } + var slotDisplays = this.displays[slotName]; // TODO clear prev + slotDisplays.push(value); + }; + /** + * @private + */ + SkinData.prototype.getDisplay = function (slotName, displayName) { + var slotDisplays = this.getDisplays(slotName); + if (slotDisplays !== null) { + for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { + var display = slotDisplays_2[_i]; + if (display !== null && display.name === displayName) { + return display; + } + } + } + return null; + }; + /** + * @private + */ + SkinData.prototype.getDisplays = function (slotName) { + if (!(slotName in this.displays)) { + return null; + } + return this.displays[slotName]; + }; + return SkinData; + }(dragonBones.BaseObject)); + dragonBones.SkinData = SkinData; +})(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 ConstraintData = /** @class */ (function (_super) { + __extends(ConstraintData, _super); + function ConstraintData() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConstraintData.prototype._onClear = function () { + this.order = 0; + this.name = ""; + this.type = 0 /* IK */; + this.target = null; // + this.root = null; // + this.bone = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @internal + */ + var IKConstraintData = /** @class */ (function (_super) { + __extends(IKConstraintData, _super); + function IKConstraintData() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraintData.toString = function () { + return "[class dragonBones.IKConstraintData]"; + }; + IKConstraintData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.scaleEnabled = false; + this.bendPositive = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; + /** + * @internal + */ + var PathConstraintData = /** @class */ (function (_super) { + __extends(PathConstraintData, _super); + function PathConstraintData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + PathConstraintData.toString = function () { + return "[class dragonBones.PathConstraintData]"; + }; + PathConstraintData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.pathSlot = null; + this.pathDisplayData = null; + this.bones.length = 0; + this.positionMode = 0 /* Fixed */; + this.spacingMode = 1 /* Fixed */; + this.rotateMode = 1 /* Chain */; + this.position = 0.0; + this.spacing = 0.0; + this.rotateOffset = 0.0; + this.rotateMix = 0.0; + this.translateMix = 0.0; + }; + PathConstraintData.prototype.AddBone = function (value) { + this.bones.push(value); + }; + return PathConstraintData; + }(ConstraintData)); + dragonBones.PathConstraintData = PathConstraintData; +})(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 GeometryData = /** @class */ (function () { + function GeometryData() { + this.weight = null; // Initial value. + } + GeometryData.prototype.clear = function () { + if (!this.isShared && this.weight !== null) { + this.weight.returnToPool(); + } + this.isShared = false; + this.inheritDeform = false; + this.offset = 0; + this.data = null; + this.weight = null; + }; + GeometryData.prototype.shareFrom = function (value) { + this.isShared = true; + this.offset = value.offset; + this.weight = value.weight; + }; + Object.defineProperty(GeometryData.prototype, "vertexCount", { + get: function () { + var intArray = this.data.intArray; + return intArray[this.offset + 0 /* GeometryVertexCount */]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GeometryData.prototype, "triangleCount", { + get: function () { + var intArray = this.data.intArray; + return intArray[this.offset + 1 /* GeometryTriangleCount */]; + }, + enumerable: true, + configurable: true + }); + return GeometryData; + }()); + dragonBones.GeometryData = GeometryData; + /** + * @private + */ + var DisplayData = /** @class */ (function (_super) { + __extends(DisplayData, _super); + function DisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.transform = new dragonBones.Transform(); + return _this; + } + DisplayData.prototype._onClear = function () { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null; // + }; + return DisplayData; + }(dragonBones.BaseObject)); + dragonBones.DisplayData = DisplayData; + /** + * @private + */ + var ImageDisplayData = /** @class */ (function (_super) { + __extends(ImageDisplayData, _super); + function ImageDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.pivot = new dragonBones.Point(); + return _this; + } + ImageDisplayData.toString = function () { + return "[class dragonBones.ImageDisplayData]"; + }; + ImageDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Image */; + this.pivot.clear(); + this.texture = null; + }; + return ImageDisplayData; + }(DisplayData)); + dragonBones.ImageDisplayData = ImageDisplayData; + /** + * @private + */ + var ArmatureDisplayData = /** @class */ (function (_super) { + __extends(ArmatureDisplayData, _super); + function ArmatureDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.actions = []; + return _this; + } + ArmatureDisplayData.toString = function () { + return "[class dragonBones.ArmatureDisplayData]"; + }; + ArmatureDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + this.type = 1 /* Armature */; + this.inheritAnimation = false; + this.actions.length = 0; + this.armature = null; + }; + /** + * @private + */ + ArmatureDisplayData.prototype.addAction = function (value) { + this.actions.push(value); + }; + return ArmatureDisplayData; + }(DisplayData)); + dragonBones.ArmatureDisplayData = ArmatureDisplayData; + /** + * @private + */ + var MeshDisplayData = /** @class */ (function (_super) { + __extends(MeshDisplayData, _super); + function MeshDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new GeometryData(); + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 2 /* Mesh */; + this.geometry.clear(); + this.texture = null; + }; + return MeshDisplayData; + }(DisplayData)); + dragonBones.MeshDisplayData = MeshDisplayData; + /** + * @private + */ + var BoundingBoxDisplayData = /** @class */ (function (_super) { + __extends(BoundingBoxDisplayData, _super); + function BoundingBoxDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.boundingBox = null; // Initial value. + return _this; + } + BoundingBoxDisplayData.toString = function () { + return "[class dragonBones.BoundingBoxDisplayData]"; + }; + BoundingBoxDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.boundingBox !== null) { + this.boundingBox.returnToPool(); + } + this.type = 3 /* BoundingBox */; + this.boundingBox = null; + }; + return BoundingBoxDisplayData; + }(DisplayData)); + dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; + /** + * @private + */ + var PathDisplayData = /** @class */ (function (_super) { + __extends(PathDisplayData, _super); + function PathDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new GeometryData(); + _this.curveLengths = []; + return _this; + } + PathDisplayData.toString = function () { + return "[class dragonBones.PathDisplayData]"; + }; + PathDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 4 /* Path */; + this.closed = false; + this.constantSpeed = false; + this.geometry.clear(); + this.curveLengths.length = 0; + }; + return PathDisplayData; + }(DisplayData)); + dragonBones.PathDisplayData = PathDisplayData; + /** + * @private + */ + var WeightData = /** @class */ (function (_super) { + __extends(WeightData, _super); + function WeightData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + WeightData.toString = function () { + return "[class dragonBones.WeightData]"; + }; + WeightData.prototype._onClear = function () { + this.count = 0; + this.offset = 0; + this.bones.length = 0; + }; + WeightData.prototype.addBone = function (value) { + this.bones.push(value); + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(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 base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + var BoundingBoxData = /** @class */ (function (_super) { + __extends(BoundingBoxData, _super); + function BoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = /** @class */ (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + RectangleBoundingBoxData.toString = function () { + return "[class dragonBones.RectangleBoundingBoxData]"; + }; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { + var code = 0 /* InSide */; // initialised as being inside of [[clip window]] + if (x < xMin) { // to the left of clip window + code |= 1 /* Left */; + } + else if (x > xMax) { // to the right of clip window + code |= 2 /* Right */; + } + if (y < yMin) { // below the clip window + code |= 4 /* Top */; + } + else if (y > yMax) { // above the clip window + code |= 8 /* Bottom */; + } + return code; + }; + /** + * @private + */ + RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; + var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; + if (inSideA && inSideB) { + return -1; + } + var intersectionCount = 0; + var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + while (true) { + if ((outcode0 | outcode1) === 0) { // Bitwise OR is 0. Trivially accept and get out of loop + intersectionCount = 2; + break; + } + else if ((outcode0 & outcode1) !== 0) { // Bitwise AND is not 0. Trivially reject and get out of loop + break; + } + // failed both tests, so calculate the line segment to clip + // from an outside point to an intersection with clip edge + var x = 0.0; + var y = 0.0; + var normalRadian = 0.0; + // At least one endpoint is outside the clip rectangle; pick it. + var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; + // Now find the intersection point; + if ((outcodeOut & 4 /* Top */) !== 0) { // point is above the clip rectangle + x = xA + (xB - xA) * (yMin - yA) / (yB - yA); + y = yMin; + if (normalRadians !== null) { + normalRadian = -Math.PI * 0.5; + } + } + else if ((outcodeOut & 8 /* Bottom */) !== 0) { // point is below the clip rectangle + x = xA + (xB - xA) * (yMax - yA) / (yB - yA); + y = yMax; + if (normalRadians !== null) { + normalRadian = Math.PI * 0.5; + } + } + else if ((outcodeOut & 2 /* Right */) !== 0) { // point is to the right of clip rectangle + y = yA + (yB - yA) * (xMax - xA) / (xB - xA); + x = xMax; + if (normalRadians !== null) { + normalRadian = 0; + } + } + else if ((outcodeOut & 1 /* Left */) !== 0) { // point is to the left of clip rectangle + y = yA + (yB - yA) * (xMin - xA) / (xB - xA); + x = xMin; + if (normalRadians !== null) { + normalRadian = Math.PI; + } + } + // Now we move outside point to intersection point to clip + // and get ready for next pass. + if (outcodeOut === outcode0) { + xA = x; + yA = y; + outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + if (normalRadians !== null) { + normalRadians.x = normalRadian; + } + } + else { + xB = x; + yB = y; + outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + if (normalRadians !== null) { + normalRadians.y = normalRadian; + } + } + } + if (intersectionCount) { + if (inSideA) { + intersectionCount = 2; // 10 + if (intersectionPointA !== null) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = xB; + } + if (normalRadians !== null) { + normalRadians.x = normalRadians.y + Math.PI; + } + } + else if (inSideB) { + intersectionCount = 1; // 01 + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (normalRadians !== null) { + normalRadians.y = normalRadians.x + Math.PI; + } + } + else { + intersectionCount = 3; // 11 + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + } + } + return intersectionCount; + }; + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inheritDoc + */ + RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + var heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + return true; + } + } + return false; + }; + /** + * @inheritDoc + */ + RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var widthH = this.width * 0.5; + var heightH = this.height * 0.5; + var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return RectangleBoundingBoxData; + }(BoundingBoxData)); + dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = /** @class */ (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + EllipseBoundingBoxData.toString = function () { + return "[class dragonBones.EllipseData]"; + }; + /** + * @private + */ + EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var d = widthH / heightH; + var dd = d * d; + yA *= d; + yB *= d; + var dX = xB - xA; + var dY = yB - yA; + var lAB = Math.sqrt(dX * dX + dY * dY); + var xD = dX / lAB; + var yD = dY / lAB; + var a = (xC - xA) * xD + (yC - yA) * yD; + var aa = a * a; + var ee = xA * xA + yA * yA; + var rr = widthH * widthH; + var dR = rr - ee + aa; + var intersectionCount = 0; + if (dR >= 0.0) { + var dT = Math.sqrt(dR); + var sA = a - dT; + var sB = a + dT; + var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); + var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); + var sideAB = inSideA * inSideB; + if (sideAB < 0) { + return -1; + } + else if (sideAB === 0) { + if (inSideA === -1) { + intersectionCount = 2; // 10 + xB = xA + sB * xD; + yB = (yA + sB * yD) / d; + if (intersectionPointA !== null) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } + else if (inSideB === 1) { + intersectionCount = 1; // 01 + xA = xA + sA * xD; + yA = (yA + sA * yD) / d; + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } + else { + intersectionCount = 3; // 11 + if (intersectionPointA !== null) { + intersectionPointA.x = xA + sA * xD; + intersectionPointA.y = (yA + sA * yD) / d; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); + } + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA + sB * xD; + intersectionPointB.y = (yA + sB * yD) / d; + if (normalRadians !== null) { + normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); + } + } + } + } + } + return intersectionCount; + }; + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inheritDoc + */ + EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + var heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + pY *= widthH / heightH; + return Math.sqrt(pX * pX + pY * pY) <= widthH; + } + } + return false; + }; + /** + * @inheritDoc + */ + EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return EllipseBoundingBoxData; + }(BoundingBoxData)); + dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var PolygonBoundingBoxData = /** @class */ (function (_super) { + __extends(PolygonBoundingBoxData, _super); + function PolygonBoundingBoxData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + _this.vertices = []; + return _this; + } + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + if (xA === xB) { + xA = xB + 0.000001; + } + if (yA === yB) { + yA = yB + 0.000001; + } + var count = vertices.length; + var dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[count - 2]; + var yC = vertices[count - 1]; + var dMin = 0.0; + var dMax = 0.0; + var xMin = 0.0; + var yMin = 0.0; + var xMax = 0.0; + var yMax = 0.0; + for (var i = 0; i < count; i += 2) { + var xD = vertices[i]; + var yD = vertices[i + 1]; + if (xC === xD) { + xC = xD + 0.0001; + } + if (yC === yD) { + yC = yD + 0.0001; + } + var dXCD = xC - xD; + var dYCD = yC - yD; + var llCD = xC * yD - yC * xD; + var ll = dXAB * dYCD - dYAB * dXCD; + var x = (llAB * dXCD - dXAB * llCD) / ll; + if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { + var y = (llAB * dYCD - dYAB * llCD) / ll; + if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { + if (intersectionPointB !== null) { + var d = x - xA; + if (d < 0.0) { + d = -d; + } + if (intersectionCount === 0) { + dMin = d; + dMax = d; + xMin = x; + yMin = y; + xMax = x; + yMax = y; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = normalRadians.x; + } + } + else { + if (d < dMin) { + dMin = d; + xMin = x; + yMin = y; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + } + } + if (d > dMax) { + dMax = d; + xMax = x; + yMax = y; + if (normalRadians !== null) { + normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + } + } + } + intersectionCount++; + } + else { + xMin = x; + yMin = y; + xMax = x; + yMax = y; + intersectionCount++; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = normalRadians.x; + } + break; + } + } + } + xC = xD; + yC = yD; + } + if (intersectionCount === 1) { + if (intersectionPointA !== null) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xMin; + intersectionPointB.y = yMin; + } + if (normalRadians !== null) { + normalRadians.y = normalRadians.x + Math.PI; + } + } + else if (intersectionCount > 1) { + intersectionCount++; + if (intersectionPointA !== null) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xMax; + intersectionPointB.y = yMax; + } + } + return intersectionCount; + }; + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 2 /* Polygon */; + this.x = 0.0; + this.y = 0.0; + this.vertices.length = 0; + }; + /** + * @inheritDoc + */ + PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var isInSide = false; + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { + for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[iP + 1]; + var yB = this.vertices[i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[iP]; + var xB = this.vertices[i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inheritDoc + */ + PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var intersectionCount = 0; + if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(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 animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var AnimationData = /** @class */ (function (_super) { + __extends(AnimationData, _super); + function AnimationData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.cachedFrames = []; + /** + * @private + */ + _this.boneTimelines = {}; + /** + * @private + */ + _this.slotTimelines = {}; + /** + * @private + */ + _this.constraintTimelines = {}; + /** + * @private + */ + _this.animationTimelines = {}; + /** + * @private + */ + _this.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var _b = 0, _c = this.slotTimelines[k]; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + delete this.slotTimelines[k]; + } + for (var k in this.constraintTimelines) { + for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + delete this.constraintTimelines[k]; + } + for (var k in this.animationTimelines) { + for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + delete this.animationTimelines[k]; + } + for (var k in this.boneCachedFrameIndices) { + delete this.boneCachedFrameIndices[k]; + } + for (var k in this.slotCachedFrameIndices) { + delete this.slotCachedFrameIndices[k]; + } + if (this.actionTimeline !== null) { + this.actionTimeline.returnToPool(); + } + if (this.zOrderTimeline !== null) { + this.zOrderTimeline.returnToPool(); + } + this.frameIntOffset = 0; + this.frameFloatOffset = 0; + this.frameOffset = 0; + this.blendType = 0 /* None */; + this.frameCount = 0; + this.playTimes = 0; + this.duration = 0.0; + this.scale = 1.0; + this.fadeInTime = 0.0; + this.cacheFrameRate = 0.0; + this.name = ""; + this.cachedFrames.length = 0; + // this.boneTimelines.clear(); + // this.slotTimelines.clear(); + // this.constraintTimelines.clear(); + // this.animationTimelines.clear(); + // this.boneCachedFrameIndices.clear(); + // this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @internal + */ + AnimationData.prototype.cacheFrames = function (frameRate) { + if (this.cacheFrameRate > 0.0) { // TODO clear cache. + return; + } + this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); + var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. + this.cachedFrames.length = cacheFrameCount; + for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { + this.cachedFrames[i] = false; + } + for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { + var bone = _a[_i]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + this.boneCachedFrameIndices[bone.name] = indices; + } + for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { + var slot = _c[_b]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + this.slotCachedFrameIndices[slot.name] = indices; + } + }; + /** + * @private + */ + AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : (this.constraintTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (timelineName) { + return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimelines = function (timelineName) { + return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getConstraintTimelines = function (timelineName) { + return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getAnimationTimelines = function (timelineName) { + return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { + return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { + return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; + }; + return AnimationData; + }(dragonBones.BaseObject)); + dragonBones.AnimationData = AnimationData; + /** + * @private + */ + var TimelineData = /** @class */ (function (_super) { + __extends(TimelineData, _super); + function TimelineData() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineData.toString = function () { + return "[class dragonBones.TimelineData]"; + }; + TimelineData.prototype._onClear = function () { + this.type = 10 /* BoneAll */; + this.offset = 0; + this.frameIndicesOffset = -1; + }; + return TimelineData; + }(dragonBones.BaseObject)); + dragonBones.TimelineData = TimelineData; + /** + * @internal + */ + var AnimationTimelineData = /** @class */ (function (_super) { + __extends(AnimationTimelineData, _super); + function AnimationTimelineData() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationTimelineData.toString = function () { + return "[class dragonBones.AnimationTimelineData]"; + }; + AnimationTimelineData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.x = 0.0; + this.y = 0.0; + }; + return AnimationTimelineData; + }(TimelineData)); + dragonBones.AnimationTimelineData = AnimationTimelineData; +})(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 animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + var AnimationConfig = /** @class */ (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additive = false; + this.displayControl = true; + this.pauseFadeIn = true; + this.resetToPose = true; + this.fadeInTweenType = 1 /* Line */; + this.playTimes = -1; + this.layer = 0; + this.position = 0.0; + this.duration = -1.0; + this.timeScale = -100.0; + this.weight = 1.0; + this.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + /** + * @private + */ + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + /** + * @private + */ + AnimationConfig.prototype.copyFrom = function (value) { + this.pauseFadeOut = value.pauseFadeOut; + this.fadeOutMode = value.fadeOutMode; + this.autoFadeOutTime = value.autoFadeOutTime; + this.fadeOutTweenType = value.fadeOutTweenType; + this.actionEnabled = value.actionEnabled; + this.additive = value.additive; + this.displayControl = value.displayControl; + this.pauseFadeIn = value.pauseFadeIn; + this.resetToPose = value.resetToPose; + this.playTimes = value.playTimes; + this.layer = value.layer; + this.position = value.position; + this.duration = value.duration; + this.timeScale = value.timeScale; + this.fadeInTime = value.fadeInTime; + this.fadeOutTime = value.fadeOutTime; + this.fadeInTweenType = value.fadeInTweenType; + this.weight = value.weight; + this.name = value.name; + this.animation = value.animation; + this.group = value.group; + this.boneMask.length = value.boneMask.length; + for (var i = 0, l = this.boneMask.length; i < l; ++i) { + this.boneMask[i] = value.boneMask[i]; + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(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 texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var TextureAtlasData = /** @class */ (function (_super) { + __extends(TextureAtlasData, _super); + function TextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.textures = {}; + return _this; + } + TextureAtlasData.prototype._onClear = function () { + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + this.autoSearch = false; + this.width = 0; + this.height = 0; + this.scale = 1.0; + // this.textures.clear(); + this.name = ""; + this.imagePath = ""; + }; + /** + * @private + */ + TextureAtlasData.prototype.copyFrom = function (value) { + this.autoSearch = value.autoSearch; + this.scale = value.scale; + this.width = value.width; + this.height = value.height; + this.name = value.name; + this.imagePath = value.imagePath; + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + // this.textures.clear(); + for (var k in value.textures) { + var texture = this.createTexture(); + texture.copyFrom(value.textures[k]); + this.textures[k] = texture; + } + }; + /** + * @internal + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Same texture: " + value.name); + return; + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (textureName) { + return textureName in this.textures ? this.textures[textureName] : null; + }; + return TextureAtlasData; + }(dragonBones.BaseObject)); + dragonBones.TextureAtlasData = TextureAtlasData; + /** + * @private + */ + var TextureData = /** @class */ (function (_super) { + __extends(TextureData, _super); + function TextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.region = new dragonBones.Rectangle(); + _this.frame = null; // Initial value. + return _this; + } + TextureData.createRectangle = function () { + return new dragonBones.Rectangle(); + }; + TextureData.prototype._onClear = function () { + this.rotated = false; + this.name = ""; + this.region.clear(); + this.parent = null; // + this.frame = null; + }; + TextureData.prototype.copyFrom = function (value) { + this.rotated = value.rotated; + this.name = value.name; + this.region.copyFrom(value.region); + this.parent = value.parent; + if (this.frame === null && value.frame !== null) { + this.frame = TextureData.createRectangle(); + } + else if (this.frame !== null && value.frame === null) { + this.frame = null; + } + if (this.frame !== null && value.frame !== null) { + this.frame.copyFrom(value.frame); + } + }; + return TextureData; + }(dragonBones.BaseObject)); + dragonBones.TextureData = TextureData; +})(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_1) { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + var Armature = /** @class */ (function (_super) { + __extends(Armature, _super); + function Armature() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._bones = []; + _this._slots = []; + /** + * @internal + */ + _this._constraints = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @internal + */ + _this._replaceTextureAtlasData = null; // Initial value. + _this._clock = null; // Initial value. + return _this; + } + Armature.toString = function () { + return "[class dragonBones.Armature]"; + }; + Armature._onSortSlots = function (a, b) { + return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; + }; + Armature.prototype._onClear = function () { + if (this._clock !== null) { // Remove clock first. + this._clock.remove(this); + } + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone.returnToPool(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot.returnToPool(); + } + for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { + var constraint = _e[_d]; + constraint.returnToPool(); + } + for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { + var action = _g[_f]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.dbClear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.userData = null; + this._lockUpdate = false; + this._slotsDirty = true; + this._zOrderDirty = false; + this._zIndexDirty = false; + this._alphaDirty = true; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._alpha = 1.0; + this._globalAlpha = 1.0; + this._bones.length = 0; + this._slots.length = 0; + this._constraints.length = 0; + this._actions.length = 0; + this._armatureData = null; // + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + /** + * @internal + */ + Armature.prototype._sortZOrder = function (slotIndices, offset) { + var slotDatas = this._armatureData.sortedSlots; + var isOriginal = slotIndices === null; + if (this._zOrderDirty || !isOriginal) { + for (var i = 0, l = slotDatas.length; i < l; ++i) { + var slotIndex = isOriginal ? i : slotIndices[offset + i]; + if (slotIndex < 0 || slotIndex >= l) { + continue; + } + var slotData = slotDatas[slotIndex]; + var slot = this.getSlot(slotData.name); + if (slot !== null) { + slot._setZOrder(i); + } + } + this._slotsDirty = true; + this._zOrderDirty = !isOriginal; + } + }; + /** + * @internal + */ + Armature.prototype._addBone = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bones.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._addSlot = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slots.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._addConstraint = function (value) { + if (this._constraints.indexOf(value) < 0) { + this._constraints.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this._armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @internal + */ + Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { + if (this._armatureData !== null) { + return; + } + this._armatureData = armatureData; + this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); + this._proxy = proxy; + this._display = display; + this._dragonBones = dragonBones; + this._proxy.dbInit(this); + this._animation.init(this); + this._animation.animations = this._armatureData.animations; + }; + /** + * @inheritDoc + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + this._lockUpdate = true; + if (this._armatureData === null) { + console.warn("The armature has been disposed."); + return; + } + else if (this._armatureData.parent === null) { + console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update animation. + this._animation.advanceTime(passedTime); + // Sort slots. + if (this._slotsDirty || this._zIndexDirty) { + this._slots.sort(Armature._onSortSlots); + if (this._zIndexDirty) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i]._setZOrder(i); // + } + } + this._slotsDirty = false; + this._zIndexDirty = false; + } + // Update alpha. + if (this._alphaDirty) { + this._alphaDirty = false; + this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone._updateAlpha(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot._updateAlpha(); + } + } + // Update bones and slots. + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { + var i = 0, l = 0; + for (i = 0, l = this._bones.length; i < l; ++i) { + this._bones[i].update(this._cacheFrameIndex); + } + for (i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].update(this._cacheFrameIndex); + } + } + // Do actions. + if (this._actions.length > 0) { + for (var _d = 0, _e = this._actions; _d < _e.length; _d++) { + var action = _e[_d]; + var actionData = action.actionData; + if (actionData !== null) { + if (actionData.type === 0 /* Play */) { + if (action.slot !== null) { + var childArmature = action.slot.childArmature; + if (childArmature !== null) { + childArmature.animation.fadeIn(actionData.name); + } + } + else if (action.bone !== null) { + for (var _f = 0, _g = this.getSlots(); _f < _g.length; _f++) { + var slot = _g[_f]; + if (slot.parent === action.bone) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.animation.fadeIn(actionData.name); + } + } + } + } + else { + this._animation.fadeIn(actionData.name); + } + } + } + action.returnToPool(); + } + this._actions.length = 0; + } + this._lockUpdate = false; + this._proxy.dbUpdate(); + }; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlot) { + if (boneName === void 0) { boneName = null; } + if (updateSlot === void 0) { updateSlot = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlot) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === bone) { + slot.invalidUpdate(); + } + } + } + } + } + else { + for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { + var bone = _c[_b]; + bone.invalidUpdate(); + } + if (updateSlot) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Armature.prototype.containsPoint = function (x, y) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.containsPoint(x, y)) { + return slot; + } + } + return null; + }; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var isV = xA === xB; + var dMin = 0.0; + var dMax = 0.0; + var intXA = 0.0; + var intYA = 0.0; + var intXB = 0.0; + var intYB = 0.0; + var intAN = 0.0; + var intBN = 0.0; + var intSlotA = null; + var intSlotB = null; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionPointA !== null || intersectionPointB !== null) { + if (intersectionPointA !== null) { + var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; + if (d < 0.0) { + d = -d; + } + if (intSlotA === null || d < dMin) { + dMin = d; + intXA = intersectionPointA.x; + intYA = intersectionPointA.y; + intSlotA = slot; + if (normalRadians) { + intAN = normalRadians.x; + } + } + } + if (intersectionPointB !== null) { + var d = intersectionPointB.x - xA; + if (d < 0.0) { + d = -d; + } + if (intSlotB === null || d > dMax) { + dMax = d; + intXB = intersectionPointB.x; + intYB = intersectionPointB.y; + intSlotB = slot; + if (normalRadians !== null) { + intBN = normalRadians.y; + } + } + } + } + else { + intSlotA = slot; + break; + } + } + } + if (intSlotA !== null && intersectionPointA !== null) { + intersectionPointA.x = intXA; + intersectionPointA.y = intYA; + if (normalRadians !== null) { + normalRadians.x = intAN; + } + } + if (intSlotB !== null && intersectionPointB !== null) { + intersectionPointB.x = intXB; + intersectionPointB.y = intYB; + if (normalRadians !== null) { + normalRadians.y = intBN; + } + } + return intSlotA; + }; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBone = function (name) { + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.name === name) { + return bone; + } + } + return null; + }; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBoneByDisplay = function (display) { + var slot = this.getSlotByDisplay(display); + return slot !== null ? slot.parent : null; + }; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlot = function (name) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.name === name) { + return slot; + } + } + return null; + }; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlotByDisplay = function (display) { + if (display !== null) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.display === display) { + return slot; + } + } + } + return null; + }; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + get: function () { + return this._flipX; + }, + set: function (value) { + if (this._flipX === value) { + return; + } + this._flipX = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "flipY", { + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + get: function () { + return this._flipY; + }, + set: function (value) { + if (this._flipY === value) { + return; + } + this._flipY = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "cacheFrameRate", { + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+             *     armature.cacheFrameRate = 24;
+             * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+             *     armature.cacheFrameRate = 24;
+             * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._armatureData.cacheFrameRate; + }, + set: function (value) { + if (this._armatureData.cacheFrameRate !== value) { + this._armatureData.cacheFrames(value); + // Set child armature frameRate. + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.cacheFrameRate = value; + } + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "name", { + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "armatureData", { + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._armatureData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "proxy", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "eventDispatcher", { + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @private + */ + get: function () { + return this._replacedTexture; + }, + set: function (value) { + if (this._replacedTexture === value) { + return; + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + this._replacedTexture = value; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + slot.invalidUpdate(); + slot.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + if (this._clock !== null) { + this._clock.remove(this); + } + this._clock = value; + if (this._clock) { + this._clock.add(this); + } + // Update childArmature clock. + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.clock = this._clock; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "parent", { + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(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 base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + var TransformObject = /** @class */ (function (_super) { + __extends(TransformObject, _super); + function TransformObject() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + */ + TransformObject.prototype._onClear = function () { + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; + this.userData = null; + this._globalDirty = false; + this._alpha = 1.0; + this._globalAlpha = 1.0; + this._armature = null; // + }; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + TransformObject._helpMatrix = new dragonBones.Matrix(); + TransformObject._helpTransform = new dragonBones.Transform(); + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(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) { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + var Bone = /** @class */ (function (_super) { + __extends(Bone, _super); + function Bone() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @internal + */ + _this.animationPose = new dragonBones.Transform(); + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this._transformDirty = false; + this._childrenTransformDirty = false; + this._localDirty = true; + this._hasConstraint = false; + this._visible = true; + this._cachedFrameIndex = -1; + this._boneData = null; // + this._parent = null; // + this._cachedFrameIndices = null; + }; + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + // For typescript. + var boneData = this._boneData; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var origin = this.origin; + var offset = this.offset; + var animationPose = this.animationPose; + var parent = this._parent; // + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var inherit = parent !== null; + var rotation = 0.0; + if (this.offsetMode === 1 /* Additive */) { + if (origin !== null) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = origin.x + offset.x + animationPose.x; + global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; + global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; + if (dragonBones.DragonBones.yDown) { + global.y = origin.y + offset.y + animationPose.y; + global.skew = origin.skew + offset.skew + animationPose.skew; + global.rotation = origin.rotation + offset.rotation + animationPose.rotation; + } + else { + global.y = origin.y - offset.y + animationPose.y; + global.skew = origin.skew - offset.skew + animationPose.skew; + global.rotation = origin.rotation - offset.rotation + animationPose.rotation; + } + } + else { + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + global.add(animationPose); + } + } + else if (this.offsetMode === 0 /* None */) { + if (origin !== null) { + global.copyFrom(origin).add(animationPose); + } + else { + global.copyFrom(animationPose); + } + } + else { + inherit = false; + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + } + if (inherit) { + var isSurface = parent._boneData.type === 1 /* Surface */; + var surfaceBone = isSurface ? parent._bone : null; + var parentMatrix = isSurface ? parent._getGlobalTransformMatrix(global.x, global.y) : parent.globalTransformMatrix; + if (boneData.inheritScale && (!isSurface || surfaceBone !== null)) { + if (isSurface) { + if (boneData.inheritRotation) { + global.rotation += parent.global.rotation; + } + surfaceBone.updateGlobalTransform(); + global.scaleX *= surfaceBone.global.scaleX; + global.scaleY *= surfaceBone.global.scaleY; + parentMatrix.transformPoint(global.x, global.y, global); + global.toMatrix(globalTransformMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } + else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + } + else { + if (!boneData.inheritRotation) { + parent.updateGlobalTransform(); + if (flipX && flipY) { + rotation = global.rotation - (parent.global.rotation + Math.PI); + } + else if (flipX) { + rotation = global.rotation + parent.global.rotation + Math.PI; + } + else if (flipY) { + rotation = global.rotation + parent.global.rotation; + } + else { + rotation = global.rotation - parent.global.rotation; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } + else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + if (isCache) { + global.fromMatrix(globalTransformMatrix); + } + else { + this._globalDirty = true; + } + } + } + else { + if (boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (boneData.inheritRotation) { + parent.updateGlobalTransform(); + if (parent.global.scaleX < 0.0) { + rotation = global.rotation + parent.global.rotation + Math.PI; + } + else { + rotation = global.rotation + parent.global.rotation; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + rotation -= global.rotation * 2.0; + if (flipX !== flipY || boneData.inheritReflection) { + global.skew += Math.PI; + } + if (!dragonBones.DragonBones.yDown) { + global.skew = -global.skew; + } + } + global.rotation = rotation; + } + else if (flipX || flipY) { + if (flipX && flipY) { + rotation = global.rotation + Math.PI; + } + else { + if (flipX) { + rotation = Math.PI - global.rotation; + } + else { + rotation = -global.rotation; + } + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + rotation = global.rotation + Math.PI; + } + else { + if (flipX) { + rotation = Math.PI - global.rotation; + } + else { + rotation = -global.rotation; + } + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + */ + Bone.prototype._updateAlpha = function () { + if (this._parent !== null) { + this._globalAlpha = this._alpha * this._parent._globalAlpha; + } + else { + this._globalAlpha = this._alpha * this._armature._globalAlpha; + } + }; + /** + * @internal + */ + Bone.prototype.init = function (boneData, armatureValue) { + if (this._boneData !== null) { + return; + } + this._boneData = boneData; + this._armature = armatureValue; + this._alpha = this._boneData.alpha; + if (this._boneData.parent !== null) { + this._parent = this._armature.getBone(this._boneData.parent.name); + } + this._armature._addBone(this); + // + this.origin = this._boneData.transform; + }; + /** + * @internal + */ + Bone.prototype.update = function (cacheFrameIndex) { + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + // + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + // + } + else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + this._localDirty = true; + }; + /** + * @internal + */ + Bone.prototype.updateByConstraint = function () { + if (this._localDirty) { + this._localDirty = false; + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { + this._updateGlobalTransformMatrix(true); + } + this._transformDirty = true; + } + }; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * - Check whether the bone contains a specific bone. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (value) { + if (value === this) { + return false; + } + var ancestor = value; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + Object.defineProperty(Bone.prototype, "boneData", { + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._boneData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "visible", { + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible === value) { + return; + } + this._visible = value; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + slot._updateVisible(); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "name", { + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._boneData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "parent", { + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(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) { + /** + * @internal + */ + var Surface = /** @class */ (function (_super) { + __extends(Surface, _super); + function Surface() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._vertices = []; + _this._deformVertices = []; + /** + * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + _this._hullCache = []; + /** + * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + _this._matrixCahce = []; + return _this; + } + Surface.toString = function () { + return "[class dragonBones.Surface]"; + }; + Surface.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._dX = 0.0; + this._dY = 0.0; + this._k = 0.0; + this._kX = 0.0; + this._kY = 0.0; + this._vertices.length = 0; + this._deformVertices.length = 0; + this._matrixCahce.length = 0; + this._hullCache.length = 0; + this._bone = null; + }; + Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { + var dabX = bX - aX; + var dabY = bY - aY; + var dacX = cX - aX; + var dacY = cY - aY; + transform.rotation = Math.atan2(dabY, dabX); + transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; + if (isDown) { + transform.rotation += Math.PI; + } + transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; + transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; + transform.toMatrix(matrix); + transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); + transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); + }; + Surface.prototype._updateVertices = function () { + var data = this._armature.armatureData.parent; + var geometry = this._boneData.geometry; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; + var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; + var vertices = this._vertices; + var animationVertices = this._deformVertices; + if (this._parent !== null) { + if (this._parent._boneData.type === 1 /* Surface */) { + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + var x = floatArray[verticesOffset + iD] + animationVertices[iD]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + var matrix = this._parent._getGlobalTransformMatrix(x, y); + // + vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; + vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty; + } + } + else { + var parentMatrix = this._parent.globalTransformMatrix; + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + var x = floatArray[verticesOffset + iD] + animationVertices[iD]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + // + vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + } + } + else { + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; + vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + } + } + }; + Surface.prototype._updateGlobalTransformMatrix = function (isCache) { + // tslint:disable-next-line:no-unused-expression + isCache; + var segmentXD = this._boneData.segmentX * 2; + var lastIndex = this._vertices.length - 2; + var lA = 200.0; + // + var raX = this._vertices[0]; + var raY = this._vertices[1]; + var rbX = this._vertices[segmentXD]; + var rbY = this._vertices[segmentXD + 1]; + var rcX = this._vertices[lastIndex]; + var rcY = this._vertices[lastIndex + 1]; + var rdX = this._vertices[lastIndex - segmentXD]; + var rdY = this._vertices[lastIndex - segmentXD + 1]; + // + var dacX = raX + (rcX - raX) * 0.5; + var dacY = raY + (rcY - raY) * 0.5; + var dbdX = rbX + (rdX - rbX) * 0.5; + var dbdY = rbY + (rdY - rbY) * 0.5; + var aX = dacX + (dbdX - dacX) * 0.5; + var aY = dacY + (dbdY - dacY) * 0.5; + var bX = rbX + (rcX - rbX) * 0.5; + var bY = rbY + (rcY - rbY) * 0.5; + var cX = rdX + (rcX - rdX) * 0.5; + var cY = rdY + (rcY - rdY) * 0.5; + // TODO interpolation + this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); + this._globalDirty = false; + }; + Surface.prototype._getGlobalTransformMatrix = function (x, y) { + var lA = 200.0; + var lB = 1000.0; + if (x < -lB || lB < x || y < -lB || lB < y) { + return this.globalTransformMatrix; + } + var isDown = false; + var surfaceData = this._boneData; + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var segmentXD = surfaceData.segmentX * 2; + var dX = this._dX; + var dY = this._dY; + var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 + var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 + var matrixIndex = 0; + var pX = indexX * dX - lA; + var pY = indexY * dY - lA; + // + var matrices = this._matrixCahce; + var helpMatrix = Surface._helpMatrix; + if (x < -lA) { + if (y < -lA || y >= lA) { // Out. + return this.globalTransformMatrix; + } + // Left. + isDown = y > this._kX * (x + lA) + pY; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexY * (segmentXD + 2); + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[2] - (segmentY - indexY) * ddX; + var sY = this._hullCache[3] - (segmentY - indexY) * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (x >= lA) { + if (y < -lA || y >= lA) { // Out. + return this.globalTransformMatrix; + } + // Right. + isDown = y > this._kX * (x - lB) + pY; + matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[0] + indexY * ddX; + var sY = this._hullCache[1] + indexY * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (y < -lA) { + if (x < -lA || x >= lA) { // Out. + return this.globalTransformMatrix; + } + // Up. + isDown = y > this._kY * (x - pX - dX) - lB; + matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexX * 2; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[8] + indexX * ddX; + var sY = this._hullCache[9] + indexX * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (y >= lA) { + if (x < -lA || x >= lA) { // Out. + return this.globalTransformMatrix; + } + // Down + isDown = y > this._kY * (x - pX - dX) + lA; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[6] - (segmentX - indexX) * ddX; + var sY = this._hullCache[7] - (segmentX - indexX) * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else { // Center. + isDown = y > this._k * (x - pX - dX) + pY; + matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + return helpMatrix; + }; + /** + * @internal + * @private + */ + Surface.prototype.init = function (surfaceData, armatureValue) { + if (this._boneData !== null) { + return; + } + _super.prototype.init.call(this, surfaceData, armatureValue); + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; + var lB = 1000.0; + var lA = 200.0; + // + this._dX = lA * 2.0 / segmentX; + this._dY = lA * 2.0 / segmentY; + this._k = -this._dY / this._dX; + this._kX = -this._dY / (lB - lA); + this._kY = -(lB - lA) / this._dX; + this._vertices.length = vertexCount * 2; + this._deformVertices.length = vertexCount * 2; + this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; + this._hullCache.length = 10; + for (var i = 0; i < vertexCount * 2; ++i) { + this._deformVertices[i] = 0.0; + } + if (this._parent !== null) { + if (this._parent.boneData.type === 0 /* Bone */) { + this._bone = this._parent; + } + else { + this._bone = this._parent._bone; + } + } + }; + /** + * @internal + */ + Surface.prototype.update = function (cacheFrameIndex) { + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + // + for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { + this._matrixCahce[i] = -1.0; + } + // + this._updateVertices(); + // + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + // Update hull vertices. + var lB = 1000.0; + var lA = 200.0; + var ddX = 2 * this.global.x; + var ddY = 2 * this.global.y; + // + var helpPoint = Surface._helpPoint; + this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); + this._hullCache[0] = helpPoint.x; + this._hullCache[1] = helpPoint.y; + this._hullCache[2] = ddX - helpPoint.x; + this._hullCache[3] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); + this._hullCache[4] = helpPoint.x; + this._hullCache[5] = helpPoint.y; + // + this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); + this._hullCache[6] = helpPoint.x; + this._hullCache[7] = helpPoint.y; + this._hullCache[8] = ddX - helpPoint.x; + this._hullCache[9] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); + this._hullCache[10] = helpPoint.x; + this._hullCache[11] = helpPoint.y; + } + else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + this._localDirty = true; + }; + return Surface; + }(dragonBones.Bone)); + dragonBones.Surface = Surface; +})(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 DisplayFrame = /** @class */ (function (_super) { + __extends(DisplayFrame, _super); + function DisplayFrame() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.deformVertices = []; + return _this; + } + DisplayFrame.toString = function () { + return "[class dragonBones.DisplayFrame]"; + }; + DisplayFrame.prototype._onClear = function () { + this.rawDisplayData = null; + this.displayData = null; + this.textureData = null; + this.display = null; + this.deformVertices.length = 0; + }; + DisplayFrame.prototype.updateDeformVertices = function () { + if (this.rawDisplayData === null || this.deformVertices.length !== 0) { + return; + } + var rawGeometryData; + if (this.rawDisplayData.type === 2 /* Mesh */) { + rawGeometryData = this.rawDisplayData.geometry; + } + else if (this.rawDisplayData.type === 4 /* Path */) { + rawGeometryData = this.rawDisplayData.geometry; + } + else { + return; + } + var vertexCount = 0; + if (rawGeometryData.weight !== null) { + vertexCount = rawGeometryData.weight.count * 2; + } + else { + vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; + } + this.deformVertices.length = vertexCount; + for (var i = 0, l = this.deformVertices.length; i < l; ++i) { + this.deformVertices[i] = 0.0; + } + }; + DisplayFrame.prototype.getGeometryData = function () { + if (this.displayData !== null) { + if (this.displayData.type === 2 /* Mesh */) { + return this.displayData.geometry; + } + if (this.displayData.type === 4 /* Path */) { + return this.displayData.geometry; + } + } + if (this.rawDisplayData !== null) { + if (this.rawDisplayData.type === 2 /* Mesh */) { + return this.rawDisplayData.geometry; + } + if (this.rawDisplayData.type === 4 /* Path */) { + return this.rawDisplayData.geometry; + } + } + return null; + }; + DisplayFrame.prototype.getBoundingBox = function () { + if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { + return this.displayData.boundingBox; + } + if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { + return this.rawDisplayData.boundingBox; + } + return null; + }; + DisplayFrame.prototype.getTextureData = function () { + if (this.displayData !== null) { + if (this.displayData.type === 0 /* Image */) { + return this.displayData.texture; + } + if (this.displayData.type === 2 /* Mesh */) { + return this.displayData.texture; + } + } + if (this.textureData !== null) { + return this.textureData; + } + if (this.rawDisplayData !== null) { + if (this.rawDisplayData.type === 0 /* Image */) { + return this.rawDisplayData.texture; + } + if (this.rawDisplayData.type === 2 /* Mesh */) { + return this.rawDisplayData.texture; + } + } + return null; + }; + return DisplayFrame; + }(dragonBones.BaseObject)); + dragonBones.DisplayFrame = DisplayFrame; + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + var Slot = /** @class */ (function (_super) { + __extends(Slot, _super); + function Slot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._localMatrix = new dragonBones.Matrix(); + /** + * @internal + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @internal + */ + _this._displayFrames = []; + /** + * @internal + */ + _this._geometryBones = []; + _this._rawDisplay = null; // Initial value. + _this._meshDisplay = null; // Initial value. + _this._display = null; + return _this; + } + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var dispayFrame = _a[_i]; + var display = dispayFrame.display; + if (display !== this._rawDisplay && display !== this._meshDisplay && + disposeDisplayList.indexOf(display) < 0) { + disposeDisplayList.push(display); + } + dispayFrame.returnToPool(); + } + for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { + var eachDisplay = disposeDisplayList_1[_b]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay, true); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. + this._disposeDisplay(this._meshDisplay, false); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay, false); + } + this.displayController = null; + this._displayDataDirty = false; + this._displayDirty = false; + this._geometryDirty = false; + this._textureDirty = false; + this._visibleDirty = false; + this._blendModeDirty = false; + this._zOrderDirty = false; + this._colorDirty = false; + this._verticesDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._zIndex = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._displayFrames.length = 0; + this._geometryBones.length = 0; + this._slotData = null; // + this._displayFrame = null; + this._geometryData = null; + this._boundingBoxData = null; + this._textureData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._parent = null; // + this._cachedFrameIndices = null; + }; + Slot.prototype._hasDisplay = function (display) { + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var displayFrame = _a[_i]; + if (displayFrame.display === display) { + return true; + } + } + return false; + }; + /** + * @internal + */ + Slot.prototype._isBonesUpdate = function () { + for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + */ + Slot.prototype._updateAlpha = function () { + var globalAlpha = this._alpha * this._parent._globalAlpha; + if (this._globalAlpha !== globalAlpha) { + this._globalAlpha = globalAlpha; + this._colorDirty = true; + } + }; + Slot.prototype._updateDisplayData = function () { + var prevDisplayFrame = this._displayFrame; + var prevGeometryData = this._geometryData; + var prevTextureData = this._textureData; + var rawDisplayData = null; + var displayData = null; + this._displayFrame = null; + this._geometryData = null; + this._boundingBoxData = null; + this._textureData = null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { + this._displayFrame = this._displayFrames[this._displayIndex]; + rawDisplayData = this._displayFrame.rawDisplayData; + displayData = this._displayFrame.displayData; + this._geometryData = this._displayFrame.getGeometryData(); + this._boundingBoxData = this._displayFrame.getBoundingBox(); + this._textureData = this._displayFrame.getTextureData(); + } + if (this._displayFrame !== prevDisplayFrame || + this._geometryData !== prevGeometryData || this._textureData !== prevTextureData) { + // Update pivot offset. + if (this._geometryData === null && this._textureData !== null) { + var imageDisplayData = ((displayData !== null && displayData.type === 0 /* Image */) ? displayData : rawDisplayData); // + var scale = this._textureData.parent.scale * this._armature._armatureData.scale; + var frame = this._textureData.frame; + this._pivotX = imageDisplayData.pivot.x; + this._pivotY = imageDisplayData.pivot.y; + var rect = frame !== null ? frame : this._textureData.region; + var width = rect.width; + var height = rect.height; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width * scale; + this._pivotY *= height * scale; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + // Update replace pivot. TODO + if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) { + rawDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); + this._pivotX -= Slot._helpPoint.x; + this._pivotY -= Slot._helpPoint.y; + imageDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); + this._pivotX += Slot._helpPoint.x; + this._pivotY += Slot._helpPoint.y; + } + if (!dragonBones.DragonBones.yDown) { + this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update original transform. + if (rawDisplayData !== null) { // Compatible. + this.origin = rawDisplayData.transform; + } + else if (displayData !== null) { // Compatible. + this.origin = displayData.transform; + } + else { + this.origin = null; + } + // TODO remove slot offset. + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + // Update geometry. + if (this._geometryData !== prevGeometryData) { + this._geometryDirty = true; + this._verticesDirty = true; + if (this._geometryData !== null) { + this._geometryBones.length = 0; + if (this._geometryData.weight !== null) { + for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { + var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); + this._geometryBones.push(bone); + } + } + } + else { + this._geometryBones.length = 0; + this._geometryData = null; + } + } + this._textureDirty = this._textureData !== prevTextureData; + this._transformDirty = true; + } + }; + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayFrame !== null) { + this._display = this._displayFrame.display; + if (this._display !== null && this._display instanceof dragonBones.Armature) { + this._childArmature = this._display; + this._display = this._childArmature.display; + } + else { + this._childArmature = null; + } + } + else { + this._display = null; + this._childArmature = null; + } + // Update display. + var currentDisplay = this._display !== null ? this._display : this._rawDisplay; + if (currentDisplay !== prevDisplay) { + this._textureDirty = true; + this._visibleDirty = true; + this._blendModeDirty = true; + // this._zOrderDirty = true; + this._colorDirty = true; + this._transformDirty = true; + this._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + } + // Update child armature. + if (this._childArmature !== prevChildArmature) { + if (prevChildArmature !== null) { + prevChildArmature._parent = null; // Update child armature parent. + prevChildArmature.clock = null; + if (prevChildArmature.inheritAnimation) { + prevChildArmature.animation.reset(); + } + } + if (this._childArmature !== null) { + this._childArmature._parent = this; // Update child armature parent. + this._childArmature.clock = this._armature.clock; + if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. + if (this._childArmature.cacheFrameRate === 0) { + var cacheFrameRate = this._armature.cacheFrameRate; + if (cacheFrameRate !== 0) { + this._childArmature.cacheFrameRate = cacheFrameRate; + } + } + // Child armature action. + if (this._displayFrame !== null) { + var actions = null; + var displayData = this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; + if (displayData !== null && displayData.type === 1 /* Armature */) { + actions = displayData.actions; + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + eventObject.slot = this; + this._armature._bufferAction(eventObject, false); + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + } + }; + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(parentMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @internal + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return; + } + this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; + this._displayDataDirty = true; + this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; + }; + /** + * @internal + */ + Slot.prototype._setZOrder = function (value) { + if (this._zOrder === value) { + // return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + return this._colorDirty = true; + }; + /** + * @internal + */ + Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { + if (this._slotData !== null) { + return; + } + this._slotData = slotData; + this._colorDirty = true; // + this._blendModeDirty = true; // + this._blendMode = this._slotData.blendMode; + this._zOrder = this._slotData.zOrder; + this._zIndex = this._slotData.zIndex; + this._alpha = this._slotData.alpha; + this._colorTransform.copyFrom(this._slotData.color); + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + // + this._armature = armatureValue; + var slotParent = this._armature.getBone(this._slotData.parent.name); + if (slotParent !== null) { + this._parent = slotParent; + } + else { + // Never; + } + this._armature._addSlot(this); + // + this._initDisplay(this._rawDisplay, false); + if (this._rawDisplay !== this._meshDisplay) { + this._initDisplay(this._meshDisplay, false); + } + this._onUpdateDisplay(); + this._addDisplay(); + }; + /** + * @internal + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDataDirty) { + this._updateDisplayData(); + this._displayDataDirty = false; + } + if (this._displayDirty) { + this._updateDisplay(); + this._displayDirty = false; + } + if (this._geometryDirty || this._textureDirty) { + if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { + this._updateFrame(); + } + this._geometryDirty = false; + this._textureDirty = false; + } + if (this._display === null) { + return; + } + if (this._visibleDirty) { + this._updateVisible(); + this._visibleDirty = false; + } + if (this._blendModeDirty) { + this._updateBlendMode(); + this._blendModeDirty = false; + } + if (this._colorDirty) { + this._updateColor(); + this._colorDirty = false; + } + if (this._zOrderDirty) { + this._updateZOrder(); + this._zOrderDirty = false; + } + if (this._geometryData !== null && this._display === this._meshDisplay) { + var isSkinned = this._geometryData.weight !== null; + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + if (this._verticesDirty || + (isSkinned && this._isBonesUpdate()) || + (isSurface && this._parent._childrenTransformDirty)) { + this._verticesDirty = false; // Allow update mesh to reset the dirty value. + this._updateMesh(); + } + if (isSkinned || isSurface) { // Compatible. + return; + } + } + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + if (this._transformDirty) { + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + this._updateGlobalTransformMatrix(isCache); + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + this._updateTransform(); + this._transformDirty = false; + } + }; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDataDirty = true; + this._displayDirty = true; + // + this._transformDirty = true; + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._updateGlobalTransformMatrix(false); + this._transformDirty = false; + } + }; + /** + * @private + */ + Slot.prototype.replaceRawDisplayData = function (displayData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.rawDisplayData !== displayData) { + displayFrame.deformVertices.length = 0; + displayFrame.rawDisplayData = displayData; + if (displayFrame.rawDisplayData === null) { + var defaultSkin = this._armature._armatureData.defaultSkin; + if (defaultSkin !== null) { + var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); + if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { + displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; + } + } + } + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceDisplayData = function (displayData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { + displayFrame.displayData = displayData; + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceTextureData = function (textureData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.textureData !== textureData) { + displayFrame.textureData = textureData; + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceDisplay = function (value, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.display !== value) { + var prevDisplay = displayFrame.display; + displayFrame.display = value; + if (prevDisplay !== null && + prevDisplay !== this._rawDisplay && prevDisplay !== this._meshDisplay && + !this._hasDisplay(prevDisplay)) { + if (prevDisplay instanceof dragonBones.Armature) { + // (eachDisplay as Armature).dispose(); + } + else { + this._disposeDisplay(prevDisplay, true); + } + } + if (value !== null && + value !== this._rawDisplay && value !== this._meshDisplay && + !this._hasDisplay(prevDisplay) && + !(value instanceof dragonBones.Armature)) { + this._initDisplay(value, true); + } + if (index === this._displayIndex) { + this._displayDirty = true; + } + } + }; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Slot.prototype.containsPoint = function (x, y) { + if (this._boundingBoxData === null) { + return false; + } + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); + return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); + }; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + if (this._boundingBoxData === null) { + return 0; + } + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); + xA = Slot._helpPoint.x; + yA = Slot._helpPoint.y; + Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); + xB = Slot._helpPoint.x; + yB = Slot._helpPoint.y; + var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionCount === 1 || intersectionCount === 2) { + if (intersectionPointA !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + if (intersectionPointB !== null) { + intersectionPointB.x = intersectionPointA.x; + intersectionPointB.y = intersectionPointA.y; + } + } + else if (intersectionPointB !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + } + else { + if (intersectionPointA !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + } + if (intersectionPointB !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + } + if (normalRadians !== null) { + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); + normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); + normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + } + } + return intersectionCount; + }; + /** + * @private + */ + Slot.prototype.getDisplayFrameAt = function (index) { + return this._displayFrames[index]; + }; + Object.defineProperty(Slot.prototype, "visible", { + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible === value) { + return; + } + this._visible = value; + this._updateVisible(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayFrameCount", { + /** + * @private + */ + get: function () { + return this._displayFrames.length; + }, + set: function (value) { + var prevCount = this._displayFrames.length; + if (prevCount < value) { + this._displayFrames.length = value; + for (var i = prevCount; i < value; ++i) { + this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); + } + } + else if (prevCount > value) { + for (var i = prevCount - 1; i < value; --i) { + this.replaceDisplay(null, i); + this._displayFrames[i].returnToPool(); + } + this._displayFrames.length = value; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * - The index of the display object displayed in the display list. + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     slot.displayIndex = 3;
+             *     slot.displayController = "none";
+             * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     slot.displayIndex = 3;
+             *     slot.displayController = "none";
+             * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + this._setDisplayIndex(value); + this.update(-1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "name", { + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._slotData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + var displays = new Array(); + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var displayFrame = _a[_i]; + displays.push(displayFrame.display); + } + return displays; + }, + set: function (value) { + this.displayFrameCount = value.length; + var index = 0; + for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { + var eachDisplay = value_1[_i]; + this.replaceDisplay(eachDisplay, index++); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "slotData", { + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._slotData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return this._boundingBoxData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "rawDisplay", { + /** + * @private + */ + get: function () { + return this._rawDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "meshDisplay", { + /** + * @private + */ + get: function () { + return this._meshDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "display", { + /** + * - The display object that the slot displays at this time. + * @example + *
+             *     let slot = armature.getSlot("text");
+             *     slot.display = new yourEngine.TextField();
+             * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+             *     let slot = armature.getSlot("text");
+             *     slot.display = new yourEngine.TextField();
+             * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + if (this._displayFrames.length === 0) { + this.displayFrameCount = 1; + this._displayIndex = 0; + } + this.replaceDisplay(value, this._displayIndex); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * - The child armature that the slot displayed at current time. + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     let prevChildArmature = slot.childArmature;
+             *     if (prevChildArmature) {
+             *         prevChildArmature.dispose();
+             *     }
+             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+             * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     let prevChildArmature = slot.childArmature;
+             *     if (prevChildArmature) {
+             *         prevChildArmature.dispose();
+             *     }
+             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+             * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._childArmature; + }, + set: function (value) { + if (this._childArmature === value) { + return; + } + this.display = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "parent", { + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(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) { + /** + * @internal + */ + var Constraint = /** @class */ (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this._armature = null; // + this._target = null; // + this._root = null; // + this._bone = null; + }; + Object.defineProperty(Constraint.prototype, "name", { + get: function () { + return this._constraintData.name; + }, + enumerable: true, + configurable: true + }); + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @internal + */ + var IKConstraint = /** @class */ (function (_super) { + __extends(IKConstraint, _super); + function IKConstraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraint.toString = function () { + return "[class dragonBones.IKConstraint]"; + }; + IKConstraint.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._scaleEnabled = false; + this._bendPositive = false; + this._weight = 1.0; + this._constraintData = null; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this._target.global; + var global = this._root.global; + var globalTransformMatrix = this._root.globalTransformMatrix; + var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + radian += Math.PI; + } + global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype._computeB = function () { + var boneLength = this._bone._boneData.length; + var parent = this._root; + var ikGlobal = this._target.global; + var parentGlobal = parent.global; + var global = this._bone.global; + var globalTransformMatrix = this._bone.globalTransformMatrix; + var x = globalTransformMatrix.a * boneLength; + var y = globalTransformMatrix.b * boneLength; + var lLL = x * x + y * y; + var lL = Math.sqrt(lLL); + var dX = global.x - parentGlobal.x; + var dY = global.y - parentGlobal.y; + var lPP = dX * dX + dY * dY; + var lP = Math.sqrt(lPP); + var rawRadian = global.rotation; + var rawParentRadian = parentGlobal.rotation; + var rawRadianA = Math.atan2(dY, dX); + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + var lTT = dX * dX + dY * dY; + var lT = Math.sqrt(lTT); + var radianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + radianA += Math.PI; + } + } + else { + var h = (lPP - lLL + lTT) / (2.0 * lTT); + var r = Math.sqrt(lPP - h * h * lTT) / lT; + var hX = parentGlobal.x + (dX * h); + var hY = parentGlobal.y + (dY * h); + var rX = -dY * r; + var rY = dX * r; + var isPPR = false; + var parentParent = parent.parent; + if (parentParent !== null) { + var parentParentMatrix = parentParent.globalTransformMatrix; + isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; + } + if (isPPR !== this._bendPositive) { + global.x = hX - rX; + global.y = hY - rY; + } + else { + global.x = hX + rX; + global.y = hY + rY; + } + radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); + parentGlobal.rotation = rawParentRadian + dR * this._weight; + parentGlobal.toMatrix(parent.globalTransformMatrix); + // + var currentRadianA = rawRadianA + dR * this._weight; + global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; + global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; + // + var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + radianB += Math.PI; + } + global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.init = function (constraintData, armature) { + if (this._constraintData !== null) { + return; + } + this._constraintData = constraintData; + this._armature = armature; + this._target = this._armature.getBone(this._constraintData.target.name); + this._root = this._armature.getBone(this._constraintData.root.name); + this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; + { + var ikConstraintData = this._constraintData; + this._scaleEnabled = ikConstraintData.scaleEnabled; + this._bendPositive = ikConstraintData.bendPositive; + this._weight = ikConstraintData.weight; + } + this._root._hasConstraint = true; + }; + IKConstraint.prototype.update = function () { + this._root.updateByConstraint(); + if (this._bone !== null) { + this._bone.updateByConstraint(); + this._computeB(); + } + else { + this._computeA(); + } + }; + IKConstraint.prototype.invalidUpdate = function () { + this._root.invalidUpdate(); + if (this._bone !== null) { + this._bone.invalidUpdate(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; + /** + * @internal + */ + var PathConstraint = /** @class */ (function (_super) { + __extends(PathConstraint, _super); + function PathConstraint() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._bones = []; + _this._spaces = []; + _this._positions = []; + _this._curves = []; + _this._boneLengths = []; + _this._pathGlobalVertices = []; + _this._segments = [10]; + return _this; + } + PathConstraint.toString = function () { + return "[class dragonBones.PathConstraint]"; + }; + PathConstraint.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.dirty = false; + this.pathOffset = 0; + this.position = 0.0; + this.spacing = 0.0; + this.rotateOffset = 0.0; + this.rotateMix = 1.0; + this.translateMix = 1.0; + this._pathSlot = null; + this._bones.length = 0; + this._spaces.length = 0; + this._positions.length = 0; + this._curves.length = 0; + this._boneLengths.length = 0; + this._pathGlobalVertices.length = 0; + }; + PathConstraint.prototype._updatePathVertices = function (verticesData) { + //计算曲线的节点数据 + var armature = this._armature; + var dragonBonesData = armature.armatureData.parent; + var scale = armature.armatureData.scale; + var intArray = dragonBonesData.intArray; + var floatArray = dragonBonesData.floatArray; + var pathOffset = verticesData.offset; + var pathVertexCount = intArray[pathOffset + 0 /* GeometryVertexCount */]; + var pathVertexOffset = intArray[pathOffset + 2 /* GeometryFloatOffset */]; + this._pathGlobalVertices.length = pathVertexCount * 2; + var weightData = verticesData.weight; + //没有骨骼约束我,那节点只受自己的Bone控制 + if (weightData === null) { + var parentBone = this._pathSlot.parent; + parentBone.updateByConstraint(); + var matrix = parentBone.globalTransformMatrix; + for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { + var vx = floatArray[iV_1++] * scale; + var vy = floatArray[iV_1++] * scale; + var x = matrix.a * vx + matrix.c * vy + matrix.tx; + var y = matrix.b * vx + matrix.d * vy + matrix.ty; + // + this._pathGlobalVertices[i] = x; + this._pathGlobalVertices[i + 1] = y; + } + return; + } + //有骨骼约束我,那我的节点受骨骼权重控制 + var bones = this._pathSlot._geometryBones; + var weightBoneCount = weightData.bones.length; + var weightOffset = weightData.offset; + var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; + var iV = floatOffset; + var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; + for (var i = 0, iW = 0; i < pathVertexCount; i++) { + var vertexBoneCount = intArray[iB++]; // + var xG = 0.0, yG = 0.0; + for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (bone === null) { + continue; + } + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var vx = floatArray[iV++] * scale; + var vy = floatArray[iV++] * scale; + xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; + yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; + } + this._pathGlobalVertices[iW++] = xG; + this._pathGlobalVertices[iW++] = yG; + } + }; + PathConstraint.prototype._computeVertices = function (start, count, offset, out) { + //TODO优化 + for (var i = offset, iW = start; i < count; i += 2) { + out[i] = this._pathGlobalVertices[iW++]; + out[i + 1] = this._pathGlobalVertices[iW++]; + } + }; + PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { + //计算当前的骨骼在曲线上的位置 + var armature = this._armature; + var intArray = armature.armatureData.parent.intArray; + var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; + var positions = this._positions; + var spaces = this._spaces; + var isClosed = pathDisplayDta.closed; + var curveVertices = Array(); + var verticesLength = vertexCount * 2; + var curveCount = verticesLength / 6; + var preCurve = -1; + var position = this.position; + positions.length = spaceCount * 3 + 2; + var pathLength = 0.0; + //不需要匀速运动,效率高些 + if (!pathDisplayDta.constantSpeed) { + var lenghts = pathDisplayDta.curveLengths; + curveCount -= isClosed ? 1 : 2; + pathLength = lenghts[curveCount]; + if (percentPosition) { + position *= pathLength; + } + if (percentSpacing) { + for (var i = 0; i < spaceCount; i++) { + spaces[i] *= pathLength; + } + } + curveVertices.length = 8; + for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + if (isClosed) { + position %= pathLength; + if (position < 0) { + position += pathLength; + } + curve = 0; + } + else if (position < 0) { + //TODO + continue; + } + else if (position > pathLength) { + //TODO + continue; + } + var percent = 0.0; + for (;; curve++) { + var len = lenghts[curve]; + if (position > len) { + continue; + } + if (curve === 0) { + percent = position / len; + } + else { + var preLen = lenghts[curve - 1]; + percent = (position - preLen) / (len - preLen); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + if (isClosed && curve === curveCount) { + //计算曲线 + this._computeVertices(verticesLength - 4, 4, 0, curveVertices); + this._computeVertices(0, 4, 4, curveVertices); + } + else { + this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); + } + } + // + this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); + } + return; + } + //匀速的 + if (isClosed) { + verticesLength += 2; + curveVertices.length = vertexCount; + this._computeVertices(2, verticesLength - 4, 0, curveVertices); + this._computeVertices(0, 2, verticesLength - 4, curveVertices); + curveVertices[verticesLength - 2] = curveVertices[0]; + curveVertices[verticesLength - 1] = curveVertices[1]; + } + else { + curveCount--; + verticesLength -= 4; + curveVertices.length = verticesLength; + this._computeVertices(2, verticesLength, 0, curveVertices); + } + // + var curves = new Array(curveCount); + pathLength = 0; + var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = curveVertices[w]; + cy1 = curveVertices[w + 1]; + cx2 = curveVertices[w + 2]; + cy2 = curveVertices[w + 3]; + x2 = curveVertices[w + 4]; + y2 = curveVertices[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) { + position *= pathLength; + } + if (percentSpacing) { + for (var i = 0; i < spaceCount; i++) { + spaces[i] *= pathLength; + } + } + var segments = this._segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (isClosed) { + p %= pathLength; + if (p < 0) + p += pathLength; + curve = 0; + } + else if (p < 0) { + continue; + } + else if (p > pathLength) { + continue; + } + // Determine curve containing position. + for (;; curve++) { + var length_1 = curves[curve]; + if (p > length_1) + continue; + if (curve === 0) + p /= length_1; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_1 - prev); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + var ii = curve * 6; + x1 = curveVertices[ii]; + y1 = curveVertices[ii + 1]; + cx1 = curveVertices[ii + 2]; + cy1 = curveVertices[ii + 3]; + cx2 = curveVertices[ii + 4]; + cy2 = curveVertices[ii + 5]; + x2 = curveVertices[ii + 6]; + y2 = curveVertices[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + // Weight by segment length. + p *= curveLength; + for (;; segment++) { + var length_2 = segments[segment]; + if (p > length_2) + continue; + if (segment === 0) + p /= length_2; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_2 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); + } + }; + //Calculates a point on the curve, for a given t value between 0 and 1. + PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { + if (t === 0) { + out[offset] = x1; + out[offset + 1] = y1; + out[offset + 2] = 0; + return; + } + if (t === 1) { + out[offset] = x2; + out[offset + 1] = y2; + out[offset + 2] = 0; + return; + } + var mt = 1 - t; + var mt2 = mt * mt; + var t2 = t * t; + var a = mt2 * mt; + var b = mt2 * t * 3; + var c = mt * t2 * 3; + var d = t * t2; + var x = a * x1 + b * cx1 + c * cx2 + d * x2; + var y = a * y1 + b * cy1 + c * cy2 + d * y2; + out[offset] = x; + out[offset + 1] = y; + if (tangents) { + //Calculates the curve tangent at the specified t value + out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); + } + else { + out[offset + 2] = 0; + } + }; + PathConstraint.prototype.init = function (constraintData, armature) { + this._constraintData = constraintData; + this._armature = armature; + var data = constraintData; + this.pathOffset = data.pathDisplayData.geometry.offset; + // + this.position = data.position; + this.spacing = data.spacing; + this.rotateOffset = data.rotateOffset; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + // + this._root = this._armature.getBone(data.root.name); + this._target = this._armature.getBone(data.target.name); + this._pathSlot = this._armature.getSlot(data.pathSlot.name); + for (var i = 0, l = data.bones.length; i < l; i++) { + var bone = this._armature.getBone(data.bones[i].name); + if (bone !== null) { + this._bones.push(bone); + } + } + if (data.rotateMode === 2 /* ChainScale */) { + this._boneLengths.length = this._bones.length; + } + this._root._hasConstraint = true; + }; + PathConstraint.prototype.update = function () { + var pathSlot = this._pathSlot; + if (pathSlot._geometryData === null || + pathSlot._geometryData.offset !== this.pathOffset) { + return; + } + var constraintData = this._constraintData; + // + //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 + var isPathVerticeDirty = false; + if (this._root._childrenTransformDirty) { + this._updatePathVertices(pathSlot._geometryData); + isPathVerticeDirty = true; + } + else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) { + this._updatePathVertices(pathSlot._geometryData); + pathSlot._verticesDirty = false; + isPathVerticeDirty = true; + } + if (!isPathVerticeDirty && !this.dirty) { + return; + } + // + var positionMode = constraintData.positionMode; + var spacingMode = constraintData.spacingMode; + var rotateMode = constraintData.rotateMode; + var bones = this._bones; + var isLengthMode = spacingMode === 0 /* Length */; + var isChainScaleMode = rotateMode === 2 /* ChainScale */; + var isTangentMode = rotateMode === 0 /* Tangent */; + var boneCount = bones.length; + var spacesCount = isTangentMode ? boneCount : boneCount + 1; + var spacing = this.spacing; + var spaces = this._spaces; + spaces.length = spacesCount; + //计曲线间隔和长度 + if (isChainScaleMode || isLengthMode) { + //Bone改变和spacing改变触发 + spaces[0] = 0; + for (var i = 0, l = spacesCount - 1; i < l; i++) { + var bone = bones[i]; + bone.updateByConstraint(); + var boneLength = bone._boneData.length; + var matrix = bone.globalTransformMatrix; + var x = boneLength * matrix.a; + var y = boneLength * matrix.b; + var len = Math.sqrt(x * x + y * y); + if (isChainScaleMode) { + this._boneLengths[i] = len; + } + spaces[i + 1] = (boneLength + spacing) * len / boneLength; + } + } + else { + for (var i = 0; i < spacesCount; i++) { + spaces[i] = spacing; + } + } + // + this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); + //根据新的节点数据重新采样 + var positions = this._positions; + var rotateOffset = this.rotateOffset; + var boneX = positions[0], boneY = positions[1]; + var tip; + if (rotateOffset === 0) { + tip = rotateMode === 1 /* Chain */; + } + else { + tip = false; + var bone = pathSlot.parent; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; + } + } + // + var rotateMix = this.rotateMix; + var translateMix = this.translateMix; + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + matrix.tx += (boneX - matrix.tx) * translateMix; + matrix.ty += (boneY - matrix.ty) * translateMix; + var x = positions[p], y = positions[p + 1]; + var dx = x - boneX, dy = y - boneY; + if (isChainScaleMode) { + var lenght = this._boneLengths[i]; + var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; + matrix.a *= s; + matrix.b *= s; + } + boneX = x; + boneY = y; + if (rotateMix > 0) { + var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; + if (isTangentMode) { + r = positions[p - 1]; + } + else { + r = Math.atan2(dy, dx); + } + r -= Math.atan2(b, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone._boneData.length; + boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; + } + else { + r += rotateOffset; + } + if (r > dragonBones.Transform.PI) { + r -= dragonBones.Transform.PI_D; + } + else if (r < -dragonBones.Transform.PI) { + r += dragonBones.Transform.PI_D; + } + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + matrix.a = cos * a - sin * b; + matrix.b = sin * a + cos * b; + matrix.c = cos * c - sin * d; + matrix.d = sin * c + cos * d; + } + bone.global.fromMatrix(matrix); + } + this.dirty = false; + }; + PathConstraint.prototype.invalidUpdate = function () { + }; + return PathConstraint; + }(Constraint)); + dragonBones.PathConstraint = PathConstraint; +})(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) { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = /** @class */ (function () { + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = 0.0; } + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._systemTime = 0.0; + this._animatebles = []; + this._clock = null; + this.time = time; + this._systemTime = new Date().getTime() * 0.001; + } + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + var currentTime = Date.now() * 0.001; + if (passedTime < 0.0) { + passedTime = currentTime - this._systemTime; + } + this._systemTime = currentTime; + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime === 0.0) { + return; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + var i = 0, r = 0, l = this._animatebles.length; + for (; i < l; ++i) { + var animatable = this._animatebles[i]; + if (animatable !== null) { + if (r > 0) { + this._animatebles[i - r] = animatable; + this._animatebles[i] = null; + } + animatable.advanceTime(passedTime); + } + else { + r++; + } + } + if (r > 0) { + l = this._animatebles.length; + for (; i < l; ++i) { + var animateble = this._animatebles[i]; + if (animateble !== null) { + this._animatebles[i - r] = animateble; + } + else { + r++; + } + } + this._animatebles.length -= r; + } + }; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + if (value === this) { + return false; + } + var ancestor = value; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.clock; + } + return ancestor === this; + }; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.add = function (value) { + if (this._animatebles.indexOf(value) < 0) { + this._animatebles.push(value); + value.clock = this; + } + }; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.remove = function (value) { + var index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles[index] = null; + value.clock = null; + } + }; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.clear = function () { + for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { + var animatable = _a[_i]; + if (animatable !== null) { + animatable.clock = null; + } + } + }; + Object.defineProperty(WorldClock.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + if (this._clock !== null) { + this._clock.remove(this); + } + this._clock = value; + if (this._clock !== null) { + this._clock.add(this); + } + }, + enumerable: true, + configurable: true + }); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(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 animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + var Animation = /** @class */ (function (_super) { + __extends(Animation, _super); + function Animation() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._animationNames = []; + _this._animationStates = []; + _this._animations = {}; + _this._blendStates = {}; + _this._animationConfig = null; // Initial value. + return _this; + } + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + Animation.prototype._onClear = function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + for (var k in this._animations) { + delete this._animations[k]; + } + for (var k in this._blendStates) { + var blendStates = this._blendStates[k]; + for (var kB in blendStates) { + blendStates[kB].returnToPool(); + } + delete this._blendStates[k]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._inheritTimeScale = 1.0; + this._animationNames.length = 0; + this._animationStates.length = 0; + //this._animations.clear(); + this._armature = null; // + this._animationConfig = null; // + this._lastAnimationState = null; + }; + Animation.prototype._fadeOut = function (animationConfig) { + switch (animationConfig.fadeOutMode) { + case 1 /* SameLayer */: + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState._parent !== null) { + continue; + } + if (animationState.layer === animationConfig.layer) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 2 /* SameGroup */: + for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { + var animationState = _c[_b]; + if (animationState._parent !== null) { + continue; + } + if (animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 3 /* SameLayerAndGroup */: + for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { + var animationState = _e[_d]; + if (animationState._parent !== null) { + continue; + } + if (animationState.layer === animationConfig.layer && + animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 4 /* All */: + for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { + var animationState = _g[_f]; + if (animationState._parent !== null) { + continue; + } + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 5 /* Single */: // TODO + default: + break; + } + }; + /** + * @internal + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { // Only animationState can reverse play. + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. + this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; + } + else { + this._inheritTimeScale = this.timeScale; + } + if (this._inheritTimeScale !== 1.0) { + passedTime *= this._inheritTimeScale; + } + for (var k in this._blendStates) { + var blendStates = this._blendStates[k]; + for (var kB in blendStates) { + blendStates[kB].reset(); + } + } + var animationStateCount = this._animationStates.length; + if (animationStateCount === 1) { + var animationState = this._animationStates[0]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + this._armature._dragonBones.bufferObject(animationState); + this._animationStates.length = 0; + this._lastAnimationState = null; + } + else { + var animationData = animationState.animationData; + var cacheFrameRate = animationData.cacheFrameRate; + if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. + this._animationDirty = false; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + if (slot.displayFrameCount > 0) { + var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; + if (rawDisplayData !== null && + rawDisplayData.parent === this._armature.armatureData.defaultSkin) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + continue; + } + } + slot._cachedFrameIndices = null; + } + } + animationState.advanceTime(passedTime, cacheFrameRate); + } + } + else if (animationStateCount > 1) { + for (var i = 0, r = 0; i < animationStateCount; ++i) { + var animationState = this._animationStates[i]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + r++; + this._armature._dragonBones.bufferObject(animationState); + this._animationDirty = true; + if (this._lastAnimationState === animationState) { // Update last animation state. + this._lastAnimationState = null; + } + } + else { + if (r > 0) { + this._animationStates[i - r] = animationState; + } + animationState.advanceTime(passedTime, 0.0); + } + if (i === animationStateCount - 1 && r > 0) { // Modify animation states size. + this._animationStates.length -= r; + if (this._lastAnimationState === null && this._animationStates.length > 0) { + this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; + } + } + } + this._armature._cacheFrameIndex = -1; + } + else { + this._armature._cacheFrameIndex = -1; + } + }; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.reset = function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + this._animationDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.stop = function (animationName) { + if (animationName === void 0) { animationName = null; } + if (animationName !== null) { + var animationState = this.getState(animationName); + if (animationState !== null) { + animationState.stop(); + } + } + else { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.stop(); + } + } + }; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + Animation.prototype.playConfig = function (animationConfig) { + var animationName = animationConfig.animation; + if (!(animationName in this._animations)) { + console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); + return null; + } + var animationData = this._animations[animationName]; + if (animationConfig.fadeOutMode === 5 /* Single */) { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState_1 = _a[_i]; + if (animationState_1._fadeState < 1 && + animationState_1.layer === animationConfig.layer && + animationState_1.animationData === animationData) { + return animationState_1; + } + } + } + if (this._animationStates.length === 0) { + animationConfig.fadeInTime = 0.0; + } + else if (animationConfig.fadeInTime < 0.0) { + animationConfig.fadeInTime = animationData.fadeInTime; + } + if (animationConfig.fadeOutTime < 0.0) { + animationConfig.fadeOutTime = animationConfig.fadeInTime; + } + if (animationConfig.timeScale <= -100.0) { + animationConfig.timeScale = 1.0 / animationData.scale; + } + if (animationData.frameCount > 0) { + if (animationConfig.position < 0.0) { + animationConfig.position %= animationData.duration; + animationConfig.position = animationData.duration - animationConfig.position; + } + else if (animationConfig.position === animationData.duration) { + animationConfig.position -= 0.000001; // Play a little time before end. + } + else if (animationConfig.position > animationData.duration) { + animationConfig.position %= animationData.duration; + } + if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { + animationConfig.duration = animationData.duration - animationConfig.position; + } + if (animationConfig.playTimes < 0) { + animationConfig.playTimes = animationData.playTimes; + } + } + else { + animationConfig.playTimes = 1; + animationConfig.position = 0.0; + if (animationConfig.duration > 0.0) { + animationConfig.duration = 0.0; + } + } + if (animationConfig.duration === 0.0) { + animationConfig.duration = -1.0; + } + this._fadeOut(animationConfig); + // + var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); + animationState.init(this._armature, animationData, animationConfig); + this._animationDirty = true; + this._armature._cacheFrameIndex = -1; + if (this._animationStates.length > 0) { // Sort animation state. + var added = false; + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + if (animationState.layer > this._animationStates[i].layer) { + added = true; + this._animationStates.splice(i, 0, animationState); + break; + } + else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { // Child armature play same name animation. + var slot = _c[_b]; + var childArmature = slot.childArmature; + if (childArmature !== null && childArmature.inheritAnimation && + childArmature.animation.hasAnimation(animationName) && + childArmature.animation.getState(animationName) === null) { + childArmature.animation.fadeIn(animationName); // + } + } + for (var k in animationData.animationTimelines) { // Blend animation node. + var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); + if (childAnimationState === null) { + continue; + } + var timelines = animationData.animationTimelines[k]; + childAnimationState.actionEnabled = false; + childAnimationState.resetToPose = false; + childAnimationState.stop(); + animationState.addState(childAnimationState, timelines); + // + var index = this._animationStates.indexOf(animationState); + var childIndex = this._animationStates.indexOf(childAnimationState); + if (childIndex < index) { + this._animationStates.splice(index, 1); + this._animationStates.splice(childIndex, 0, animationState); + } + } + // if (!this._armature._lockUpdate && animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. + // this._armature.advanceTime(0.0); + // } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.play = function (animationName, playTimes) { + if (animationName === void 0) { animationName = null; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName !== null ? animationName : ""; + if (animationName !== null && animationName.length > 0) { + this.playConfig(this._animationConfig); + } + else if (this._lastAnimationState === null) { + var defaultAnimation = this._armature.armatureData.defaultAnimation; + if (defaultAnimation !== null) { + this._animationConfig.animation = defaultAnimation.name; + this.playConfig(this._animationConfig); + } + } + else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { + this._lastAnimationState.play(); + } + else { + this._animationConfig.animation = this._lastAnimationState.name; + this.playConfig(this._animationConfig); + } + return this._lastAnimationState; + }; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { + if (fadeInTime === void 0) { fadeInTime = -1.0; } + if (playTimes === void 0) { playTimes = -1; } + if (layer === void 0) { layer = 0; } + if (group === void 0) { group = null; } + if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } + this._animationConfig.clear(); + this._animationConfig.fadeOutMode = fadeOutMode; + this._animationConfig.playTimes = playTimes; + this._animationConfig.layer = layer; + this._animationConfig.fadeInTime = fadeInTime; + this._animationConfig.animation = animationName; + this._animationConfig.group = group !== null ? group : ""; + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { + if (time === void 0) { time = 0.0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.position = time; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { + if (frame === void 0) { frame = 0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.frameCount > 0 ? animationData.duration * frame / animationData.frameCount : 0.0; + } + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { + if (progress === void 0) { progress = 0.0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); + } + return this.playConfig(this._animationConfig); + }; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByTime = function (animationName, time) { + if (time === void 0) { time = 0.0; } + var animationState = this.gotoAndPlayByTime(animationName, time, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { + if (frame === void 0) { frame = 0; } + var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { + if (progress === void 0) { progress = 0.0; } + var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * @internal + */ + Animation.prototype.getBlendState = function (type, name, target) { + if (!(type in this._blendStates)) { + this._blendStates[type] = {}; + } + var blendStates = this._blendStates[type]; + if (!(name in blendStates)) { + var blendState = blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState); + blendState.target = target; + } + return blendStates[name]; + }; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态。 + * @param animationName - 动画状态名称。 + * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName, layer) { + if (layer === void 0) { layer = -1; } + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { + return animationState; + } + } + return null; + }; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState.isPlaying) { + return true; + } + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "isCompleted", { + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (!animationState.isCompleted) { + return false; + } + } + return this._animationStates.length > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationName", { + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationNames", { + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animations; + }, + set: function (value) { + if (this._animations === value) { + return; + } + this._animationNames.length = 0; + for (var k in this._animations) { + delete this._animations[k]; + } + for (var k in value) { + this._animationNames.push(k); + this._animations[k] = value[k]; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + this._animationConfig.clear(); + return this._animationConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationState", { + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(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 animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + var AnimationState = /** @class */ (function (_super) { + __extends(AnimationState, _super); + function AnimationState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._boneMask = []; + _this._boneTimelines = []; + _this._boneBlendTimelines = []; + _this._slotTimelines = []; + _this._slotBlendTimelines = []; + _this._constraintTimelines = []; + _this._animationTimelines = []; + _this._poseTimelines = []; + /** + * @internal + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + AnimationState.prototype._onClear = function () { + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.returnToPool(); + } + for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { + var timeline = _l[_k]; + var animationState = timeline.target; + if (animationState._parent === this) { + animationState._fadeState = 1; + animationState._subFadeState = 1; + animationState._parent = null; + } + timeline.returnToPool(); + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.actionEnabled = false; + this.additive = false; + this.displayControl = false; + this.resetToPose = false; + this.blendType = 0 /* None */; + this.playTimes = 1; + this.layer = 0; + this.timeScale = 1.0; + this._weight = 1.0; + this.parameterX = 0.0; + this.parameterY = 0.0; + this.positionX = 0.0; + this.positionY = 0.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this._timelineDirty = 2; + this._playheadState = 0; + this._fadeState = -1; + this._subFadeState = -1; + this._position = 0.0; + this._duration = 0.0; + this._fadeTime = 0.0; + this._time = 0.0; + this._fadeProgress = 0.0; + this._weightResult = 0.0; + this._boneMask.length = 0; + this._boneTimelines.length = 0; + this._boneBlendTimelines.length = 0; + this._slotTimelines.length = 0; + this._slotBlendTimelines.length = 0; + this._constraintTimelines.length = 0; + this._animationTimelines.length = 0; + this._poseTimelines.length = 0; + // this._bonePoses.clear(); + this._animationData = null; // + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + this._activeChildA = null; + this._activeChildB = null; + this._parent = null; + }; + AnimationState.prototype._updateTimelines = function () { + { // Update constraint timelines. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); + if (timelineDatas !== null) { + for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { + var timelineData = timelineDatas_1[_b]; + switch (timelineData.type) { + case 30 /* IKConstraint */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.target = constraint; + timeline.init(this._armature, this, timelineData); + this._constraintTimelines.push(timeline); + break; + } + default: + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.target = constraint; + timeline.init(this._armature, this, null); + this._constraintTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + }; + AnimationState.prototype._updateBoneAndSlotTimelines = function () { + { // Update bone and surface timelines. + var boneTimelines = {}; + // Create bone timelines map. + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.target.target.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + var timelineName = timeline.target.target.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + // + for (var _d = 0, _e = this._armature.getBones(); _d < _e.length; _d++) { + var bone = _e[_d]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + if (timelineName in boneTimelines) { // Remove bone timeline from map. + delete boneTimelines[timelineName]; + } + else { // Create new bone timeline. + var timelineDatas = this._animationData.getBoneTimelines(timelineName); + var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); + if (timelineDatas !== null) { + for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { + var timelineData = timelineDatas_2[_f]; + switch (timelineData.type) { + case 10 /* BoneAll */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 11 /* BoneTranslate */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 12 /* BoneRotate */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 13 /* BoneScale */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 60 /* BoneAlpha */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); + timeline.init(this._armature, this, timelineData); + this._boneBlendTimelines.push(timeline); + break; + } + case 50 /* Surface */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); + timeline.init(this._armature, this, timelineData); + this._boneBlendTimelines.push(timeline); + break; + } + default: + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + if (bone._boneData.type === 0 /* Bone */) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + else { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); + timeline.init(this._armature, this, null); + this._boneBlendTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + for (var k in boneTimelines) { // Remove bone timelines. + for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { + var timeline = _h[_g]; + var index = this._boneTimelines.indexOf(timeline); + if (index >= 0) { + this._boneTimelines.splice(index, 1); + timeline.returnToPool(); + } + index = this._boneBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._boneBlendTimelines.splice(index, 1); + timeline.returnToPool(); + } + } + } + } + { // Update slot timelines. + var slotTimelines = {}; + var ffdFlags = []; + // Create slot timelines map. + for (var _j = 0, _k = this._slotTimelines; _j < _k.length; _j++) { + var timeline = _k[_j]; + var timelineName = timeline.target.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _l = 0, _m = this._slotBlendTimelines; _l < _m.length; _l++) { + var timeline = _m[_l]; + var timelineName = timeline.target.target.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + // + for (var _o = 0, _p = this._armature.getSlots(); _o < _p.length; _o++) { + var slot = _p[_o]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + if (timelineName in slotTimelines) { // Remove slot timeline from map. + delete slotTimelines[timelineName]; + } + else { // Create new slot timeline. + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + var timelineDatas = this._animationData.getSlotTimelines(timelineName); + if (timelineDatas !== null) { + for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { + var timelineData = timelineDatas_3[_q]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 23 /* SlotZIndex */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); + timeline.init(this._armature, this, timelineData); + this._slotBlendTimelines.push(timeline); + break; + } + case 21 /* SlotColor */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotDeform */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); + timeline.init(this._armature, this, timelineData); + if (timeline.target !== null) { + this._slotBlendTimelines.push(timeline); + ffdFlags.push(timeline.geometryOffset); + } + else { + timeline.returnToPool(); + } + break; + } + case 24 /* SlotAlpha */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); + timeline.init(this._armature, this, timelineData); + this._slotBlendTimelines.push(timeline); + break; + } + default: + break; + } + } + } + if (this.resetToPose) { // Pose timeline. + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayFrame = slot.getDisplayFrameAt(i); + if (displayFrame.deformVertices.length === 0) { + continue; + } + var geometryData = displayFrame.getGeometryData(); + if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.geometryOffset = geometryData.offset; // + timeline.displayFrame = displayFrame; // + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); + timeline.init(this._armature, this, null); + this._slotBlendTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { // Remove slot timelines. + for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { + var timeline = _s[_r]; + var index = this._slotTimelines.indexOf(timeline); + if (index >= 0) { + this._slotTimelines.splice(index, 1); + timeline.returnToPool(); + } + index = this._slotBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._slotBlendTimelines.splice(index, 1); + timeline.returnToPool(); + } + } + } + } + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { // Fade start event. + this._subFadeState = 0; + var eventActive = this._parent === null && this.actionEnabled; + if (eventActive) { + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + if (passedTime < 0.0) { + passedTime = -passedTime; + } + this._fadeTime += passedTime; + if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. + this._subFadeState = 1; + this._fadeProgress = isFadeOut ? 0.0 : 1.0; + } + else if (this._fadeTime > 0.0) { // Fading. + this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); + } + else { // Before fade. + this._fadeProgress = isFadeOut ? 1.0 : 0.0; + } + if (this._subFadeState > 0) { // Fade complete event. + if (!isFadeOut) { + this._playheadState |= 1; // x1 + this._fadeState = 0; + } + var eventActive = this._parent === null && this.actionEnabled; + if (eventActive) { + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + }; + /** + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationData = animationData; + // + this.resetToPose = animationConfig.resetToPose; + this.additive = animationConfig.additive; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.blendType = animationData.blendType; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + // + this._weight = animationConfig.weight; + if (animationConfig.pauseFadeIn) { + this._playheadState = 2; // 10 + } + else { + this._playheadState = 3; // 11 + } + if (animationConfig.duration < 0.0) { + this._position = 0.0; + this._duration = this._animationData.duration; + if (animationConfig.position !== 0.0) { + if (this.timeScale >= 0.0) { + this._time = animationConfig.position; + } + else { + this._time = animationConfig.position - this._duration; + } + } + else { + this._time = 0.0; + } + } + else { + this._position = animationConfig.position; + this._duration = animationConfig.duration; + this._time = 0.0; + } + if (this.timeScale < 0.0 && this._time === 0.0) { + this._time = -0.000001; // Turn to end. + } + if (this.fadeTotalTime <= 0.0) { + this._fadeProgress = 0.999999; // Make different. + } + if (animationConfig.boneMask.length > 0) { + this._boneMask.length = animationConfig.boneMask.length; + for (var i = 0, l = this._boneMask.length; i < l; ++i) { + this._boneMask[i] = animationConfig.boneMask[i]; + } + } + this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); + this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); + this._actionTimeline.currentTime = this._time; + if (this._actionTimeline.currentTime < 0.0) { + this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; + } + if (this._animationData.zOrderTimeline !== null) { + this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); + } + }; + /** + * @internal + */ + AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { + // Update fade time. + if (this._fadeState !== 0 || this._subFadeState !== 0) { + this._advanceFadeTime(passedTime); + } + // Update time. + if (this._playheadState === 3) { // 11 + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + this._time += passedTime; + } + // Update timeline. + if (this._timelineDirty !== 0) { + if (this._timelineDirty === 2) { + this._updateTimelines(); + } + this._timelineDirty = 0; + this._updateBoneAndSlotTimelines(); + } + var isBlendDirty = this._fadeState !== 0 || this._subFadeState === 0; + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this._weight * this._fadeProgress; + if (this._parent !== null) { + this._weightResult *= this._parent._weightResult; + } + if (this._actionTimeline.playState <= 0) { // Update main timeline. + this._actionTimeline.update(time); + } + if (this._weight === 0.0) { + return; + } + if (isCacheEnabled) { // Cache time internval. + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { // Update zOrder timeline. + this._zOrderTimeline.update(time); + } + if (isCacheEnabled) { // Update cache. + var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint + if (this._armature._cacheFrameIndex === cacheFrameIndex) { // Same cache. + isUpdateTimeline = false; + isUpdateBoneTimeline = false; + } + else { + this._armature._cacheFrameIndex = cacheFrameIndex; + if (this._animationData.cachedFrames[cacheFrameIndex]) { // Cached. + isUpdateBoneTimeline = false; + } + else { // Cache. + this._animationData.cachedFrames[cacheFrameIndex] = true; + } + } + } + if (isUpdateTimeline) { + var isBlend = false; + var prevTarget = null; // + if (isUpdateBoneTimeline) { + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (timeline.target !== prevTarget) { + var blendState = timeline.target; + isBlend = blendState.update(this); + prevTarget = blendState; + if (blendState.dirty === 1) { + var pose = blendState.target.animationPose; + pose.x = 0.0; + pose.y = 0.0; + pose.rotation = 0.0; + pose.skew = 0.0; + pose.scaleX = 1.0; + pose.scaleY = 1.0; + } + } + if (isBlend) { + timeline.blend(isBlendDirty); + } + } + } + for (var i = 0, l = this._boneBlendTimelines.length; i < l; ++i) { + var timeline = this._boneBlendTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (timeline.target.update(this)) { + timeline.blend(isBlendDirty); + } + } + if (this.displayControl) { + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (timeline.playState <= 0) { + var slot = timeline.target; + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + timeline.update(time); + } + } + } + } + for (var i = 0, l = this._slotBlendTimelines.length; i < l; ++i) { + var timeline = this._slotBlendTimelines[i]; + if (timeline.playState <= 0) { + var blendState = timeline.target; + timeline.update(time); + if (blendState.update(this)) { + timeline.blend(isBlendDirty); + } + } + } + for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { + var timeline = this._constraintTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + } + if (this._animationTimelines.length > 0) { + var dL = 100.0; + var dR = 100.0; + var leftState = null; + var rightState = null; + for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { + var timeline = this._animationTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (this.blendType === 1 /* E1D */) { // TODO + var animationState = timeline.target; + var d = this.parameterX - animationState.positionX; + if (d >= 0.0) { + if (d < dL) { + dL = d; + leftState = animationState; + } + } + else { + if (-d < dR) { + dR = -d; + rightState = animationState; + } + } + } + } + if (leftState !== null) { + if (this._activeChildA !== leftState) { + if (this._activeChildA !== null) { + this._activeChildA.weight = 0.0; + } + this._activeChildA = leftState; + this._activeChildA.activeTimeline(); + } + if (this._activeChildB !== rightState) { + if (this._activeChildB !== null) { + this._activeChildB.weight = 0.0; + } + this._activeChildB = rightState; + } + leftState.weight = dR / (dL + dR); + if (rightState) { + rightState.weight = 1.0 - leftState.weight; + } + } + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + if (this._poseTimelines.length > 0) { // Remove pose timelines. + for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var index = this._boneTimelines.indexOf(timeline); + if (index >= 0) { + this._boneTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._boneBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._boneBlendTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._slotTimelines.indexOf(timeline); + if (index >= 0) { + this._slotTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._slotBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._slotBlendTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._constraintTimelines.indexOf(timeline); + if (index >= 0) { + this._constraintTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + } + this._poseTimelines.length = 0; + } + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { // Auto fade out. + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { + if (pausePlayhead === void 0) { pausePlayhead = true; } + if (fadeOutTime < 0.0) { + fadeOutTime = 0.0; + } + if (pausePlayhead) { + this._playheadState &= 2; // x0 + } + if (this._fadeState > 0) { + if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { // If the animation is already in fade out, the new fade out will be ignored. + return; + } + } + else { + this._fadeState = 1; + this._subFadeState = -1; + if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { + this._fadeProgress = 0.000001; // Modify fade progress to different value. + } + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.fadeOut(); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.fadeOut(); + } + for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.fadeOut(); + } + for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.fadeOut(); + } + for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { + var timeline = _l[_k]; + timeline.fadeOut(); + // + var animaitonState = timeline.target; + animaitonState.fadeOut(999999.0, true); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * - Check if a specific bone mask is included. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (boneName) { + return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; + }; + /** + * - Add a specific bone mask. + * @param boneName - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (boneName, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(boneName); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(boneName) < 0) { // Add mixing + this._boneMask.push(boneName); + } + if (recursive) { // Add recursive mixing. + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + this._timelineDirty = 1; + }; + /** + * - Remove the mask of a specific bone. + * @param boneName - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (boneName, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(boneName); + if (index >= 0) { // Remove mixing. + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(boneName); + if (currentBone !== null) { + var bones = this._armature.getBones(); + if (this._boneMask.length > 0) { // Remove recursive mixing. + for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { + var bone = bones_1[_i]; + var index_1 = this._boneMask.indexOf(bone.name); + if (index_1 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_1, 1); + } + } + } + else { // Add unrecursive mixing. + for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { + var bone = bones_2[_a]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + } + } + this._timelineDirty = 1; + }; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = 1; + }; + /** + * @private + */ + AnimationState.prototype.addState = function (animationState, timelineDatas) { + if (timelineDatas === void 0) { timelineDatas = null; } + if (timelineDatas !== null) { + for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { + var timelineData = timelineDatas_4[_i]; + switch (timelineData.type) { + case 40 /* AnimationProgress */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + if (this.blendType !== 0 /* None */) { + var animaitonTimelineData = timelineData; + animationState.positionX = animaitonTimelineData.x; + animationState.positionY = animaitonTimelineData.y; + animationState.weight = 0.0; + } + animationState._parent = this; + this.resetToPose = false; + break; + } + case 41 /* AnimationWeight */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + break; + } + case 42 /* AnimationParameter */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + break; + } + default: + break; + } + } + } + if (animationState._parent === null) { + animationState._parent = this; + } + }; + /** + * @internal + */ + AnimationState.prototype.activeTimeline = function () { + for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.dirty = true; + timeline.currentTime = -1.0; + } + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isCompleted", { + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentTime; + }, + set: function (value) { + var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); + if (value < 0 || this._duration < value) { + value = (value % this._duration) + currentPlayTimes * this._duration; + if (value < 0) { + value += this._duration; + } + } + if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && + value === this._duration && this._parent === null) { + value = this._duration - 0.000001; // + } + if (this._time === value) { + return; + } + this._time = value; + this._actionTimeline.setCurrentTime(this._time); + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.playState = -1; + } + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.playState = -1; + } + for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.playState = -1; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "weight", { + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + get: function () { + return this._weight; + }, + set: function (value) { + if (this._weight === value) { + return; + } + this._weight = value; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.dirty = true; + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.dirty = true; + } + for (var _d = 0, _e = this._slotBlendTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.dirty = true; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "animationData", { + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; + /** + * @internal + */ + var BlendState = /** @class */ (function (_super) { + __extends(BlendState, _super); + function BlendState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BlendState.toString = function () { + return "[class dragonBones.BlendState]"; + }; + BlendState.prototype._onClear = function () { + this.reset(); + this.target = null; + }; + BlendState.prototype.update = function (animationState) { + var animationLayer = animationState.layer; + var animationWeight = animationState._weightResult; + if (this.dirty > 0) { + if (this.leftWeight > 0.0) { + if (this.layer !== animationLayer) { + if (this.layerWeight >= this.leftWeight) { + this.dirty++; + this.layer = animationLayer; + this.leftWeight = 0.0; + this.blendWeight = 0.0; + return false; + } + this.layer = animationLayer; + this.leftWeight -= this.layerWeight; + this.layerWeight = 0.0; + } + animationWeight *= this.leftWeight; + this.dirty++; + this.blendWeight = animationWeight; + this.layerWeight += this.blendWeight; + return true; + } + return false; + } + this.dirty++; + this.layer = animationLayer; + this.leftWeight = 1.0; + this.blendWeight = animationWeight; + this.layerWeight = animationWeight; + return true; + }; + BlendState.prototype.reset = function () { + this.dirty = 0; + this.layer = 0; + this.leftWeight = 0.0; + this.layerWeight = 0.0; + this.blendWeight = 0.0; + }; + BlendState.BONE_TRANSFORM = "boneTransform"; + BlendState.BONE_ALPHA = "boneAlpha"; + BlendState.SURFACE = "surface"; + BlendState.SLOT_DEFORM = "slotDeform"; + BlendState.SLOT_ALPHA = "slotAlpha"; + BlendState.SLOT_Z_INDEX = "slotZIndex"; + return BlendState; + }(dragonBones.BaseObject)); + dragonBones.BlendState = BlendState; +})(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) { + /** + * @internal + */ + var TimelineState = /** @class */ (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.dirty = false; + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this.target = null; + this._isTween = false; + this._valueOffset = 0; + this._frameValueOffset = 0; + this._frameOffset = 0; + this._frameRate = 0; + this._frameCount = 0; + this._frameIndex = -1; + this._frameRateR = 0.0; + this._position = 0.0; + this._duration = 0.0; + this._timeScale = 1.0; + this._timeOffset = 0.0; + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._valueArray = null; // + this._timelineArray = null; // + this._frameIndices = null; // + }; + TimelineState.prototype._setCurrentTime = function (passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._actionTimeline !== null && this._frameCount <= 1) { // No frame or only one frame. + this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; + this.currentPlayTimes = 1; + this.currentTime = this._actionTimeline.currentTime; + } + else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { // Action timeline or has scale and offset. + var playTimes = this._animationState.playTimes; + var totalTime = playTimes * this._duration; + passedTime *= this._timeScale; + if (this._timeOffset !== 0.0) { + passedTime += this._timeOffset * this._animationData.duration; + } + if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { + if (this.playState <= 0 && this._animationState._playheadState === 3) { + this.playState = 1; + } + this.currentPlayTimes = playTimes; + if (passedTime < 0.0) { + this.currentTime = 0.0; + } + else { + this.currentTime = this.playState === 1 ? this._duration + 0.000001 : this._duration; // Precision problem + } + } + else { + if (this.playState !== 0 && this._animationState._playheadState === 3) { + this.playState = 0; + } + if (passedTime < 0.0) { + passedTime = -passedTime; + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = this._duration - (passedTime % this._duration); + } + else { + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = passedTime % this._duration; + } + } + this.currentTime += this._position; + } + else { // Multi frames. + this.playState = this._actionTimeline.playState; + this.currentPlayTimes = this._actionTimeline.currentPlayTimes; + this.currentTime = this._actionTimeline.currentTime; + } + if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { + return false; + } + // Clear frame flag when timeline start or loopComplete. + if ((prevState < 0 && this.playState !== prevState) || + (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { + this._frameIndex = -1; + } + return true; + }; + TimelineState.prototype.init = function (armature, animationState, timelineData) { + this._armature = armature; + this._animationState = animationState; + this._timelineData = timelineData; + this._actionTimeline = this._animationState._actionTimeline; + if (this === this._actionTimeline) { + this._actionTimeline = null; // + } + this._animationData = this._animationState.animationData; + // + this._frameRate = this._animationData.parent.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. + this._frameArray = dragonBonesData.frameArray; + this._timelineArray = dragonBonesData.timelineArray; + this._frameIndices = dragonBonesData.frameIndices; + // + this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; + this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; + this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; + } + }; + TimelineState.prototype.fadeOut = function () { + this.dirty = false; + }; + TimelineState.prototype.update = function (passedTime) { + if (this._setCurrentTime(passedTime)) { + if (this._frameCount > 1) { + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { + this._frameIndex = frameIndex; + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; + this._onArriveAtFrame(); + } + } + else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (this._timelineData !== null) { // May be pose timeline. + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; + } + this._onArriveAtFrame(); + } + if (this._isTween || this.dirty) { + this._onUpdateFrame(); + } + } + }; + TimelineState.prototype.blend = function (_isDirty) { + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + */ + var TweenTimelineState = /** @class */ (function (_super) { + __extends(TweenTimelineState, _super); + function TweenTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { + var value = progress; + switch (tweenType) { + case 3 /* QuadIn */: + value = Math.pow(progress, 2.0); + break; + case 4 /* QuadOut */: + value = 1.0 - Math.pow(1.0 - progress, 2.0); + break; + case 5 /* QuadInOut */: + value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); + break; + } + return (value - progress) * easing + progress; + }; + TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { + if (progress <= 0.0) { + return 0.0; + } + else if (progress >= 1.0) { + return 1.0; + } + var isOmited = count > 0; + var segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = 0.0; + var toValue = 0.0; + if (isOmited) { + fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; + } + else { + fromValue = samples[offset + valueIndex - 1]; + toValue = samples[offset + valueIndex]; + } + return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; + }; + TweenTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._tweenType = 0 /* None */; + this._curveCount = 0; + this._framePosition = 0.0; + this._frameDurationR = 0.0; + this._tweenEasing = 0.0; + this._tweenProgress = 0.0; + this._valueScale = 1.0; + }; + TweenTimelineState.prototype._onArriveAtFrame = function () { + if (this._frameCount > 1 && + (this._frameIndex !== this._frameCount - 1 || + this._animationState.playTimes === 0 || + this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { + this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; + this._isTween = this._tweenType !== 0 /* None */; + if (this._isTween) { + if (this._tweenType === 2 /* Curve */) { + this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; + } + else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { + this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; + } + } + else { + this.dirty = true; + } + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; + if (this._frameIndex === this._frameCount - 1) { + this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); + } + else { + var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; + var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; + if (frameDuration > 0) { + this._frameDurationR = 1.0 / frameDuration; + } + else { + this._frameDurationR = 0.0; + } + } + } + else { + this.dirty = true; + this._isTween = false; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._isTween) { + this.dirty = true; + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + if (this._tweenType === 2 /* Curve */) { + this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); + } + else if (this._tweenType !== 1 /* Line */) { + this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); + } + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + */ + var SingleValueTimelineState = /** @class */ (function (_super) { + __extends(SingleValueTimelineState, _super); + function SingleValueTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SingleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._current = 0.0; + this._difference = 0.0; + this._result = 0.0; + }; + SingleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + 1; + if (valueScale === 1.0) { + this._current = valueArray[valueOffset]; + this._difference = valueArray[nextValueOffset] - this._current; + } + else { + this._current = valueArray[valueOffset] * valueScale; + this._difference = valueArray[nextValueOffset] * valueScale - this._current; + } + } + else { + this._result = valueArray[valueOffset] * valueScale; + } + } + else { + this._result = 0.0; + } + }; + SingleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._result = this._current + this._difference * this._tweenProgress; + } + }; + return SingleValueTimelineState; + }(TweenTimelineState)); + dragonBones.SingleValueTimelineState = SingleValueTimelineState; + /** + * @internal + */ + var DoubleValueTimelineState = /** @class */ (function (_super) { + __extends(DoubleValueTimelineState, _super); + function DoubleValueTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + DoubleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._currentA = 0.0; + this._currentB = 0.0; + this._differenceA = 0.0; + this._differenceB = 0.0; + this._resultA = 0.0; + this._resultB = 0.0; + }; + DoubleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + 2; + if (valueScale === 1.0) { + this._currentA = valueArray[valueOffset]; + this._currentB = valueArray[valueOffset + 1]; + this._differenceA = valueArray[nextValueOffset] - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; + } + else { + this._currentA = valueArray[valueOffset] * valueScale; + this._currentB = valueArray[valueOffset + 1] * valueScale; + this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; + } + } + else { + this._resultA = valueArray[valueOffset] * valueScale; + this._resultB = valueArray[valueOffset + 1] * valueScale; + } + } + else { + this._resultA = 0.0; + this._resultB = 0.0; + } + }; + DoubleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._resultA = this._currentA + this._differenceA * this._tweenProgress; + this._resultB = this._currentB + this._differenceB * this._tweenProgress; + } + }; + return DoubleValueTimelineState; + }(TweenTimelineState)); + dragonBones.DoubleValueTimelineState = DoubleValueTimelineState; + /** + * @internal + */ + var MutilpleValueTimelineState = /** @class */ (function (_super) { + __extends(MutilpleValueTimelineState, _super); + function MutilpleValueTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._rd = []; + return _this; + } + MutilpleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._valueCount = 0; + this._rd.length = 0; + }; + MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + var valueCount = this._valueCount; + var rd = this._rd; + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + valueCount; + if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; + } + } + } + else if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i]; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] * valueScale; + } + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = 0.0; + } + } + }; + MutilpleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + var valueCount = this._valueCount; + var valueScale = this._valueScale; + var tweenProgress = this._tweenProgress; + var valueArray = this._valueArray; + var rd = this._rd; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; + if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; + } + } + } + }; + return MutilpleValueTimelineState; + }(TweenTimelineState)); + dragonBones.MutilpleValueTimelineState = MutilpleValueTimelineState; +})(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) { + /** + * @internal + */ + var ActionTimelineState = /** @class */ (function (_super) { + __extends(ActionTimelineState, _super); + function ActionTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + ActionTimelineState.toString = function () { + return "[class dragonBones.ActionTimelineState]"; + }; + ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { + var eventDispatcher = this._armature.eventDispatcher; + if (this._animationState.actionEnabled) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; + var actionCount = this._frameArray[frameOffset + 1]; + var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._bufferAction(eventObject, true); + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + } + }; + ActionTimelineState.prototype._onArriveAtFrame = function () { }; + ActionTimelineState.prototype._onUpdateFrame = function () { }; + ActionTimelineState.prototype.update = function (passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._setCurrentTime(passedTime)) { + var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; + var eventDispatcher = this._armature.eventDispatcher; + if (prevState < 0) { + if (this.playState !== prevState) { + if (this._animationState.displayControl && this._animationState.resetToPose) { // Reset zorder to pose. + this._armature._sortZOrder(null, 0); + } + prevPlayTimes = this.currentPlayTimes; + if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = dragonBones.EventObject.START; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + else { + return; + } + } + var isReverse = this._animationState.timeScale < 0.0; + var loopCompleteEvent = null; + var completeEvent = null; + if (eventActive && this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; + loopCompleteEvent.armature = this._armature; + loopCompleteEvent.animationState = this._animationState; + } + if (this.playState > 0) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { + completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + completeEvent.type = dragonBones.EventObject.COMPLETE; + completeEvent.armature = this._armature; + completeEvent.animationState = this._animationState; + } + } + } + if (this._frameCount > 1) { + var timelineData = this._timelineData; + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { // Arrive at frame. + var crossedFrameIndex = this._frameIndex; + this._frameIndex = frameIndex; + if (this._timelineArray !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; + if (isReverse) { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (crossedFrameIndex === frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + while (crossedFrameIndex >= 0) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && + framePosition <= this._position + this._duration) { // Support interval play. + this._onCrossFrame(crossedFrameIndex); + } + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event after first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex > 0) { + crossedFrameIndex--; + } + else { + crossedFrameIndex = this._frameCount - 1; + } + if (crossedFrameIndex === frameIndex) { + break; + } + } + } + else { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { // Crossed. + if (crossedFrameIndex > 0) { + crossedFrameIndex--; + } + else { + crossedFrameIndex = this._frameCount - 1; + } + } + else if (crossedFrameIndex === frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + while (crossedFrameIndex >= 0) { + if (crossedFrameIndex < this._frameCount - 1) { + crossedFrameIndex++; + } + else { + crossedFrameIndex = 0; + } + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && + framePosition <= this._position + this._duration // + ) { // Support interval play. + this._onCrossFrame(crossedFrameIndex); + } + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event before first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex === frameIndex) { + break; + } + } + } + } + } + } + else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (this._timelineData !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; + // Arrive at frame. + var framePosition = this._frameArray[this._frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { + this._onCrossFrame(this._frameIndex); + } + } + else if (this._position <= framePosition) { // Loop complete. + if (!isReverse && loopCompleteEvent !== null) { // Add loop complete event before first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + this._onCrossFrame(this._frameIndex); + } + } + } + if (loopCompleteEvent !== null) { + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + } + if (completeEvent !== null) { + this._armature._dragonBones.bufferEvent(completeEvent); + } + } + }; + ActionTimelineState.prototype.setCurrentTime = function (value) { + this._setCurrentTime(value); + this._frameIndex = -1; + }; + return ActionTimelineState; + }(dragonBones.TimelineState)); + dragonBones.ActionTimelineState = ActionTimelineState; + /** + * @internal + */ + var ZOrderTimelineState = /** @class */ (function (_super) { + __extends(ZOrderTimelineState, _super); + function ZOrderTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + ZOrderTimelineState.toString = function () { + return "[class dragonBones.ZOrderTimelineState]"; + }; + ZOrderTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var count = this._frameArray[this._frameOffset + 1]; + if (count > 0) { + this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); + } + else { + this._armature._sortZOrder(null, 0); + } + } + }; + ZOrderTimelineState.prototype._onUpdateFrame = function () { }; + return ZOrderTimelineState; + }(dragonBones.TimelineState)); + dragonBones.ZOrderTimelineState = ZOrderTimelineState; + /** + * @internal + */ + var BoneAllTimelineState = /** @class */ (function (_super) { + __extends(BoneAllTimelineState, _super); + function BoneAllTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneAllTimelineState.toString = function () { + return "[class dragonBones.BoneAllTimelineState]"; + }; + BoneAllTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._isTween && this._frameIndex === this._frameCount - 1) { + this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); + this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); + } + if (this._timelineData === null) { // Pose. + this._rd[4] = 1.0; + this._rd[5] = 1.0; + } + }; + BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = 6; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + this.dirty = false; + this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); + this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); + }; + BoneAllTimelineState.prototype.blend = function (isDirty) { + var valueScale = this._armature.armatureData.scale; + var rd = this._rd; + // + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.x += rd[0] * blendWeight * valueScale; + result.y += rd[1] * blendWeight * valueScale; + result.rotation += rd[2] * blendWeight; + result.skew += rd[3] * blendWeight; + result.scaleX += (rd[4] - 1.0) * blendWeight; + result.scaleY += (rd[5] - 1.0) * blendWeight; + } + else { + result.x = rd[0] * blendWeight * valueScale; + result.y = rd[1] * blendWeight * valueScale; + result.rotation = rd[2] * blendWeight; + result.skew = rd[3] * blendWeight; + result.scaleX = (rd[4] - 1.0) * blendWeight + 1.0; // + result.scaleY = (rd[5] - 1.0) * blendWeight + 1.0; // + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneAllTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + */ + var BoneTranslateTimelineState = /** @class */ (function (_super) { + __extends(BoneTranslateTimelineState, _super); + function BoneTranslateTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTranslateTimelineState.toString = function () { + return "[class dragonBones.BoneTranslateTimelineState]"; + }; + BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneTranslateTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.x += this._resultA * blendWeight; + result.y += this._resultB * blendWeight; + } + else if (blendWeight !== 1.0) { + result.x = this._resultA * blendWeight; + result.y = this._resultB * blendWeight; + } + else { + result.x = this._resultA; + result.y = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneTranslateTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; + /** + * @internal + */ + var BoneRotateTimelineState = /** @class */ (function (_super) { + __extends(BoneRotateTimelineState, _super); + function BoneRotateTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneRotateTimelineState.toString = function () { + return "[class dragonBones.BoneRotateTimelineState]"; + }; + BoneRotateTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._isTween && this._frameIndex === this._frameCount - 1) { + this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); + this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); + } + }; + BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneRotateTimelineState.prototype.fadeOut = function () { + this.dirty = false; + this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); + this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); + }; + BoneRotateTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.rotation += this._resultA * blendWeight; + result.skew += this._resultB * blendWeight; + } + else if (blendWeight !== 1.0) { + result.rotation = this._resultA * blendWeight; + result.skew = this._resultB * blendWeight; + } + else { + result.rotation = this._resultA; + result.skew = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneRotateTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; + /** + * @internal + */ + var BoneScaleTimelineState = /** @class */ (function (_super) { + __extends(BoneScaleTimelineState, _super); + function BoneScaleTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneScaleTimelineState.toString = function () { + return "[class dragonBones.BoneScaleTimelineState]"; + }; + BoneScaleTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + this._resultA = 1.0; + this._resultB = 1.0; + } + }; + BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneScaleTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.scaleX += (this._resultA - 1.0) * blendWeight; + result.scaleY += (this._resultB - 1.0) * blendWeight; + } + else if (blendWeight !== 1.0) { + result.scaleX = (this._resultA - 1.0) * blendWeight + 1.0; + result.scaleY = (this._resultB - 1.0) * blendWeight + 1.0; + } + else { + result.scaleX = this._resultA; + result.scaleY = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneScaleTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; + /** + * @internal + */ + var SurfaceTimelineState = /** @class */ (function (_super) { + __extends(SurfaceTimelineState, _super); + function SurfaceTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SurfaceTimelineState.toString = function () { + return "[class dragonBones.SurfaceTimelineState]"; + }; + SurfaceTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._deformCount = 0; + this._deformOffset = 0; + this._sameValueOffset = 0; + }; + SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; + var frameIntArray = dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = dragonBonesData.frameFloatArray; + this._rd.length = this._valueCount * 2; + } + else { + this._deformCount = this.target.target._deformVertices.length; + } + }; + SurfaceTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var surface = blendState.target; + var blendWeight = blendState.blendWeight; + var result = surface._deformVertices; + var valueArray = this._valueArray; + if (valueArray !== null) { + var valueCount = this._valueCount; + var deformOffset = this._deformOffset; + var sameValueOffset = this._sameValueOffset; + var rd = this._rd; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0.0; + if (i < deformOffset) { + value = valueArray[sameValueOffset + i]; + } + else if (i < deformOffset + valueCount) { + value = rd[i - deformOffset]; + } + else { + value = valueArray[sameValueOffset + i - valueCount]; + } + if (blendState.dirty > 1) { + result[i] += value * blendWeight; + } + else { + result[i] = value * blendWeight; + } + } + } + else if (blendState.dirty === 1) { + for (var i = 0; i < this._deformCount; ++i) { + result[i] = 0.0; + } + } + if (isDirty || this.dirty) { + this.dirty = false; + surface._transformDirty = true; + } + }; + return SurfaceTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.SurfaceTimelineState = SurfaceTimelineState; + /** + * @internal + */ + var AlphaTimelineState = /** @class */ (function (_super) { + __extends(AlphaTimelineState, _super); + function AlphaTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AlphaTimelineState.toString = function () { + return "[class dragonBones.AlphaTimelineState]"; + }; + AlphaTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + this._result = 1.0; + } + }; + AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.01; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + AlphaTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var alphaTarget = blendState.target; + var blendWeight = blendState.blendWeight; + if (blendState.dirty > 1) { + alphaTarget._alpha += this._result * blendWeight; + if (alphaTarget._alpha > 1.0) { + alphaTarget._alpha = 1.0; + } + } + else { + alphaTarget._alpha = this._result * blendWeight; + } + if (isDirty || this.dirty) { + this.dirty = false; + this._armature._alphaDirty = true; + } + }; + return AlphaTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AlphaTimelineState = AlphaTimelineState; + /** + * @internal + */ + var SlotDisplayTimelineState = /** @class */ (function (_super) { + __extends(SlotDisplayTimelineState, _super); + function SlotDisplayTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDisplayTimelineState.toString = function () { + return "[class dragonBones.SlotDisplayTimelineState]"; + }; + SlotDisplayTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var slot = this.target; + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; + if (slot.displayIndex !== displayIndex) { + slot._setDisplayIndex(displayIndex, true); + } + } + }; + SlotDisplayTimelineState.prototype._onUpdateFrame = function () { + }; + return SlotDisplayTimelineState; + }(dragonBones.TimelineState)); + dragonBones.SlotDisplayTimelineState = SlotDisplayTimelineState; + /** + * @internal + */ + var SlotColorTimelineState = /** @class */ (function (_super) { + __extends(SlotColorTimelineState, _super); + function SlotColorTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; + _this._difference = [0, 0, 0, 0, 0, 0, 0, 0]; + _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; + return _this; + } + SlotColorTimelineState.toString = function () { + return "[class dragonBones.SlotColorTimelineState]"; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; + var colorArray = dragonBonesData.colorArray; + var frameIntArray = dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; + var colorOffset = frameIntArray[valueOffset]; + if (colorOffset < 0) { + colorOffset += 65536; // Fixed out of bounds bug. + } + if (this._isTween) { + this._current[0] = colorArray[colorOffset++]; + this._current[1] = colorArray[colorOffset++]; + this._current[2] = colorArray[colorOffset++]; + this._current[3] = colorArray[colorOffset++]; + this._current[4] = colorArray[colorOffset++]; + this._current[5] = colorArray[colorOffset++]; + this._current[6] = colorArray[colorOffset++]; + this._current[7] = colorArray[colorOffset++]; + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1]; + } + if (colorOffset < 0) { + colorOffset += 65536; // Fixed out of bounds bug. + } + this._difference[0] = colorArray[colorOffset++] - this._current[0]; + this._difference[1] = colorArray[colorOffset++] - this._current[1]; + this._difference[2] = colorArray[colorOffset++] - this._current[2]; + this._difference[3] = colorArray[colorOffset++] - this._current[3]; + this._difference[4] = colorArray[colorOffset++] - this._current[4]; + this._difference[5] = colorArray[colorOffset++] - this._current[5]; + this._difference[6] = colorArray[colorOffset++] - this._current[6]; + this._difference[7] = colorArray[colorOffset++] - this._current[7]; + } + else { + this._result[0] = colorArray[colorOffset++] * 0.01; + this._result[1] = colorArray[colorOffset++] * 0.01; + this._result[2] = colorArray[colorOffset++] * 0.01; + this._result[3] = colorArray[colorOffset++] * 0.01; + this._result[4] = colorArray[colorOffset++]; + this._result[5] = colorArray[colorOffset++]; + this._result[6] = colorArray[colorOffset++]; + this._result[7] = colorArray[colorOffset++]; + } + } + else { // Pose. + var slot = this.target; + var color = slot.slotData.color; + this._result[0] = color.alphaMultiplier; + this._result[1] = color.redMultiplier; + this._result[2] = color.greenMultiplier; + this._result[3] = color.blueMultiplier; + this._result[4] = color.alphaOffset; + this._result[5] = color.redOffset; + this._result[6] = color.greenOffset; + this._result[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; + } + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._isTween = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._isTween || this.dirty) { + var slot = this.target; + var result = slot._colorTransform; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + if (result.alphaMultiplier !== this._result[0] || + result.redMultiplier !== this._result[1] || + result.greenMultiplier !== this._result[2] || + result.blueMultiplier !== this._result[3] || + result.alphaOffset !== this._result[4] || + result.redOffset !== this._result[5] || + result.greenOffset !== this._result[6] || + result.blueOffset !== this._result[7]) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); + result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; + result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; + result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; + result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; + result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; + result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; + result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; + result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; + slot._colorDirty = true; + } + } + else if (this.dirty) { + this.dirty = false; + if (result.alphaMultiplier !== this._result[0] || + result.redMultiplier !== this._result[1] || + result.greenMultiplier !== this._result[2] || + result.blueMultiplier !== this._result[3] || + result.alphaOffset !== this._result[4] || + result.redOffset !== this._result[5] || + result.greenOffset !== this._result[6] || + result.blueOffset !== this._result[7]) { + result.alphaMultiplier = this._result[0]; + result.redMultiplier = this._result[1]; + result.greenMultiplier = this._result[2]; + result.blueMultiplier = this._result[3]; + result.alphaOffset = this._result[4]; + result.redOffset = this._result[5]; + result.greenOffset = this._result[6]; + result.blueOffset = this._result[7]; + slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.TweenTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + */ + var SlotZIndexTimelineState = /** @class */ (function (_super) { + __extends(SlotZIndexTimelineState, _super); + function SlotZIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotZIndexTimelineState.toString = function () { + return "[class dragonBones.SlotZIndexTimelineState]"; + }; + SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + var blendState = this.target; + var slot = blendState.target; + this._result = slot.slotData.zIndex; + } + }; + SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + SlotZIndexTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var slot = blendState.target; + var blendWeight = blendState.blendWeight; + if (blendState.dirty > 1) { + slot._zIndex += this._result * blendWeight; + } + else { + slot._zIndex = this._result * blendWeight; + } + if (isDirty || this.dirty) { + this.dirty = false; + this._armature._zIndexDirty = true; + } + }; + return SlotZIndexTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.SlotZIndexTimelineState = SlotZIndexTimelineState; + /** + * @internal + */ + var DeformTimelineState = /** @class */ (function (_super) { + __extends(DeformTimelineState, _super); + function DeformTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + DeformTimelineState.toString = function () { + return "[class dragonBones.DeformTimelineState]"; + }; + DeformTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.geometryOffset = 0; + this.displayFrame = null; + this._deformCount = 0; + this._deformOffset = 0; + this._sameValueOffset = 0; + }; + DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + var dragonBonesData = this._animationData.parent.parent; + var frameIntArray = dragonBonesData.frameIntArray; + var slot = this.target.target; + this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; + if (this.geometryOffset < 0) { + this.geometryOffset += 65536; // Fixed out of bounds bug. + } + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayFrame = slot.getDisplayFrameAt(i); + var geometryData = displayFrame.getGeometryData(); + if (geometryData === null) { + continue; + } + if (geometryData.offset === this.geometryOffset) { + this.displayFrame = displayFrame; + this.displayFrame.updateDeformVertices(); + break; + } + } + if (this.displayFrame === null) { + this.returnToPool(); // + return; + } + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = dragonBonesData.frameFloatArray; + this._rd.length = this._valueCount * 2; + } + else { + this._deformCount = this.displayFrame.deformVertices.length; + } + }; + DeformTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var slot = blendState.target; + var blendWeight = blendState.blendWeight; + var result = this.displayFrame.deformVertices; + var valueArray = this._valueArray; + if (valueArray !== null) { + var valueCount = this._valueCount; + var deformOffset = this._deformOffset; + var sameValueOffset = this._sameValueOffset; + var rd = this._rd; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0.0; + if (i < deformOffset) { + value = valueArray[sameValueOffset + i]; + } + else if (i < deformOffset + valueCount) { + value = rd[i - deformOffset]; + } + else { + value = valueArray[sameValueOffset + i - valueCount]; + } + if (blendState.dirty > 1) { + result[i] += value * blendWeight; + } + else { + result[i] = value * blendWeight; + } + } + } + else if (blendState.dirty === 1) { + for (var i = 0; i < this._deformCount; ++i) { + result[i] = 0.0; + } + } + if (isDirty || this.dirty) { + this.dirty = false; + if (slot._geometryData === this.displayFrame.getGeometryData()) { + slot._verticesDirty = true; + } + } + }; + return DeformTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.DeformTimelineState = DeformTimelineState; + /** + * @internal + */ + var IKConstraintTimelineState = /** @class */ (function (_super) { + __extends(IKConstraintTimelineState, _super); + function IKConstraintTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraintTimelineState.toString = function () { + return "[class dragonBones.IKConstraintTimelineState]"; + }; + IKConstraintTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var ikConstraint = this.target; + if (this._timelineData !== null) { + ikConstraint._bendPositive = this._currentA > 0.0; + ikConstraint._weight = this._currentB; + } + else { + var ikConstraintData = ikConstraint._constraintData; + ikConstraint._bendPositive = ikConstraintData.bendPositive; + ikConstraint._weight = ikConstraintData.weight; + } + ikConstraint.invalidUpdate(); + this.dirty = false; + }; + IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.01; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return IKConstraintTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; + /** + * @internal + */ + var AnimationProgressTimelineState = /** @class */ (function (_super) { + __extends(AnimationProgressTimelineState, _super); + function AnimationProgressTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationProgressTimelineState.toString = function () { + return "[class dragonBones.AnimationProgressTimelineState]"; + }; + AnimationProgressTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.currentTime = this._result * animationState.totalTime; + } + this.dirty = false; + }; + AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationProgressTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AnimationProgressTimelineState = AnimationProgressTimelineState; + /** + * @internal + */ + var AnimationWeightTimelineState = /** @class */ (function (_super) { + __extends(AnimationWeightTimelineState, _super); + function AnimationWeightTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationWeightTimelineState.toString = function () { + return "[class dragonBones.AnimationWeightTimelineState]"; + }; + AnimationWeightTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.weight = this._result; + } + this.dirty = false; + }; + AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationWeightTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AnimationWeightTimelineState = AnimationWeightTimelineState; + /** + * @internal + */ + var AnimationParametersTimelineState = /** @class */ (function (_super) { + __extends(AnimationParametersTimelineState, _super); + function AnimationParametersTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationParametersTimelineState.toString = function () { + return "[class dragonBones.AnimationParametersTimelineState]"; + }; + AnimationParametersTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.parameterX = this._resultA; + animationState.parameterY = this._resultB; + } + this.dirty = false; + }; + AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationParametersTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.AnimationParametersTimelineState = AnimationParametersTimelineState; +})(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 properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = /** @class */ (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @internal + * @private + */ + EventObject.actionDataToInstance = function (data, instance, armature) { + if (data.type === 0 /* Play */) { + instance.type = EventObject.FRAME_EVENT; + } + else { + instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; + } + instance.name = data.name; + instance.armature = armature; + instance.actionData = data; + instance.data = data.data; + if (data.bone !== null) { + instance.bone = armature.getBone(data.bone.name); + } + if (data.slot !== null) { + instance.slot = armature.getSlot(data.slot.name); + } + }; + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + EventObject.prototype._onClear = function () { + this.time = 0.0; + this.type = ""; + this.name = ""; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.actionData = null; + this.data = null; + }; + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(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 DataParser = /** @class */ (function () { + function DataParser() { + } + DataParser._getArmatureType = function (value) { + switch (value.toLowerCase()) { + case "stage": + return 2 /* Stage */; + case "armature": + return 0 /* Armature */; + case "movieclip": + return 1 /* MovieClip */; + default: + return 0 /* Armature */; + } + }; + DataParser._getBoneType = function (value) { + switch (value.toLowerCase()) { + case "bone": + return 0 /* Bone */; + case "surface": + return 1 /* Surface */; + default: + return 0 /* Bone */; + } + }; + DataParser._getPositionMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "percent": + return 1 /* Percent */; + case "fixed": + return 0 /* Fixed */; + default: + return 1 /* Percent */; + } + }; + DataParser._getSpacingMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "length": + return 0 /* Length */; + case "percent": + return 2 /* Percent */; + case "fixed": + return 1 /* Fixed */; + default: + return 0 /* Length */; + } + }; + DataParser._getRotateMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "tangent": + return 0 /* Tangent */; + case "chain": + return 1 /* Chain */; + case "chainscale": + return 2 /* ChainScale */; + default: + return 0 /* Tangent */; + } + }; + DataParser._getDisplayType = function (value) { + switch (value.toLowerCase()) { + case "image": + return 0 /* Image */; + case "mesh": + return 2 /* Mesh */; + case "armature": + return 1 /* Armature */; + case "boundingbox": + return 3 /* BoundingBox */; + case "path": + return 4 /* Path */; + default: + return 0 /* Image */; + } + }; + DataParser._getBoundingBoxType = function (value) { + switch (value.toLowerCase()) { + case "rectangle": + return 0 /* Rectangle */; + case "ellipse": + return 1 /* Ellipse */; + case "polygon": + return 2 /* Polygon */; + default: + return 0 /* Rectangle */; + } + }; + DataParser._getBlendMode = function (value) { + switch (value.toLowerCase()) { + case "normal": + return 0 /* Normal */; + case "add": + return 1 /* Add */; + case "alpha": + return 2 /* Alpha */; + case "darken": + return 3 /* Darken */; + case "difference": + return 4 /* Difference */; + case "erase": + return 5 /* Erase */; + case "hardlight": + return 6 /* HardLight */; + case "invert": + return 7 /* Invert */; + case "layer": + return 8 /* Layer */; + case "lighten": + return 9 /* Lighten */; + case "multiply": + return 10 /* Multiply */; + case "overlay": + return 11 /* Overlay */; + case "screen": + return 12 /* Screen */; + case "subtract": + return 13 /* Subtract */; + default: + return 0 /* Normal */; + } + }; + DataParser._getAnimationBlendType = function (value) { + switch (value.toLowerCase()) { + case "none": + return 0 /* None */; + case "1d": + return 1 /* E1D */; + default: + return 0 /* None */; + } + }; + DataParser._getActionType = function (value) { + switch (value.toLowerCase()) { + case "play": + return 0 /* Play */; + case "frame": + return 10 /* Frame */; + case "sound": + return 11 /* Sound */; + default: + return 0 /* Play */; + } + }; + DataParser.DATA_VERSION_2_3 = "2.3"; + DataParser.DATA_VERSION_3_0 = "3.0"; + DataParser.DATA_VERSION_4_0 = "4.0"; + DataParser.DATA_VERSION_4_5 = "4.5"; + DataParser.DATA_VERSION_5_0 = "5.0"; + DataParser.DATA_VERSION_5_5 = "5.5"; + DataParser.DATA_VERSION_5_6 = "5.6"; + DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_6; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0, + DataParser.DATA_VERSION_5_5, + DataParser.DATA_VERSION_5_6 + ]; + DataParser.TEXTURE_ATLAS = "textureAtlas"; + DataParser.SUB_TEXTURE = "SubTexture"; + DataParser.FORMAT = "format"; + DataParser.IMAGE_PATH = "imagePath"; + DataParser.WIDTH = "width"; + DataParser.HEIGHT = "height"; + DataParser.ROTATED = "rotated"; + DataParser.FRAME_X = "frameX"; + DataParser.FRAME_Y = "frameY"; + DataParser.FRAME_WIDTH = "frameWidth"; + DataParser.FRAME_HEIGHT = "frameHeight"; + DataParser.DRADON_BONES = "dragonBones"; + DataParser.USER_DATA = "userData"; + DataParser.ARMATURE = "armature"; + DataParser.CANVAS = "canvas"; + DataParser.BONE = "bone"; + DataParser.SURFACE = "surface"; + DataParser.SLOT = "slot"; + DataParser.CONSTRAINT = "constraint"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.FRAME = "frame"; + DataParser.IK = "ik"; + DataParser.PATH_CONSTRAINT = "path"; + DataParser.ANIMATION = "animation"; + DataParser.TIMELINE = "timeline"; + DataParser.FFD = "ffd"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.DISPLAY_FRAME = "displayFrame"; + DataParser.COLOR_FRAME = "colorFrame"; + DataParser.DEFAULT_ACTIONS = "defaultActions"; + DataParser.ACTIONS = "actions"; + DataParser.EVENTS = "events"; + DataParser.INTS = "ints"; + DataParser.FLOATS = "floats"; + DataParser.STRINGS = "strings"; + DataParser.TRANSFORM = "transform"; + DataParser.PIVOT = "pivot"; + DataParser.AABB = "aabb"; + DataParser.COLOR = "color"; + DataParser.VERSION = "version"; + DataParser.COMPATIBLE_VERSION = "compatibleVersion"; + DataParser.FRAME_RATE = "frameRate"; + DataParser.TYPE = "type"; + DataParser.SUB_TYPE = "subType"; + DataParser.NAME = "name"; + DataParser.PARENT = "parent"; + DataParser.TARGET = "target"; + DataParser.STAGE = "stage"; + DataParser.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + DataParser.Z_ORDER = "zOrder"; + DataParser.Z_INDEX = "zIndex"; + DataParser.BLEND_MODE = "blendMode"; + DataParser.INHERIT_TRANSLATION = "inheritTranslation"; + DataParser.INHERIT_ROTATION = "inheritRotation"; + DataParser.INHERIT_SCALE = "inheritScale"; + DataParser.INHERIT_REFLECTION = "inheritReflection"; + DataParser.INHERIT_ANIMATION = "inheritAnimation"; + DataParser.INHERIT_DEFORM = "inheritDeform"; + DataParser.SEGMENT_X = "segmentX"; + DataParser.SEGMENT_Y = "segmentY"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.BLEND_TYPE = "blendType"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + DataParser.CLOCK_WISE = "clockwise"; + DataParser.CURVE = "curve"; + DataParser.SOUND = "sound"; + DataParser.EVENT = "event"; + DataParser.ACTION = "action"; + DataParser.X = "x"; + DataParser.Y = "y"; + DataParser.SKEW_X = "skX"; + DataParser.SKEW_Y = "skY"; + DataParser.SCALE_X = "scX"; + DataParser.SCALE_Y = "scY"; + DataParser.VALUE = "value"; + DataParser.ROTATE = "rotate"; + DataParser.SKEW = "skew"; + DataParser.ALPHA = "alpha"; + DataParser.ALPHA_OFFSET = "aO"; + DataParser.RED_OFFSET = "rO"; + DataParser.GREEN_OFFSET = "gO"; + DataParser.BLUE_OFFSET = "bO"; + DataParser.ALPHA_MULTIPLIER = "aM"; + DataParser.RED_MULTIPLIER = "rM"; + DataParser.GREEN_MULTIPLIER = "gM"; + DataParser.BLUE_MULTIPLIER = "bM"; + DataParser.UVS = "uvs"; + DataParser.VERTICES = "vertices"; + DataParser.TRIANGLES = "triangles"; + DataParser.WEIGHTS = "weights"; + DataParser.SLOT_POSE = "slotPose"; + DataParser.BONE_POSE = "bonePose"; + DataParser.BONES = "bones"; + DataParser.POSITION_MODE = "positionMode"; + DataParser.SPACING_MODE = "spacingMode"; + DataParser.ROTATE_MODE = "rotateMode"; + DataParser.SPACING = "spacing"; + DataParser.ROTATE_OFFSET = "rotateOffset"; + DataParser.ROTATE_MIX = "rotateMix"; + DataParser.TRANSLATE_MIX = "translateMix"; + DataParser.TARGET_DISPLAY = "targetDisplay"; + DataParser.CLOSED = "closed"; + DataParser.CONSTANT_SPEED = "constantSpeed"; + DataParser.VERTEX_COUNT = "vertexCount"; + DataParser.LENGTHS = "lengths"; + DataParser.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(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 ObjectDataParser = /** @class */ (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._geometry = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._frameValueType = 0 /* Step */; + _this._defaultColorOffset = -1; + _this._prevClockwise = 0; + _this._prevRotation = 0.0; + _this._frameDefaultValue = 0.0; + _this._frameValueScale = 1.0; + _this._helpMatrixA = new dragonBones.Matrix(); + _this._helpMatrixB = new dragonBones.Matrix(); + _this._helpTransform = new dragonBones.Transform(); + _this._helpColorTransform = new dragonBones.ColorTransform(); + _this._helpPoint = new dragonBones.Point(); + _this._helpArray = []; + _this._intArray = []; + _this._floatArray = []; + _this._frameIntArray = []; + _this._frameFloatArray = []; + _this._frameArray = []; + _this._timelineArray = []; + _this._colorArray = []; + _this._cacheRawMeshes = []; + _this._cacheMeshes = []; + _this._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._cacheBones = {}; + _this._slotChildActions = {}; + return _this; + } + ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "boolean") { + return value; + } + else if (type === "string") { + switch (value) { + case "0": + case "NaN": + case "": + case "false": + case "null": + case "undefined": + return false; + default: + return true; + } + } + else { + return !!value; + } + } + return defaultValue; + }; + ObjectDataParser._getNumber = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + if (value === null || value === "NaN") { + return defaultValue; + } + return +value || 0; + } + return defaultValue; + }; + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + return value; + } + return String(value); + } + return defaultValue; + }; + ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { + var l_t = 1.0 - t; + var powA = l_t * l_t; + var powB = t * t; + var kA = l_t * powA; + var kB = 3.0 * t * powA; + var kC = 3.0 * l_t * powB; + var kD = t * powB; + result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; + result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; + }; + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + if (curveCount % 3 === 1) { + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); // float + while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; + var x1 = isInCurve ? curve[stepIndex] : 0.0; + var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; + var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; + var lower = 0.0; + var higher = 1.0; + while (higher - lower > 0.0001) { + var percentage = (higher + lower) * 0.5; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0.0) { + lower = percentage; + } + else { + higher = percentage; + } + } + samples[i] = this._helpPoint.y; + } + return true; + } + else { + var stepIndex = 0; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); // float + while (curve[stepIndex + 6] < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + var x1 = curve[stepIndex]; + var y1 = curve[stepIndex + 1]; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = curve[stepIndex + 6]; + var y4 = curve[stepIndex + 7]; + var lower = 0.0; + var higher = 1.0; + while (higher - lower > 0.0001) { + var percentage = (higher + lower) * 0.5; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0.0) { + lower = percentage; + } + else { + higher = percentage; + } + } + samples[i] = this._helpPoint.y; + } + return false; + } + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (dragonBones.DataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (dragonBones.DataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (dragonBones.DataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (dragonBones.DataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (dragonBones.DataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = this._armature.actions.length; + var actions = this._parseActionData(rawData, type, bone, slot); + var frameIndex = 0; + var frame = null; + for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + this._armature.addAction(action, false); + } + if (this._actionFrames.length === 0) { // First frame. + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { // Get same frame. + var eachFrame = _b[_a]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + else if (eachFrame.frameStart > frameStart) { + break; + } + frameIndex++; + } + if (frame === null) { // Create and cache frame. + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.splice(frameIndex, 0, frame); + } + for (var i = 0; i < actions.length; ++i) { // Cache action offsets. + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { // Data error. + armature.frameRate = 24; + } + this._armature = armature; + if (dragonBones.DataParser.CANVAS in rawData) { + var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (dragonBones.DataParser.COLOR in rawCanvas) { + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; + canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; + canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; + canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; + armature.canvas = canvas; + } + if (dragonBones.DataParser.AABB in rawData) { + var rawAABB = rawData[dragonBones.DataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; + } + if (dragonBones.DataParser.BONE in rawData) { + var rawBones = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); + var bone = this._parseBone(rawBone); + if (parentName.length > 0) { // Get bone parent. + var parent_1 = armature.getBone(parentName); + if (parent_1 !== null) { + bone.parent = parent_1; + } + else { // Cache. + if (!(parentName in this._cacheBones)) { + this._cacheBones[parentName] = []; + } + this._cacheBones[parentName].push(bone); + } + } + if (bone.name in this._cacheBones) { + for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { + var child = _b[_a]; + child.parent = bone; + } + delete this._cacheBones[bone.name]; + } + armature.addBone(bone); + this._rawBones.push(bone); // Cache raw bones sort. + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawIKS = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + var constraint = this._parseIKConstraint(rawIK); + if (constraint) { + armature.addConstraint(constraint); + } + } + } + armature.sortBones(); + if (dragonBones.DataParser.SLOT in rawData) { + var zOrder = 0; + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot, zOrder++)); + } + } + if (dragonBones.DataParser.SKIN in rawData) { + var rawSkins = rawData[dragonBones.DataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { + var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; + for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { + var rawPath = rawPaths_1[_f]; + var constraint = this._parsePathConstraint(rawPath); + if (constraint) { + armature.addConstraint(constraint); + } + } + } + for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { // Link mesh. + var rawData_1 = this._cacheRawMeshes[i]; + var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); + if (shareName.length === 0) { + continue; + } + var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + if (skinName.length === 0) { // + skinName = dragonBones.DataParser.DEFAULT_NAME; + } + var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; + if (shareMesh === null) { + continue; // Error. + } + var mesh = this._cacheMeshes[i]; + mesh.geometry.shareFrom(shareMesh.geometry); + } + if (dragonBones.DataParser.ANIMATION in rawData) { + var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; + for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { + var rawAnimation = rawAnimations_1[_g]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); + for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { + var action = actions_3[_h]; + armature.addAction(action, true); + if (action.type === 0 /* Play */) { // Set default animation from default action. + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + } + } + } + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { + var action = actions_4[_j]; + armature.addAction(action, false); + } + } + // Clear helper. + this._rawBones.length = 0; + this._cacheRawMeshes.length = 0; + this._cacheMeshes.length = 0; + this._armature = null; + for (var k in this._weightSlotPose) { + delete this._weightSlotPose[k]; + } + for (var k in this._weightBonePoses) { + delete this._weightBonePoses[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + return armature; + }; + ObjectDataParser.prototype._parseBone = function (rawData) { + var type = 0 /* Bone */; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); + } + if (type === 0 /* Bone */) { + var scale = this._armature.scale; + var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; + bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + if (dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); + } + return bone; + } + var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); + surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); + surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); + this._parseGeometry(rawData, surface.geometry); + return surface; + }; + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); + if (bone === null) { + return null; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (target === null) { + return null; + } + var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); + constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 0 /* IK */; + constraint.target = target; + if (chain > 0 && bone.parent !== null) { + constraint.root = bone.parent; + constraint.bone = bone; + } + else { + constraint.root = bone; + constraint.bone = null; + } + return constraint; + }; + ObjectDataParser.prototype._parsePathConstraint = function (rawData) { + var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (target === null) { + return null; + } + var defaultSkin = this._armature.defaultSkin; + if (defaultSkin === null) { + return null; + } + //TODO + var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); + if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { + return null; + } + var bones = rawData[dragonBones.DataParser.BONES]; + if (bones === null || bones.length === 0) { + return null; + } + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 1 /* Path */; + constraint.pathSlot = target; + constraint.pathDisplayData = targetDisplay; + constraint.target = target.parent; + constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); + constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); + constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); + constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); + constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); + constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); + constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); + constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); + // + for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { + var boneName = bones_3[_i]; + var bone = this._armature.getBone(boneName); + if (bone !== null) { + constraint.AddBone(bone); + if (constraint.root === null) { + constraint.root = bone; + } + } + } + return constraint; + }; + ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + slot.zOrder = zOrder; + slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); + slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // + if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { + slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); + } + if (dragonBones.DataParser.COLOR in rawData) { + slot.color = dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); + } + else { + slot.color = dragonBones.SlotData.DEFAULT_COLOR; + } + if (dragonBones.DataParser.ACTIONS in rawData) { + this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + } + return slot; + }; + ObjectDataParser.prototype._parseSkin = function (rawData) { + var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = dragonBones.DataParser.DEFAULT_NAME; + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + this._skin = skin; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (dragonBones.DataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + if (rawDisplay) { + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + else { + skin.addDisplay(slotName, null); + } + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); + var type = 0 /* Image */; + var display = null; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: { + var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + } + case 1 /* Armature */: { + var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { + var action = actions_5[_i]; + armatureDisplay.addAction(action); + } + } + else if (this._slot.name in this._slotChildActions) { + var displays = this._skin.getDisplays(this._slot.name); + if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { + for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { + var action = _b[_a]; + armatureDisplay.addAction(action); + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + } + case 2 /* Mesh */: { + var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + if (dragonBones.DataParser.SHARE in rawData) { + meshDisplay.geometry.data = this._data; + this._cacheRawMeshes.push(rawData); + this._cacheMeshes.push(meshDisplay); + } + else { + this._parseMesh(rawData, meshDisplay); + } + break; + } + case 3 /* BoundingBox */: { + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + case 4 /* Path */: { + var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; + var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); + pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); + pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); + pathDisplay.name = name; + pathDisplay.path = path.length > 0 ? path : name; + pathDisplay.curveLengths.length = rawCurveLengths.length; + for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { + pathDisplay.curveLengths[i] = rawCurveLengths[i]; + } + this._parsePath(rawData, pathDisplay); + break; + } + } + if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); + } + return display; + }; + ObjectDataParser.prototype._parsePath = function (rawData, display) { + this._parseGeometry(rawData, display.geometry); + }; + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (dragonBones.DataParser.PIVOT in rawData) { + var rawPivot = rawData[dragonBones.DataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + this._parseGeometry(rawData, mesh.geometry); + if (dragonBones.DataParser.WEIGHTS in rawData) { // Cache pose data. + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; + this._weightSlotPose[meshName] = rawSlotPose; + this._weightBonePoses[meshName] = rawBonePoses; + } + }; + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { + type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + if (dragonBones.DataParser.VERTICES in rawData) { + var scale = this._armature.scale; + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertices = polygonBoundingBox.vertices; + vertices.length = rawVertices.length; + for (var i = 0, l = rawVertices.length; i < l; i += 2) { + var x = rawVertices[i] * scale; + var y = rawVertices[i + 1] * scale; + vertices[i] = x; + vertices[i + 1] = y; + // AABB. + if (i === 0) { + polygonBoundingBox.x = x; + polygonBoundingBox.y = y; + polygonBoundingBox.width = x; + polygonBoundingBox.height = y; + } + else { + if (x < polygonBoundingBox.x) { + polygonBoundingBox.x = x; + } + else if (x > polygonBoundingBox.width) { + polygonBoundingBox.width = x; + } + if (y < polygonBoundingBox.y) { + polygonBoundingBox.y = y; + } + else if (y > polygonBoundingBox.height) { + polygonBoundingBox.height = y; + } + } + } + polygonBoundingBox.width -= polygonBoundingBox.x; + polygonBoundingBox.height -= polygonBoundingBox.y; + } + else { + console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); + } + return polygonBoundingBox; + }; + ObjectDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.blendType = dragonBones.DataParser._getAnimationBlendType(ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); + animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; // float + animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.DataParser.DEFAULT_NAME; + } + animation.frameIntOffset = this._frameIntArray.length; + animation.frameFloatOffset = this._frameFloatArray.length; + animation.frameOffset = this._frameArray.length; + this._animation = animation; + if (dragonBones.DataParser.FRAME in rawData) { + var rawFrames = rawData[dragonBones.DataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount > 0) { + for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { + var rawFrame = rawFrames[i]; + this._parseActionDataInFrame(rawFrame, frameStart, null, null); + frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + } + if (dragonBones.DataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, 0 /* Step */, 0, this._parseZOrderFrame); + } + if (dragonBones.DataParser.BONE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.FFD in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + if (skinName.length === 0) { // + skinName = dragonBones.DataParser.DEFAULT_NAME; + } + this._slot = this._armature.getSlot(slotName); + this._mesh = this._armature.getMesh(skinName, slotName, displayName); + if (this._slot === null || this._mesh === null) { + continue; + } + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, 2 /* Float */, 0, this._parseSlotDeformFrame); + if (timeline !== null) { + this._animation.addSlotTimeline(slotName, timeline); + } + this._slot = null; // + this._mesh = null; // + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { + var rawTimeline = rawTimelines_4[_c]; + var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var constraint = this._armature.getConstraint(constraintName); + if (constraint === null) { + continue; + } + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, 1 /* Int */, 2, this._parseIKConstraintFrame); + if (timeline !== null) { + this._animation.addConstraintTimeline(constraintName, timeline); + } + } + } + if (this._actionFrames.length > 0) { + this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, 0 /* Step */, 0, this._parseActionFrame); + this._actionFrames.length = 0; + } + if (dragonBones.DataParser.TIMELINE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; + for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { + var rawTimeline = rawTimelines_5[_d]; + var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = null; + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 20 /* SlotDisplay */: // TODO + case 23 /* SlotZIndex */: + case 60 /* BoneAlpha */: + case 24 /* SlotAlpha */: + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + if (timelineType === 20 /* SlotDisplay */) { + this._frameValueType = 0 /* Step */; + this._frameValueScale = 1.0; + } + else { + this._frameValueType = 1 /* Int */; + if (timelineType === 23 /* SlotZIndex */) { + this._frameValueScale = 1.0; + } + else if (timelineType === 40 /* AnimationProgress */ || + timelineType === 41 /* AnimationWeight */) { + this._frameValueScale = 10000.0; + } + else { + this._frameValueScale = 100.0; + } + } + if (timelineType === 60 /* BoneAlpha */ || + timelineType === 24 /* SlotAlpha */ || + timelineType === 41 /* AnimationWeight */) { + this._frameDefaultValue = 1.0; + } + else { + this._frameDefaultValue = 0.0; + } + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); + var animaitonTimeline = timeline; + animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 1, this._parseSingleValueFrame, timeline); + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 30 /* IKConstraint */: + case 42 /* AnimationParameter */: + if (timelineType === 30 /* IKConstraint */ || + timelineType === 42 /* AnimationParameter */) { + this._frameValueType = 1 /* Int */; + if (timelineType === 42 /* AnimationParameter */) { + this._frameValueScale = 10000.0; + } + else { + this._frameValueScale = 100.0; + } + } + else { + if (timelineType === 12 /* BoneRotate */) { + this._frameValueScale = dragonBones.Transform.DEG_RAD; + } + else { + this._frameValueScale = 1.0; + } + this._frameValueType = 2 /* Float */; + } + if (timelineType === 13 /* BoneScale */ || + timelineType === 30 /* IKConstraint */) { + this._frameDefaultValue = 1.0; + } + else { + this._frameDefaultValue = 0.0; + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 2, this._parseDoubleValueFrame); + break; + case 1 /* ZOrder */: + // TODO + break; + case 50 /* Surface */: { + var surface = this._armature.getBone(timelineName); + if (surface === null) { + continue; + } + this._geometry = surface.geometry; + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); + this._geometry = null; // + break; + } + case 22 /* SlotDeform */: { + this._geometry = null; // + for (var skinName in this._armature.skins) { + var skin = this._armature.skins[skinName]; + for (var slontName in skin.displays) { + var displays = skin.displays[slontName]; + for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { + var display = displays_1[_e]; + if (display !== null && display.name === timelineName) { + this._geometry = display.geometry; + break; + } + } + } + } + if (this._geometry === null) { + continue; + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); + this._geometry = null; // + break; + } + case 21 /* SlotColor */: + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 1 /* Int */, 1, this._parseSlotColorFrame); + break; + } + if (timeline !== null) { + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 1 /* ZOrder */: + // TODO + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 50 /* Surface */: + case 60 /* BoneAlpha */: + this._animation.addBoneTimeline(timelineName, timeline); + break; + case 20 /* SlotDisplay */: + case 21 /* SlotColor */: + case 22 /* SlotDeform */: + case 23 /* SlotZIndex */: + case 24 /* SlotAlpha */: + this._animation.addSlotTimeline(timelineName, timeline); + break; + case 30 /* IKConstraint */: + this._animation.addConstraintTimeline(timelineName, timeline); + break; + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + case 42 /* AnimationParameter */: + this._animation.addAnimationTimeline(timelineName, timeline); + break; + } + } + } + } + this._animation = null; // + return animation; + }; + ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, timelineType, frameValueType, frameValueCount, frameParser, timeline) { + if (timeline === void 0) { timeline = null; } + if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { + rawFrames = rawData[framesKey]; + } + if (rawFrames === null) { + return null; + } + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var frameIntArrayLength = this._frameIntArray.length; + var frameFloatArrayLength = this._frameFloatArray.length; + var timelineOffset = this._timelineArray.length; + if (timeline === null) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + } + timeline.type = timelineType; + timeline.offset = timelineOffset; + this._frameValueType = frameValueType; + this._timeline = timeline; + this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + if (rawData !== null) { + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); + } + else { + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; + } + this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; + switch (this._frameValueType) { + case 0 /* Step */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; + break; + case 1 /* Int */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + break; + case 2 /* Float */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + break; + } + if (keyFrameCount === 1) { // Only one frame. + timeline.frameIndicesOffset = -1; + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + var frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var rawFrame = rawFrames[iK]; + frameStart = i; // frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + if (rawFrame instanceof ActionFrame) { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + else { + frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; // + return timeline; + }; + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { + this._frameDefaultValue = 0.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, 2 /* Float */, 2, this._parseDoubleValueFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.ROTATE_FRAME in rawData) { + this._frameDefaultValue = 0.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, 2 /* Float */, 2, this._parseBoneRotateFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.SCALE_FRAME in rawData) { + this._frameDefaultValue = 1.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, 2 /* Float */, 2, this._parseBoneScaleFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, 2 /* Float */, 6, this._parseBoneAllFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + this._bone = null; // + this._slot = null; // + }; + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (slot === null) { + return; + } + var displayTimeline = null; + var colorTimeline = null; + this._slot = slot; + if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { + displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); + } + else { + displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); + } + if (dragonBones.DataParser.COLOR_FRAME in rawData) { + colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); + } + else { + colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); + } + if (displayTimeline !== null) { + this._animation.addSlotTimeline(slot.name, displayTimeline); + } + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot.name, colorTimeline); + } + this._slot = null; // + }; + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { + // tslint:disable-next-line:no-unused-expression + rawData; + // tslint:disable-next-line:no-unused-expression + frameCount; + var frameOffset = this._frameArray.length; + this._frameArray.length += 1; + this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (frameCount > 0) { + if (dragonBones.DataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); + this._frameArray.length += 1 + 1 + this._helpArray.length; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited ? sampleCount : -sampleCount; + for (var i = 0; i < sampleCount; ++i) { + this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (dragonBones.DataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { + var frameOffset = 0; + switch (this._frameValueType) { + case 0: { + frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue); + break; + } + case 1: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale); + break; + } + case 2: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 1; + this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale; + break; + } + } + return frameOffset; + }; + ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { + var frameOffset = 0; + switch (this._frameValueType) { + case 0: { + frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 2; + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue); + this._frameArray[frameOffset + 2] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue); + break; + } + case 1: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale); + this._frameIntArray[frameValueOffset + 1] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale); + break; + } + case 2: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale; + this._frameFloatArray[frameValueOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale; + break; + } + } + return frameOffset; + }; + ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { + // tslint:disable-next-line:no-unused-expression + frameCount; + var frameOffset = this._frameArray.length; + var actionCount = frame.actions.length; + this._frameArray.length += 1 + 1 + actionCount; + this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { // Action offsets. + this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (dragonBones.DataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; + if (rawZOrder.length > 0) { + var slotCount = this._armature.sortedSlots.length; + var unchanged = new Array(slotCount - rawZOrder.length / 2); + var zOrders = new Array(slotCount); + for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { + unchanged[i_1] = 0; + } + for (var i_2 = 0; i_2 < slotCount; ++i_2) { + zOrders[i_2] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { + var slotIndex = rawZOrder[i_3]; + var zOrderOffset = rawZOrder[i_3 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + var index = originalIndex + zOrderOffset; + zOrders[index] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + this._frameArray.length += 1 + slotCount; + this._frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; + } + else { + this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; + } + } + return frameOffset; + } + } + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { + this._helpTransform.identity(); + if (dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevClockwise === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + // + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 6; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { + // Modify rotation. + var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; + if (frameStart !== 0) { + if (this._prevClockwise === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); + this._prevRotation = rotation; + // + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + if (dragonBones.DataParser.VALUE in rawData) { + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); + } + else { + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + } + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var colorOffset = -1; + if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { + var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; + for (var k in rawColor) { // Detects the presence of color. + // tslint:disable-next-line:no-unused-expression + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = this._colorArray.length; + this._colorArray.length += 8; + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defaultColorOffset < 0) { + this._defaultColorOffset = colorOffset = this._colorArray.length; + this._colorArray.length += 8; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + } + colorOffset = this._defaultColorOffset; + } + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; + var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; + var weight = this._mesh.geometry.weight; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (weight !== null) { + var rawSlotPose = this._weightSlotPose[meshName]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + this._frameFloatArray.length += weight.count * 2; + iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; + } + else { + this._frameFloatArray.length += vertexCount * 2; + } + for (var i = 0; i < vertexCount * 2; i += 2) { + if (rawVertices === null) { // Fill 0. + x = 0.0; + y = 0.0; + } + else { + if (i < offset || i - offset >= rawVertices.length) { + x = 0.0; + } + else { + x = rawVertices[i - offset]; + } + if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { + y = 0.0; + } + else { + y = rawVertices[i + 1 - offset]; + } + } + if (weight !== null) { // If mesh is skinned, transform point by bone bind pose. + var rawBonePoses = this._weightBonePoses[meshName]; + var vertexBoneCount = this._intArray[iB++]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var boneIndex = this._intArray[iB++]; + this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; + this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; + this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { + var actions = new Array(); + if (typeof rawData === "string") { + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + actions.push(action); + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { + var rawAction = rawData_2[_i]; + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); + } + else { + if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { + action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); + } + if (dragonBones.DataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (dragonBones.DataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + var userData = null; + if (dragonBones.DataParser.INTS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[dragonBones.DataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + userData.addInt(rawValue); + } + } + if (dragonBones.DataParser.FLOATS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + userData.addFloat(rawValue); + } + } + if (dragonBones.DataParser.STRINGS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + userData.addString(rawValue); + } + } + action.data = userData; + actions.push(action); + } + } + return actions; + }; + ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? + rawData[dragonBones.DataParser.VERTICES] : + (dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null); + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; + var weight = this._geometry.weight; + var x = 0.0; + var y = 0.0; + if (weight !== null) { + // TODO + } + else { + this._frameFloatArray.length += vertexCount * 2; + for (var i = 0; i < vertexCount * 2; i += 2) { + if (rawVertices !== null) { + if (i < offset || i - offset >= rawVertices.length) { + x = 0.0; + } + else { + x = rawVertices[i - offset]; + } + if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { + y = 0.0; + } + else { + y = rawVertices[i + 1 - offset]; + } + } + else { + x = 0.0; + y = 0.0; + } + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; + this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; + if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); + }; + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); + }; + ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = 0; + var geometryOffset = this._intArray.length; + var verticesOffset = this._floatArray.length; + // + geometry.offset = geometryOffset; + geometry.data = this._data; + // + this._intArray.length += 1 + 1 + 1 + 1; + this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; + this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; + this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // + // + this._floatArray.length += vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + this._floatArray[verticesOffset + i] = rawVertices[i]; + } + if (dragonBones.DataParser.TRIANGLES in rawData) { + var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; + triangleCount = Math.floor(rawTriangles.length / 3); // uint + // + this._intArray.length += triangleCount * 3; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; + } + } + // Fill triangle count. + this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; + if (dragonBones.DataParser.UVS in rawData) { + var rawUVs = rawData[dragonBones.DataParser.UVS]; + var uvOffset = verticesOffset + vertexCount * 2; + this._floatArray.length += vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + this._floatArray[uvOffset + i] = rawUVs[i]; + } + } + if (dragonBones.DataParser.WEIGHTS in rawData) { + var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; + var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint + var weightOffset = this._intArray.length; + var floatOffset = this._floatArray.length; + var weightBoneCount = 0; + var sortedBones = this._armature.sortedBones; + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = weightCount; + weight.offset = weightOffset; + this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; + this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; + if (dragonBones.DataParser.BONE_POSE in rawData) { + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + weightBoneIndices.length = weightBoneCount; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + weightBoneIndices[i] = rawBoneIndex; + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += weightCount * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint + var x = this._floatArray[verticesOffset + iD]; + var y = this._floatArray[verticesOffset + iD + 1]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var rawBoneIndex = rawWeights[iW++]; // uint + var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); + this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + this._intArray[iB++] = boneIndex; + this._floatArray[iV++] = rawWeights[iW++]; + this._floatArray[iV++] = this._helpPoint.x; + this._floatArray[iV++] = this._helpPoint.y; + } + } + } + else { + var rawBones = rawData[dragonBones.DataParser.BONES]; + weightBoneCount = rawBones.length; + for (var i = 0; i < weightBoneCount; i++) { + var rawBoneIndex = rawBones[i]; + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += weightCount * 3; + for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { + var vertexBoneCount = rawWeights[iW++]; + this._intArray[iB++] = vertexBoneCount; + for (var j = 0; j < vertexBoneCount; j++) { + var boneIndex = rawWeights[iW++]; + var boneWeight = rawWeights[iW++]; + var x = rawVertices[iV++]; + var y = rawVertices[iV++]; + this._intArray[iB++] = rawBones.indexOf(boneIndex); + this._floatArray[iF++] = boneWeight; + this._floatArray[iF++] = x; + this._floatArray[iF++] = y; + } + } + } + geometry.weight = weight; + } + }; + ObjectDataParser.prototype._parseArray = function (rawData) { + // tslint:disable-next-line:no-unused-expression + rawData; + this._intArray.length = 0; + this._floatArray.length = 0; + this._frameIntArray.length = 0; + this._frameFloatArray.length = 0; + this._frameArray.length = 0; + this._timelineArray.length = 0; + this._colorArray.length = 0; + }; + ObjectDataParser.prototype._modifyArray = function () { + // Align. + if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._intArray.push(0); + } + if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._frameIntArray.push(0); + } + if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._frameArray.push(0); + } + if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { + this._timelineArray.push(0); + } + if ((this._timelineArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._colorArray.push(0); + } + var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; + var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; + var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; + var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; + var l7 = this._colorArray.length * Int16Array.BYTES_PER_ELEMENT; + var lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7; + // + var binary = new ArrayBuffer(lTotal); + var intArray = new Int16Array(binary, 0, this._intArray.length); + var floatArray = new Float32Array(binary, l1, this._floatArray.length); + var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); + var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); + var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); + var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); + var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); + for (var i = 0, l = this._intArray.length; i < l; ++i) { + intArray[i] = this._intArray[i]; + } + for (var i = 0, l = this._floatArray.length; i < l; ++i) { + floatArray[i] = this._floatArray[i]; + } + for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { + frameIntArray[i] = this._frameIntArray[i]; + } + for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { + frameFloatArray[i] = this._frameFloatArray[i]; + } + for (var i = 0, l = this._frameArray.length; i < l; ++i) { + frameArray[i] = this._frameArray[i]; + } + for (var i = 0, l = this._timelineArray.length; i < l; ++i) { + timelineArray[i] = this._timelineArray[i]; + } + for (var i = 0, l = this._colorArray.length; i < l; ++i) { + colorArray[i] = this._colorArray[i]; + } + this._data.binary = binary; + this._data.intArray = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = frameArray; + this._data.timelineArray = timelineArray; + this._data.colorArray = colorArray; + this._defaultColorOffset = -1; + }; + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined, "Data error."); + var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); + if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || + dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { // Data error. + data.frameRate = 24; + } + if (dragonBones.DataParser.ARMATURE in rawData) { + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; + for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { + var rawArmature = rawArmatures_1[_i]; + data.addArmature(this._parseArmature(rawArmature, scale)); + } + if (!this._data.binary) { // DragonBones.webAssembly ? 0 : null; + this._modifyArray(); + } + if (dragonBones.DataParser.STAGE in rawData) { + data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); + } + else if (data.armatureNames.length > 0) { + data.stage = data.getArmature(data.armatureNames[0]); + } + this._data = null; + } + if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; + } + return data; + } + else { + console.assert(false, "Nonsupport data version: " + version + "\n" + + "Please convert DragonBones data to support version.\n" + + "Read more: https://github.com/DragonBones/Tools/"); + } + return null; + }; + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 1.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { + return false; + } + var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; + this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); + if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { + this._rawTextureAtlasIndex = 0; + this._rawTextureAtlases = null; + } + return true; + } + // Texture format. + textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); + textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; + textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); + if (dragonBones.DataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); + textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); + textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); + textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); + textureData.frame.width = frameWidth; + textureData.frame.height = frameHeight; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + /** + * @private + */ + var ActionFrame = /** @class */ (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); + dragonBones.ActionFrame = ActionFrame; +})(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 BinaryDataParser = /** @class */ (function (_super) { + __extends(BinaryDataParser, _super); + function BinaryDataParser() { + return _super !== null && _super.apply(this, arguments) || this; + } + BinaryDataParser.prototype._inRange = function (a, min, max) { + return min <= a && a <= max; + }; + BinaryDataParser.prototype._decodeUTF8 = function (data) { + var EOF_byte = -1; + var EOF_code_point = -1; + var FATAL_POINT = 0xFFFD; + var pos = 0; + var result = ""; + var code_point; + var utf8_code_point = 0; + var utf8_bytes_needed = 0; + var utf8_bytes_seen = 0; + var utf8_lower_boundary = 0; + while (data.length > pos) { + var _byte = data[pos++]; + if (_byte === EOF_byte) { + if (utf8_bytes_needed !== 0) { + code_point = FATAL_POINT; + } + else { + code_point = EOF_code_point; + } + } + else { + if (utf8_bytes_needed === 0) { + if (this._inRange(_byte, 0x00, 0x7F)) { + code_point = _byte; + } + else { + if (this._inRange(_byte, 0xC2, 0xDF)) { + utf8_bytes_needed = 1; + utf8_lower_boundary = 0x80; + utf8_code_point = _byte - 0xC0; + } + else if (this._inRange(_byte, 0xE0, 0xEF)) { + utf8_bytes_needed = 2; + utf8_lower_boundary = 0x800; + utf8_code_point = _byte - 0xE0; + } + else if (this._inRange(_byte, 0xF0, 0xF4)) { + utf8_bytes_needed = 3; + utf8_lower_boundary = 0x10000; + utf8_code_point = _byte - 0xF0; + } + else { + } + utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); + code_point = null; + } + } + else if (!this._inRange(_byte, 0x80, 0xBF)) { + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + pos--; + code_point = _byte; + } + else { + utf8_bytes_seen += 1; + utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + if (utf8_bytes_seen !== utf8_bytes_needed) { + code_point = null; + } + else { + var cp = utf8_code_point; + var lower_boundary = utf8_lower_boundary; + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { + code_point = cp; + } + else { + code_point = _byte; + } + } + } + } + //Decode string + if (code_point !== null && code_point !== EOF_code_point) { + if (code_point <= 0xFFFF) { + if (code_point > 0) + result += String.fromCharCode(code_point); + } + else { + code_point -= 0x10000; + result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); + result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); + } + } + } + return result; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var frameIndicesOffset = 0; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; // + return timeline; + }; + BinaryDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.blendType = dragonBones.DataParser._getAnimationBlendType(dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); + animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; // float + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.DataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.DataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.DataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); + } + if (dragonBones.DataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); + } + if (dragonBones.DataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var bone = this._armature.getBone(k); + if (bone === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addBoneTimeline(bone.name, timeline); + } + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var slot = this._armature.getSlot(k); + if (slot === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addSlotTimeline(slot.name, timeline); + } + } + } + if (dragonBones.DataParser.CONSTRAINT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var constraint = this._armature.getConstraint(k); + if (constraint === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addConstraintTimeline(constraint.name, timeline); + } + } + } + if (dragonBones.DataParser.TIMELINE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; + for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { + var rawTimeline = rawTimelines_6[_i]; + var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); + if (timelineOffset >= 0) { + var timelineType = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = null; + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); + var animaitonTimeline = timeline; + animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); + } + timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 1 /* ZOrder */: + // TODO + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 50 /* Surface */: + case 60 /* BoneAlpha */: + this._animation.addBoneTimeline(timelineName, timeline); + break; + case 20 /* SlotDisplay */: + case 21 /* SlotColor */: + case 22 /* SlotDeform */: + case 23 /* SlotZIndex */: + case 24 /* SlotAlpha */: + this._animation.addSlotTimeline(timelineName, timeline); + break; + case 30 /* IKConstraint */: + this._animation.addConstraintTimeline(timelineName, timeline); + break; + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + case 42 /* AnimationParameter */: + this._animation.addAnimationTimeline(timelineName, timeline); + break; + } + } + } + } + this._animation = null; + return animation; + }; + BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { + geometry.offset = rawData[dragonBones.DataParser.OFFSET]; + geometry.data = this._data; + var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; + if (weightOffset >= 0) { + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; + var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.addBone(this._rawBones[boneIndex]); + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + var weightCount = 0; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; + weightCount += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + weight.count = weightCount; + geometry.weight = weight; + } + }; + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.DataParser.OFFSET]; + var l1 = offsets[1]; + var l2 = offsets[3]; + var l3 = offsets[5]; + var l4 = offsets[7]; + var l5 = offsets[9]; + var l6 = offsets[11]; + var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. + var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); + var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); + var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); + var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); + var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); + var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); + var colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. + this._data.binary = this._binary; + this._data.intArray = this._intArrayBuffer = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = this._frameArrayBuffer = frameArray; + this._data.timelineArray = this._timelineArrayBuffer = timelineArray; + this._data.colorArray = colorArray; + }; + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); + var tag = new Uint8Array(rawData, 0, 8); + if (tag[0] !== "D".charCodeAt(0) || + tag[1] !== "B".charCodeAt(0) || + tag[2] !== "D".charCodeAt(0) || + tag[3] !== "T".charCodeAt(0)) { + console.assert(false, "Nonsupport data."); + return null; + } + var headerLength = new Uint32Array(rawData, 8, 1)[0]; + var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); + var headerString = this._decodeUTF8(headerBytes); + var header = JSON.parse(headerString); + // + this._binaryOffset = 8 + 4 + headerLength; + this._binary = rawData; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(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) { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = /** @class */ (function () { + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * @private + */ + this.autoSearch = false; + this._dragonBonesDataMap = {}; + this._textureAtlasDataMap = {}; + this._dragonBones = null; + this._dataParser = null; + if (BaseFactory._objectParser === null) { + BaseFactory._objectParser = new dragonBones.ObjectDataParser(); + } + if (BaseFactory._binaryParser === null) { + BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); + } + this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; + } + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { + if (textureAtlasName in this._textureAtlasDataMap) { + for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { + var textureAtlasData = _a[_i]; + var textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + if (this.autoSearch) { // Will be search all data, if the autoSearch is true. + for (var k in this._textureAtlasDataMap) { + for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { + var textureAtlasData = _c[_b]; + if (textureAtlasData.autoSearch) { + var textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + } + } + return null; + }; + BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { + var dragonBonesData = null; + var armatureData = null; + if (dragonBonesName.length > 0) { + if (dragonBonesName in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; + armatureData = dragonBonesData.getArmature(armatureName); + } + } + if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { // Will be search all data, if do not give a data name or the autoSearch is true. + for (var k in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[k]; + if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { + armatureData = dragonBonesData.getArmature(armatureName); + if (armatureData !== null) { + dragonBonesName = k; + break; + } + } + } + } + if (armatureData !== null) { + dataPackage.dataName = dragonBonesName; + dataPackage.textureAtlasName = textureAtlasName; + dataPackage.data = dragonBonesData; + dataPackage.armature = armatureData; + dataPackage.skin = null; + if (skinName.length > 0) { + dataPackage.skin = armatureData.getSkin(skinName); + if (dataPackage.skin === null && this.autoSearch) { + for (var k in this._dragonBonesDataMap) { + var skinDragonBonesData = this._dragonBonesDataMap[k]; + var skinArmatureData = skinDragonBonesData.getArmature(skinName); + if (skinArmatureData !== null) { + dataPackage.skin = skinArmatureData.defaultSkin; + break; + } + } + } + } + if (dataPackage.skin === null) { + dataPackage.skin = armatureData.defaultSkin; + } + return true; + } + return false; + }; + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { + var boneData = _a[_i]; + var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); + bone.init(boneData, armature); + } + }; + /** + * @private + */ + BaseFactory.prototype._buildSlots = function (dataPackage, armature) { + var currentSkin = dataPackage.skin; + var defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin === null || defaultSkin === null) { + return; + } + var skinSlots = {}; + for (var k in defaultSkin.displays) { + var displays = defaultSkin.getDisplays(k); + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.getDisplays(k); + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; + var slot = this._buildSlot(dataPackage, slotData, armature); + if (displayDatas !== null) { + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + slot.replaceRawDisplayData(displayData, i); + if (displayData !== null) { + if (dataPackage.textureAtlasName.length > 0) { + var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + slot.replaceTextureData(textureData, i); + } + var display = this._getSlotDisplay(dataPackage, displayData, slot); + slot.replaceDisplay(display, i); + } + else { + slot.replaceDisplay(null); + } + } + } + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { + var constraints = dataPackage.armature.constraints; + for (var k in constraints) { + var constraintData = constraints[k]; + // TODO more constraint type. + switch (constraintData.type) { + case 0 /* IK */: + var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + ikConstraint.init(constraintData, armature); + armature._addConstraint(ikConstraint); + break; + case 1 /* Path */: + var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); + pathConstraint.init(constraintData, armature); + armature._addConstraint(pathConstraint); + break; + default: + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + constraint.init(constraintData, armature); + armature._addConstraint(constraint); + break; + } + } + }; + BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { + return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); + }; + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; + var display = null; + switch (displayData.type) { + case 0 /* Image */: { + var imageDisplayData = displayData; + if (imageDisplayData.texture === null) { + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); + } + display = slot.rawDisplay; + break; + } + case 2 /* Mesh */: { + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + } + case 1 /* Armature */: { + var armatureDisplayData = displayData; + var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); + if (childArmature !== null) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.length > 0) { + for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { + var action = actions_6[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); + eventObject.slot = slot; + slot.armature._bufferAction(eventObject, false); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + case 3 /* BoundingBox */: + break; + default: + break; + } + return display; + }; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 1.0; } + var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; + var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 1.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * - Update texture atlases. + * @param textureAtlases - The texture atlas objects. + * @param name - The texture atlas name. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 更新贴图集对象。 + * @param textureAtlases - 多个贴图集对象。 + * @param name - 贴图集名称。 + * @version DragonBones 5.7 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { + var textureAtlasDatas = this.getTextureAtlasData(name); + if (textureAtlasDatas !== null) { + for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { + if (i < textureAtlases.length) { + this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); + } + } + } + }; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.getDragonBonesData = function (name) { + return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; + }; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.addDragonBonesData = function (data, name) { + if (name === void 0) { name = null; } + name = name !== null ? name : data.name; + if (name in this._dragonBonesDataMap) { + if (this._dragonBonesDataMap[name] === data) { + return; + } + console.warn("Can not add same name data: " + name); + return; + } + this._dragonBonesDataMap[name] = data; + }; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { + if (disposeData === void 0) { disposeData = true; } + if (name in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); + } + delete this._dragonBonesDataMap[name]; + } + }; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.getTextureAtlasData = function (name) { + return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; + }; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.addTextureAtlasData = function (data, name) { + if (name === void 0) { name = null; } + name = name !== null ? name : data.name; + var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); + if (textureAtlasList.indexOf(data) < 0) { + textureAtlasList.push(data); + } + }; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { + if (disposeData === void 0) { disposeData = true; } + if (name in this._textureAtlasDataMap) { + var textureAtlasDataList = this._textureAtlasDataMap[name]; + if (disposeData) { + for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { + var textureAtlasData = textureAtlasDataList_1[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[name]; + } + }; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { + return null; + } + return dataPackage.armature; + }; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.clear = function (disposeData) { + if (disposeData === void 0) { disposeData = true; } + for (var k in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); + } + delete this._dragonBonesDataMap[k]; + } + for (var k in this._textureAtlasDataMap) { + if (disposeData) { + var textureAtlasDataList = this._textureAtlasDataMap[k]; + for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { + var textureAtlasData = textureAtlasDataList_2[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[k]; + } + }; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + if (skinName === void 0) { skinName = ""; } + if (textureAtlasName === void 0) { textureAtlasName = ""; } + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { + console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); + return null; + } + var armature = this._buildArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + this._buildConstraints(dataPackage, armature); + armature.invalidUpdate(null, true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * @private + */ + BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + slot.replaceDisplayData(displayData, displayIndex); + if (displayData !== null) { + var display = this._getSlotDisplay(null, displayData, slot); + if (displayData.type === 0 /* Image */) { + var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; + if (rawDisplayData !== null && + rawDisplayData.type === 2 /* Mesh */) { + display = slot.meshDisplay; + } + } + slot.replaceDisplay(display, displayIndex); + } + else { + slot.replaceDisplay(null, displayIndex); + } + }; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (armatureData === null || armatureData.defaultSkin === null) { + return false; + } + var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); + this.replaceDisplay(slot, displayData, displayIndex); + return true; + }; + /** + * @private + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (!armatureData || !armatureData.defaultSkin) { + return false; + } + var displayDatas = armatureData.defaultSkin.getDisplays(slotName); + if (!displayDatas) { + return false; + } + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + this.replaceDisplay(slot, displayData, i); + } + return true; + }; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { + if (isOverride === void 0) { isOverride = false; } + if (exclude === void 0) { exclude = null; } + var success = false; + var defaultSkin = skin.parent.defaultSkin; + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (exclude !== null && exclude.indexOf(slot.name) >= 0) { + continue; + } + var displayDatas = skin.getDisplays(slot.name); + if (displayDatas === null) { + if (defaultSkin !== null && skin !== defaultSkin) { + displayDatas = defaultSkin.getDisplays(slot.name); + } + if (displayDatas === null) { + if (isOverride) { + slot.displayFrameCount = 0; + } + continue; + } + } + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + slot.replaceRawDisplayData(displayData, i); + if (displayData !== null) { + slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); + } + else { + slot.replaceDisplay(null, i); + } + } + success = true; + } + return success; + }; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { + if (isOverride === void 0) { isOverride = true; } + var skinData = armatureData.defaultSkin; + if (skinData === null) { + return false; + } + if (isOverride) { + armature.animation.animations = armatureData.animations; + } + else { + var rawAnimations = armature.animation.animations; + var animations = {}; + for (var k in rawAnimations) { + animations[k] = rawAnimations[k]; + } + for (var k in armatureData.animations) { + animations[k] = armatureData.animations[k]; + } + armature.animation.animations = animations; + } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var index = 0; + for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { + var display = _c[_b]; + if (display instanceof dragonBones.Armature) { + var displayDatas = skinData.getDisplays(slot.name); + if (displayDatas !== null && index < displayDatas.length) { + var displayData = displayDatas[index]; + if (displayData !== null && displayData.type === 1 /* Armature */) { + var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); + if (childArmatureData) { + this.replaceAnimation(display, childArmatureData, isOverride); + } + } + } + } + index++; + } + } + return true; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + Object.defineProperty(BaseFactory.prototype, "clock", { + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + get: function () { + return this._dragonBones.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseFactory.prototype, "dragonBones", { + /** + * @private + */ + get: function () { + return this._dragonBones; + }, + enumerable: true, + configurable: true + }); + BaseFactory._objectParser = null; + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; + /** + * @private + */ + var BuildArmaturePackage = /** @class */ (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; +})(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. + */ +if (CC_EDITOR) { + _Scene.Sandbox._globalsVerifier_loadPluginScript.ignoreNames['dragonBones'] = true; +} +var dragonBones; +(function (dragonBones) { + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; + var DragonBonesAsset = /** @class */ (function (_super) { + __extends(DragonBonesAsset, _super); + function DragonBonesAsset() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.dragonBonesData = ""; + _this.textureAtlases = []; + _this.textures = []; + return _this; + } + __decorate([ + property + ], DragonBonesAsset.prototype, "dragonBonesData", void 0); + __decorate([ + property([cc.String]) + ], DragonBonesAsset.prototype, "textureAtlases", void 0); + __decorate([ + property([cc.Texture2D]) + ], DragonBonesAsset.prototype, "textures", void 0); + DragonBonesAsset = __decorate([ + ccclass("DragonBones.DragonBonesAsset") + ], DragonBonesAsset); + return DragonBonesAsset; + }(cc.Asset)); + dragonBones.DragonBonesAsset = DragonBonesAsset; +})(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 Cocos texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosTextureAtlasData = /** @class */ (function (_super) { + __extends(CocosTextureAtlasData, _super); + function CocosTextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._renderTexture = null; // Initial value. + return _this; + } + CocosTextureAtlasData.toString = function () { + return "[class dragonBones.CocosTextureAtlasData]"; + }; + CocosTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this._renderTexture !== null) { + // this._renderTexture.dispose(); + } + this._renderTexture = null; + }; + CocosTextureAtlasData.prototype.createTexture = function () { + return dragonBones.BaseObject.borrowObject(CocosTextureData); + }; + Object.defineProperty(CocosTextureAtlasData.prototype, "renderTexture", { + /** + * - The Cocos texture. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._renderTexture; + }, + set: function (value) { + if (this._renderTexture === value) { + return; + } + this._renderTexture = value; + if (this._renderTexture !== null) { + for (var k in this.textures) { + var textureData = this.textures[k]; + if (textureData.renderTexture !== null) { + textureData.renderTexture.destroy(); + } + var reat = cc.rect(textureData.region.x, textureData.region.y, textureData.rotated ? textureData.region.height : textureData.region.width, textureData.rotated ? textureData.region.width : textureData.region.height); + var offset = cc.v2(); + var originSize = cc.size(reat.size.width, reat.size.height); + textureData.renderTexture = new cc.SpriteFrame(this._renderTexture, reat, textureData.rotated, offset, originSize); + } + } + else { + for (var k in this.textures) { + var textureData = this.textures[k]; + if (textureData.renderTexture !== null) { + textureData.renderTexture.destroy(); + } + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + return CocosTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.CocosTextureAtlasData = CocosTextureAtlasData; + /** + * @internal + */ + var CocosTextureData = /** @class */ (function (_super) { + __extends(CocosTextureData, _super); + function CocosTextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.renderTexture = null; // Initial value. + return _this; + } + CocosTextureData.toString = function () { + return "[class dragonBones.CocosTextureData]"; + }; + CocosTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + this.renderTexture.destroy(); + } + this.renderTexture = null; + }; + return CocosTextureData; + }(dragonBones.TextureData)); + dragonBones.CocosTextureData = CocosTextureData; +})(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) { + // const _defaultItems = cc.Enum({ "None": -1 }); + // function _setItems(object: any, key: string, items: any) { + // (cc.Class as any).attr( // creator.d.ts error. + // object, + // key, + // { + // type: "Enum", + // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. + // } + // ); + // } + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, executeInEditMode = _a.executeInEditMode, disallowMultiple = _a.disallowMultiple, playOnFocus = _a.playOnFocus, menu = _a.menu, help = _a.help; + /** + * @see dragonBones.IArmatureProxy + */ + var CocosArmatureComponent = /** @class */ (function (_super) { + __extends(CocosArmatureComponent, _super); + function CocosArmatureComponent() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.debugDraw = false; + _this._debugDraw = false; + /** + * @internal + */ + _this._armature = null; + // Editor. + /** + * @internal + */ + _this._armatureName = ""; + _this.dragonBonesName = ''; + /** + * @internal + */ + _this._animationName = ""; + // Visibie. + /** + * @internal + */ + _this._dragonBonesAsset = null; + /** + * @internal + */ + _this._armatureNames = []; + /** + * @internal + */ + _this._animationNames = []; + /** + * @internal + */ + _this._playTimes = -1; + /** + * @internal + */ + _this._timeScale = 1.0; + return _this; + } + CocosArmatureComponent_1 = CocosArmatureComponent; + CocosArmatureComponent.prototype.dbInit = function (armature) { + this._armature = armature; + }; + CocosArmatureComponent.prototype.dbClear = function () { + this._armature = null; + _super.prototype.destroy.call(this); + }; + CocosArmatureComponent.prototype.dbUpdate = function () { + var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + } + }; + CocosArmatureComponent.prototype.dispose = function (_isposeProxy) { + if (_isposeProxy === void 0) { _isposeProxy = true; } + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + CocosArmatureComponent.prototype.destroy = function () { + this.dispose(); + if (false) { // `super.destroy()` will be called in `dbClear()`. + _super.prototype.destroy.call(this); + } + return true; + }; + /** + * @private + */ + CocosArmatureComponent.prototype.dispatchDBEvent = function (type, eventObject) { + var event = new cc.Event.EventCustom(type, false); + event.setUserData(eventObject); + this.node.dispatchEvent(event); + }; + CocosArmatureComponent.prototype.hasDBEventListener = function (type) { + return this.node.hasEventListener(type, false); // creator.d.ts error. + }; + CocosArmatureComponent.prototype.addDBEventListener = function (type, listener, target) { + this.node.on(type, listener, target); + }; + CocosArmatureComponent.prototype.removeDBEventListener = function (type, listener, target) { + this.node.off(type, listener, target); + }; + Object.defineProperty(CocosArmatureComponent.prototype, "armature", { + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CocosArmatureComponent.prototype, "animation", { + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CocosArmatureComponent.prototype, "dragonBonesAsset", { + get: function () { + return this._dragonBonesAsset || null; + }, + set: function (value) { + this._dragonBonesAsset = value; + this._loadAndDisplayDragonBones(); + }, + enumerable: true, + configurable: true + }); + CocosArmatureComponent.prototype._loadAndDisplayDragonBones = function () { + console.warn("\u5F00\u59CB\u521B\u5EFA DragonBones Armature"); + var notExistAsset = !this.dragonBonesAsset + || !this.dragonBonesAsset.dragonBonesData + || !this.dragonBonesAsset.textureAtlases + || !this.dragonBonesAsset.textures; + if (notExistAsset) { + console.error("dragonBonesAsset \u4E3A\u7A7A"); + return; + } + console.warn("\u521B\u5EFA DragonBones Armature"); + this._parseDragonAsset(); + this._parseDragonAtlasAsset(); + this.display(); + }; + CocosArmatureComponent.prototype._parseDragonAsset = function () { + var dragonBonesData; + if (typeof this.dragonBonesAsset.dragonBonesData === 'string') { + console.log("JSON.parse(this.dragonBonesAsset.dragonBonesData)"); + dragonBonesData = JSON.parse(this.dragonBonesAsset.dragonBonesData); + } + else { + dragonBonesData = this.dragonBonesAsset.dragonBonesData; + } + var data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); + if (data === null) { + console.warn("DragonBones Armature not exist"); + return; + } + this._armatureName = data.armatureNames[0]; + console.log("parseDragonBonesData", data); + }; + CocosArmatureComponent.prototype._parseDragonAtlasAsset = function () { + var _this = this; + var textureAtlases = this.dragonBonesAsset.textureAtlases; + if (typeof textureAtlases[0] === 'string') { + console.log('JSON.parse(this.dragonBonesAsset.textureAtlases)'); + textureAtlases = JSON.parse(textureAtlases); + } + else { + textureAtlases = this.dragonBonesAsset.textureAtlases; + } + var texture = Array.isArray(this.dragonBonesAsset.textures) ? this.dragonBonesAsset.textures[0] : this.dragonBonesAsset.textures; + if (typeof texture === 'string') { + cc.textureCache.addImage(texture, function (tex, error) { + if (error) { + console.error("error:" + error.message, error); + return; + } + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); + console.log("parseTextureAtlasData", data); + console.log("dragonBonesAsset", _this.dragonBonesAsset); + console.log("textureAtlases", textureAtlases); + console.log("texture", tex); + }, this); + } + else { + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); + console.log("string parseTextureAtlasData", data); + console.log("string dragonBonesAsset", this.dragonBonesAsset); + } + }; + CocosArmatureComponent.prototype.display = function () { + console.warn("Armature name:" + this._armatureName + ",dragonBonesName:" + this.dragonBonesName); + var armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); + if (!armatureComponent) { + console.log("armatureComponent is null"); + return; + } + armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); + armatureComponent.node.x = 0.0; + armatureComponent.node.y = 0; + this.node.addChild(armatureComponent.node); + this._dragonBonesNode = armatureComponent.node; + console.log("play animation default animation"); + }; + CocosArmatureComponent.prototype.onLoad = function () { + // this.display(); + if (!!this._dragonBonesNode) { + var component = this._dragonBonesNode.getComponent(CocosArmatureComponent_1); + var state = component.animation.play(component.animation.animationNames[0], 0); + if (!state) { + return; + } + console.warn("\u64AD\u653E\u52A8\u753B\uFF1A" + state.name, state); + } + else { + this._loadAndDisplayDragonBones(); + // this.onLoad(); + // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); + // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); + } + }; + var CocosArmatureComponent_1; + __decorate([ + property(cc.String) + ], CocosArmatureComponent.prototype, "_armatureName", void 0); + __decorate([ + property(cc.String) + ], CocosArmatureComponent.prototype, "_animationName", void 0); + __decorate([ + property({ + type: dragonBones.DragonBonesAsset, + }) + ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); + __decorate([ + property({ + type: dragonBones.DragonBonesAsset, + displayName: "DragonBones", + tooltip: "DragonBones Asset", + visible: true, + }) + ], CocosArmatureComponent.prototype, "dragonBonesAsset", null); + __decorate([ + property({ + type: [cc.String], + displayName: "Armature", + tooltip: "The armature name.", + visible: true, + editorOnly: true, + serializable: false, + }) + ], CocosArmatureComponent.prototype, "_armatureNames", void 0); + __decorate([ + property({ + type: [cc.String], + displayName: "Animation", + tooltip: "The animation name.", + visible: true, + editorOnly: true, + serializable: false, + }) + ], CocosArmatureComponent.prototype, "_animationNames", void 0); + __decorate([ + property({ + type: cc.Integer, + displayName: "Play times", + tooltip: "The animation play times.", + visible: true, + slide: true, + range: [-1, 99, 1], + }) + ], CocosArmatureComponent.prototype, "_playTimes", void 0); + __decorate([ + property({ + type: cc.Float, + displayName: "TimeScale", + tooltip: "The animation play speed.", + visible: true, + slide: true, + range: [-2, 2, 0.01], + }) + ], CocosArmatureComponent.prototype, "_timeScale", void 0); + CocosArmatureComponent = CocosArmatureComponent_1 = __decorate([ + ccclass("CocosArmatureComponent"), + executeInEditMode, + disallowMultiple, + playOnFocus, + menu("DragonBones/Armature"), + executeInEditMode, + help("https://github.com/DragonBones/") + ], CocosArmatureComponent); + return CocosArmatureComponent; + }(cc.Component)); + dragonBones.CocosArmatureComponent = CocosArmatureComponent; +})(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 Cocos slot. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosSlot = /** @class */ (function (_super) { + __extends(CocosSlot, _super); + function CocosSlot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._ccMeshDirty = false; + return _this; + } + CocosSlot.toString = function () { + return "[class dragonBones.CocosSlot]"; + }; + CocosSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._textureScale = 1.0; + this._renderDisplay = null; + }; + CocosSlot.prototype._initDisplay = function (_value, _isRetain) { + }; + CocosSlot.prototype._disposeDisplay = function (value, isRelease) { + if (!isRelease) { + value.destroy(); + } + }; + CocosSlot.prototype._onUpdateDisplay = function () { + this._renderDisplay = (this._display ? this._display : this._rawDisplay); + }; + CocosSlot.prototype._addDisplay = function () { + var container = this._armature.display; + container.addChild(this._renderDisplay, this._zOrder); + }; + CocosSlot.prototype._replaceDisplay = function (value) { + var container = this._armature.display; + var prevDisplay = value; + if (this._renderDisplay.parent !== container) { + container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder()); + } + // container.removeChild(prevDisplay, false); + this._renderDisplay.active = true; + prevDisplay.active = false; + this._textureScale = 1.0; + }; + CocosSlot.prototype._removeDisplay = function () { + this._renderDisplay.parent.removeChild(this._renderDisplay, false); + }; + CocosSlot.prototype._updateZOrder = function () { + if (this._renderDisplay.getLocalZOrder() === this._zOrder) { + return; + } + this._renderDisplay.setLocalZOrder(this._zOrder); + }; + /** + * @internal + */ + CocosSlot.prototype._updateVisible = function () { + this._renderDisplay.active = this._parent.visible && this._visible; + }; + CocosSlot.prototype._updateBlendMode = function () { + var sprite = this._renderDisplay.getComponent(cc.Sprite); + if (sprite) { + switch (this._blendMode) { + case 0 /* Normal */: + break; + case 1 /* Add */: + var texture = sprite.spriteFrame.getTexture(); + var BlendFunc = cc.BlendFunc; // creator.d.ts error. + if (texture && texture.hasPremultipliedAlpha()) { + sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.ONE, BlendFunc.BlendFactor.ONE); // creator.d.ts error. + } + else { + sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.SRC_ALPHA, BlendFunc.BlendFactor.ONE); // creator.d.ts error. + } + break; + case 3 /* Darken */: + break; + case 4 /* Difference */: + break; + case 6 /* HardLight */: + break; + case 9 /* Lighten */: + break; + case 10 /* Multiply */: + break; + case 11 /* Overlay */: + break; + case 12 /* Screen */: + break; + default: + break; + } + } + else if (this._childArmature !== null) { + for (var _i = 0, _a = this._childArmature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + slot._blendMode = this._blendMode; + slot._updateBlendMode(); + } + } + }; + CocosSlot.prototype._updateColor = function () { + var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha * 255; + var color = this._renderDisplay.color; + this._renderDisplay.opacity = alpha; + color.setR(this._colorTransform.redMultiplier * 0xFF); + color.setG(this._colorTransform.greenMultiplier * 0xFF); + color.setB(this._colorTransform.blueMultiplier * 0xFF); + this._renderDisplay.setColor(color); // creator.d.ts error. + }; + CocosSlot.prototype._updateFrame = function () { + var currentTextureData = this._textureData; + var sprite = this._renderDisplay.getComponent(cc.Sprite); + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + var currentTextureAtlasData = currentTextureData.parent; + if (this._armature.replacedTexture !== null) { // Update replaced texture atlas. + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData; + } + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); + } + var renderTexture = currentTextureData.renderTexture; + if (renderTexture !== null) { + if (this._geometryData !== null) { // Mesh. + var data = this._geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; + var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; + var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; + if (vertexOffset < 0) { + vertexOffset += 65536; // Fixed out of bouds bug. + } + var uvOffset = vertexOffset + vertexCount * 2; + var scale = this._armature._armatureData.scale; + var textureAtlasSize = renderTexture.getTexture().getContentSizeInPixels(); + var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : textureAtlasSize.width; + var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : textureAtlasSize.height; + var region = currentTextureData.region; + var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); + var polygonInfo = { + triangles: { + verts: [], + indices: [] + }, + rect: boundsRect + }; + for (var i = 0, l = vertexCount * 2; i < l; i += 2) { + var vertex = { + x: floatArray[vertexOffset + i] * scale, + y: -floatArray[vertexOffset + i + 1] * scale, + u: floatArray[uvOffset + i], + v: floatArray[uvOffset + i + 1] + }; + if (currentTextureData.rotated) { + var backU = vertex.u; + vertex.u = (region.x + (1.0 - vertex.v) * region.width) / textureAtlasWidth; + vertex.v = (region.y + backU * region.height) / textureAtlasHeight; + } + else { + vertex.u = (region.x + vertex.u * region.width) / textureAtlasWidth; + vertex.v = (region.y + vertex.v * region.height) / textureAtlasHeight; + } + polygonInfo.triangles.verts[i / 2] = vertex; + if (boundsRect.x > vertex.x) { + boundsRect.x = vertex.x; + } + if (boundsRect.width < vertex.x) { + boundsRect.width = vertex.x; + } + if (boundsRect.y > vertex.y) { + boundsRect.y = vertex.y; + } + if (boundsRect.height < vertex.y) { + boundsRect.height = vertex.y; + } + } + for (var i = 0; i < triangleCount * 3; ++i) { + polygonInfo.triangles.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; + } + this._textureScale = 1.0; + sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.MESH); // creator.d.ts error. + sprite.spriteFrame = renderTexture; + sprite._sgNode.setMeshPolygonInfo(polygonInfo); // creator.d.ts error. + sprite._sgNode.setContentSize(cc.size(boundsRect.width, boundsRect.height)); // creator.d.ts error. + var isSkinned = this._geometryData.weight !== null; + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + if (isSkinned || isSurface) { + this._identityTransform(); + } + // Delay to update cocos mesh. (some cocos bug.) + this._ccMeshDirty = true; + } + else { // Normal texture. + this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; + sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. + sprite.spriteFrame = renderTexture; + sprite._sgNode.setContentSize(renderTexture.getOriginalSize()); // creator.d.ts error. + } + this._visibleDirty = true; + // this._blendModeDirty = true; + // this._colorDirty = true; + return; + } + } + this._renderDisplay.active = false; + this._renderDisplay.setPosition(0.0, 0.0); + }; + CocosSlot.prototype._updateMesh = function () { + var scale = this._armature._armatureData.scale; + var deformVertices = this._displayFrame.deformVertices; + var bones = this._geometryBones; + var geometryData = this._geometryData; + var weightData = geometryData.weight; + var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform; + var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite; + var polygonInfo = meshDisplay.getMeshPolygonInfo(); + if (!polygonInfo) { + return; + } + var verticesAndUVs = polygonInfo.triangles.verts; + var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); + if (weightData !== null) { + var data = geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; + if (weightFloatOffset < 0) { + weightFloatOffset += 65536; // Fixed out of bouds bug. + } + for (var i = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { + var boneCount = intArray[iB++]; + var xG = 0.0, yG = 0.0; + for (var j = 0; j < boneCount; ++j) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var xL = floatArray[iV++] * scale; + var yL = floatArray[iV++] * scale; + if (hasDeform) { + xL += deformVertices[iF++]; + yL += deformVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + var vertex = verticesAndUVs[i]; + vertex.x = xG; + vertex.y = yG; + if (boundsRect.x > xG) { + boundsRect.x = xG; + } + if (boundsRect.width < xG) { + boundsRect.width = xG; + } + if (boundsRect.y > yG) { + boundsRect.y = yG; + } + if (boundsRect.height < yG) { + boundsRect.height = yG; + } + } + } + else { + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + var data = geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; + if (vertexOffset < 0) { + vertexOffset += 65536; // Fixed out of bouds bug. + } + for (var i = 0, l = vertexCount * 2; i < l; i += 2) { + var iH = i / 2; // int. + var x = floatArray[vertexOffset + i] * scale; + var y = floatArray[vertexOffset + i + 1] * scale; + if (hasDeform) { + x += deformVertices[i]; + y += deformVertices[i + 1]; + } + var vertex = verticesAndUVs[iH]; + if (isSurface) { + var matrix = this._parent._getGlobalTransformMatrix(x, y); + vertex.x = matrix.a * x + matrix.c * y + matrix.tx; + vertex.y = matrix.b * x + matrix.d * y + matrix.ty; + // + x = vertex.x; + y = vertex.y; + } + else { + vertex.x = x; + y = vertex.y = -y; + } + if (boundsRect.x > x) { + boundsRect.x = x; + } + if (boundsRect.width < x) { + boundsRect.width = x; + } + if (boundsRect.y > y) { + boundsRect.y = y; + } + if (boundsRect.height < y) { + boundsRect.height = y; + } + } + } + boundsRect.width -= boundsRect.x; + boundsRect.height -= boundsRect.y; + polygonInfo.rect = boundsRect; + meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height)); + meshDisplay.setMeshPolygonInfo(polygonInfo); + if (weightData !== null) { + this._identityTransform(); + } + else { + var transform = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); + this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); + this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; + this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; + this._renderDisplay.scaleX = transform.scaleX * this._textureScale; + this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; + } + if (this._ccMeshDirty) { + this._ccMeshDirty = false; + this._verticesDirty = true; + } + }; + CocosSlot.prototype._updateTransform = function () { + // const globalTransformMatrix = this.globalTransformMatrix; + // const helpMatrix = TransformObject._helpMatrix; + // helpMatrix.a = globalTransformMatrix.a; + // helpMatrix.b = globalTransformMatrix.b; + // helpMatrix.c = -globalTransformMatrix.c; + // helpMatrix.d = -globalTransformMatrix.d; + // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + // helpMatrix.tx = globalTransformMatrix.tx - (globalTransformMatrix.a * this._pivotX + globalTransformMatrix.c * this._pivotY); + // helpMatrix.ty = (globalTransformMatrix.ty - (globalTransformMatrix.b * this._pivotX + globalTransformMatrix.d * this._pivotY)); + // } + // else { + // helpMatrix.tx = globalTransformMatrix.tx; + // helpMatrix.ty = globalTransformMatrix.ty; + // } + // (this._renderDisplay as any)._sgNode._renderCmd.setNodeToParentTransform(helpMatrix); // creator.d.ts error. + this.updateGlobalTransform(); + var transform = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); + this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); + } + else { + this._renderDisplay.x = transform.x; + this._renderDisplay.y = transform.y; + } + this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; + this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; + this._renderDisplay.scaleX = transform.scaleX * this._textureScale; + this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; + }; + CocosSlot.prototype._identityTransform = function () { + // const helpMatrix = TransformObject._helpMatrix; + // helpMatrix.a = 1.0; + // helpMatrix.b = 0.0; + // helpMatrix.c = -0.0; + // helpMatrix.d = -1.0; + // helpMatrix.tx = 0.0; + // helpMatrix.ty = 0.0; + // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix); + this._renderDisplay.x = 0.0; + this._renderDisplay.y = 0.0; + this._renderDisplay.rotationX = 0.0; + this._renderDisplay.rotationY = 0.0; + this._renderDisplay.scaleX = 1.0; + this._renderDisplay.scaleY = 1.0; + }; + return CocosSlot; + }(dragonBones.Slot)); + dragonBones.CocosSlot = CocosSlot; +})(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) { + var ccclass = cc._decorator.ccclass; + var ClockHandler = /** @class */ (function (_super) { + __extends(ClockHandler, _super); + function ClockHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ClockHandler.prototype.update = function (passedTime) { + CocosFactory.factory.dragonBones.advanceTime(passedTime); + }; + ClockHandler = __decorate([ + ccclass + ], ClockHandler); + return ClockHandler; + }(cc.Component)); + /** + * - The Cocos factory. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosFactory = /** @class */ (function (_super) { + __extends(CocosFactory, _super); + function CocosFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + var _this = _super.call(this, dataParser) || this; + _this._node = null; + _this._armatureNode = null; + if (!CC_EDITOR) { // Is playing. + if (_this._node === null) { + var nodeName = "DragonBones Node"; + _this._node = cc.find(nodeName); + if (_this._node === null) { + _this._node = new cc.Node(nodeName); + cc.game.addPersistRootNode(_this._node); + } + } + if (!_this._node.getComponent(ClockHandler)) { + _this._node.addComponent(ClockHandler); + } + var eventManager = _this._node.getComponent(dragonBones.CocosArmatureComponent) || _this._node.addComponent(dragonBones.CocosArmatureComponent); + if (CocosFactory._dragonBonesInstance === null) { + CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); + // + dragonBones.DragonBones.yDown = false; + } + } + else { + if (CocosFactory._dragonBonesInstance === null) { + CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(null); + // + dragonBones.DragonBones.yDown = false; + } + } + _this._dragonBones = CocosFactory._dragonBonesInstance; + return _this; + } + Object.defineProperty(CocosFactory, "factory", { + /** + * - A global factory instance that can be used directly. + * @version DragonBones 4.7 + * @language en_US + */ + /** + * - 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + if (this._factory === null) { + this._factory = new CocosFactory(); + } + return this._factory; + }, + enumerable: true, + configurable: true + }); + CocosFactory.prototype._isSupportMesh = function () { + if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { // creator.d.ts error. + console.warn("Only webgl mode can support mesh."); + return false; + } + return true; + }; + CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); + } + return textureAtlasData; + }; + CocosFactory.prototype._buildArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplay = this._armatureNode === null ? new cc.Node(dataPackage.armature.name) : this._armatureNode; + var armatureComponent = armatureDisplay.getComponent(dragonBones.CocosArmatureComponent) || armatureDisplay.addComponent(dragonBones.CocosArmatureComponent); + armatureDisplay.setOpacityModifyRGB(false); + armatureDisplay.setCascadeOpacityEnabled(true); + armatureDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. + this._armatureNode = null; + armatureComponent._armature = armature; + armature.init(dataPackage.armature, armatureComponent, armatureDisplay, this._dragonBones); + return armature; + }; + CocosFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { + var childDisplayName = slot.slotData.name + " (" + displayData.path.replace("/", "_") + ")"; // + var proxy = slot.armature.proxy; + var childNode = cc.find(childDisplayName, proxy.node); + var childArmature = null; + if (!childNode) { + if (dataPackage !== null) { + childArmature = this.buildArmature(displayData.path, dataPackage.dataName); + } + else { + childArmature = this.buildArmature(displayData.path, displayData.parent.parent.parent.name); + } + } + else { + var childArmatureComponent = childNode.getComponent(dragonBones.CocosArmatureComponent) || null; + if (childArmatureComponent === null) { + if (dataPackage !== null) { + childArmatureComponent = this.buildArmatureComponent(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage.textureAtlasName, childNode); + } + else { + childArmatureComponent = this.buildArmatureComponent(displayData.path, "", "", "", childNode); + } + } + if (childArmatureComponent !== null) { + childArmature = childArmatureComponent.armature; + } + } + if (childArmature === null) { + return null; + } + var childArmatureDisplay = childArmature.display; + childArmatureDisplay.name = childDisplayName; + if (childArmatureDisplay.parent !== proxy.node) { + proxy.node.addChild(childArmatureDisplay, slot._zOrder); + } + childArmatureDisplay.active = false; + return childArmature; + }; + CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.CocosSlot); + var armatureDisplay = armature.display; + var rawSlotDisplay = cc.find(slotData.name, armatureDisplay) || new cc.Node(slotData.name); + rawSlotDisplay.addComponent(cc.Sprite); + rawSlotDisplay.setAnchorPoint(0.0, 0.0); + rawSlotDisplay.setOpacityModifyRGB(false); + rawSlotDisplay.setCascadeOpacityEnabled(true); + rawSlotDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. + slot.init(slotData, armature, rawSlotDisplay, rawSlotDisplay); + return slot; + }; + /** + * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. + * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. + * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature component. + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 + * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 + * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架组件。 + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language zh_CN + */ + CocosFactory.prototype.buildArmatureComponent = function (armatureName, dragonBonesName, skinName, textureAtlasName, node) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + if (skinName === void 0) { skinName = ""; } + if (textureAtlasName === void 0) { textureAtlasName = ""; } + if (node === void 0) { node = null; } + this._armatureNode = node; + var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.proxy; + } + return null; + }; + /** + * - Create the display object with the specified texture. + * @param textureName - The texture data name. + * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建带有指定贴图的显示对象。 + * @param textureName - 贴图数据名称。 + * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { + if (textureAtlasName === void 0) { textureAtlasName = null; } + var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); + if (textureData !== null && textureData.renderTexture !== null) { + var texture = textureData.renderTexture; + var sprite = new cc.Sprite(); + sprite.spriteFrame = texture; + return sprite; + } + return null; + }; + Object.defineProperty(CocosFactory.prototype, "soundEventManager", { + /** + * - A global sound event manager. + * Sound events can be listened to uniformly from the manager. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 全局声音事件管理器。 + * 声音事件可以从该管理器统一侦听。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._dragonBones.eventManager.node; + }, + enumerable: true, + configurable: true + }); + CocosFactory._dragonBonesInstance = null; + CocosFactory._factory = null; + return CocosFactory; + }(dragonBones.BaseFactory)); + dragonBones.CocosFactory = CocosFactory; +})(dragonBones || (dragonBones = {})); diff --git a/Cocos/1.x/out/dragonBones.min.js b/Cocos/1.x/out/dragonBones.min.js old mode 100644 new mode 100755 index 97497d27..3257a318 --- a/Cocos/1.x/out/dragonBones.min.js +++ b/Cocos/1.x/out/dragonBones.min.js @@ -1 +1 @@ -"use strict";var __extends=this&&this.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)if(e.hasOwnProperty(a))t[a]=e[a]};return function(t,e){r(t,e);function a(){this.constructor=t}t.prototype=e===null?Object.create(e):(a.prototype=e.prototype,new a)}}();var __decorate=this&&this.__decorate||function(t,e,a,r){var i=arguments.length,n=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,a):r,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")n=Reflect.decorate(t,e,a,r);else for(var o=t.length-1;o>=0;o--)if(s=t[o])n=(i<3?s(n):i>3?s(e,a,n):s(e,a))||n;return i>3&&n&&Object.defineProperty(e,a,n),n};var dragonBones;(function(o){var t=function(){function e(t){this._clock=new o.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=t;console.info("DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}e.prototype.advanceTime=function(t){if(this._objects.length>0){for(var e=0,a=this._objects;e0){for(var i=0;ie){r.length=e}n._maxCountMap[a]=e}else{n._defaultMaxCount=e;for(var a in n._poolsMap){var r=n._poolsMap[a];if(r.length>e){r.length=e}if(a in n._maxCountMap){n._maxCountMap[a]=e}}}};n.clearPool=function(t){if(t===void 0){t=null}if(t!==null){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in n._poolsMap){var a=n._poolsMap[r];a.length=0}}};n.borrowObject=function(t){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var i=new t;i._onClear();return i};n.prototype.returnToPool=function(){this._onClear();n._returnObject(this)};n._hashCode=0;n._defaultMaxCount=3e3;n._maxCountMap={};n._poolsMap={};return n}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=1}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=a;this.d=r;this.tx=i;this.ty=n}t.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};t.prototype.copyFrom=function(t){this.a=t.a;this.b=t.b;this.c=t.c;this.d=t.d;this.tx=t.tx;this.ty=t.ty;return this};t.prototype.copyFromArray=function(t,e){if(e===void 0){e=0}this.a=t[e];this.b=t[e+1];this.c=t[e+2];this.d=t[e+3];this.tx=t[e+4];this.ty=t[e+5];return this};t.prototype.identity=function(){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this};t.prototype.concat=function(t){var e=this.a*t.a;var a=0;var r=0;var i=this.d*t.d;var n=this.tx*t.a+t.tx;var s=this.ty*t.d+t.ty;if(this.b!==0||this.c!==0){e+=this.b*t.c;a+=this.b*t.d;r+=this.c*t.a;i+=this.c*t.b}if(t.b!==0||t.c!==0){a+=this.a*t.b;r+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=a;this.c=r;this.d=i;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var a=this.c;var r=this.d;var i=this.tx;var n=this.ty;if(e===0&&a===0){this.b=this.c=0;if(t===0||r===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;r=this.d=1/r;this.tx=-t*i;this.ty=-r*n}return this}var s=t*r-e*a;if(s===0){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this}s=1/s;var o=this.a=r*s;e=this.b=-e*s;a=this.c=-a*s;r=this.d=t*s;this.tx=-(o*i+a*n);this.ty=-(e*i+r*n);return this};t.prototype.transformPoint=function(t,e,a,r){if(r===void 0){r=false}a.x=this.a*t+this.c*e;a.y=this.b*t+this.d*e;if(!r){a.x+=this.tx;a.y+=this.ty}};t.prototype.transformRectangle=function(t,e){if(e===void 0){e=false}var a=this.a;var r=this.b;var i=this.c;var n=this.d;var s=e?0:this.tx;var o=e?0:this.ty;var l=t.x;var h=t.y;var u=l+t.width;var f=h+t.height;var _=a*l+i*h+s;var m=r*l+n*h+o;var c=a*u+i*h+s;var p=r*u+n*h+o;var d=a*u+i*f+s;var y=r*u+n*f+o;var v=a*l+i*f+s;var g=r*l+n*f+o;var D=0;if(_>c){D=_;_=c;c=D}if(d>v){D=d;d=v;v=D}t.x=Math.floor(_v?c:v)-t.x);if(m>p){D=m;m=p;p=D}if(y>g){D=y;y=g;g=D}t.y=Math.floor(mg?p:g)-t.y)};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function n(t,e,a,r,i,n){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}if(i===void 0){i=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=a;this.rotation=r;this.scaleX=i;this.scaleY=n}n.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};n.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY};n.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.skew=t.skew;this.rotation=t.rotation;this.scaleX=t.scaleX;this.scaleY=t.scaleY;return this};n.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};n.prototype.add=function(t){this.x+=t.x;this.y+=t.y;this.skew+=t.skew;this.rotation+=t.rotation;this.scaleX*=t.scaleX;this.scaleY*=t.scaleY;return this};n.prototype.minus=function(t){this.x-=t.x;this.y-=t.y;this.skew-=t.skew;this.rotation-=t.rotation;this.scaleX/=t.scaleX;this.scaleY/=t.scaleY;return this};n.prototype.fromMatrix=function(t){var e=this.scaleX,a=this.scaleY;var r=n.PI_Q;this.x=t.tx;this.y=t.ty;this.rotation=Math.atan(t.b/t.a);var i=Math.atan(-t.c/t.d);this.scaleX=this.rotation>-r&&this.rotation-r&&i=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;i=i-Math.PI}this.skew=i-this.rotation;return this};n.prototype.toMatrix=function(t){if(this.rotation===0){t.a=1;t.b=0}else{t.a=Math.cos(this.rotation);t.b=Math.sin(this.rotation)}if(this.skew===0){t.c=-t.b;t.d=t.a}else{t.c=-Math.sin(this.skew+this.rotation);t.d=Math.cos(this.skew+this.rotation)}if(this.scaleX!==1){t.a*=this.scaleX;t.b*=this.scaleX}if(this.scaleY!==1){t.c*=this.scaleY;t.d*=this.scaleY}t.tx=this.x;t.ty=this.y;return this};n.PI=Math.PI;n.PI_D=Math.PI*2;n.PI_H=Math.PI/2;n.PI_Q=Math.PI/4;n.RAD_DEG=180/Math.PI;n.DEG_RAD=Math.PI/180;return n}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(a===void 0){a=1}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}if(s===void 0){s=0}if(o===void 0){o=0}this.alphaMultiplier=t;this.redMultiplier=e;this.greenMultiplier=a;this.blueMultiplier=r;this.alphaOffset=i;this.redOffset=n;this.greenOffset=s;this.blueOffset=o}t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier;this.redMultiplier=t.redMultiplier;this.greenMultiplier=t.greenMultiplier;this.blueMultiplier=t.blueMultiplier;this.alphaOffset=t.alphaOffset;this.redOffset=t.redOffset;this.greenOffset=t.greenOffset;this.blueOffset=t.blueOffset};t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1;this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0};return t}();t.ColorTransform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e){if(t===void 0){t=0}if(e===void 0){e=0}this.x=t;this.y=e}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y};t.prototype.clear=function(){this.x=this.y=0};return t}();t.Point=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}this.x=t;this.y=e;this.width=a;this.height=r}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.width=t.width;this.height=t.height};t.prototype.clear=function(){this.x=this.y=0;this.width=this.height=0};return t}();t.Rectangle=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.ints=[];t.floats=[];t.strings=[];return t}t.toString=function(){return"[class dragonBones.UserData]"};t.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};t.prototype.addInt=function(t){this.ints.push(t)};t.prototype.addFloat=function(t){this.floats.push(t)};t.prototype.addString=function(t){this.strings.push(t)};t.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){a=0}if(this.sortedBones.indexOf(i)>=0){continue}var n=false;for(var s in this.constraints){var o=this.constraints[s];if(o.root===i&&this.sortedBones.indexOf(o.target)<0){n=true;break}}if(n){continue}if(i.parent!==null&&this.sortedBones.indexOf(i.parent)<0){continue}this.sortedBones.push(i);r++}};t.prototype.cacheFrames=function(t){if(this.cacheFrameRate>0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};t.prototype.setCacheFrame=function(t,e){var a=this.parent.cachedFrames;var r=a.length;a.length+=10;a[r]=t.a;a[r+1]=t.b;a[r+2]=t.c;a[r+3]=t.d;a[r+4]=t.tx;a[r+5]=t.ty;a[r+6]=e.rotation;a[r+7]=e.skew;a[r+8]=e.scaleX;a[r+9]=e.scaleY;return r};t.prototype.getCacheFrame=function(t,e,a){var r=this.parent.cachedFrames;t.a=r[a];t.b=r[a+1];t.c=r[a+2];t.d=r[a+3];t.tx=r[a+4];t.ty=r[a+5];e.rotation=r[a+6];e.skew=r[a+7];e.scaleX=r[a+8];e.scaleY=r[a+9];e.x=t.tx;e.y=t.ty};t.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t;this.sortedBones.push(t)};t.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t;this.sortedSlots.push(t)};t.prototype.addConstraint=function(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t};t.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this;this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}if(t.name==="default"){this.defaultSkin=t}};t.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};t.prototype.addAction=function(t,e){if(e){this.defaultActions.push(t)}else{this.actions.push(t)}};t.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};t.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};t.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null};t.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};t.prototype.getMesh=function(t,e,a){var r=this.getSkin(t);if(r===null){return null}return r.getDisplay(e,a)};t.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return t}(a.BaseObject);a.ArmatureData=t;var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.transform=new a.Transform;t.userData=null;return t}t.toString=function(){return"[class dragonBones.BoneData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.inheritTranslation=false;this.inheritRotation=false;this.inheritScale=false;this.inheritReflection=false;this.type=0;this.length=0;this.alpha=1;this.name="";this.transform.identity();this.userData=null;this.parent=null};return t}(a.BaseObject);a.BoneData=e;var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.geometry=new a.GeometryData;return t}t.toString=function(){return"[class dragonBones.SurfaceData]"};t.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=1;this.segmentX=0;this.segmentY=0;this.geometry.clear()};return t}(e);a.SurfaceData=r;var i=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.color=null;t.userData=null;return t}t.createColor=function(){return new a.ColorTransform};t.toString=function(){return"[class dragonBones.SlotData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.blendMode=0;this.displayIndex=0;this.zOrder=0;this.zIndex=0;this.alpha=1;this.name="";this.color=null;this.userData=null;this.parent=null};t.DEFAULT_COLOR=new a.ColorTransform;return t}(a.BaseObject);a.SlotData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.CanvasData]"};e.prototype._onClear=function(){this.hasBackground=false;this.color=0;this.x=0;this.y=0;this.width=0;this.height=0};return e}(t.BaseObject);t.CanvasData=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.displays={};return t}t.toString=function(){return"[class dragonBones.SkinData]"};t.prototype._onClear=function(){for(var t in this.displays){var e=this.displays[t];for(var a=0,r=e;ai){s|=2}if(en){s|=8}return s};D.rectangleIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=t>i&&tn&&ei&&an&&r=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){return true}}return false};D.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=this.width*.5;var l=this.height*.5;var h=D.rectangleIntersectsSegment(t,e,a,r,-o,-l,o,l,i,n,s);return h};return D}(e);t.RectangleBoundingBoxData=h;var a=function(t){__extends(l,t);function l(){return t!==null&&t.apply(this,arguments)||this}l.toString=function(){return"[class dragonBones.EllipseData]"};l.ellipseIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=s/o;var _=f*f;e*=f;r*=f;var m=a-t;var c=r-e;var p=Math.sqrt(m*m+c*c);var d=m/p;var y=c/p;var v=(i-t)*d+(n-e)*y;var g=v*v;var D=t*t+e*e;var T=s*s;var b=T-D+g;var A=0;if(b>=0){var S=Math.sqrt(b);var P=v-S;var O=v+S;var x=P<0?-1:P<=p?0:1;var B=O<0?-1:O<=p?0:1;var E=x*B;if(E<0){return-1}else if(E===0){if(x===-1){A=2;a=t+O*d;r=(e+O*y)/f;if(l!==null){l.x=a;l.y=r}if(h!==null){h.x=a;h.y=r}if(u!==null){u.x=Math.atan2(r/T*_,a/T);u.y=u.x+Math.PI}}else if(B===1){A=1;t=t+P*d;e=(e+P*y)/f;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(u!==null){u.x=Math.atan2(e/T*_,t/T);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+P*d;l.y=(e+P*y)/f;if(u!==null){u.x=Math.atan2(l.y/T*_,l.x/T)}}if(h!==null){h.x=t+O*d;h.y=(e+O*y)/f;if(u!==null){u.y=Math.atan2(h.y/T*_,h.x/T)}}}}}return A};l.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};l.prototype.containsPoint=function(t,e){var a=this.width*.5;if(t>=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){e*=a/r;return Math.sqrt(t*t+e*e)<=a}}return false};l.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=l.ellipseIntersectsSegment(t,e,a,r,0,0,this.width*.5,this.height*.5,i,n,s);return o};return l}(e);t.EllipseBoundingBoxData=a;var r=function(e){__extends(l,e);function l(){var t=e!==null&&e.apply(this,arguments)||this;t.vertices=[];return t}l.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};l.polygonIntersectsSegment=function(t,e,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(t===a){t=a+1e-6}if(e===r){e=r+1e-6}var l=i.length;var h=t-a;var u=e-r;var f=t*r-e*a;var _=0;var m=i[l-2];var c=i[l-1];var p=0;var d=0;var y=0;var v=0;var g=0;var D=0;for(var T=0;T=m&&B<=b||B>=b&&B<=m)&&(h===0||B>=t&&B<=a||B>=a&&B<=t)){var E=(f*P-u*O)/x;if((E>=c&&E<=A||E>=A&&E<=c)&&(u===0||E>=e&&E<=r||E>=r&&E<=e)){if(s!==null){var M=B-t;if(M<0){M=-M}if(_===0){p=M;d=M;y=B;v=E;g=B;D=E;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}}else{if(Md){d=M;g=B;D=E;if(o!==null){o.y=Math.atan2(A-c,b-m)-Math.PI*.5}}}_++}else{y=B;v=E;g=B;D=E;_++;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}break}}}m=b;c=A}if(_===1){if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=y;s.y=v}if(o!==null){o.y=o.x+Math.PI}}else if(_>1){_++;if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=g;s.y=D}}return _};l.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=2;this.x=0;this.y=0;this.vertices.length=0};l.prototype.containsPoint=function(t,e){var a=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var r=0,i=this.vertices.length,n=i-2;r=e||s=e){var l=this.vertices[n];var h=this.vertices[r];if((e-o)*(l-h)/(s-o)+h0){return}this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var a=0,r=this.cacheFrames.length;ae._zIndex*1e3+e._zOrder?1:-1};y.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=n){continue}var o=a[s];var l=this.getSlot(o.name);if(l!==null){l._setZOrder(i)}}this._slotsDirty=true;this._zOrderDirty=!r}};y.prototype._addBone=function(t){if(this._bones.indexOf(t)<0){this._bones.push(t)}};y.prototype._addSlot=function(t){if(this._slots.indexOf(t)<0){this._slots.push(t)}};y.prototype._addConstraint=function(t){if(this._constraints.indexOf(t)<0){this._constraints.push(t)}};y.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};y.prototype.dispose=function(){if(this._armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};y.prototype.init=function(t,e,a,r){if(this._armatureData!==null){return}this._armatureData=t;this._animation=i.BaseObject.borrowObject(i.Animation);this._proxy=e;this._display=a;this._dragonBones=r;this._proxy.dbInit(this);this._animation.init(this);this._animation.animations=this._armatureData.animations};y.prototype.advanceTime=function(t){if(this._lockUpdate){return}this._lockUpdate=true;if(this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");return}var e=this._cacheFrameIndex;this._animation.advanceTime(t);if(this._slotsDirty||this._zIndexDirty){this._slots.sort(y._onSortSlots);if(this._zIndexDirty){for(var a=0,r=this._slots.length;a0){for(var u=0,f=this._actions;u0){var a=this.getBone(t);if(a!==null){a.invalidUpdate();if(e){for(var r=0,i=this._slots;r0){if(i!==null||n!==null){if(i!==null){var b=o?i.y-e:i.x-t;if(b<0){b=-b}if(d===null||bh){h=b;_=n.x;m=n.y;y=D;if(s!==null){p=s.y}}}}else{d=D;break}}}if(d!==null&&i!==null){i.x=u;i.y=f;if(s!==null){s.x=c}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=p}}return d};y.prototype.getBone=function(t){for(var e=0,a=this._bones;e=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(o)}if(o&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};t.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};t.prototype.invalidUpdate=function(){this._transformDirty=true};t.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};Object.defineProperty(t.prototype,"boneData",{get:function(){return this._boneData},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;for(var e=0,a=this._armature.getSlots();e=a){return this.globalTransformMatrix}i=e>this._kX*(t+a)+p;m=((s*o+s+o+o+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=_*(l+2);var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[2]-(o-_)*g;var b=this._hullCache[3]-(o-_)*D;var A=this._vertices;if(i){this._getAffineTransform(-a,p+u,r-a,u,A[v+l+2],A[v+l+3],T+g,b+D,A[v],A[v+1],S._helpTransform,y,true)}else{this._getAffineTransform(-r,p,r-a,u,T,b,A[v],A[v+1],T+g,b+D,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(t>=a){if(e<-a||e>=a){return this.globalTransformMatrix}i=e>this._kX*(t-r)+p;m=((s*o+s+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=(_+1)*(l+2)-2;var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[0]+_*g;var b=this._hullCache[1]+_*D;var A=this._vertices;if(i){this._getAffineTransform(r,p+u,r-a,u,T+g,b+D,A[v+l+2],A[v+l+3],T,b,S._helpTransform,y,true)}else{this._getAffineTransform(a,p,r-a,u,A[v],A[v+1],T,b,A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e<-a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)-r;m=((s*o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[8]+f*g;var b=this._hullCache[9]+f*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,-a,h,r-a,A[v+2],A[v+3],A[v],A[v+1],T+g,b+D,S._helpTransform,y,true)}else{this._getAffineTransform(c,-r,h,r-a,T,b,T+g,b+D,A[v],A[v+1],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e>=a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)+a;m=((s*o+s+o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=o*(l+2)+f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[6]-(s-f)*g;var b=this._hullCache[7]-(s-f)*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,r,h,r-a,T+g,b+D,T,b,A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,a,h,r-a,A[v],A[v+1],A[v+2],A[v+3],T,b,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else{i=e>this._k*(t-c-h)+p;m=((s*_+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2+_*(l+2);var A=this._vertices;if(i){this._getAffineTransform(c+h,p+u,h,u,A[v+l+4],A[v+l+5],A[v+l+2],A[v+l+3],A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,p,h,u,A[v],A[v+1],A[v+2],A[v+3],A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}return y};S.prototype.init=function(t,e){if(this._boneData!==null){return}l.prototype.init.call(this,t,e);var a=t.segmentX;var r=t.segmentY;var i=this._armature.armatureData.parent.intArray[t.geometry.offset+0];var n=1e3;var s=200;this._dX=s*2/a;this._dY=s*2/r;this._k=-this._dY/this._dX;this._kX=-this._dY/(n-s);this._kY=-(n-s)/this._dX;this._vertices.length=i*2;this._deformVertices.length=i*2;this._matrixCahce.length=(a*r+a*2+r*2)*2*7;this._hullCache.length=10;for(var o=0;o=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(h)}if(h&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}var u=1e3;var f=200;var _=2*this.global.x;var m=2*this.global.y;var c=S._helpPoint;this.globalTransformMatrix.transformPoint(u,-f,c);this._hullCache[0]=c.x;this._hullCache[1]=c.y;this._hullCache[2]=_-c.x;this._hullCache[3]=m-c.y;this.globalTransformMatrix.transformPoint(0,this._dY,c,true);this._hullCache[4]=c.x;this._hullCache[5]=c.y;this.globalTransformMatrix.transformPoint(f,u,c);this._hullCache[6]=c.x;this._hullCache[7]=c.y;this._hullCache[8]=_-c.x;this._hullCache[9]=m-c.y;this.globalTransformMatrix.transformPoint(this._dX,0,c,true);this._hullCache[10]=c.x;this._hullCache[11]=c.y}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};return S}(t.Bone);t.Surface=e})(dragonBones||(dragonBones={}));var dragonBones;(function(p){var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.deformVertices=[];return t}t.toString=function(){return"[class dragonBones.DisplayFrame]"};t.prototype._onClear=function(){this.rawDisplayData=null;this.displayData=null;this.textureData=null;this.display=null;this.deformVertices.length=0};t.prototype.updateDeformVertices=function(){if(this.rawDisplayData===null||this.deformVertices.length!==0){return}var t;if(this.rawDisplayData.type===2){t=this.rawDisplayData.geometry}else if(this.rawDisplayData.type===4){t=this.rawDisplayData.geometry}else{return}var e=0;if(t.weight!==null){e=t.weight.count*2}else{e=t.data.intArray[t.offset+0]*2}this.deformVertices.length=e;for(var a=0,r=this.deformVertices.length;a=0&&this._displayIndex0){for(var s=0,o=i;s=0&&this._cachedFrameIndices!==null){var r=this._cachedFrameIndices[t];if(r>=0&&this._cachedFrameIndex===r){this._transformDirty=false}else if(r>=0){this._transformDirty=true;this._cachedFrameIndex=r}else if(this._transformDirty||this._parent._childrenTransformDirty){this._transformDirty=true;this._cachedFrameIndex=-1}else if(this._cachedFrameIndex>=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}else if(this._transformDirty||this._parent._childrenTransformDirty){t=-1;this._transformDirty=true;this._cachedFrameIndex=-1}if(this._transformDirty){if(this._cachedFrameIndex<0){var i=t>=0;this._updateGlobalTransformMatrix(i);if(i&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}this._updateTransform();this._transformDirty=false}};c.prototype.invalidUpdate=function(){this._displayDataDirty=true;this._displayDirty=true;this._transformDirty=true};c.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._updateGlobalTransformMatrix(false);this._transformDirty=false}};c.prototype.replaceRawDisplayData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.rawDisplayData!==t){a.deformVertices.length=0;a.rawDisplayData=t;if(a.rawDisplayData===null){var r=this._armature._armatureData.defaultSkin;if(r!==null){var i=r.getDisplays(this._slotData.name);if(i!==null&&e=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.displayData!==t&&a.rawDisplayData!==t){a.displayData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceTextureData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.textureData!==t){a.textureData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceDisplay=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.display!==t){var r=a.display;a.display=t;if(r!==null&&r!==this._rawDisplay&&r!==this._meshDisplay&&!this._hasDisplay(r)){if(r instanceof p.Armature){}else{this._disposeDisplay(r,true)}}if(t!==null&&t!==this._rawDisplay&&t!==this._meshDisplay&&!this._hasDisplay(r)&&!(t instanceof p.Armature)){this._initDisplay(t,true)}if(e===this._displayIndex){this._displayDirty=true}}};c.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);return this._boundingBoxData.containsPoint(c._helpPoint.x,c._helpPoint.y)};c.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);t=c._helpPoint.x;e=c._helpPoint.y;c._helpMatrix.transformPoint(a,r,c._helpPoint);a=c._helpPoint.x;r=c._helpPoint.y;var o=this._boundingBoxData.intersectsSegment(t,e,a,r,i,n,s);if(o>0){if(o===1||o===2){if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i);if(n!==null){n.x=i.x;n.y=i.y}}else if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}else{if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i)}if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}if(s!==null){this.globalTransformMatrix.transformPoint(Math.cos(s.x),Math.sin(s.x),c._helpPoint,true);s.x=Math.atan2(c._helpPoint.y,c._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(s.y),Math.sin(s.y),c._helpPoint,true);s.y=Math.atan2(c._helpPoint.y,c._helpPoint.x)}}return o};c.prototype.getDisplayFrameAt=function(t){return this._displayFrames[t]};Object.defineProperty(c.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;this._updateVisible()},enumerable:true,configurable:true});Object.defineProperty(c.prototype,"displayFrameCount",{get:function(){return this._displayFrames.length},set:function(t){var e=this._displayFrames.length;if(et){for(var a=e-1;ad){continue}var b=0;for(;;D++){var A=y[D];if(p>A){continue}if(D===0){b=p/A}else{var S=y[D-1];b=(p-S)/(A-S)}break}if(D!==c){c=D;if(u&&D===m){this._computeVertices(_-4,4,0,f);this._computeVertices(0,4,4,f)}else{this._computeVertices(D*6+2,8,0,f)}}this.addCurvePosition(b,f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],l,g,a)}return}if(u){_+=2;f.length=o;this._computeVertices(2,_-4,0,f);this._computeVertices(0,2,_-4,f);f[_-2]=f[0];f[_-1]=f[1]}else{m--;_-=4;f.length=_;this._computeVertices(2,_,0,f)}var P=new Array(m);d=0;var O=f[0],x=f[1],B=0,E=0,M=0,I=0,C=0,F=0;var w,N,R,j,k,L,V,Y;for(var v=0,U=2;vd){continue}for(;;D++){var W=P[D];if(H>W)continue;if(D===0)H/=W;else{var K=P[D-1];H=(H-K)/(W-K)}break}if(D!==c){c=D;var Z=D*6;O=f[Z];x=f[Z+1];B=f[Z+2];E=f[Z+3];M=f[Z+4];I=f[Z+5];C=f[Z+6];F=f[Z+7];w=(O-B*2+M)*.03;N=(x-E*2+I)*.03;R=((B-M)*3-O+C)*.006;j=((E-I)*3-x+F)*.006;k=w*2+R;L=N*2+j;V=(B-O)*.3+w+R*.16666667;Y=(E-x)*.3+N+j*.16666667;G=Math.sqrt(V*V+Y*Y);X[0]=G;for(Z=1;Z<8;Z++){V+=k;Y+=L;k+=R;L+=j;G+=Math.sqrt(V*V+Y*Y);X[Z]=G}V+=k;Y+=L;G+=Math.sqrt(V*V+Y*Y);X[8]=G;V+=k+R;Y+=L+j;G+=Math.sqrt(V*V+Y*Y);X[9]=G;z=0}H*=G;for(;;z++){var q=X[z];if(H>q)continue;if(z===0)H/=q;else{var K=X[z-1];H=z+(H-K)/(q-K)}break}this.addCurvePosition(H*.1,O,x,B,E,M,I,C,F,l,g,a)}};t.prototype.addCurvePosition=function(t,e,a,r,i,n,s,o,l,h,u,f){if(t===0){h[u]=e;h[u+1]=a;h[u+2]=0;return}if(t===1){h[u]=o;h[u+1]=l;h[u+2]=0;return}var _=1-t;var m=_*_;var c=t*t;var p=m*_;var d=m*t*3;var y=_*c*3;var v=t*c;var g=p*e+d*r+y*n+v*o;var D=p*a+d*i+y*s+v*l;h[u]=g;h[u+1]=D;if(f){h[u+2]=Math.atan2(D-(p*a+d*i+y*s),g-(p*e+d*r+y*n))}else{h[u+2]=0}};t.prototype.init=function(t,e){this._constraintData=t;this._armature=e;var a=t;this.pathOffset=a.pathDisplayData.geometry.offset;this.position=a.position;this.spacing=a.spacing;this.rotateOffset=a.rotateOffset;this.rotateMix=a.rotateMix;this.translateMix=a.translateMix;this._root=this._armature.getBone(a.root.name);this._target=this._armature.getBone(a.target.name);this._pathSlot=this._armature.getSlot(a.pathSlot.name);for(var r=0,i=a.bones.length;r0?U.Transform.DEG_RAD:-U.Transform.DEG_RAD}}var x=this.rotateMix;var B=this.translateMix;for(var c=0,E=3;c0){var w=v.a,N=v.b,R=v.c,j=v.d,k=void 0,L=void 0,V=void 0;if(h){k=b[E-1]}else{k=Math.atan2(I,M)}k-=Math.atan2(N,w);if(O){L=Math.cos(k);V=Math.sin(k);var Y=d._boneData.length;S+=(Y*(L*w-V*N)-M)*x;P+=(Y*(V*w+L*N)-I)*x}else{k+=A}if(k>U.Transform.PI){k-=U.Transform.PI_D}else if(k<-U.Transform.PI){k+=U.Transform.PI_D}k*=x;L=Math.cos(k);V=Math.sin(k);v.a=L*w-V*N;v.b=V*w+L*N;v.c=L*R-V*j;v.d=V*R+L*j}d.global.fromMatrix(v)}this.dirty=false};t.prototype.invalidUpdate=function(){};return t}(t);U.PathConstraint=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t){if(t===void 0){t=0}this.time=0;this.timeScale=1;this._systemTime=0;this._animatebles=[];this._clock=null;this.time=t;this._systemTime=(new Date).getTime()*.001}t.prototype.advanceTime=function(t){if(t!==t){t=0}var e=Date.now()*.001;if(t<0){t=e-this._systemTime}this._systemTime=e;if(this.timeScale!==1){t*=this.timeScale}if(t===0){return}if(t<0){this.time-=t}else{this.time+=t}var a=0,r=0,i=this._animatebles.length;for(;a0){this._animatebles[a-r]=n;this._animatebles[a]=null}n.advanceTime(t)}else{r++}}if(r>0){i=this._animatebles.length;for(;a=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&n._subFadeState>0){this._armature._dragonBones.bufferObject(n);this._animationStates.length=0;this._lastAnimationState=null}else{var s=n.animationData;var o=s.cacheFrameRate;if(this._animationDirty&&o>0){this._animationDirty=false;for(var l=0,h=this._armature.getBones();l0){var c=m.getDisplayFrameAt(0).rawDisplayData;if(c!==null&&c.parent===this._armature.armatureData.defaultSkin){m._cachedFrameIndices=s.getSlotCachedFrameIndices(m.name);continue}}m._cachedFrameIndices=null}}n.advanceTime(t,o)}}else if(i>1){for(var p=0,d=0;p0&&n._subFadeState>0){d++;this._armature._dragonBones.bufferObject(n);this._animationDirty=true;if(this._lastAnimationState===n){this._lastAnimationState=null}}else{if(d>0){this._animationStates[p-d]=n}n.advanceTime(t,0)}if(p===i-1&&d>0){this._animationStates.length-=d;if(this._lastAnimationState===null&&this._animationStates.length>0){this._lastAnimationState=this._animationStates[this._animationStates.length-1]}}}this._armature._cacheFrameIndex=-1}else{this._armature._cacheFrameIndex=-1}};t.prototype.reset=function(){for(var t=0,e=this._animationStates;t0){if(t.position<0){t.position%=a.duration;t.position=a.duration-t.position}else if(t.position===a.duration){t.position-=1e-6}else if(t.position>a.duration){t.position%=a.duration}if(t.duration>0&&t.position+t.duration>a.duration){t.duration=a.duration-t.position}if(t.playTimes<0){t.playTimes=a.playTimes}}else{t.playTimes=1;t.position=0;if(t.duration>0){t.duration=0}}if(t.duration===0){t.duration=-1}this._fadeOut(t);var s=g.BaseObject.borrowObject(g.AnimationState);s.init(this._armature,a,t);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var o=false;for(var l=0,h=this._animationStates.length;lthis._animationStates[l].layer){o=true;this._animationStates.splice(l,0,s);break}else if(l!==h-1&&s.layer>this._animationStates[l+1].layer){o=true;this._animationStates.splice(l+1,0,s);break}}if(!o){this._animationStates.push(s)}}else{this._animationStates.push(s)}for(var u=0,f=this._armature.getSlots();u0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var a=this._armature.armatureData.defaultAnimation;if(a!==null){this._animationConfig.animation=a.name;this.playConfig(this._animationConfig)}}else if(!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted){this._lastAnimationState.play()}else{this._animationConfig.animation=this._lastAnimationState.name;this.playConfig(this._animationConfig)}return this._lastAnimationState};t.prototype.fadeIn=function(t,e,a,r,i,n){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(i===void 0){i=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=i!==null?i:"";return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByTime=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByFrame=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.frameCount>0?r.duration*e/r.frameCount:0}return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByProgress=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};t.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByTime(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByFrame(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByProgress(t,e,1);if(a!==null){a.stop()}return a};t.prototype.getBlendState=function(t,e,a){if(!(t in this._blendStates)){this._blendStates[t]={}}var r=this._blendStates[t];if(!(e in r)){var i=r[e]=g.BaseObject.borrowObject(g.BlendState);i.target=a}return r[e]};t.prototype.getState=function(t,e){if(e===void 0){e=-1}var a=this._animationStates.length;while(a--){var r=this._animationStates[a];if(r.name===t&&(e<0||r.layer===e)){return r}}return null};t.prototype.hasAnimation=function(t){return t in this._animations};t.prototype.getStates=function(){return this._animationStates};Object.defineProperty(t.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations===t){return}this._animationNames.length=0;for(var e in this._animations){delete this._animations[e]}for(var e in t){this._animationNames.push(e);this._animations[e]=t[e]}},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});return t}(g.BaseObject);g.Animation=t})(dragonBones||(dragonBones={}));var dragonBones;(function(L){var t=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t._boneMask=[];t._boneTimelines=[];t._boneBlendTimelines=[];t._slotTimelines=[];t._slotBlendTimelines=[];t._constraintTimelines=[];t._animationTimelines=[];t._poseTimelines=[];t._actionTimeline=null;t._zOrderTimeline=null;return t}t.toString=function(){return"[class dragonBones.AnimationState]"};t.prototype._onClear=function(){for(var t=0,e=this._boneTimelines;t=0){this._boneTimelines.splice(v,1);r.returnToPool()}v=this._boneBlendTimelines.indexOf(r);if(v>=0){this._boneBlendTimelines.splice(v,1);r.returnToPool()}}}}{var g={};var D=[];for(var T=0,b=this._slotTimelines;T=0){this._slotTimelines.splice(v,1);r.returnToPool()}v=this._slotBlendTimelines.indexOf(r);if(v>=0){this._slotBlendTimelines.splice(v,1);r.returnToPool()}}}}};t.prototype._advanceFadeTime=function(t){var e=this._fadeState>0;if(this._subFadeState<0){this._subFadeState=0;var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT:L.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}if(t<0){t=-t}this._fadeTime+=t;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=e?0:1}else if(this._fadeTime>0){this._fadeProgress=e?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=e?1:0}if(this._subFadeState>0){if(!e){this._playheadState|=1;this._fadeState=0}var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT_COMPLETE:L.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}};t.prototype.init=function(t,e,a){if(this._armature!==null){return}this._armature=t;this._animationData=e;this.resetToPose=a.resetToPose;this.additive=a.additive;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.blendType=e.blendType;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;this._weight=a.weight;if(a.pauseFadeIn){this._playheadState=2}else{this._playheadState=3}if(a.duration<0){this._position=0;this._duration=this._animationData.duration;if(a.position!==0){if(this.timeScale>=0){this._time=a.position}else{this._time=a.position-this._duration}}else{this._time=0}}else{this._position=a.position;this._duration=a.duration;this._time=0}if(this.timeScale<0&&this._time===0){this._time=-1e-6}if(this.fadeTotalTime<=0){this._fadeProgress=.999999}if(a.boneMask.length>0){this._boneMask.length=a.boneMask.length;for(var r=0,i=this._boneMask.length;r0;var i=true;var n=true;var s=this._time;this._weightResult=this._weight*this._fadeProgress;if(this._parent!==null){this._weightResult*=this._parent._weightResult}if(this._actionTimeline.playState<=0){this._actionTimeline.update(s)}if(this._weight===0){return}if(r){var o=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0){this._zOrderTimeline.update(s)}if(r){var l=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===l){i=false;n=false}else{this._armature._cacheFrameIndex=l;if(this._animationData.cachedFrames[l]){n=false}else{this._animationData.cachedFrames[l]=true}}}if(i){var h=false;var u=null;if(n){for(var f=0,_=this._boneTimelines.length;f<_;++f){var m=this._boneTimelines[f];if(m.playState<=0){m.update(s)}if(m.target!==u){var c=m.target;h=c.update(this);u=c;if(c.dirty===1){var p=c.target.animationPose;p.x=0;p.y=0;p.rotation=0;p.skew=0;p.scaleX=1;p.scaleY=1}}if(h){m.blend(a)}}}for(var f=0,_=this._boneBlendTimelines.length;f<_;++f){var m=this._boneBlendTimelines[f];if(m.playState<=0){m.update(s)}if(m.target.update(this)){m.blend(a)}}if(this.displayControl){for(var f=0,_=this._slotTimelines.length;f<_;++f){var m=this._slotTimelines[f];if(m.playState<=0){var d=m.target;var y=d.displayController;if(y===null||y===this.name||y===this.group){m.update(s)}}}}for(var f=0,_=this._slotBlendTimelines.length;f<_;++f){var m=this._slotBlendTimelines[f];if(m.playState<=0){var c=m.target;m.update(s);if(c.update(this)){m.blend(a)}}}for(var f=0,_=this._constraintTimelines.length;f<_;++f){var m=this._constraintTimelines[f];if(m.playState<=0){m.update(s)}}if(this._animationTimelines.length>0){var v=100;var g=100;var D=null;var T=null;for(var f=0,_=this._animationTimelines.length;f<_;++f){var m=this._animationTimelines[f];if(m.playState<=0){m.update(s)}if(this.blendType===1){var b=m.target;var A=this.parameterX-b.positionX;if(A>=0){if(A0){this._subFadeState=0;if(this._poseTimelines.length>0){for(var S=0,P=this._poseTimelines;S=0){this._boneTimelines.splice(O,1);m.returnToPool();continue}O=this._boneBlendTimelines.indexOf(m);if(O>=0){this._boneBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._slotTimelines.indexOf(m);if(O>=0){this._slotTimelines.splice(O,1);m.returnToPool();continue}O=this._slotBlendTimelines.indexOf(m);if(O>=0){this._slotBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._constraintTimelines.indexOf(m);if(O>=0){this._constraintTimelines.splice(O,1);m.returnToPool();continue}}this._poseTimelines.length=0}}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};t.prototype.play=function(){this._playheadState=3};t.prototype.stop=function(){this._playheadState&=1};t.prototype.fadeOut=function(t,e){if(e===void 0){e=true}if(t<0){t=0}if(e){this._playheadState&=2}if(this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime){return}}else{this._fadeState=1;this._subFadeState=-1;if(t<=0||this._fadeProgress<=0){this._fadeProgress=1e-6}for(var a=0,r=this._boneTimelines;a1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};t.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};t.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var a=this._armature.getBone(t);if(a===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var r=0,i=this._armature.getBones();r=0){this._boneMask.splice(a,1)}if(e){var r=this._armature.getBone(t);if(r!==null){var i=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=i;n=0&&r.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=i;h0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if(t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&this._parent===null){t=this._duration-1e-6}if(this._time===t){return}this._time=t;this._actionTimeline.setCurrentTime(this._time);if(this._zOrderTimeline!==null){this._zOrderTimeline.playState=-1}for(var a=0,r=this._boneTimelines;a0){if(this.leftWeight>0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight){this.dirty++;this.layer=e;this.leftWeight=0;this.blendWeight=0;return false}this.layer=e;this.leftWeight-=this.layerWeight;this.layerWeight=0}a*=this.leftWeight;this.dirty++;this.blendWeight=a;this.layerWeight+=this.blendWeight;return true}return false}this.dirty++;this.layer=e;this.leftWeight=1;this.blendWeight=a;this.layerWeight=a;return true};e.prototype.reset=function(){this.dirty=0;this.layer=0;this.leftWeight=0;this.layerWeight=0;this.blendWeight=0};e.BONE_TRANSFORM="boneTransform";e.BONE_ALPHA="boneAlpha";e.SURFACE="surface";e.SLOT_DEFORM="slotDeform";e.SLOT_ALPHA="slotAlpha";e.SLOT_Z_INDEX="slotZIndex";return e}(L.BaseObject);L.BlendState=V})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){this.dirty=false;this.playState=-1;this.currentPlayTimes=-1;this.currentTime=-1;this.target=null;this._isTween=false;this._valueOffset=0;this._frameValueOffset=0;this._frameOffset=0;this._frameRate=0;this._frameCount=0;this._frameIndex=-1;this._frameRateR=0;this._position=0;this._duration=0;this._timeScale=1;this._timeOffset=0;this._animationData=null;this._timelineData=null;this._armature=null;this._animationState=null;this._actionTimeline=null;this._frameArray=null;this._valueArray=null;this._timelineArray=null;this._frameIndices=null};e.prototype._setCurrentTime=function(t){var e=this.playState;var a=this.currentPlayTimes;var r=this.currentTime;if(this._actionTimeline!==null&&this._frameCount<=1){this.playState=this._actionTimeline.playState>=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var i=this._animationState.playTimes;var n=i*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(i>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=i;if(t<0){this.currentTime=0}else{this.currentTime=this.playState===1?this._duration+1e-6:this._duration}}else{if(this.playState!==0&&this._animationState._playheadState===3){this.playState=0}if(t<0){t=-t;this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=this._duration-t%this._duration}else{this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=t%this._duration}}this.currentTime+=this._position}else{this.playState=this._actionTimeline.playState;this.currentPlayTimes=this._actionTimeline.currentPlayTimes;this.currentTime=this._actionTimeline.currentTime}if(this.currentPlayTimes===a&&this.currentTime===r){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==a){this._frameIndex=-1}return true};e.prototype.init=function(t,e,a){this._armature=t;this._animationState=e;this._timelineData=a;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._animationData=this._animationState.animationData;this._frameRate=this._animationData.parent.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;if(this._timelineData!==null){var r=this._animationData.parent.parent;this._frameArray=r.frameArray;this._timelineArray=r.timelineArray;this._frameIndices=r.frameIndices;this._frameCount=this._timelineArray[this._timelineData.offset+2];this._frameValueOffset=this._timelineArray[this._timelineData.offset+4];this._timeScale=100/this._timelineArray[this._timelineData.offset+0];this._timeOffset=this._timelineArray[this._timelineData.offset+1]*.01}};e.prototype.fadeOut=function(){this.dirty=false};e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var a=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==a){this._frameIndex=a;this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex];this._onArriveAtFrame()}}else if(this._frameIndex<0){this._frameIndex=0;if(this._timelineData!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]}this._onArriveAtFrame()}if(this._isTween||this.dirty){this._onUpdateFrame()}}};e.prototype.blend=function(t){};return e}(t.BaseObject);t.TimelineState=e;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,a){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI));break}return(r-e)*a+e};e._getEasingCurveValue=function(t,e,a,r){if(t<=0){return 0}else if(t>=1){return 1}var i=a>0;var n=a+1;var s=Math.floor(t*n);var o=0;var l=0;if(i){o=s===0?0:e[r+s-1];l=s===n-1?1e4:e[r+s]}else{o=e[r+s-1];l=e[r+s]}return(o+(l-o)*(t*n-s))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenEasing=0;this._tweenProgress=0;this._valueScale=1};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){this._frameDurationR=1/e}else{this._frameDurationR=0}}}else{this.dirty=true;this._isTween=false}};e.prototype._onUpdateFrame=function(){if(this._isTween){this.dirty=true;this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR;if(this._tweenType===2){this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3)}else if(this._tweenType!==1){this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)}}};return e}(e);t.TweenTimelineState=a;var r=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._current=0;this._difference=0;this._result=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+1;if(t===1){this._current=e[a];this._difference=e[r]-this._current}else{this._current=e[a]*t;this._difference=e[r]*t-this._current}}else{this._result=e[a]*t}}else{this._result=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._result=this._current+this._difference*this._tweenProgress}};return t}(a);t.SingleValueTimelineState=r;var i=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._currentA=0;this._currentB=0;this._differenceA=0;this._differenceB=0;this._resultA=0;this._resultB=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex*2;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+2;if(t===1){this._currentA=e[a];this._currentB=e[a+1];this._differenceA=e[r]-this._currentA;this._differenceB=e[r+1]-this._currentB}else{this._currentA=e[a]*t;this._currentB=e[a+1]*t;this._differenceA=e[r]*t-this._currentA;this._differenceB=e[r+1]*t-this._currentB}}else{this._resultA=e[a]*t;this._resultB=e[a+1]*t}}else{this._resultA=0;this._resultB=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._resultA=this._currentA+this._differenceA*this._tweenProgress;this._resultB=this._currentB+this._differenceB*this._tweenProgress}};return t}(a);t.DoubleValueTimelineState=i;var n=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._rd=[];return t}t.prototype._onClear=function(){o.prototype._onClear.call(this);this._valueCount=0;this._rd.length=0};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);var t=this._valueCount;var e=this._rd;if(this._timelineData!==null){var a=this._valueScale;var r=this._valueArray;var i=this._valueOffset+this._frameValueOffset+this._frameIndex*t;if(this._isTween){var n=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:i+t;if(a===1){for(var s=0;s0){if(n.hasDBEventListener(y.EventObject.COMPLETE)){h=y.BaseObject.borrowObject(y.EventObject);h.type=y.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var u=this._timelineData;var f=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[u.frameIndicesOffset+f];if(this._frameIndex!==_){var m=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[u.offset+5+this._frameIndex];if(o){if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(m)}if(l!==null&&m===0){this._armature._dragonBones.bufferEvent(l);l=null}if(m>0){m--}else{m=this._frameCount-1}if(m===_){break}}}else{if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this.currentPlayTimes===a){if(r<=d){if(m>0){m--}else{m=this._frameCount-1}}else if(m===_){m=-1}}}while(m>=0){if(m=0){var t=this._frameArray[this._frameOffset+1];if(t>0){this._armature._sortZOrder(this._frameArray,this._frameOffset+2)}else{this._armature._sortZOrder(null,0)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.ZOrderTimelineState=e;var a=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])}if(this._timelineData===null){this._rd[4]=1;this._rd[5]=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=6;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])};t.prototype.blend=function(t){var e=this._armature.armatureData.scale;var a=this._rd;var r=this.target;var i=r.target;var n=r.blendWeight;var s=i.animationPose;if(r.dirty>1){s.x+=a[0]*n*e;s.y+=a[1]*n*e;s.rotation+=a[2]*n;s.skew+=a[3]*n;s.scaleX+=(a[4]-1)*n;s.scaleY+=(a[5]-1)*n}else{s.x=a[0]*n*e;s.y=a[1]*n*e;s.rotation=a[2]*n;s.skew=a[3]*n;s.scaleX=(a[4]-1)*n+1;s.scaleY=(a[5]-1)*n+1}if(t||this.dirty){this.dirty=false;i._transformDirty=true}};return t}(y.MutilpleValueTimelineState);y.BoneAllTimelineState=a;var r=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.x+=this._resultA*r;i.y+=this._resultB*r}else if(r!==1){i.x=this._resultA*r;i.y=this._resultB*r}else{i.x=this._resultA;i.y=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneTranslateTimelineState=r;var i=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._differenceA=y.Transform.normalizeRadian(this._differenceA);this._differenceB=y.Transform.normalizeRadian(this._differenceB)}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._resultA=y.Transform.normalizeRadian(this._resultA);this._resultB=y.Transform.normalizeRadian(this._resultB)};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.rotation+=this._resultA*r;i.skew+=this._resultB*r}else if(r!==1){i.rotation=this._resultA*r;i.skew=this._resultB*r}else{i.rotation=this._resultA;i.skew=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneRotateTimelineState=i;var n=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){this._resultA=1;this._resultB=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.scaleX+=(this._resultA-1)*r;i.scaleY+=(this._resultB-1)*r}else if(r!==1){i.scaleX=(this._resultA-1)*r+1;i.scaleY=(this._resultB-1)*r+1}else{i.scaleX=this._resultA;i.scaleY=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneScaleTimelineState=n;var s=function(s){__extends(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SurfaceTimelineState]"};t.prototype._onClear=function(){s.prototype._onClear.call(this);this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){s.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.parent.parent;var i=r.frameIntArray;var n=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=i[n+2];this._deformCount=i[n+1];this._deformOffset=i[n+3];this._sameValueOffset=i[n+4]+this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=r.frameFloatArray;this._rd.length=this._valueCount*2}else{this._deformCount=this.target.target._deformVertices.length}};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a._deformVertices;var n=this._valueArray;if(n!==null){var s=this._valueCount;var o=this._deformOffset;var l=this._sameValueOffset;var h=this._rd;for(var u=0;u1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u1){a._alpha+=this._result*r;if(a._alpha>1){a._alpha=1}}else{a._alpha=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._alphaDirty=true}};return t}(y.SingleValueTimelineState);y.AlphaTimelineState=o;var l=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDisplayTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this.target;var e=this._timelineData!==null?this._frameArray[this._frameOffset+1]:t._slotData.displayIndex;if(t.displayIndex!==e){t._setDisplayIndex(e,true)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.SlotDisplayTimelineState=l;var h=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._current=[0,0,0,0,0,0,0,0];t._difference=[0,0,0,0,0,0,0,0];t._result=[0,0,0,0,0,0,0,0];return t}t.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._animationData.parent.parent;var e=t.colorArray;var a=t.frameIntArray;var r=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex;var i=a[r];if(i<0){i+=65536}if(this._isTween){this._current[0]=e[i++];this._current[1]=e[i++];this._current[2]=e[i++];this._current[3]=e[i++];this._current[4]=e[i++];this._current[5]=e[i++];this._current[6]=e[i++];this._current[7]=e[i++];if(this._frameIndex===this._frameCount-1){i=a[this._animationData.frameIntOffset+this._frameValueOffset]}else{i=a[r+1]}if(i<0){i+=65536}this._difference[0]=e[i++]-this._current[0];this._difference[1]=e[i++]-this._current[1];this._difference[2]=e[i++]-this._current[2];this._difference[3]=e[i++]-this._current[3];this._difference[4]=e[i++]-this._current[4];this._difference[5]=e[i++]-this._current[5];this._difference[6]=e[i++]-this._current[6];this._difference[7]=e[i++]-this._current[7]}else{this._result[0]=e[i++]*.01;this._result[1]=e[i++]*.01;this._result[2]=e[i++]*.01;this._result[3]=e[i++]*.01;this._result[4]=e[i++];this._result[5]=e[i++];this._result[6]=e[i++];this._result[7]=e[i++]}}else{var n=this.target;var s=n.slotData.color;this._result[0]=s.alphaMultiplier;this._result[1]=s.redMultiplier;this._result[2]=s.greenMultiplier;this._result[3]=s.blueMultiplier;this._result[4]=s.alphaOffset;this._result[5]=s.redOffset;this._result[6]=s.greenOffset;this._result[7]=s.blueOffset}};t.prototype._onUpdateFrame=function(){o.prototype._onUpdateFrame.call(this);if(this._isTween){this._result[0]=(this._current[0]+this._difference[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._difference[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._difference[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._difference[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._difference[4]*this._tweenProgress;this._result[5]=this._current[5]+this._difference[5]*this._tweenProgress;this._result[6]=this._current[6]+this._difference[6]*this._tweenProgress;this._result[7]=this._current[7]+this._difference[7]*this._tweenProgress}};t.prototype.fadeOut=function(){this._isTween=false};t.prototype.update=function(t){o.prototype.update.call(this,t);if(this._isTween||this.dirty){var e=this.target;var a=e._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);a.alphaMultiplier+=(this._result[0]-a.alphaMultiplier)*r;a.redMultiplier+=(this._result[1]-a.redMultiplier)*r;a.greenMultiplier+=(this._result[2]-a.greenMultiplier)*r;a.blueMultiplier+=(this._result[3]-a.blueMultiplier)*r;a.alphaOffset+=(this._result[4]-a.alphaOffset)*r;a.redOffset+=(this._result[5]-a.redOffset)*r;a.greenOffset+=(this._result[6]-a.greenOffset)*r;a.blueOffset+=(this._result[7]-a.blueOffset)*r;e._colorDirty=true}}else if(this.dirty){this.dirty=false;if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){a.alphaMultiplier=this._result[0];a.redMultiplier=this._result[1];a.greenMultiplier=this._result[2];a.blueMultiplier=this._result[3];a.alphaOffset=this._result[4];a.redOffset=this._result[5];a.greenOffset=this._result[6];a.blueOffset=this._result[7];e._colorDirty=true}}}};return t}(y.TweenTimelineState);y.SlotColorTimelineState=h;var u=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SlotZIndexTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){var t=this.target;var e=t.target;this._result=e.slotData.zIndex}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueArray=this._animationData.parent.parent.frameIntArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;if(e.dirty>1){a._zIndex+=this._result*r}else{a._zIndex=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._zIndexDirty=true}};return t}(y.SingleValueTimelineState);y.SlotZIndexTimelineState=u;var f=function(f){__extends(t,f);function t(){return f!==null&&f.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.DeformTimelineState]"};t.prototype._onClear=function(){f.prototype._onClear.call(this);this.geometryOffset=0;this.displayFrame=null;this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){f.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];var i=this._animationData.parent.parent;var n=i.frameIntArray;var s=this.target.target;this.geometryOffset=n[r+0];if(this.geometryOffset<0){this.geometryOffset+=65536}for(var o=0,l=s.displayFrameCount;o1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u0;t._weight=this._currentB}else{var e=t._constraintData;t._bendPositive=e.bendPositive;t._weight=e.weight}t.invalidUpdate();this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=.01;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.IKConstraintTimelineState=_;var m=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationProgressTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.currentTime=this._result*t.totalTime}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationProgressTimelineState=m;var c=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationWeightTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.weight=this._result}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationWeightTimelineState=c;var p=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationParametersTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.parameterX=this._resultA;t.parameterY=this._resultB}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.AnimationParametersTimelineState=p})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}r.actionDataToInstance=function(t,e,a){if(t.type===0){e.type=r.FRAME_EVENT}else{e.type=t.type===10?r.FRAME_EVENT:r.SOUND_EVENT}e.name=t.name;e.armature=a;e.actionData=t;e.data=t.data;if(t.bone!==null){e.bone=a.getBone(t.bone.name)}if(t.slot!==null){e.slot=a.getSlot(t.slot.name)}};r.toString=function(){return"[class dragonBones.EventObject]"};r.prototype._onClear=function(){this.time=0;this.type="";this.name="";this.armature=null;this.bone=null;this.slot=null;this.animationState=null;this.actionData=null;this.data=null};r.START="start";r.LOOP_COMPLETE="loopComplete";r.COMPLETE="complete";r.FADE_IN="fadeIn";r.FADE_IN_COMPLETE="fadeInComplete";r.FADE_OUT="fadeOut";r.FADE_OUT_COMPLETE="fadeOutComplete";r.FRAME_EVENT="frameEvent";r.SOUND_EVENT="soundEvent";return r}(t.BaseObject);t.EventObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(){}t._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}};t._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}};t._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}};t._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}};t._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}};t._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}};t._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}};t._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}};t._getAnimationBlendType=function(t){switch(t.toLowerCase()){case"none":return 0;case"1d":return 1;default:return 0}};t._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}};t.DATA_VERSION_2_3="2.3";t.DATA_VERSION_3_0="3.0";t.DATA_VERSION_4_0="4.0";t.DATA_VERSION_4_5="4.5";t.DATA_VERSION_5_0="5.0";t.DATA_VERSION_5_5="5.5";t.DATA_VERSION_5_6="5.6";t.DATA_VERSION=t.DATA_VERSION_5_6;t.DATA_VERSIONS=[t.DATA_VERSION_4_0,t.DATA_VERSION_4_5,t.DATA_VERSION_5_0,t.DATA_VERSION_5_5,t.DATA_VERSION_5_6];t.TEXTURE_ATLAS="textureAtlas";t.SUB_TEXTURE="SubTexture";t.FORMAT="format";t.IMAGE_PATH="imagePath";t.WIDTH="width";t.HEIGHT="height";t.ROTATED="rotated";t.FRAME_X="frameX";t.FRAME_Y="frameY";t.FRAME_WIDTH="frameWidth";t.FRAME_HEIGHT="frameHeight";t.DRADON_BONES="dragonBones";t.USER_DATA="userData";t.ARMATURE="armature";t.CANVAS="canvas";t.BONE="bone";t.SURFACE="surface";t.SLOT="slot";t.CONSTRAINT="constraint";t.SKIN="skin";t.DISPLAY="display";t.FRAME="frame";t.IK="ik";t.PATH_CONSTRAINT="path";t.ANIMATION="animation";t.TIMELINE="timeline";t.FFD="ffd";t.TRANSLATE_FRAME="translateFrame";t.ROTATE_FRAME="rotateFrame";t.SCALE_FRAME="scaleFrame";t.DISPLAY_FRAME="displayFrame";t.COLOR_FRAME="colorFrame";t.DEFAULT_ACTIONS="defaultActions";t.ACTIONS="actions";t.EVENTS="events";t.INTS="ints";t.FLOATS="floats";t.STRINGS="strings";t.TRANSFORM="transform";t.PIVOT="pivot";t.AABB="aabb";t.COLOR="color";t.VERSION="version";t.COMPATIBLE_VERSION="compatibleVersion";t.FRAME_RATE="frameRate";t.TYPE="type";t.SUB_TYPE="subType";t.NAME="name";t.PARENT="parent";t.TARGET="target";t.STAGE="stage";t.SHARE="share";t.PATH="path";t.LENGTH="length";t.DISPLAY_INDEX="displayIndex";t.Z_ORDER="zOrder";t.Z_INDEX="zIndex";t.BLEND_MODE="blendMode";t.INHERIT_TRANSLATION="inheritTranslation";t.INHERIT_ROTATION="inheritRotation";t.INHERIT_SCALE="inheritScale";t.INHERIT_REFLECTION="inheritReflection";t.INHERIT_ANIMATION="inheritAnimation";t.INHERIT_DEFORM="inheritDeform";t.SEGMENT_X="segmentX";t.SEGMENT_Y="segmentY";t.BEND_POSITIVE="bendPositive";t.CHAIN="chain";t.WEIGHT="weight";t.BLEND_TYPE="blendType";t.FADE_IN_TIME="fadeInTime";t.PLAY_TIMES="playTimes";t.SCALE="scale";t.OFFSET="offset";t.POSITION="position";t.DURATION="duration";t.TWEEN_EASING="tweenEasing";t.TWEEN_ROTATE="tweenRotate";t.TWEEN_SCALE="tweenScale";t.CLOCK_WISE="clockwise";t.CURVE="curve";t.SOUND="sound";t.EVENT="event";t.ACTION="action";t.X="x";t.Y="y";t.SKEW_X="skX";t.SKEW_Y="skY";t.SCALE_X="scX";t.SCALE_Y="scY";t.VALUE="value";t.ROTATE="rotate";t.SKEW="skew";t.ALPHA="alpha";t.ALPHA_OFFSET="aO";t.RED_OFFSET="rO";t.GREEN_OFFSET="gO";t.BLUE_OFFSET="bO";t.ALPHA_MULTIPLIER="aM";t.RED_MULTIPLIER="rM";t.GREEN_MULTIPLIER="gM";t.BLUE_MULTIPLIER="bM";t.UVS="uvs";t.VERTICES="vertices";t.TRIANGLES="triangles";t.WEIGHTS="weights";t.SLOT_POSE="slotPose";t.BONE_POSE="bonePose";t.BONES="bones";t.POSITION_MODE="positionMode";t.SPACING_MODE="spacingMode";t.ROTATE_MODE="rotateMode";t.SPACING="spacing";t.ROTATE_OFFSET="rotateOffset";t.ROTATE_MIX="rotateMix";t.TRANSLATE_MIX="translateMix";t.TARGET_DISPLAY="targetDisplay";t.CLOSED="closed";t.CONSTANT_SPEED="constantSpeed";t.VERTEX_COUNT="vertexCount";t.LENGTHS="lengths";t.GOTO_AND_PLAY="gotoAndPlay";t.DEFAULT_NAME="default";return t}();t.DataParser=e})(dragonBones||(dragonBones={}));var dragonBones;(function(tt){var t=function(e){__extends($,e);function $(){var t=e!==null&&e.apply(this,arguments)||this;t._rawTextureAtlasIndex=0;t._rawBones=[];t._data=null;t._armature=null;t._bone=null;t._geometry=null;t._slot=null;t._skin=null;t._mesh=null;t._animation=null;t._timeline=null;t._rawTextureAtlases=null;t._frameValueType=0;t._defaultColorOffset=-1;t._prevClockwise=0;t._prevRotation=0;t._frameDefaultValue=0;t._frameValueScale=1;t._helpMatrixA=new tt.Matrix;t._helpMatrixB=new tt.Matrix;t._helpTransform=new tt.Transform;t._helpColorTransform=new tt.ColorTransform;t._helpPoint=new tt.Point;t._helpArray=[];t._intArray=[];t._floatArray=[];t._frameIntArray=[];t._frameFloatArray=[];t._frameArray=[];t._timelineArray=[];t._colorArray=[];t._cacheRawMeshes=[];t._cacheMeshes=[];t._actionFrames=[];t._weightSlotPose={};t._weightBonePoses={};t._cacheBones={};t._slotChildActions={};return t}$._getBoolean=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="boolean"){return r}else if(i==="string"){switch(r){case"0":case"NaN":case"":case"false":case"null":case"undefined":return false;default:return true}}else{return!!r}}return a};$._getNumber=function(t,e,a){if(e in t){var r=t[e];if(r===null||r==="NaN"){return a}return+r||0}return a};$._getString=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="string"){return r}return String(r)}return a};$.prototype._getCurvePoint=function(t,e,a,r,i,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var m=u*f;var c=3*l*f;var p=3*u*_;var d=l*_;h.x=m*t+c*a+p*i+d*s;h.y=m*e+c*r+p*n+d*o};$.prototype._samplingEasingCurve=function(t,e){var a=t.length;if(a%3===1){var r=-2;for(var i=0,n=e.length;i=0&&r+61e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return true}else{var r=0;for(var i=0,n=e.length;i1e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return false}};$.prototype._parseActionDataInFrame=function(t,e,a,r){if(tt.DataParser.EVENT in t){this._mergeActionFrame(t[tt.DataParser.EVENT],e,10,a,r)}if(tt.DataParser.SOUND in t){this._mergeActionFrame(t[tt.DataParser.SOUND],e,11,a,r)}if(tt.DataParser.ACTION in t){this._mergeActionFrame(t[tt.DataParser.ACTION],e,0,a,r)}if(tt.DataParser.EVENTS in t){this._mergeActionFrame(t[tt.DataParser.EVENTS],e,10,a,r)}if(tt.DataParser.ACTIONS in t){this._mergeActionFrame(t[tt.DataParser.ACTIONS],e,0,a,r)}};$.prototype._mergeActionFrame=function(t,e,a,r,i){var n=this._armature.actions.length;var s=this._parseActionData(t,a,r,i);var o=0;var l=null;for(var h=0,u=s;he){break}o++}if(l===null){l=new D;l.frameStart=e;this._actionFrames.splice(o,0,l)}for(var p=0;p0){var _=a.getBone(u);if(_!==null){f.parent=_}else{if(!(u in this._cacheBones)){this._cacheBones[u]=[]}this._cacheBones[u].push(f)}}if(f.name in this._cacheBones){for(var m=0,c=this._cacheBones[f.name];m0&&e.parent!==null){i.root=e.parent;i.bone=e}else{i.root=e;i.bone=null}return i};$.prototype._parsePathConstraint=function(t){var e=this._armature.getSlot($._getString(t,tt.DataParser.TARGET,""));if(e===null){return null}var a=this._armature.defaultSkin;if(a===null){return null}var r=a.getDisplay(e.name,$._getString(t,tt.DataParser.TARGET_DISPLAY,e.name));if(r===null||!(r instanceof tt.PathDisplayData)){return null}var i=t[tt.DataParser.BONES];if(i===null||i.length===0){return null}var n=tt.BaseObject.borrowObject(tt.PathConstraintData);n.name=$._getString(t,tt.DataParser.NAME,"");n.type=1;n.pathSlot=e;n.pathDisplayData=r;n.target=e.parent;n.positionMode=tt.DataParser._getPositionMode($._getString(t,tt.DataParser.POSITION_MODE,""));n.spacingMode=tt.DataParser._getSpacingMode($._getString(t,tt.DataParser.SPACING_MODE,""));n.rotateMode=tt.DataParser._getRotateMode($._getString(t,tt.DataParser.ROTATE_MODE,""));n.position=$._getNumber(t,tt.DataParser.POSITION,0);n.spacing=$._getNumber(t,tt.DataParser.SPACING,0);n.rotateOffset=$._getNumber(t,tt.DataParser.ROTATE_OFFSET,0);n.rotateMix=$._getNumber(t,tt.DataParser.ROTATE_MIX,1);n.translateMix=$._getNumber(t,tt.DataParser.TRANSLATE_MIX,1);for(var s=0,o=i;s0?a:e;this._parsePivot(t,n);break}case 1:{var s=i=tt.BaseObject.borrowObject(tt.ArmatureDisplayData);s.name=e;s.path=a.length>0?a:e;s.inheritAnimation=true;if(tt.DataParser.ACTIONS in t){var o=this._parseActionData(t[tt.DataParser.ACTIONS],0,null,null);for(var l=0,h=o;l0?a:e;if(tt.DataParser.SHARE in t){c.geometry.data=this._data;this._cacheRawMeshes.push(t);this._cacheMeshes.push(c)}else{this._parseMesh(t,c)}break}case 3:{var p=this._parseBoundingBox(t);if(p!==null){var d=i=tt.BaseObject.borrowObject(tt.BoundingBoxDisplayData);d.name=e;d.path=a.length>0?a:e;d.boundingBox=p}break}case 4:{var y=t[tt.DataParser.LENGTHS];var v=i=tt.BaseObject.borrowObject(tt.PathDisplayData);v.closed=$._getBoolean(t,tt.DataParser.CLOSED,false);v.constantSpeed=$._getBoolean(t,tt.DataParser.CONSTANT_SPEED,false);v.name=e;v.path=a.length>0?a:e;v.curveLengths.length=y.length;for(var g=0,D=y.length;ge.width){e.width=o}if(le.height){e.height=l}}}e.width-=e.x;e.height-=e.y}else{console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.")}return e};$.prototype._parseAnimation=function(t){var e=tt.BaseObject.borrowObject(tt.AnimationData);e.blendType=tt.DataParser._getAnimationBlendType($._getString(t,tt.DataParser.BLEND_TYPE,""));e.frameCount=$._getNumber(t,tt.DataParser.DURATION,0);e.playTimes=$._getNumber(t,tt.DataParser.PLAY_TIMES,1);e.duration=e.frameCount/this._armature.frameRate;e.fadeInTime=$._getNumber(t,tt.DataParser.FADE_IN_TIME,0);e.scale=$._getNumber(t,tt.DataParser.SCALE,1);e.name=$._getString(t,tt.DataParser.NAME,tt.DataParser.DEFAULT_NAME);if(e.name.length===0){e.name=tt.DataParser.DEFAULT_NAME}e.frameIntOffset=this._frameIntArray.length;e.frameFloatOffset=this._frameFloatArray.length;e.frameOffset=this._frameArray.length;this._animation=e;if(tt.DataParser.FRAME in t){var a=t[tt.DataParser.FRAME];var r=a.length;if(r>0){for(var i=0,n=0;i0){this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,0,0,this._parseActionFrame);this._actionFrames.length=0}if(tt.DataParser.TIMELINE in t){var o=t[tt.DataParser.TIMELINE];for(var A=0,S=o;A0&&a in t){e=t[a]}if(e===null){return null}var l=e.length;if(l===0){return null}var h=this._frameIntArray.length;var u=this._frameFloatArray.length;var f=this._timelineArray.length;if(o===null){o=tt.BaseObject.borrowObject(tt.TimelineData)}o.type=r;o.offset=f;this._frameValueType=i;this._timeline=o;this._timelineArray.length+=1+1+1+1+1+l;if(t!==null){this._timelineArray[f+0]=Math.round($._getNumber(t,tt.DataParser.SCALE,1)*100);this._timelineArray[f+1]=Math.round($._getNumber(t,tt.DataParser.OFFSET,0)*100)}else{this._timelineArray[f+0]=100;this._timelineArray[f+1]=0}this._timelineArray[f+2]=l;this._timelineArray[f+3]=n;switch(this._frameValueType){case 0:this._timelineArray[f+4]=0;break;case 1:this._timelineArray[f+4]=h-this._animation.frameIntOffset;break;case 2:this._timelineArray[f+4]=u-this._animation.frameFloatOffset;break}if(l===1){o.frameIndicesOffset=-1;this._timelineArray[f+5+0]=s.call(this,e[0],0,0)-this._animation.frameOffset}else{var _=this._animation.frameCount+1;var m=this._data.frameIndices;var c=m.length;m.length+=_;o.frameIndicesOffset=c;for(var p=0,d=0,y=0,v=0;p<_;++p){if(y+v<=p&&d0){if(tt.DataParser.CURVE in t){var i=a+1;this._helpArray.length=i;var n=this._samplingEasingCurve(t[tt.DataParser.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length;this._frameArray[r+1]=2;this._frameArray[r+2]=n?i:-i;for(var s=0;s0){var n=this._armature.sortedSlots.length;var s=new Array(n-i.length/2);var o=new Array(n);for(var l=0;l0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.TWEEN_ROTATE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=6;this._frameFloatArray[n++]=this._helpTransform.x;this._frameFloatArray[n++]=this._helpTransform.y;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=this._helpTransform.skew;this._frameFloatArray[n++]=this._helpTransform.scaleX;this._frameFloatArray[n++]=this._helpTransform.scaleY;this._parseActionDataInFrame(t,e,this._bone,this._slot);return i};$.prototype._parseBoneTranslateFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,0);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,0);return r};$.prototype._parseBoneRotateFrame=function(t,e,a){var r=$._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD;if(e!==0){if(this._prevClockwise===0){r=this._prevRotation+tt.Transform.normalizeRadian(r-this._prevRotation)}else{if(this._prevClockwise>0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.CLOCK_WISE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=$._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD;return i};$.prototype._parseBoneScaleFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,1);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,1);return r};$.prototype._parseSlotDisplayFrame=function(t,e,a){var r=this._parseFrame(t,e,a);this._frameArray.length+=1;if(tt.DataParser.VALUE in t){this._frameArray[r+1]=$._getNumber(t,tt.DataParser.VALUE,0)}else{this._frameArray[r+1]=$._getNumber(t,tt.DataParser.DISPLAY_INDEX,0)}this._parseActionDataInFrame(t,e,this._slot.parent,this._slot);return r};$.prototype._parseSlotColorFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=-1;if(tt.DataParser.VALUE in t||tt.DataParser.COLOR in t){var n=tt.DataParser.VALUE in t?t[tt.DataParser.VALUE]:t[tt.DataParser.COLOR];for(var s in n){s;this._parseColorTransform(n,this._helpColorTransform);i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=Math.round(this._helpColorTransform.alphaMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.redMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.greenMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.blueMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.alphaOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.redOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.greenOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.blueOffset);i-=8;break}}if(i<0){if(this._defaultColorOffset<0){this._defaultColorOffset=i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0}i=this._defaultColorOffset}var o=this._frameIntArray.length;this._frameIntArray.length+=1;this._frameIntArray[o]=i;return r};$.prototype._parseSlotDeformFrame=function(t,e,a){var r=this._frameFloatArray.length;var i=this._parseTweenFrame(t,e,a);var n=tt.DataParser.VERTICES in t?t[tt.DataParser.VERTICES]:null;var s=$._getNumber(t,tt.DataParser.OFFSET,0);var o=this._intArray[this._mesh.geometry.offset+0];var l=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name;var h=this._mesh.geometry.weight;var u=0;var f=0;var _=0;var m=0;if(h!==null){var c=this._weightSlotPose[l];this._helpMatrixA.copyFromArray(c,0);this._frameFloatArray.length+=h.count*2;_=h.offset+2+h.bones.length}else{this._frameFloatArray.length+=o*2}for(var p=0;p=n.length){u=0}else{u=n[p-s]}if(p+1=n.length){f=0}else{f=n[p+1-s]}}if(h!==null){var d=this._weightBonePoses[l];var y=this._intArray[_++];this._helpMatrixA.transformPoint(u,f,this._helpPoint,true);u=this._helpPoint.x;f=this._helpPoint.y;for(var v=0;v=n.length){h=0}else{h=n[f-s]}if(f+1=n.length){u=0}else{u=n[f+1-s]}}else{h=0;u=0}this._frameFloatArray[r+f]=h;this._frameFloatArray[r+f+1]=u}}if(e===0){var _=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1;this._frameIntArray[_+0]=this._geometry.offset;this._frameIntArray[_+1]=this._frameFloatArray.length-r;this._frameIntArray[_+2]=this._frameFloatArray.length-r;this._frameIntArray[_+3]=0;this._frameIntArray[_+4]=r-this._animation.frameFloatOffset;this._timelineArray[this._timeline.offset+3]=_-this._animation.frameIntOffset}return i};$.prototype._parseTransform=function(t,e,a){e.x=$._getNumber(t,tt.DataParser.X,0)*a;e.y=$._getNumber(t,tt.DataParser.Y,0)*a;if(tt.DataParser.ROTATE in t||tt.DataParser.SKEW in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD)}else if(tt.DataParser.SKEW_X in t||tt.DataParser.SKEW_Y in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_Y,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_X,0)*tt.Transform.DEG_RAD)-e.rotation}e.scaleX=$._getNumber(t,tt.DataParser.SCALE_X,1);e.scaleY=$._getNumber(t,tt.DataParser.SCALE_Y,1)};$.prototype._parseColorTransform=function(t,e){e.alphaMultiplier=$._getNumber(t,tt.DataParser.ALPHA_MULTIPLIER,100)*.01;e.redMultiplier=$._getNumber(t,tt.DataParser.RED_MULTIPLIER,100)*.01;e.greenMultiplier=$._getNumber(t,tt.DataParser.GREEN_MULTIPLIER,100)*.01;e.blueMultiplier=$._getNumber(t,tt.DataParser.BLUE_MULTIPLIER,100)*.01;e.alphaOffset=$._getNumber(t,tt.DataParser.ALPHA_OFFSET,0);e.redOffset=$._getNumber(t,tt.DataParser.RED_OFFSET,0);e.greenOffset=$._getNumber(t,tt.DataParser.GREEN_OFFSET,0);e.blueOffset=$._getNumber(t,tt.DataParser.BLUE_OFFSET,0)};$.prototype._parseGeometry=function(t,e){var a=t[tt.DataParser.VERTICES];var r=Math.floor(a.length/2);var i=0;var n=this._intArray.length;var s=this._floatArray.length;e.offset=n;e.data=this._data;this._intArray.length+=1+1+1+1;this._intArray[n+0]=r;this._intArray[n+2]=s;this._intArray[n+3]=-1;this._floatArray.length+=r*2;for(var o=0,l=r*2;o=0||tt.DataParser.DATA_VERSIONS.indexOf(r)>=0){var i=tt.BaseObject.borrowObject(tt.DragonBonesData);i.version=a;i.name=$._getString(t,tt.DataParser.NAME,"");i.frameRate=$._getNumber(t,tt.DataParser.FRAME_RATE,24);if(i.frameRate===0){i.frameRate=24}if(tt.DataParser.ARMATURE in t){this._data=i;this._parseArray(t);var n=t[tt.DataParser.ARMATURE];for(var s=0,o=n;s0){i.stage=i.getArmature(i.armatureNames[0])}this._data=null}if(tt.DataParser.TEXTURE_ATLAS in t){this._rawTextureAtlases=t[tt.DataParser.TEXTURE_ATLAS]}return i}else{console.assert(false,"Nonsupport data version: "+a+"\n"+"Please convert DragonBones data to support version.\n"+"Read more: https://github.com/DragonBones/Tools/")}return null};$.prototype.parseTextureAtlasData=function(t,e,a){if(a===void 0){a=1}console.assert(t!==undefined);if(t===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0){return false}var r=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(r,e,a);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}e.width=$._getNumber(t,tt.DataParser.WIDTH,0);e.height=$._getNumber(t,tt.DataParser.HEIGHT,0);e.scale=a===1?1/$._getNumber(t,tt.DataParser.SCALE,1):a;e.name=$._getString(t,tt.DataParser.NAME,"");e.imagePath=$._getString(t,tt.DataParser.IMAGE_PATH,"");if(tt.DataParser.SUB_TEXTURE in t){var i=t[tt.DataParser.SUB_TEXTURE];for(var n=0,s=i.length;n0&&h>0){u.frame=tt.TextureData.createRectangle();u.frame.x=$._getNumber(o,tt.DataParser.FRAME_X,0);u.frame.y=$._getNumber(o,tt.DataParser.FRAME_Y,0);u.frame.width=l;u.frame.height=h}e.addTexture(u)}}return true};$.getInstance=function(){if($._objectDataParserInstance===null){$._objectDataParserInstance=new $}return $._objectDataParserInstance};$._objectDataParserInstance=null;return $}(tt.DataParser);tt.ObjectDataParser=t;var D=function(){function t(){this.frameStart=0;this.actions=[]}return t}();tt.ActionFrame=D})(dragonBones||(dragonBones={}));var dragonBones;(function(g){var t=function(o){__extends(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}t.prototype._inRange=function(t,e,a){return e<=t&&t<=a};t.prototype._decodeUTF8=function(t){var e=-1;var a=-1;var r=65533;var i=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>i){var f=t[i++];if(f===e){if(l!==0){s=r}else{s=a}}else{if(l===0){if(this._inRange(f,0,127)){s=f}else{if(this._inRange(f,194,223)){l=1;u=128;o=f-192}else if(this._inRange(f,224,239)){l=2;u=2048;o=f-224}else if(this._inRange(f,240,244)){l=3;u=65536;o=f-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(f,128,191)){o=0;l=0;h=0;u=0;i--;s=f}else{h+=1;o=o+(f-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var m=u;o=0;l=0;h=0;u=0;if(this._inRange(_,m,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=f}}}}if(s!==null&&s!==a){if(s<=65535){if(s>0)n+=String.fromCharCode(s)}else{s-=65536;n+=String.fromCharCode(55296+(s>>10&1023));n+=String.fromCharCode(56320+(s&1023))}}}return n};t.prototype._parseBinaryTimeline=function(t,e,a){if(a===void 0){a=null}var r=a!==null?a:g.BaseObject.borrowObject(g.TimelineData);r.type=t;r.offset=e;this._timeline=r;var i=this._timelineArrayBuffer[r.offset+2];if(i===1){r.frameIndicesOffset=-1}else{var n=0;var s=this._animation.frameCount+1;var o=this._data.frameIndices;n=o.length;o.length+=s;r.frameIndicesOffset=n;for(var l=0,h=0,u=0,f=0;l=0){var h=g.ObjectDataParser._getNumber(d,g.DataParser.TYPE,0);var y=g.ObjectDataParser._getString(d,g.DataParser.NAME,"");var f=null;if(h===40&&e.blendType!==0){f=g.BaseObject.borrowObject(g.AnimationTimelineData);var v=f;v.x=g.ObjectDataParser._getNumber(d,g.DataParser.X,0);v.y=g.ObjectDataParser._getNumber(d,g.DataParser.Y,0)}f=this._parseBinaryTimeline(h,u,f);switch(h){case 0:break;case 1:break;case 11:case 12:case 13:case 50:case 60:this._animation.addBoneTimeline(y,f);break;case 20:case 21:case 22:case 23:case 24:this._animation.addSlotTimeline(y,f);break;case 30:this._animation.addConstraintTimeline(y,f);break;case 40:case 41:case 42:this._animation.addAnimationTimeline(y,f);break}}}}this._animation=null;return e};t.prototype._parseGeometry=function(t,e){e.offset=t[g.DataParser.OFFSET];e.data=this._data;var a=this._intArrayBuffer[e.offset+3];if(a>=0){var r=g.BaseObject.borrowObject(g.WeightData);var i=this._intArrayBuffer[e.offset+0];var n=this._intArrayBuffer[a+0];r.offset=a;for(var s=0;s12?e[13]:0;var h=new Int16Array(this._binary,this._binaryOffset+e[0],a/Int16Array.BYTES_PER_ELEMENT);var u=new Float32Array(this._binary,this._binaryOffset+e[2],r/Float32Array.BYTES_PER_ELEMENT);var f=new Int16Array(this._binary,this._binaryOffset+e[4],i/Int16Array.BYTES_PER_ELEMENT);var _=new Float32Array(this._binary,this._binaryOffset+e[6],n/Float32Array.BYTES_PER_ELEMENT);var m=new Int16Array(this._binary,this._binaryOffset+e[8],s/Int16Array.BYTES_PER_ELEMENT);var c=new Uint16Array(this._binary,this._binaryOffset+e[10],o/Uint16Array.BYTES_PER_ELEMENT);var p=l>0?new Int16Array(this._binary,this._binaryOffset+e[12],l/Int16Array.BYTES_PER_ELEMENT):h;this._data.binary=this._binary;this._data.intArray=this._intArrayBuffer=h;this._data.floatArray=u;this._data.frameIntArray=f;this._data.frameFloatArray=_;this._data.frameArray=this._frameArrayBuffer=m;this._data.timelineArray=this._timelineArrayBuffer=c;this._data.colorArray=p};t.prototype.parseDragonBonesData=function(t,e){if(e===void 0){e=1}console.assert(t!==null&&t!==undefined&&t instanceof ArrayBuffer,"Data error.");var a=new Uint8Array(t,0,8);if(a[0]!=="D".charCodeAt(0)||a[1]!=="B".charCodeAt(0)||a[2]!=="D".charCodeAt(0)||a[3]!=="T".charCodeAt(0)){console.assert(false,"Nonsupport data.");return null}var r=new Uint32Array(t,8,1)[0];var i=new Uint8Array(t,8+4,r);var n=this._decodeUTF8(i);var s=JSON.parse(n);this._binaryOffset=8+4+r;this._binary=t;return o.prototype.parseDragonBonesData.call(this,s,e)};t.getInstance=function(){if(t._binaryDataParserInstance===null){t._binaryDataParserInstance=new t}return t._binaryDataParserInstance};t._binaryDataParserInstance=null;return t}(g.ObjectDataParser);g.BinaryDataParser=t})(dragonBones||(dragonBones={}));var dragonBones;(function(y){var t=function(){function s(t){if(t===void 0){t=null}this.autoSearch=false;this._dragonBonesDataMap={};this._textureAtlasDataMap={};this._dragonBones=null;this._dataParser=null;if(s._objectParser===null){s._objectParser=new y.ObjectDataParser}if(s._binaryParser===null){s._binaryParser=new y.BinaryDataParser}this._dataParser=t!==null?t:s._objectParser}s.prototype._isSupportMesh=function(){return true};s.prototype._getTextureData=function(t,e){if(t in this._textureAtlasDataMap){for(var a=0,r=this._textureAtlasDataMap[t];a0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(a)}}if(s===null&&(e.length===0||this.autoSearch)){for(var o in this._dragonBonesDataMap){n=this._dragonBonesDataMap[o];if(e.length===0||n.autoSearch){s=n.getArmature(a);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=i;t.data=n;t.armature=s;t.skin=null;if(r.length>0){t.skin=s.getSkin(r);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(r);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};s.prototype._buildBones=function(t,e){for(var a=0,r=t.armature.sortedBones;a0){var p=this._getTextureData(t.textureAtlasName,c.path);f.replaceTextureData(p,_)}var d=this._getSlotDisplay(t,c,f);f.replaceDisplay(d,_)}else{f.replaceDisplay(null)}}}f._setDisplayIndex(h.displayIndex,true)}};s.prototype._buildConstraints=function(t,e){var a=t.armature.constraints;for(var r in a){var i=a[r];switch(i.type){case 0:var n=y.BaseObject.borrowObject(y.IKConstraint);n.init(i,e);e._addConstraint(n);break;case 1:var s=y.BaseObject.borrowObject(y.PathConstraint);s.init(i,e);e._addConstraint(s);break;default:var o=y.BaseObject.borrowObject(y.IKConstraint);o.init(i,e);e._addConstraint(o);break}}};s.prototype._buildChildArmature=function(t,e,a){return this.buildArmature(a.path,t!==null?t.dataName:"","",t!==null?t.textureAtlasName:"")};s.prototype._getSlotDisplay=function(t,e,a){var r=t!==null?t.dataName:e.parent.parent.parent.name;var i=null;switch(e.type){case 0:{var n=e;if(n.texture===null){n.texture=this._getTextureData(r,e.path)}i=a.rawDisplay;break}case 2:{var s=e;if(s.texture===null){s.texture=this._getTextureData(r,s.path)}if(this._isSupportMesh()){i=a.meshDisplay}else{i=a.rawDisplay}break}case 1:{var o=e;var l=this._buildChildArmature(t,a,o);if(l!==null){l.inheritAnimation=o.inheritAnimation;if(!l.inheritAnimation){var h=o.actions.length>0?o.actions:l.armatureData.defaultActions;if(h.length>0){for(var u=0,f=h;u=0){continue}var h=e.getDisplays(l.name);if(h===null){if(n!==null&&e!==n){h=n.getDisplays(l.name)}if(h===null){if(a){l.displayFrameCount=0}continue}}l.displayFrameCount=h.length;for(var u=0,f=l.displayFrameCount;u=0&&this._display!==null&&t!==null){var a=t.parent;if(this._armature.replacedTexture!==null){if(this._armature._replaceTextureAtlasData===null){a=k.BaseObject.borrowObject(k.CocosTextureAtlasData);a.copyFrom(t.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}t=a.getTexture(t.name)}var r=t.renderTexture;if(r!==null){if(this._geometryData!==null){var i=this._geometryData.data;var n=i.intArray;var s=i.floatArray;var o=n[this._geometryData.offset+0];var l=n[this._geometryData.offset+1];var h=n[this._geometryData.offset+2];if(h<0){h+=65536}var u=h+o*2;var f=this._armature._armatureData.scale;var _=r.getTexture().getContentSizeInPixels();var m=a.width>0?a.width:_.width;var c=a.height>0?a.height:_.height;var p=t.region;var d=cc.rect(999999,999999,-999999,-999999);var y={triangles:{verts:[],indices:[]},rect:d};for(var v=0,g=o*2;vD.x){d.x=D.x}if(d.widthD.y){d.y=D.y}if(d.height0&&r.inheritDeform;var s=this._renderDisplay.getComponent(cc.Sprite)._sgNode;var o=s.getMeshPolygonInfo();if(!o){return}var l=o.triangles.verts;var h=cc.rect(999999,999999,-999999,-999999);if(i!==null){var u=r.data;var f=u.intArray;var _=u.floatArray;var m=f[r.offset+0];var c=f[i.offset+1];if(c<0){c+=65536}for(var p=0,d=i.offset+2+a.length,y=c,v=0;pD){h.x=D}if(h.widthT){h.y=T}if(h.heightw){h.x=w}if(h.widthN){h.y=N}if(h.height=0;o--)if(s=t[o])n=(i<3?s(n):i>3?s(e,a,n):s(e,a))||n;return i>3&&n&&Object.defineProperty(e,a,n),n};var dragonBones;(function(o){var t=function(){function e(t){this._clock=new o.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=t;console.info("YuPeng DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}e.prototype.advanceTime=function(t){if(this._objects.length>0){for(var e=0,a=this._objects;e0){for(var i=0;ie){r.length=e}n._maxCountMap[a]=e}else{n._defaultMaxCount=e;for(var a in n._poolsMap){var r=n._poolsMap[a];if(r.length>e){r.length=e}if(a in n._maxCountMap){n._maxCountMap[a]=e}}}};n.clearPool=function(t){if(t===void 0){t=null}if(t!==null){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in n._poolsMap){var a=n._poolsMap[r];a.length=0}}};n.borrowObject=function(t){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var i=new t;i._onClear();return i};n.prototype.returnToPool=function(){this._onClear();n._returnObject(this)};n._hashCode=0;n._defaultMaxCount=3e3;n._maxCountMap={};n._poolsMap={};return n}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=1}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=a;this.d=r;this.tx=i;this.ty=n}t.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};t.prototype.copyFrom=function(t){this.a=t.a;this.b=t.b;this.c=t.c;this.d=t.d;this.tx=t.tx;this.ty=t.ty;return this};t.prototype.copyFromArray=function(t,e){if(e===void 0){e=0}this.a=t[e];this.b=t[e+1];this.c=t[e+2];this.d=t[e+3];this.tx=t[e+4];this.ty=t[e+5];return this};t.prototype.identity=function(){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this};t.prototype.concat=function(t){var e=this.a*t.a;var a=0;var r=0;var i=this.d*t.d;var n=this.tx*t.a+t.tx;var s=this.ty*t.d+t.ty;if(this.b!==0||this.c!==0){e+=this.b*t.c;a+=this.b*t.d;r+=this.c*t.a;i+=this.c*t.b}if(t.b!==0||t.c!==0){a+=this.a*t.b;r+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=a;this.c=r;this.d=i;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var a=this.c;var r=this.d;var i=this.tx;var n=this.ty;if(e===0&&a===0){this.b=this.c=0;if(t===0||r===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;r=this.d=1/r;this.tx=-t*i;this.ty=-r*n}return this}var s=t*r-e*a;if(s===0){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this}s=1/s;var o=this.a=r*s;e=this.b=-e*s;a=this.c=-a*s;r=this.d=t*s;this.tx=-(o*i+a*n);this.ty=-(e*i+r*n);return this};t.prototype.transformPoint=function(t,e,a,r){if(r===void 0){r=false}a.x=this.a*t+this.c*e;a.y=this.b*t+this.d*e;if(!r){a.x+=this.tx;a.y+=this.ty}};t.prototype.transformRectangle=function(t,e){if(e===void 0){e=false}var a=this.a;var r=this.b;var i=this.c;var n=this.d;var s=e?0:this.tx;var o=e?0:this.ty;var l=t.x;var h=t.y;var u=l+t.width;var f=h+t.height;var _=a*l+i*h+s;var m=r*l+n*h+o;var c=a*u+i*h+s;var p=r*u+n*h+o;var d=a*u+i*f+s;var y=r*u+n*f+o;var v=a*l+i*f+s;var g=r*l+n*f+o;var D=0;if(_>c){D=_;_=c;c=D}if(d>v){D=d;d=v;v=D}t.x=Math.floor(_v?c:v)-t.x);if(m>p){D=m;m=p;p=D}if(y>g){D=y;y=g;g=D}t.y=Math.floor(mg?p:g)-t.y)};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function n(t,e,a,r,i,n){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}if(i===void 0){i=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=a;this.rotation=r;this.scaleX=i;this.scaleY=n}n.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};n.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY};n.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.skew=t.skew;this.rotation=t.rotation;this.scaleX=t.scaleX;this.scaleY=t.scaleY;return this};n.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};n.prototype.add=function(t){this.x+=t.x;this.y+=t.y;this.skew+=t.skew;this.rotation+=t.rotation;this.scaleX*=t.scaleX;this.scaleY*=t.scaleY;return this};n.prototype.minus=function(t){this.x-=t.x;this.y-=t.y;this.skew-=t.skew;this.rotation-=t.rotation;this.scaleX/=t.scaleX;this.scaleY/=t.scaleY;return this};n.prototype.fromMatrix=function(t){var e=this.scaleX,a=this.scaleY;var r=n.PI_Q;this.x=t.tx;this.y=t.ty;this.rotation=Math.atan(t.b/t.a);var i=Math.atan(-t.c/t.d);this.scaleX=this.rotation>-r&&this.rotation-r&&i=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;i=i-Math.PI}this.skew=i-this.rotation;return this};n.prototype.toMatrix=function(t){if(this.rotation===0){t.a=1;t.b=0}else{t.a=Math.cos(this.rotation);t.b=Math.sin(this.rotation)}if(this.skew===0){t.c=-t.b;t.d=t.a}else{t.c=-Math.sin(this.skew+this.rotation);t.d=Math.cos(this.skew+this.rotation)}if(this.scaleX!==1){t.a*=this.scaleX;t.b*=this.scaleX}if(this.scaleY!==1){t.c*=this.scaleY;t.d*=this.scaleY}t.tx=this.x;t.ty=this.y;return this};n.PI=Math.PI;n.PI_D=Math.PI*2;n.PI_H=Math.PI/2;n.PI_Q=Math.PI/4;n.RAD_DEG=180/Math.PI;n.DEG_RAD=Math.PI/180;return n}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(a===void 0){a=1}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}if(s===void 0){s=0}if(o===void 0){o=0}this.alphaMultiplier=t;this.redMultiplier=e;this.greenMultiplier=a;this.blueMultiplier=r;this.alphaOffset=i;this.redOffset=n;this.greenOffset=s;this.blueOffset=o}t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier;this.redMultiplier=t.redMultiplier;this.greenMultiplier=t.greenMultiplier;this.blueMultiplier=t.blueMultiplier;this.alphaOffset=t.alphaOffset;this.redOffset=t.redOffset;this.greenOffset=t.greenOffset;this.blueOffset=t.blueOffset};t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1;this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0};return t}();t.ColorTransform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e){if(t===void 0){t=0}if(e===void 0){e=0}this.x=t;this.y=e}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y};t.prototype.clear=function(){this.x=this.y=0};return t}();t.Point=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}this.x=t;this.y=e;this.width=a;this.height=r}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.width=t.width;this.height=t.height};t.prototype.clear=function(){this.x=this.y=0;this.width=this.height=0};return t}();t.Rectangle=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.ints=[];t.floats=[];t.strings=[];return t}t.toString=function(){return"[class dragonBones.UserData]"};t.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};t.prototype.addInt=function(t){this.ints.push(t)};t.prototype.addFloat=function(t){this.floats.push(t)};t.prototype.addString=function(t){this.strings.push(t)};t.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){a=0}if(this.sortedBones.indexOf(i)>=0){continue}var n=false;for(var s in this.constraints){var o=this.constraints[s];if(o.root===i&&this.sortedBones.indexOf(o.target)<0){n=true;break}}if(n){continue}if(i.parent!==null&&this.sortedBones.indexOf(i.parent)<0){continue}this.sortedBones.push(i);r++}};t.prototype.cacheFrames=function(t){if(this.cacheFrameRate>0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};t.prototype.setCacheFrame=function(t,e){var a=this.parent.cachedFrames;var r=a.length;a.length+=10;a[r]=t.a;a[r+1]=t.b;a[r+2]=t.c;a[r+3]=t.d;a[r+4]=t.tx;a[r+5]=t.ty;a[r+6]=e.rotation;a[r+7]=e.skew;a[r+8]=e.scaleX;a[r+9]=e.scaleY;return r};t.prototype.getCacheFrame=function(t,e,a){var r=this.parent.cachedFrames;t.a=r[a];t.b=r[a+1];t.c=r[a+2];t.d=r[a+3];t.tx=r[a+4];t.ty=r[a+5];e.rotation=r[a+6];e.skew=r[a+7];e.scaleX=r[a+8];e.scaleY=r[a+9];e.x=t.tx;e.y=t.ty};t.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t;this.sortedBones.push(t)};t.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t;this.sortedSlots.push(t)};t.prototype.addConstraint=function(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t};t.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this;this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}if(t.name==="default"){this.defaultSkin=t}};t.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};t.prototype.addAction=function(t,e){if(e){this.defaultActions.push(t)}else{this.actions.push(t)}};t.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};t.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};t.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null};t.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};t.prototype.getMesh=function(t,e,a){var r=this.getSkin(t);if(r===null){return null}return r.getDisplay(e,a)};t.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return t}(a.BaseObject);a.ArmatureData=t;var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.transform=new a.Transform;t.userData=null;return t}t.toString=function(){return"[class dragonBones.BoneData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.inheritTranslation=false;this.inheritRotation=false;this.inheritScale=false;this.inheritReflection=false;this.type=0;this.length=0;this.alpha=1;this.name="";this.transform.identity();this.userData=null;this.parent=null};return t}(a.BaseObject);a.BoneData=e;var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.geometry=new a.GeometryData;return t}t.toString=function(){return"[class dragonBones.SurfaceData]"};t.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=1;this.segmentX=0;this.segmentY=0;this.geometry.clear()};return t}(e);a.SurfaceData=r;var i=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.color=null;t.userData=null;return t}t.createColor=function(){return new a.ColorTransform};t.toString=function(){return"[class dragonBones.SlotData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.blendMode=0;this.displayIndex=0;this.zOrder=0;this.zIndex=0;this.alpha=1;this.name="";this.color=null;this.userData=null;this.parent=null};t.DEFAULT_COLOR=new a.ColorTransform;return t}(a.BaseObject);a.SlotData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.CanvasData]"};e.prototype._onClear=function(){this.hasBackground=false;this.color=0;this.x=0;this.y=0;this.width=0;this.height=0};return e}(t.BaseObject);t.CanvasData=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.displays={};return t}t.toString=function(){return"[class dragonBones.SkinData]"};t.prototype._onClear=function(){for(var t in this.displays){var e=this.displays[t];for(var a=0,r=e;ai){s|=2}if(en){s|=8}return s};D.rectangleIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=t>i&&tn&&ei&&an&&r=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){return true}}return false};D.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=this.width*.5;var l=this.height*.5;var h=D.rectangleIntersectsSegment(t,e,a,r,-o,-l,o,l,i,n,s);return h};return D}(e);t.RectangleBoundingBoxData=h;var a=function(t){__extends(l,t);function l(){return t!==null&&t.apply(this,arguments)||this}l.toString=function(){return"[class dragonBones.EllipseData]"};l.ellipseIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=s/o;var _=f*f;e*=f;r*=f;var m=a-t;var c=r-e;var p=Math.sqrt(m*m+c*c);var d=m/p;var y=c/p;var v=(i-t)*d+(n-e)*y;var g=v*v;var D=t*t+e*e;var T=s*s;var b=T-D+g;var A=0;if(b>=0){var S=Math.sqrt(b);var P=v-S;var O=v+S;var x=P<0?-1:P<=p?0:1;var B=O<0?-1:O<=p?0:1;var E=x*B;if(E<0){return-1}else if(E===0){if(x===-1){A=2;a=t+O*d;r=(e+O*y)/f;if(l!==null){l.x=a;l.y=r}if(h!==null){h.x=a;h.y=r}if(u!==null){u.x=Math.atan2(r/T*_,a/T);u.y=u.x+Math.PI}}else if(B===1){A=1;t=t+P*d;e=(e+P*y)/f;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(u!==null){u.x=Math.atan2(e/T*_,t/T);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+P*d;l.y=(e+P*y)/f;if(u!==null){u.x=Math.atan2(l.y/T*_,l.x/T)}}if(h!==null){h.x=t+O*d;h.y=(e+O*y)/f;if(u!==null){u.y=Math.atan2(h.y/T*_,h.x/T)}}}}}return A};l.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};l.prototype.containsPoint=function(t,e){var a=this.width*.5;if(t>=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){e*=a/r;return Math.sqrt(t*t+e*e)<=a}}return false};l.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=l.ellipseIntersectsSegment(t,e,a,r,0,0,this.width*.5,this.height*.5,i,n,s);return o};return l}(e);t.EllipseBoundingBoxData=a;var r=function(e){__extends(l,e);function l(){var t=e!==null&&e.apply(this,arguments)||this;t.vertices=[];return t}l.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};l.polygonIntersectsSegment=function(t,e,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(t===a){t=a+1e-6}if(e===r){e=r+1e-6}var l=i.length;var h=t-a;var u=e-r;var f=t*r-e*a;var _=0;var m=i[l-2];var c=i[l-1];var p=0;var d=0;var y=0;var v=0;var g=0;var D=0;for(var T=0;T=m&&B<=b||B>=b&&B<=m)&&(h===0||B>=t&&B<=a||B>=a&&B<=t)){var E=(f*P-u*O)/x;if((E>=c&&E<=A||E>=A&&E<=c)&&(u===0||E>=e&&E<=r||E>=r&&E<=e)){if(s!==null){var M=B-t;if(M<0){M=-M}if(_===0){p=M;d=M;y=B;v=E;g=B;D=E;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}}else{if(Md){d=M;g=B;D=E;if(o!==null){o.y=Math.atan2(A-c,b-m)-Math.PI*.5}}}_++}else{y=B;v=E;g=B;D=E;_++;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}break}}}m=b;c=A}if(_===1){if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=y;s.y=v}if(o!==null){o.y=o.x+Math.PI}}else if(_>1){_++;if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=g;s.y=D}}return _};l.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=2;this.x=0;this.y=0;this.vertices.length=0};l.prototype.containsPoint=function(t,e){var a=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var r=0,i=this.vertices.length,n=i-2;r=e||s=e){var l=this.vertices[n];var h=this.vertices[r];if((e-o)*(l-h)/(s-o)+h0){return}this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var a=0,r=this.cacheFrames.length;ae._zIndex*1e3+e._zOrder?1:-1};y.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=n){continue}var o=a[s];var l=this.getSlot(o.name);if(l!==null){l._setZOrder(i)}}this._slotsDirty=true;this._zOrderDirty=!r}};y.prototype._addBone=function(t){if(this._bones.indexOf(t)<0){this._bones.push(t)}};y.prototype._addSlot=function(t){if(this._slots.indexOf(t)<0){this._slots.push(t)}};y.prototype._addConstraint=function(t){if(this._constraints.indexOf(t)<0){this._constraints.push(t)}};y.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};y.prototype.dispose=function(){if(this._armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};y.prototype.init=function(t,e,a,r){if(this._armatureData!==null){return}this._armatureData=t;this._animation=i.BaseObject.borrowObject(i.Animation);this._proxy=e;this._display=a;this._dragonBones=r;this._proxy.dbInit(this);this._animation.init(this);this._animation.animations=this._armatureData.animations};y.prototype.advanceTime=function(t){if(this._lockUpdate){return}this._lockUpdate=true;if(this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");return}var e=this._cacheFrameIndex;this._animation.advanceTime(t);if(this._slotsDirty||this._zIndexDirty){this._slots.sort(y._onSortSlots);if(this._zIndexDirty){for(var a=0,r=this._slots.length;a0){for(var u=0,f=this._actions;u0){var a=this.getBone(t);if(a!==null){a.invalidUpdate();if(e){for(var r=0,i=this._slots;r0){if(i!==null||n!==null){if(i!==null){var b=o?i.y-e:i.x-t;if(b<0){b=-b}if(d===null||bh){h=b;_=n.x;m=n.y;y=D;if(s!==null){p=s.y}}}}else{d=D;break}}}if(d!==null&&i!==null){i.x=u;i.y=f;if(s!==null){s.x=c}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=p}}return d};y.prototype.getBone=function(t){for(var e=0,a=this._bones;e=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(o)}if(o&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};t.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};t.prototype.invalidUpdate=function(){this._transformDirty=true};t.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};Object.defineProperty(t.prototype,"boneData",{get:function(){return this._boneData},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;for(var e=0,a=this._armature.getSlots();e=a){return this.globalTransformMatrix}i=e>this._kX*(t+a)+p;m=((s*o+s+o+o+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=_*(l+2);var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[2]-(o-_)*g;var b=this._hullCache[3]-(o-_)*D;var A=this._vertices;if(i){this._getAffineTransform(-a,p+u,r-a,u,A[v+l+2],A[v+l+3],T+g,b+D,A[v],A[v+1],S._helpTransform,y,true)}else{this._getAffineTransform(-r,p,r-a,u,T,b,A[v],A[v+1],T+g,b+D,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(t>=a){if(e<-a||e>=a){return this.globalTransformMatrix}i=e>this._kX*(t-r)+p;m=((s*o+s+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=(_+1)*(l+2)-2;var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[0]+_*g;var b=this._hullCache[1]+_*D;var A=this._vertices;if(i){this._getAffineTransform(r,p+u,r-a,u,T+g,b+D,A[v+l+2],A[v+l+3],T,b,S._helpTransform,y,true)}else{this._getAffineTransform(a,p,r-a,u,A[v],A[v+1],T,b,A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e<-a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)-r;m=((s*o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[8]+f*g;var b=this._hullCache[9]+f*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,-a,h,r-a,A[v+2],A[v+3],A[v],A[v+1],T+g,b+D,S._helpTransform,y,true)}else{this._getAffineTransform(c,-r,h,r-a,T,b,T+g,b+D,A[v],A[v+1],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e>=a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)+a;m=((s*o+s+o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=o*(l+2)+f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[6]-(s-f)*g;var b=this._hullCache[7]-(s-f)*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,r,h,r-a,T+g,b+D,T,b,A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,a,h,r-a,A[v],A[v+1],A[v+2],A[v+3],T,b,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else{i=e>this._k*(t-c-h)+p;m=((s*_+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2+_*(l+2);var A=this._vertices;if(i){this._getAffineTransform(c+h,p+u,h,u,A[v+l+4],A[v+l+5],A[v+l+2],A[v+l+3],A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,p,h,u,A[v],A[v+1],A[v+2],A[v+3],A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}return y};S.prototype.init=function(t,e){if(this._boneData!==null){return}l.prototype.init.call(this,t,e);var a=t.segmentX;var r=t.segmentY;var i=this._armature.armatureData.parent.intArray[t.geometry.offset+0];var n=1e3;var s=200;this._dX=s*2/a;this._dY=s*2/r;this._k=-this._dY/this._dX;this._kX=-this._dY/(n-s);this._kY=-(n-s)/this._dX;this._vertices.length=i*2;this._deformVertices.length=i*2;this._matrixCahce.length=(a*r+a*2+r*2)*2*7;this._hullCache.length=10;for(var o=0;o=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(h)}if(h&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}var u=1e3;var f=200;var _=2*this.global.x;var m=2*this.global.y;var c=S._helpPoint;this.globalTransformMatrix.transformPoint(u,-f,c);this._hullCache[0]=c.x;this._hullCache[1]=c.y;this._hullCache[2]=_-c.x;this._hullCache[3]=m-c.y;this.globalTransformMatrix.transformPoint(0,this._dY,c,true);this._hullCache[4]=c.x;this._hullCache[5]=c.y;this.globalTransformMatrix.transformPoint(f,u,c);this._hullCache[6]=c.x;this._hullCache[7]=c.y;this._hullCache[8]=_-c.x;this._hullCache[9]=m-c.y;this.globalTransformMatrix.transformPoint(this._dX,0,c,true);this._hullCache[10]=c.x;this._hullCache[11]=c.y}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};return S}(t.Bone);t.Surface=e})(dragonBones||(dragonBones={}));var dragonBones;(function(p){var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.deformVertices=[];return t}t.toString=function(){return"[class dragonBones.DisplayFrame]"};t.prototype._onClear=function(){this.rawDisplayData=null;this.displayData=null;this.textureData=null;this.display=null;this.deformVertices.length=0};t.prototype.updateDeformVertices=function(){if(this.rawDisplayData===null||this.deformVertices.length!==0){return}var t;if(this.rawDisplayData.type===2){t=this.rawDisplayData.geometry}else if(this.rawDisplayData.type===4){t=this.rawDisplayData.geometry}else{return}var e=0;if(t.weight!==null){e=t.weight.count*2}else{e=t.data.intArray[t.offset+0]*2}this.deformVertices.length=e;for(var a=0,r=this.deformVertices.length;a=0&&this._displayIndex0){for(var s=0,o=i;s=0&&this._cachedFrameIndices!==null){var r=this._cachedFrameIndices[t];if(r>=0&&this._cachedFrameIndex===r){this._transformDirty=false}else if(r>=0){this._transformDirty=true;this._cachedFrameIndex=r}else if(this._transformDirty||this._parent._childrenTransformDirty){this._transformDirty=true;this._cachedFrameIndex=-1}else if(this._cachedFrameIndex>=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}else if(this._transformDirty||this._parent._childrenTransformDirty){t=-1;this._transformDirty=true;this._cachedFrameIndex=-1}if(this._transformDirty){if(this._cachedFrameIndex<0){var i=t>=0;this._updateGlobalTransformMatrix(i);if(i&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}this._updateTransform();this._transformDirty=false}};c.prototype.invalidUpdate=function(){this._displayDataDirty=true;this._displayDirty=true;this._transformDirty=true};c.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._updateGlobalTransformMatrix(false);this._transformDirty=false}};c.prototype.replaceRawDisplayData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.rawDisplayData!==t){a.deformVertices.length=0;a.rawDisplayData=t;if(a.rawDisplayData===null){var r=this._armature._armatureData.defaultSkin;if(r!==null){var i=r.getDisplays(this._slotData.name);if(i!==null&&e=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.displayData!==t&&a.rawDisplayData!==t){a.displayData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceTextureData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.textureData!==t){a.textureData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceDisplay=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.display!==t){var r=a.display;a.display=t;if(r!==null&&r!==this._rawDisplay&&r!==this._meshDisplay&&!this._hasDisplay(r)){if(r instanceof p.Armature){}else{this._disposeDisplay(r,true)}}if(t!==null&&t!==this._rawDisplay&&t!==this._meshDisplay&&!this._hasDisplay(r)&&!(t instanceof p.Armature)){this._initDisplay(t,true)}if(e===this._displayIndex){this._displayDirty=true}}};c.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);return this._boundingBoxData.containsPoint(c._helpPoint.x,c._helpPoint.y)};c.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);t=c._helpPoint.x;e=c._helpPoint.y;c._helpMatrix.transformPoint(a,r,c._helpPoint);a=c._helpPoint.x;r=c._helpPoint.y;var o=this._boundingBoxData.intersectsSegment(t,e,a,r,i,n,s);if(o>0){if(o===1||o===2){if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i);if(n!==null){n.x=i.x;n.y=i.y}}else if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}else{if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i)}if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}if(s!==null){this.globalTransformMatrix.transformPoint(Math.cos(s.x),Math.sin(s.x),c._helpPoint,true);s.x=Math.atan2(c._helpPoint.y,c._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(s.y),Math.sin(s.y),c._helpPoint,true);s.y=Math.atan2(c._helpPoint.y,c._helpPoint.x)}}return o};c.prototype.getDisplayFrameAt=function(t){return this._displayFrames[t]};Object.defineProperty(c.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;this._updateVisible()},enumerable:true,configurable:true});Object.defineProperty(c.prototype,"displayFrameCount",{get:function(){return this._displayFrames.length},set:function(t){var e=this._displayFrames.length;if(et){for(var a=e-1;ad){continue}var b=0;for(;;D++){var A=y[D];if(p>A){continue}if(D===0){b=p/A}else{var S=y[D-1];b=(p-S)/(A-S)}break}if(D!==c){c=D;if(u&&D===m){this._computeVertices(_-4,4,0,f);this._computeVertices(0,4,4,f)}else{this._computeVertices(D*6+2,8,0,f)}}this.addCurvePosition(b,f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],l,g,a)}return}if(u){_+=2;f.length=o;this._computeVertices(2,_-4,0,f);this._computeVertices(0,2,_-4,f);f[_-2]=f[0];f[_-1]=f[1]}else{m--;_-=4;f.length=_;this._computeVertices(2,_,0,f)}var P=new Array(m);d=0;var O=f[0],x=f[1],B=0,E=0,M=0,I=0,C=0,F=0;var w,N,R,j,k,L,V,Y;for(var v=0,U=2;vd){continue}for(;;D++){var W=P[D];if(H>W)continue;if(D===0)H/=W;else{var K=P[D-1];H=(H-K)/(W-K)}break}if(D!==c){c=D;var Z=D*6;O=f[Z];x=f[Z+1];B=f[Z+2];E=f[Z+3];M=f[Z+4];I=f[Z+5];C=f[Z+6];F=f[Z+7];w=(O-B*2+M)*.03;N=(x-E*2+I)*.03;R=((B-M)*3-O+C)*.006;j=((E-I)*3-x+F)*.006;k=w*2+R;L=N*2+j;V=(B-O)*.3+w+R*.16666667;Y=(E-x)*.3+N+j*.16666667;G=Math.sqrt(V*V+Y*Y);X[0]=G;for(Z=1;Z<8;Z++){V+=k;Y+=L;k+=R;L+=j;G+=Math.sqrt(V*V+Y*Y);X[Z]=G}V+=k;Y+=L;G+=Math.sqrt(V*V+Y*Y);X[8]=G;V+=k+R;Y+=L+j;G+=Math.sqrt(V*V+Y*Y);X[9]=G;z=0}H*=G;for(;;z++){var q=X[z];if(H>q)continue;if(z===0)H/=q;else{var K=X[z-1];H=z+(H-K)/(q-K)}break}this.addCurvePosition(H*.1,O,x,B,E,M,I,C,F,l,g,a)}};t.prototype.addCurvePosition=function(t,e,a,r,i,n,s,o,l,h,u,f){if(t===0){h[u]=e;h[u+1]=a;h[u+2]=0;return}if(t===1){h[u]=o;h[u+1]=l;h[u+2]=0;return}var _=1-t;var m=_*_;var c=t*t;var p=m*_;var d=m*t*3;var y=_*c*3;var v=t*c;var g=p*e+d*r+y*n+v*o;var D=p*a+d*i+y*s+v*l;h[u]=g;h[u+1]=D;if(f){h[u+2]=Math.atan2(D-(p*a+d*i+y*s),g-(p*e+d*r+y*n))}else{h[u+2]=0}};t.prototype.init=function(t,e){this._constraintData=t;this._armature=e;var a=t;this.pathOffset=a.pathDisplayData.geometry.offset;this.position=a.position;this.spacing=a.spacing;this.rotateOffset=a.rotateOffset;this.rotateMix=a.rotateMix;this.translateMix=a.translateMix;this._root=this._armature.getBone(a.root.name);this._target=this._armature.getBone(a.target.name);this._pathSlot=this._armature.getSlot(a.pathSlot.name);for(var r=0,i=a.bones.length;r0?U.Transform.DEG_RAD:-U.Transform.DEG_RAD}}var x=this.rotateMix;var B=this.translateMix;for(var c=0,E=3;c0){var w=v.a,N=v.b,R=v.c,j=v.d,k=void 0,L=void 0,V=void 0;if(h){k=b[E-1]}else{k=Math.atan2(I,M)}k-=Math.atan2(N,w);if(O){L=Math.cos(k);V=Math.sin(k);var Y=d._boneData.length;S+=(Y*(L*w-V*N)-M)*x;P+=(Y*(V*w+L*N)-I)*x}else{k+=A}if(k>U.Transform.PI){k-=U.Transform.PI_D}else if(k<-U.Transform.PI){k+=U.Transform.PI_D}k*=x;L=Math.cos(k);V=Math.sin(k);v.a=L*w-V*N;v.b=V*w+L*N;v.c=L*R-V*j;v.d=V*R+L*j}d.global.fromMatrix(v)}this.dirty=false};t.prototype.invalidUpdate=function(){};return t}(t);U.PathConstraint=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t){if(t===void 0){t=0}this.time=0;this.timeScale=1;this._systemTime=0;this._animatebles=[];this._clock=null;this.time=t;this._systemTime=(new Date).getTime()*.001}t.prototype.advanceTime=function(t){if(t!==t){t=0}var e=Date.now()*.001;if(t<0){t=e-this._systemTime}this._systemTime=e;if(this.timeScale!==1){t*=this.timeScale}if(t===0){return}if(t<0){this.time-=t}else{this.time+=t}var a=0,r=0,i=this._animatebles.length;for(;a0){this._animatebles[a-r]=n;this._animatebles[a]=null}n.advanceTime(t)}else{r++}}if(r>0){i=this._animatebles.length;for(;a=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&n._subFadeState>0){this._armature._dragonBones.bufferObject(n);this._animationStates.length=0;this._lastAnimationState=null}else{var s=n.animationData;var o=s.cacheFrameRate;if(this._animationDirty&&o>0){this._animationDirty=false;for(var l=0,h=this._armature.getBones();l0){var c=m.getDisplayFrameAt(0).rawDisplayData;if(c!==null&&c.parent===this._armature.armatureData.defaultSkin){m._cachedFrameIndices=s.getSlotCachedFrameIndices(m.name);continue}}m._cachedFrameIndices=null}}n.advanceTime(t,o)}}else if(i>1){for(var p=0,d=0;p0&&n._subFadeState>0){d++;this._armature._dragonBones.bufferObject(n);this._animationDirty=true;if(this._lastAnimationState===n){this._lastAnimationState=null}}else{if(d>0){this._animationStates[p-d]=n}n.advanceTime(t,0)}if(p===i-1&&d>0){this._animationStates.length-=d;if(this._lastAnimationState===null&&this._animationStates.length>0){this._lastAnimationState=this._animationStates[this._animationStates.length-1]}}}this._armature._cacheFrameIndex=-1}else{this._armature._cacheFrameIndex=-1}};t.prototype.reset=function(){for(var t=0,e=this._animationStates;t0){if(t.position<0){t.position%=a.duration;t.position=a.duration-t.position}else if(t.position===a.duration){t.position-=1e-6}else if(t.position>a.duration){t.position%=a.duration}if(t.duration>0&&t.position+t.duration>a.duration){t.duration=a.duration-t.position}if(t.playTimes<0){t.playTimes=a.playTimes}}else{t.playTimes=1;t.position=0;if(t.duration>0){t.duration=0}}if(t.duration===0){t.duration=-1}this._fadeOut(t);var s=g.BaseObject.borrowObject(g.AnimationState);s.init(this._armature,a,t);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var o=false;for(var l=0,h=this._animationStates.length;lthis._animationStates[l].layer){o=true;this._animationStates.splice(l,0,s);break}else if(l!==h-1&&s.layer>this._animationStates[l+1].layer){o=true;this._animationStates.splice(l+1,0,s);break}}if(!o){this._animationStates.push(s)}}else{this._animationStates.push(s)}for(var u=0,f=this._armature.getSlots();u0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var a=this._armature.armatureData.defaultAnimation;if(a!==null){this._animationConfig.animation=a.name;this.playConfig(this._animationConfig)}}else if(!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted){this._lastAnimationState.play()}else{this._animationConfig.animation=this._lastAnimationState.name;this.playConfig(this._animationConfig)}return this._lastAnimationState};t.prototype.fadeIn=function(t,e,a,r,i,n){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(i===void 0){i=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=i!==null?i:"";return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByTime=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByFrame=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.frameCount>0?r.duration*e/r.frameCount:0}return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByProgress=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};t.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByTime(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByFrame(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByProgress(t,e,1);if(a!==null){a.stop()}return a};t.prototype.getBlendState=function(t,e,a){if(!(t in this._blendStates)){this._blendStates[t]={}}var r=this._blendStates[t];if(!(e in r)){var i=r[e]=g.BaseObject.borrowObject(g.BlendState);i.target=a}return r[e]};t.prototype.getState=function(t,e){if(e===void 0){e=-1}var a=this._animationStates.length;while(a--){var r=this._animationStates[a];if(r.name===t&&(e<0||r.layer===e)){return r}}return null};t.prototype.hasAnimation=function(t){return t in this._animations};t.prototype.getStates=function(){return this._animationStates};Object.defineProperty(t.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations===t){return}this._animationNames.length=0;for(var e in this._animations){delete this._animations[e]}for(var e in t){this._animationNames.push(e);this._animations[e]=t[e]}},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});return t}(g.BaseObject);g.Animation=t})(dragonBones||(dragonBones={}));var dragonBones;(function(L){var t=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t._boneMask=[];t._boneTimelines=[];t._boneBlendTimelines=[];t._slotTimelines=[];t._slotBlendTimelines=[];t._constraintTimelines=[];t._animationTimelines=[];t._poseTimelines=[];t._actionTimeline=null;t._zOrderTimeline=null;return t}t.toString=function(){return"[class dragonBones.AnimationState]"};t.prototype._onClear=function(){for(var t=0,e=this._boneTimelines;t=0){this._boneTimelines.splice(v,1);r.returnToPool()}v=this._boneBlendTimelines.indexOf(r);if(v>=0){this._boneBlendTimelines.splice(v,1);r.returnToPool()}}}}{var g={};var D=[];for(var T=0,b=this._slotTimelines;T=0){this._slotTimelines.splice(v,1);r.returnToPool()}v=this._slotBlendTimelines.indexOf(r);if(v>=0){this._slotBlendTimelines.splice(v,1);r.returnToPool()}}}}};t.prototype._advanceFadeTime=function(t){var e=this._fadeState>0;if(this._subFadeState<0){this._subFadeState=0;var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT:L.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}if(t<0){t=-t}this._fadeTime+=t;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=e?0:1}else if(this._fadeTime>0){this._fadeProgress=e?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=e?1:0}if(this._subFadeState>0){if(!e){this._playheadState|=1;this._fadeState=0}var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT_COMPLETE:L.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}};t.prototype.init=function(t,e,a){if(this._armature!==null){return}this._armature=t;this._animationData=e;this.resetToPose=a.resetToPose;this.additive=a.additive;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.blendType=e.blendType;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;this._weight=a.weight;if(a.pauseFadeIn){this._playheadState=2}else{this._playheadState=3}if(a.duration<0){this._position=0;this._duration=this._animationData.duration;if(a.position!==0){if(this.timeScale>=0){this._time=a.position}else{this._time=a.position-this._duration}}else{this._time=0}}else{this._position=a.position;this._duration=a.duration;this._time=0}if(this.timeScale<0&&this._time===0){this._time=-1e-6}if(this.fadeTotalTime<=0){this._fadeProgress=.999999}if(a.boneMask.length>0){this._boneMask.length=a.boneMask.length;for(var r=0,i=this._boneMask.length;r0;var i=true;var n=true;var s=this._time;this._weightResult=this._weight*this._fadeProgress;if(this._parent!==null){this._weightResult*=this._parent._weightResult}if(this._actionTimeline.playState<=0){this._actionTimeline.update(s)}if(this._weight===0){return}if(r){var o=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0){this._zOrderTimeline.update(s)}if(r){var l=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===l){i=false;n=false}else{this._armature._cacheFrameIndex=l;if(this._animationData.cachedFrames[l]){n=false}else{this._animationData.cachedFrames[l]=true}}}if(i){var h=false;var u=null;if(n){for(var f=0,_=this._boneTimelines.length;f<_;++f){var m=this._boneTimelines[f];if(m.playState<=0){m.update(s)}if(m.target!==u){var c=m.target;h=c.update(this);u=c;if(c.dirty===1){var p=c.target.animationPose;p.x=0;p.y=0;p.rotation=0;p.skew=0;p.scaleX=1;p.scaleY=1}}if(h){m.blend(a)}}}for(var f=0,_=this._boneBlendTimelines.length;f<_;++f){var m=this._boneBlendTimelines[f];if(m.playState<=0){m.update(s)}if(m.target.update(this)){m.blend(a)}}if(this.displayControl){for(var f=0,_=this._slotTimelines.length;f<_;++f){var m=this._slotTimelines[f];if(m.playState<=0){var d=m.target;var y=d.displayController;if(y===null||y===this.name||y===this.group){m.update(s)}}}}for(var f=0,_=this._slotBlendTimelines.length;f<_;++f){var m=this._slotBlendTimelines[f];if(m.playState<=0){var c=m.target;m.update(s);if(c.update(this)){m.blend(a)}}}for(var f=0,_=this._constraintTimelines.length;f<_;++f){var m=this._constraintTimelines[f];if(m.playState<=0){m.update(s)}}if(this._animationTimelines.length>0){var v=100;var g=100;var D=null;var T=null;for(var f=0,_=this._animationTimelines.length;f<_;++f){var m=this._animationTimelines[f];if(m.playState<=0){m.update(s)}if(this.blendType===1){var b=m.target;var A=this.parameterX-b.positionX;if(A>=0){if(A0){this._subFadeState=0;if(this._poseTimelines.length>0){for(var S=0,P=this._poseTimelines;S=0){this._boneTimelines.splice(O,1);m.returnToPool();continue}O=this._boneBlendTimelines.indexOf(m);if(O>=0){this._boneBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._slotTimelines.indexOf(m);if(O>=0){this._slotTimelines.splice(O,1);m.returnToPool();continue}O=this._slotBlendTimelines.indexOf(m);if(O>=0){this._slotBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._constraintTimelines.indexOf(m);if(O>=0){this._constraintTimelines.splice(O,1);m.returnToPool();continue}}this._poseTimelines.length=0}}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};t.prototype.play=function(){this._playheadState=3};t.prototype.stop=function(){this._playheadState&=1};t.prototype.fadeOut=function(t,e){if(e===void 0){e=true}if(t<0){t=0}if(e){this._playheadState&=2}if(this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime){return}}else{this._fadeState=1;this._subFadeState=-1;if(t<=0||this._fadeProgress<=0){this._fadeProgress=1e-6}for(var a=0,r=this._boneTimelines;a1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};t.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};t.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var a=this._armature.getBone(t);if(a===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var r=0,i=this._armature.getBones();r=0){this._boneMask.splice(a,1)}if(e){var r=this._armature.getBone(t);if(r!==null){var i=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=i;n=0&&r.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=i;h0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if(t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&this._parent===null){t=this._duration-1e-6}if(this._time===t){return}this._time=t;this._actionTimeline.setCurrentTime(this._time);if(this._zOrderTimeline!==null){this._zOrderTimeline.playState=-1}for(var a=0,r=this._boneTimelines;a0){if(this.leftWeight>0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight){this.dirty++;this.layer=e;this.leftWeight=0;this.blendWeight=0;return false}this.layer=e;this.leftWeight-=this.layerWeight;this.layerWeight=0}a*=this.leftWeight;this.dirty++;this.blendWeight=a;this.layerWeight+=this.blendWeight;return true}return false}this.dirty++;this.layer=e;this.leftWeight=1;this.blendWeight=a;this.layerWeight=a;return true};e.prototype.reset=function(){this.dirty=0;this.layer=0;this.leftWeight=0;this.layerWeight=0;this.blendWeight=0};e.BONE_TRANSFORM="boneTransform";e.BONE_ALPHA="boneAlpha";e.SURFACE="surface";e.SLOT_DEFORM="slotDeform";e.SLOT_ALPHA="slotAlpha";e.SLOT_Z_INDEX="slotZIndex";return e}(L.BaseObject);L.BlendState=V})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){this.dirty=false;this.playState=-1;this.currentPlayTimes=-1;this.currentTime=-1;this.target=null;this._isTween=false;this._valueOffset=0;this._frameValueOffset=0;this._frameOffset=0;this._frameRate=0;this._frameCount=0;this._frameIndex=-1;this._frameRateR=0;this._position=0;this._duration=0;this._timeScale=1;this._timeOffset=0;this._animationData=null;this._timelineData=null;this._armature=null;this._animationState=null;this._actionTimeline=null;this._frameArray=null;this._valueArray=null;this._timelineArray=null;this._frameIndices=null};e.prototype._setCurrentTime=function(t){var e=this.playState;var a=this.currentPlayTimes;var r=this.currentTime;if(this._actionTimeline!==null&&this._frameCount<=1){this.playState=this._actionTimeline.playState>=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var i=this._animationState.playTimes;var n=i*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(i>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=i;if(t<0){this.currentTime=0}else{this.currentTime=this.playState===1?this._duration+1e-6:this._duration}}else{if(this.playState!==0&&this._animationState._playheadState===3){this.playState=0}if(t<0){t=-t;this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=this._duration-t%this._duration}else{this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=t%this._duration}}this.currentTime+=this._position}else{this.playState=this._actionTimeline.playState;this.currentPlayTimes=this._actionTimeline.currentPlayTimes;this.currentTime=this._actionTimeline.currentTime}if(this.currentPlayTimes===a&&this.currentTime===r){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==a){this._frameIndex=-1}return true};e.prototype.init=function(t,e,a){this._armature=t;this._animationState=e;this._timelineData=a;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._animationData=this._animationState.animationData;this._frameRate=this._animationData.parent.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;if(this._timelineData!==null){var r=this._animationData.parent.parent;this._frameArray=r.frameArray;this._timelineArray=r.timelineArray;this._frameIndices=r.frameIndices;this._frameCount=this._timelineArray[this._timelineData.offset+2];this._frameValueOffset=this._timelineArray[this._timelineData.offset+4];this._timeScale=100/this._timelineArray[this._timelineData.offset+0];this._timeOffset=this._timelineArray[this._timelineData.offset+1]*.01}};e.prototype.fadeOut=function(){this.dirty=false};e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var a=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==a){this._frameIndex=a;this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex];this._onArriveAtFrame()}}else if(this._frameIndex<0){this._frameIndex=0;if(this._timelineData!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]}this._onArriveAtFrame()}if(this._isTween||this.dirty){this._onUpdateFrame()}}};e.prototype.blend=function(t){};return e}(t.BaseObject);t.TimelineState=e;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,a){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI));break}return(r-e)*a+e};e._getEasingCurveValue=function(t,e,a,r){if(t<=0){return 0}else if(t>=1){return 1}var i=a>0;var n=a+1;var s=Math.floor(t*n);var o=0;var l=0;if(i){o=s===0?0:e[r+s-1];l=s===n-1?1e4:e[r+s]}else{o=e[r+s-1];l=e[r+s]}return(o+(l-o)*(t*n-s))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenEasing=0;this._tweenProgress=0;this._valueScale=1};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){this._frameDurationR=1/e}else{this._frameDurationR=0}}}else{this.dirty=true;this._isTween=false}};e.prototype._onUpdateFrame=function(){if(this._isTween){this.dirty=true;this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR;if(this._tweenType===2){this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3)}else if(this._tweenType!==1){this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)}}};return e}(e);t.TweenTimelineState=a;var r=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._current=0;this._difference=0;this._result=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+1;if(t===1){this._current=e[a];this._difference=e[r]-this._current}else{this._current=e[a]*t;this._difference=e[r]*t-this._current}}else{this._result=e[a]*t}}else{this._result=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._result=this._current+this._difference*this._tweenProgress}};return t}(a);t.SingleValueTimelineState=r;var i=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._currentA=0;this._currentB=0;this._differenceA=0;this._differenceB=0;this._resultA=0;this._resultB=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex*2;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+2;if(t===1){this._currentA=e[a];this._currentB=e[a+1];this._differenceA=e[r]-this._currentA;this._differenceB=e[r+1]-this._currentB}else{this._currentA=e[a]*t;this._currentB=e[a+1]*t;this._differenceA=e[r]*t-this._currentA;this._differenceB=e[r+1]*t-this._currentB}}else{this._resultA=e[a]*t;this._resultB=e[a+1]*t}}else{this._resultA=0;this._resultB=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._resultA=this._currentA+this._differenceA*this._tweenProgress;this._resultB=this._currentB+this._differenceB*this._tweenProgress}};return t}(a);t.DoubleValueTimelineState=i;var n=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._rd=[];return t}t.prototype._onClear=function(){o.prototype._onClear.call(this);this._valueCount=0;this._rd.length=0};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);var t=this._valueCount;var e=this._rd;if(this._timelineData!==null){var a=this._valueScale;var r=this._valueArray;var i=this._valueOffset+this._frameValueOffset+this._frameIndex*t;if(this._isTween){var n=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:i+t;if(a===1){for(var s=0;s0){if(n.hasDBEventListener(y.EventObject.COMPLETE)){h=y.BaseObject.borrowObject(y.EventObject);h.type=y.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var u=this._timelineData;var f=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[u.frameIndicesOffset+f];if(this._frameIndex!==_){var m=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[u.offset+5+this._frameIndex];if(o){if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(m)}if(l!==null&&m===0){this._armature._dragonBones.bufferEvent(l);l=null}if(m>0){m--}else{m=this._frameCount-1}if(m===_){break}}}else{if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this.currentPlayTimes===a){if(r<=d){if(m>0){m--}else{m=this._frameCount-1}}else if(m===_){m=-1}}}while(m>=0){if(m=0){var t=this._frameArray[this._frameOffset+1];if(t>0){this._armature._sortZOrder(this._frameArray,this._frameOffset+2)}else{this._armature._sortZOrder(null,0)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.ZOrderTimelineState=e;var a=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])}if(this._timelineData===null){this._rd[4]=1;this._rd[5]=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=6;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])};t.prototype.blend=function(t){var e=this._armature.armatureData.scale;var a=this._rd;var r=this.target;var i=r.target;var n=r.blendWeight;var s=i.animationPose;if(r.dirty>1){s.x+=a[0]*n*e;s.y+=a[1]*n*e;s.rotation+=a[2]*n;s.skew+=a[3]*n;s.scaleX+=(a[4]-1)*n;s.scaleY+=(a[5]-1)*n}else{s.x=a[0]*n*e;s.y=a[1]*n*e;s.rotation=a[2]*n;s.skew=a[3]*n;s.scaleX=(a[4]-1)*n+1;s.scaleY=(a[5]-1)*n+1}if(t||this.dirty){this.dirty=false;i._transformDirty=true}};return t}(y.MutilpleValueTimelineState);y.BoneAllTimelineState=a;var r=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.x+=this._resultA*r;i.y+=this._resultB*r}else if(r!==1){i.x=this._resultA*r;i.y=this._resultB*r}else{i.x=this._resultA;i.y=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneTranslateTimelineState=r;var i=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._differenceA=y.Transform.normalizeRadian(this._differenceA);this._differenceB=y.Transform.normalizeRadian(this._differenceB)}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._resultA=y.Transform.normalizeRadian(this._resultA);this._resultB=y.Transform.normalizeRadian(this._resultB)};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.rotation+=this._resultA*r;i.skew+=this._resultB*r}else if(r!==1){i.rotation=this._resultA*r;i.skew=this._resultB*r}else{i.rotation=this._resultA;i.skew=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneRotateTimelineState=i;var n=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){this._resultA=1;this._resultB=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.scaleX+=(this._resultA-1)*r;i.scaleY+=(this._resultB-1)*r}else if(r!==1){i.scaleX=(this._resultA-1)*r+1;i.scaleY=(this._resultB-1)*r+1}else{i.scaleX=this._resultA;i.scaleY=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneScaleTimelineState=n;var s=function(s){__extends(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SurfaceTimelineState]"};t.prototype._onClear=function(){s.prototype._onClear.call(this);this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){s.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.parent.parent;var i=r.frameIntArray;var n=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=i[n+2];this._deformCount=i[n+1];this._deformOffset=i[n+3];this._sameValueOffset=i[n+4]+this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=r.frameFloatArray;this._rd.length=this._valueCount*2}else{this._deformCount=this.target.target._deformVertices.length}};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a._deformVertices;var n=this._valueArray;if(n!==null){var s=this._valueCount;var o=this._deformOffset;var l=this._sameValueOffset;var h=this._rd;for(var u=0;u1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u1){a._alpha+=this._result*r;if(a._alpha>1){a._alpha=1}}else{a._alpha=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._alphaDirty=true}};return t}(y.SingleValueTimelineState);y.AlphaTimelineState=o;var l=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDisplayTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this.target;var e=this._timelineData!==null?this._frameArray[this._frameOffset+1]:t._slotData.displayIndex;if(t.displayIndex!==e){t._setDisplayIndex(e,true)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.SlotDisplayTimelineState=l;var h=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._current=[0,0,0,0,0,0,0,0];t._difference=[0,0,0,0,0,0,0,0];t._result=[0,0,0,0,0,0,0,0];return t}t.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._animationData.parent.parent;var e=t.colorArray;var a=t.frameIntArray;var r=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex;var i=a[r];if(i<0){i+=65536}if(this._isTween){this._current[0]=e[i++];this._current[1]=e[i++];this._current[2]=e[i++];this._current[3]=e[i++];this._current[4]=e[i++];this._current[5]=e[i++];this._current[6]=e[i++];this._current[7]=e[i++];if(this._frameIndex===this._frameCount-1){i=a[this._animationData.frameIntOffset+this._frameValueOffset]}else{i=a[r+1]}if(i<0){i+=65536}this._difference[0]=e[i++]-this._current[0];this._difference[1]=e[i++]-this._current[1];this._difference[2]=e[i++]-this._current[2];this._difference[3]=e[i++]-this._current[3];this._difference[4]=e[i++]-this._current[4];this._difference[5]=e[i++]-this._current[5];this._difference[6]=e[i++]-this._current[6];this._difference[7]=e[i++]-this._current[7]}else{this._result[0]=e[i++]*.01;this._result[1]=e[i++]*.01;this._result[2]=e[i++]*.01;this._result[3]=e[i++]*.01;this._result[4]=e[i++];this._result[5]=e[i++];this._result[6]=e[i++];this._result[7]=e[i++]}}else{var n=this.target;var s=n.slotData.color;this._result[0]=s.alphaMultiplier;this._result[1]=s.redMultiplier;this._result[2]=s.greenMultiplier;this._result[3]=s.blueMultiplier;this._result[4]=s.alphaOffset;this._result[5]=s.redOffset;this._result[6]=s.greenOffset;this._result[7]=s.blueOffset}};t.prototype._onUpdateFrame=function(){o.prototype._onUpdateFrame.call(this);if(this._isTween){this._result[0]=(this._current[0]+this._difference[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._difference[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._difference[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._difference[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._difference[4]*this._tweenProgress;this._result[5]=this._current[5]+this._difference[5]*this._tweenProgress;this._result[6]=this._current[6]+this._difference[6]*this._tweenProgress;this._result[7]=this._current[7]+this._difference[7]*this._tweenProgress}};t.prototype.fadeOut=function(){this._isTween=false};t.prototype.update=function(t){o.prototype.update.call(this,t);if(this._isTween||this.dirty){var e=this.target;var a=e._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);a.alphaMultiplier+=(this._result[0]-a.alphaMultiplier)*r;a.redMultiplier+=(this._result[1]-a.redMultiplier)*r;a.greenMultiplier+=(this._result[2]-a.greenMultiplier)*r;a.blueMultiplier+=(this._result[3]-a.blueMultiplier)*r;a.alphaOffset+=(this._result[4]-a.alphaOffset)*r;a.redOffset+=(this._result[5]-a.redOffset)*r;a.greenOffset+=(this._result[6]-a.greenOffset)*r;a.blueOffset+=(this._result[7]-a.blueOffset)*r;e._colorDirty=true}}else if(this.dirty){this.dirty=false;if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){a.alphaMultiplier=this._result[0];a.redMultiplier=this._result[1];a.greenMultiplier=this._result[2];a.blueMultiplier=this._result[3];a.alphaOffset=this._result[4];a.redOffset=this._result[5];a.greenOffset=this._result[6];a.blueOffset=this._result[7];e._colorDirty=true}}}};return t}(y.TweenTimelineState);y.SlotColorTimelineState=h;var u=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SlotZIndexTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){var t=this.target;var e=t.target;this._result=e.slotData.zIndex}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueArray=this._animationData.parent.parent.frameIntArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;if(e.dirty>1){a._zIndex+=this._result*r}else{a._zIndex=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._zIndexDirty=true}};return t}(y.SingleValueTimelineState);y.SlotZIndexTimelineState=u;var f=function(f){__extends(t,f);function t(){return f!==null&&f.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.DeformTimelineState]"};t.prototype._onClear=function(){f.prototype._onClear.call(this);this.geometryOffset=0;this.displayFrame=null;this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){f.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];var i=this._animationData.parent.parent;var n=i.frameIntArray;var s=this.target.target;this.geometryOffset=n[r+0];if(this.geometryOffset<0){this.geometryOffset+=65536}for(var o=0,l=s.displayFrameCount;o1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u0;t._weight=this._currentB}else{var e=t._constraintData;t._bendPositive=e.bendPositive;t._weight=e.weight}t.invalidUpdate();this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=.01;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.IKConstraintTimelineState=_;var m=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationProgressTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.currentTime=this._result*t.totalTime}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationProgressTimelineState=m;var c=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationWeightTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.weight=this._result}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationWeightTimelineState=c;var p=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationParametersTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.parameterX=this._resultA;t.parameterY=this._resultB}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.AnimationParametersTimelineState=p})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}r.actionDataToInstance=function(t,e,a){if(t.type===0){e.type=r.FRAME_EVENT}else{e.type=t.type===10?r.FRAME_EVENT:r.SOUND_EVENT}e.name=t.name;e.armature=a;e.actionData=t;e.data=t.data;if(t.bone!==null){e.bone=a.getBone(t.bone.name)}if(t.slot!==null){e.slot=a.getSlot(t.slot.name)}};r.toString=function(){return"[class dragonBones.EventObject]"};r.prototype._onClear=function(){this.time=0;this.type="";this.name="";this.armature=null;this.bone=null;this.slot=null;this.animationState=null;this.actionData=null;this.data=null};r.START="start";r.LOOP_COMPLETE="loopComplete";r.COMPLETE="complete";r.FADE_IN="fadeIn";r.FADE_IN_COMPLETE="fadeInComplete";r.FADE_OUT="fadeOut";r.FADE_OUT_COMPLETE="fadeOutComplete";r.FRAME_EVENT="frameEvent";r.SOUND_EVENT="soundEvent";return r}(t.BaseObject);t.EventObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(){}t._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}};t._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}};t._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}};t._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}};t._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}};t._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}};t._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}};t._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}};t._getAnimationBlendType=function(t){switch(t.toLowerCase()){case"none":return 0;case"1d":return 1;default:return 0}};t._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}};t.DATA_VERSION_2_3="2.3";t.DATA_VERSION_3_0="3.0";t.DATA_VERSION_4_0="4.0";t.DATA_VERSION_4_5="4.5";t.DATA_VERSION_5_0="5.0";t.DATA_VERSION_5_5="5.5";t.DATA_VERSION_5_6="5.6";t.DATA_VERSION=t.DATA_VERSION_5_6;t.DATA_VERSIONS=[t.DATA_VERSION_4_0,t.DATA_VERSION_4_5,t.DATA_VERSION_5_0,t.DATA_VERSION_5_5,t.DATA_VERSION_5_6];t.TEXTURE_ATLAS="textureAtlas";t.SUB_TEXTURE="SubTexture";t.FORMAT="format";t.IMAGE_PATH="imagePath";t.WIDTH="width";t.HEIGHT="height";t.ROTATED="rotated";t.FRAME_X="frameX";t.FRAME_Y="frameY";t.FRAME_WIDTH="frameWidth";t.FRAME_HEIGHT="frameHeight";t.DRADON_BONES="dragonBones";t.USER_DATA="userData";t.ARMATURE="armature";t.CANVAS="canvas";t.BONE="bone";t.SURFACE="surface";t.SLOT="slot";t.CONSTRAINT="constraint";t.SKIN="skin";t.DISPLAY="display";t.FRAME="frame";t.IK="ik";t.PATH_CONSTRAINT="path";t.ANIMATION="animation";t.TIMELINE="timeline";t.FFD="ffd";t.TRANSLATE_FRAME="translateFrame";t.ROTATE_FRAME="rotateFrame";t.SCALE_FRAME="scaleFrame";t.DISPLAY_FRAME="displayFrame";t.COLOR_FRAME="colorFrame";t.DEFAULT_ACTIONS="defaultActions";t.ACTIONS="actions";t.EVENTS="events";t.INTS="ints";t.FLOATS="floats";t.STRINGS="strings";t.TRANSFORM="transform";t.PIVOT="pivot";t.AABB="aabb";t.COLOR="color";t.VERSION="version";t.COMPATIBLE_VERSION="compatibleVersion";t.FRAME_RATE="frameRate";t.TYPE="type";t.SUB_TYPE="subType";t.NAME="name";t.PARENT="parent";t.TARGET="target";t.STAGE="stage";t.SHARE="share";t.PATH="path";t.LENGTH="length";t.DISPLAY_INDEX="displayIndex";t.Z_ORDER="zOrder";t.Z_INDEX="zIndex";t.BLEND_MODE="blendMode";t.INHERIT_TRANSLATION="inheritTranslation";t.INHERIT_ROTATION="inheritRotation";t.INHERIT_SCALE="inheritScale";t.INHERIT_REFLECTION="inheritReflection";t.INHERIT_ANIMATION="inheritAnimation";t.INHERIT_DEFORM="inheritDeform";t.SEGMENT_X="segmentX";t.SEGMENT_Y="segmentY";t.BEND_POSITIVE="bendPositive";t.CHAIN="chain";t.WEIGHT="weight";t.BLEND_TYPE="blendType";t.FADE_IN_TIME="fadeInTime";t.PLAY_TIMES="playTimes";t.SCALE="scale";t.OFFSET="offset";t.POSITION="position";t.DURATION="duration";t.TWEEN_EASING="tweenEasing";t.TWEEN_ROTATE="tweenRotate";t.TWEEN_SCALE="tweenScale";t.CLOCK_WISE="clockwise";t.CURVE="curve";t.SOUND="sound";t.EVENT="event";t.ACTION="action";t.X="x";t.Y="y";t.SKEW_X="skX";t.SKEW_Y="skY";t.SCALE_X="scX";t.SCALE_Y="scY";t.VALUE="value";t.ROTATE="rotate";t.SKEW="skew";t.ALPHA="alpha";t.ALPHA_OFFSET="aO";t.RED_OFFSET="rO";t.GREEN_OFFSET="gO";t.BLUE_OFFSET="bO";t.ALPHA_MULTIPLIER="aM";t.RED_MULTIPLIER="rM";t.GREEN_MULTIPLIER="gM";t.BLUE_MULTIPLIER="bM";t.UVS="uvs";t.VERTICES="vertices";t.TRIANGLES="triangles";t.WEIGHTS="weights";t.SLOT_POSE="slotPose";t.BONE_POSE="bonePose";t.BONES="bones";t.POSITION_MODE="positionMode";t.SPACING_MODE="spacingMode";t.ROTATE_MODE="rotateMode";t.SPACING="spacing";t.ROTATE_OFFSET="rotateOffset";t.ROTATE_MIX="rotateMix";t.TRANSLATE_MIX="translateMix";t.TARGET_DISPLAY="targetDisplay";t.CLOSED="closed";t.CONSTANT_SPEED="constantSpeed";t.VERTEX_COUNT="vertexCount";t.LENGTHS="lengths";t.GOTO_AND_PLAY="gotoAndPlay";t.DEFAULT_NAME="default";return t}();t.DataParser=e})(dragonBones||(dragonBones={}));var dragonBones;(function(tt){var t=function(e){__extends($,e);function $(){var t=e!==null&&e.apply(this,arguments)||this;t._rawTextureAtlasIndex=0;t._rawBones=[];t._data=null;t._armature=null;t._bone=null;t._geometry=null;t._slot=null;t._skin=null;t._mesh=null;t._animation=null;t._timeline=null;t._rawTextureAtlases=null;t._frameValueType=0;t._defaultColorOffset=-1;t._prevClockwise=0;t._prevRotation=0;t._frameDefaultValue=0;t._frameValueScale=1;t._helpMatrixA=new tt.Matrix;t._helpMatrixB=new tt.Matrix;t._helpTransform=new tt.Transform;t._helpColorTransform=new tt.ColorTransform;t._helpPoint=new tt.Point;t._helpArray=[];t._intArray=[];t._floatArray=[];t._frameIntArray=[];t._frameFloatArray=[];t._frameArray=[];t._timelineArray=[];t._colorArray=[];t._cacheRawMeshes=[];t._cacheMeshes=[];t._actionFrames=[];t._weightSlotPose={};t._weightBonePoses={};t._cacheBones={};t._slotChildActions={};return t}$._getBoolean=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="boolean"){return r}else if(i==="string"){switch(r){case"0":case"NaN":case"":case"false":case"null":case"undefined":return false;default:return true}}else{return!!r}}return a};$._getNumber=function(t,e,a){if(e in t){var r=t[e];if(r===null||r==="NaN"){return a}return+r||0}return a};$._getString=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="string"){return r}return String(r)}return a};$.prototype._getCurvePoint=function(t,e,a,r,i,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var m=u*f;var c=3*l*f;var p=3*u*_;var d=l*_;h.x=m*t+c*a+p*i+d*s;h.y=m*e+c*r+p*n+d*o};$.prototype._samplingEasingCurve=function(t,e){var a=t.length;if(a%3===1){var r=-2;for(var i=0,n=e.length;i=0&&r+61e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return true}else{var r=0;for(var i=0,n=e.length;i1e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return false}};$.prototype._parseActionDataInFrame=function(t,e,a,r){if(tt.DataParser.EVENT in t){this._mergeActionFrame(t[tt.DataParser.EVENT],e,10,a,r)}if(tt.DataParser.SOUND in t){this._mergeActionFrame(t[tt.DataParser.SOUND],e,11,a,r)}if(tt.DataParser.ACTION in t){this._mergeActionFrame(t[tt.DataParser.ACTION],e,0,a,r)}if(tt.DataParser.EVENTS in t){this._mergeActionFrame(t[tt.DataParser.EVENTS],e,10,a,r)}if(tt.DataParser.ACTIONS in t){this._mergeActionFrame(t[tt.DataParser.ACTIONS],e,0,a,r)}};$.prototype._mergeActionFrame=function(t,e,a,r,i){var n=this._armature.actions.length;var s=this._parseActionData(t,a,r,i);var o=0;var l=null;for(var h=0,u=s;he){break}o++}if(l===null){l=new D;l.frameStart=e;this._actionFrames.splice(o,0,l)}for(var p=0;p0){var _=a.getBone(u);if(_!==null){f.parent=_}else{if(!(u in this._cacheBones)){this._cacheBones[u]=[]}this._cacheBones[u].push(f)}}if(f.name in this._cacheBones){for(var m=0,c=this._cacheBones[f.name];m0&&e.parent!==null){i.root=e.parent;i.bone=e}else{i.root=e;i.bone=null}return i};$.prototype._parsePathConstraint=function(t){var e=this._armature.getSlot($._getString(t,tt.DataParser.TARGET,""));if(e===null){return null}var a=this._armature.defaultSkin;if(a===null){return null}var r=a.getDisplay(e.name,$._getString(t,tt.DataParser.TARGET_DISPLAY,e.name));if(r===null||!(r instanceof tt.PathDisplayData)){return null}var i=t[tt.DataParser.BONES];if(i===null||i.length===0){return null}var n=tt.BaseObject.borrowObject(tt.PathConstraintData);n.name=$._getString(t,tt.DataParser.NAME,"");n.type=1;n.pathSlot=e;n.pathDisplayData=r;n.target=e.parent;n.positionMode=tt.DataParser._getPositionMode($._getString(t,tt.DataParser.POSITION_MODE,""));n.spacingMode=tt.DataParser._getSpacingMode($._getString(t,tt.DataParser.SPACING_MODE,""));n.rotateMode=tt.DataParser._getRotateMode($._getString(t,tt.DataParser.ROTATE_MODE,""));n.position=$._getNumber(t,tt.DataParser.POSITION,0);n.spacing=$._getNumber(t,tt.DataParser.SPACING,0);n.rotateOffset=$._getNumber(t,tt.DataParser.ROTATE_OFFSET,0);n.rotateMix=$._getNumber(t,tt.DataParser.ROTATE_MIX,1);n.translateMix=$._getNumber(t,tt.DataParser.TRANSLATE_MIX,1);for(var s=0,o=i;s0?a:e;this._parsePivot(t,n);break}case 1:{var s=i=tt.BaseObject.borrowObject(tt.ArmatureDisplayData);s.name=e;s.path=a.length>0?a:e;s.inheritAnimation=true;if(tt.DataParser.ACTIONS in t){var o=this._parseActionData(t[tt.DataParser.ACTIONS],0,null,null);for(var l=0,h=o;l0?a:e;if(tt.DataParser.SHARE in t){c.geometry.data=this._data;this._cacheRawMeshes.push(t);this._cacheMeshes.push(c)}else{this._parseMesh(t,c)}break}case 3:{var p=this._parseBoundingBox(t);if(p!==null){var d=i=tt.BaseObject.borrowObject(tt.BoundingBoxDisplayData);d.name=e;d.path=a.length>0?a:e;d.boundingBox=p}break}case 4:{var y=t[tt.DataParser.LENGTHS];var v=i=tt.BaseObject.borrowObject(tt.PathDisplayData);v.closed=$._getBoolean(t,tt.DataParser.CLOSED,false);v.constantSpeed=$._getBoolean(t,tt.DataParser.CONSTANT_SPEED,false);v.name=e;v.path=a.length>0?a:e;v.curveLengths.length=y.length;for(var g=0,D=y.length;ge.width){e.width=o}if(le.height){e.height=l}}}e.width-=e.x;e.height-=e.y}else{console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.")}return e};$.prototype._parseAnimation=function(t){var e=tt.BaseObject.borrowObject(tt.AnimationData);e.blendType=tt.DataParser._getAnimationBlendType($._getString(t,tt.DataParser.BLEND_TYPE,""));e.frameCount=$._getNumber(t,tt.DataParser.DURATION,0);e.playTimes=$._getNumber(t,tt.DataParser.PLAY_TIMES,1);e.duration=e.frameCount/this._armature.frameRate;e.fadeInTime=$._getNumber(t,tt.DataParser.FADE_IN_TIME,0);e.scale=$._getNumber(t,tt.DataParser.SCALE,1);e.name=$._getString(t,tt.DataParser.NAME,tt.DataParser.DEFAULT_NAME);if(e.name.length===0){e.name=tt.DataParser.DEFAULT_NAME}e.frameIntOffset=this._frameIntArray.length;e.frameFloatOffset=this._frameFloatArray.length;e.frameOffset=this._frameArray.length;this._animation=e;if(tt.DataParser.FRAME in t){var a=t[tt.DataParser.FRAME];var r=a.length;if(r>0){for(var i=0,n=0;i0){this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,0,0,this._parseActionFrame);this._actionFrames.length=0}if(tt.DataParser.TIMELINE in t){var o=t[tt.DataParser.TIMELINE];for(var A=0,S=o;A0&&a in t){e=t[a]}if(e===null){return null}var l=e.length;if(l===0){return null}var h=this._frameIntArray.length;var u=this._frameFloatArray.length;var f=this._timelineArray.length;if(o===null){o=tt.BaseObject.borrowObject(tt.TimelineData)}o.type=r;o.offset=f;this._frameValueType=i;this._timeline=o;this._timelineArray.length+=1+1+1+1+1+l;if(t!==null){this._timelineArray[f+0]=Math.round($._getNumber(t,tt.DataParser.SCALE,1)*100);this._timelineArray[f+1]=Math.round($._getNumber(t,tt.DataParser.OFFSET,0)*100)}else{this._timelineArray[f+0]=100;this._timelineArray[f+1]=0}this._timelineArray[f+2]=l;this._timelineArray[f+3]=n;switch(this._frameValueType){case 0:this._timelineArray[f+4]=0;break;case 1:this._timelineArray[f+4]=h-this._animation.frameIntOffset;break;case 2:this._timelineArray[f+4]=u-this._animation.frameFloatOffset;break}if(l===1){o.frameIndicesOffset=-1;this._timelineArray[f+5+0]=s.call(this,e[0],0,0)-this._animation.frameOffset}else{var _=this._animation.frameCount+1;var m=this._data.frameIndices;var c=m.length;m.length+=_;o.frameIndicesOffset=c;for(var p=0,d=0,y=0,v=0;p<_;++p){if(y+v<=p&&d0){if(tt.DataParser.CURVE in t){var i=a+1;this._helpArray.length=i;var n=this._samplingEasingCurve(t[tt.DataParser.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length;this._frameArray[r+1]=2;this._frameArray[r+2]=n?i:-i;for(var s=0;s0){var n=this._armature.sortedSlots.length;var s=new Array(n-i.length/2);var o=new Array(n);for(var l=0;l0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.TWEEN_ROTATE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=6;this._frameFloatArray[n++]=this._helpTransform.x;this._frameFloatArray[n++]=this._helpTransform.y;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=this._helpTransform.skew;this._frameFloatArray[n++]=this._helpTransform.scaleX;this._frameFloatArray[n++]=this._helpTransform.scaleY;this._parseActionDataInFrame(t,e,this._bone,this._slot);return i};$.prototype._parseBoneTranslateFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,0);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,0);return r};$.prototype._parseBoneRotateFrame=function(t,e,a){var r=$._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD;if(e!==0){if(this._prevClockwise===0){r=this._prevRotation+tt.Transform.normalizeRadian(r-this._prevRotation)}else{if(this._prevClockwise>0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.CLOCK_WISE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=$._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD;return i};$.prototype._parseBoneScaleFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,1);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,1);return r};$.prototype._parseSlotDisplayFrame=function(t,e,a){var r=this._parseFrame(t,e,a);this._frameArray.length+=1;if(tt.DataParser.VALUE in t){this._frameArray[r+1]=$._getNumber(t,tt.DataParser.VALUE,0)}else{this._frameArray[r+1]=$._getNumber(t,tt.DataParser.DISPLAY_INDEX,0)}this._parseActionDataInFrame(t,e,this._slot.parent,this._slot);return r};$.prototype._parseSlotColorFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=-1;if(tt.DataParser.VALUE in t||tt.DataParser.COLOR in t){var n=tt.DataParser.VALUE in t?t[tt.DataParser.VALUE]:t[tt.DataParser.COLOR];for(var s in n){s;this._parseColorTransform(n,this._helpColorTransform);i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=Math.round(this._helpColorTransform.alphaMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.redMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.greenMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.blueMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.alphaOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.redOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.greenOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.blueOffset);i-=8;break}}if(i<0){if(this._defaultColorOffset<0){this._defaultColorOffset=i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0}i=this._defaultColorOffset}var o=this._frameIntArray.length;this._frameIntArray.length+=1;this._frameIntArray[o]=i;return r};$.prototype._parseSlotDeformFrame=function(t,e,a){var r=this._frameFloatArray.length;var i=this._parseTweenFrame(t,e,a);var n=tt.DataParser.VERTICES in t?t[tt.DataParser.VERTICES]:null;var s=$._getNumber(t,tt.DataParser.OFFSET,0);var o=this._intArray[this._mesh.geometry.offset+0];var l=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name;var h=this._mesh.geometry.weight;var u=0;var f=0;var _=0;var m=0;if(h!==null){var c=this._weightSlotPose[l];this._helpMatrixA.copyFromArray(c,0);this._frameFloatArray.length+=h.count*2;_=h.offset+2+h.bones.length}else{this._frameFloatArray.length+=o*2}for(var p=0;p=n.length){u=0}else{u=n[p-s]}if(p+1=n.length){f=0}else{f=n[p+1-s]}}if(h!==null){var d=this._weightBonePoses[l];var y=this._intArray[_++];this._helpMatrixA.transformPoint(u,f,this._helpPoint,true);u=this._helpPoint.x;f=this._helpPoint.y;for(var v=0;v=n.length){h=0}else{h=n[f-s]}if(f+1=n.length){u=0}else{u=n[f+1-s]}}else{h=0;u=0}this._frameFloatArray[r+f]=h;this._frameFloatArray[r+f+1]=u}}if(e===0){var _=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1;this._frameIntArray[_+0]=this._geometry.offset;this._frameIntArray[_+1]=this._frameFloatArray.length-r;this._frameIntArray[_+2]=this._frameFloatArray.length-r;this._frameIntArray[_+3]=0;this._frameIntArray[_+4]=r-this._animation.frameFloatOffset;this._timelineArray[this._timeline.offset+3]=_-this._animation.frameIntOffset}return i};$.prototype._parseTransform=function(t,e,a){e.x=$._getNumber(t,tt.DataParser.X,0)*a;e.y=$._getNumber(t,tt.DataParser.Y,0)*a;if(tt.DataParser.ROTATE in t||tt.DataParser.SKEW in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD)}else if(tt.DataParser.SKEW_X in t||tt.DataParser.SKEW_Y in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_Y,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_X,0)*tt.Transform.DEG_RAD)-e.rotation}e.scaleX=$._getNumber(t,tt.DataParser.SCALE_X,1);e.scaleY=$._getNumber(t,tt.DataParser.SCALE_Y,1)};$.prototype._parseColorTransform=function(t,e){e.alphaMultiplier=$._getNumber(t,tt.DataParser.ALPHA_MULTIPLIER,100)*.01;e.redMultiplier=$._getNumber(t,tt.DataParser.RED_MULTIPLIER,100)*.01;e.greenMultiplier=$._getNumber(t,tt.DataParser.GREEN_MULTIPLIER,100)*.01;e.blueMultiplier=$._getNumber(t,tt.DataParser.BLUE_MULTIPLIER,100)*.01;e.alphaOffset=$._getNumber(t,tt.DataParser.ALPHA_OFFSET,0);e.redOffset=$._getNumber(t,tt.DataParser.RED_OFFSET,0);e.greenOffset=$._getNumber(t,tt.DataParser.GREEN_OFFSET,0);e.blueOffset=$._getNumber(t,tt.DataParser.BLUE_OFFSET,0)};$.prototype._parseGeometry=function(t,e){var a=t[tt.DataParser.VERTICES];var r=Math.floor(a.length/2);var i=0;var n=this._intArray.length;var s=this._floatArray.length;e.offset=n;e.data=this._data;this._intArray.length+=1+1+1+1;this._intArray[n+0]=r;this._intArray[n+2]=s;this._intArray[n+3]=-1;this._floatArray.length+=r*2;for(var o=0,l=r*2;o=0||tt.DataParser.DATA_VERSIONS.indexOf(r)>=0){var i=tt.BaseObject.borrowObject(tt.DragonBonesData);i.version=a;i.name=$._getString(t,tt.DataParser.NAME,"");i.frameRate=$._getNumber(t,tt.DataParser.FRAME_RATE,24);if(i.frameRate===0){i.frameRate=24}if(tt.DataParser.ARMATURE in t){this._data=i;this._parseArray(t);var n=t[tt.DataParser.ARMATURE];for(var s=0,o=n;s0){i.stage=i.getArmature(i.armatureNames[0])}this._data=null}if(tt.DataParser.TEXTURE_ATLAS in t){this._rawTextureAtlases=t[tt.DataParser.TEXTURE_ATLAS]}return i}else{console.assert(false,"Nonsupport data version: "+a+"\n"+"Please convert DragonBones data to support version.\n"+"Read more: https://github.com/DragonBones/Tools/")}return null};$.prototype.parseTextureAtlasData=function(t,e,a){if(a===void 0){a=1}console.assert(t!==undefined);if(t===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0){return false}var r=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(r,e,a);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}e.width=$._getNumber(t,tt.DataParser.WIDTH,0);e.height=$._getNumber(t,tt.DataParser.HEIGHT,0);e.scale=a===1?1/$._getNumber(t,tt.DataParser.SCALE,1):a;e.name=$._getString(t,tt.DataParser.NAME,"");e.imagePath=$._getString(t,tt.DataParser.IMAGE_PATH,"");if(tt.DataParser.SUB_TEXTURE in t){var i=t[tt.DataParser.SUB_TEXTURE];for(var n=0,s=i.length;n0&&h>0){u.frame=tt.TextureData.createRectangle();u.frame.x=$._getNumber(o,tt.DataParser.FRAME_X,0);u.frame.y=$._getNumber(o,tt.DataParser.FRAME_Y,0);u.frame.width=l;u.frame.height=h}e.addTexture(u)}}return true};$.getInstance=function(){if($._objectDataParserInstance===null){$._objectDataParserInstance=new $}return $._objectDataParserInstance};$._objectDataParserInstance=null;return $}(tt.DataParser);tt.ObjectDataParser=t;var D=function(){function t(){this.frameStart=0;this.actions=[]}return t}();tt.ActionFrame=D})(dragonBones||(dragonBones={}));var dragonBones;(function(g){var t=function(o){__extends(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}t.prototype._inRange=function(t,e,a){return e<=t&&t<=a};t.prototype._decodeUTF8=function(t){var e=-1;var a=-1;var r=65533;var i=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>i){var f=t[i++];if(f===e){if(l!==0){s=r}else{s=a}}else{if(l===0){if(this._inRange(f,0,127)){s=f}else{if(this._inRange(f,194,223)){l=1;u=128;o=f-192}else if(this._inRange(f,224,239)){l=2;u=2048;o=f-224}else if(this._inRange(f,240,244)){l=3;u=65536;o=f-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(f,128,191)){o=0;l=0;h=0;u=0;i--;s=f}else{h+=1;o=o+(f-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var m=u;o=0;l=0;h=0;u=0;if(this._inRange(_,m,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=f}}}}if(s!==null&&s!==a){if(s<=65535){if(s>0)n+=String.fromCharCode(s)}else{s-=65536;n+=String.fromCharCode(55296+(s>>10&1023));n+=String.fromCharCode(56320+(s&1023))}}}return n};t.prototype._parseBinaryTimeline=function(t,e,a){if(a===void 0){a=null}var r=a!==null?a:g.BaseObject.borrowObject(g.TimelineData);r.type=t;r.offset=e;this._timeline=r;var i=this._timelineArrayBuffer[r.offset+2];if(i===1){r.frameIndicesOffset=-1}else{var n=0;var s=this._animation.frameCount+1;var o=this._data.frameIndices;n=o.length;o.length+=s;r.frameIndicesOffset=n;for(var l=0,h=0,u=0,f=0;l=0){var h=g.ObjectDataParser._getNumber(d,g.DataParser.TYPE,0);var y=g.ObjectDataParser._getString(d,g.DataParser.NAME,"");var f=null;if(h===40&&e.blendType!==0){f=g.BaseObject.borrowObject(g.AnimationTimelineData);var v=f;v.x=g.ObjectDataParser._getNumber(d,g.DataParser.X,0);v.y=g.ObjectDataParser._getNumber(d,g.DataParser.Y,0)}f=this._parseBinaryTimeline(h,u,f);switch(h){case 0:break;case 1:break;case 11:case 12:case 13:case 50:case 60:this._animation.addBoneTimeline(y,f);break;case 20:case 21:case 22:case 23:case 24:this._animation.addSlotTimeline(y,f);break;case 30:this._animation.addConstraintTimeline(y,f);break;case 40:case 41:case 42:this._animation.addAnimationTimeline(y,f);break}}}}this._animation=null;return e};t.prototype._parseGeometry=function(t,e){e.offset=t[g.DataParser.OFFSET];e.data=this._data;var a=this._intArrayBuffer[e.offset+3];if(a>=0){var r=g.BaseObject.borrowObject(g.WeightData);var i=this._intArrayBuffer[e.offset+0];var n=this._intArrayBuffer[a+0];r.offset=a;for(var s=0;s12?e[13]:0;var h=new Int16Array(this._binary,this._binaryOffset+e[0],a/Int16Array.BYTES_PER_ELEMENT);var u=new Float32Array(this._binary,this._binaryOffset+e[2],r/Float32Array.BYTES_PER_ELEMENT);var f=new Int16Array(this._binary,this._binaryOffset+e[4],i/Int16Array.BYTES_PER_ELEMENT);var _=new Float32Array(this._binary,this._binaryOffset+e[6],n/Float32Array.BYTES_PER_ELEMENT);var m=new Int16Array(this._binary,this._binaryOffset+e[8],s/Int16Array.BYTES_PER_ELEMENT);var c=new Uint16Array(this._binary,this._binaryOffset+e[10],o/Uint16Array.BYTES_PER_ELEMENT);var p=l>0?new Int16Array(this._binary,this._binaryOffset+e[12],l/Int16Array.BYTES_PER_ELEMENT):h;this._data.binary=this._binary;this._data.intArray=this._intArrayBuffer=h;this._data.floatArray=u;this._data.frameIntArray=f;this._data.frameFloatArray=_;this._data.frameArray=this._frameArrayBuffer=m;this._data.timelineArray=this._timelineArrayBuffer=c;this._data.colorArray=p};t.prototype.parseDragonBonesData=function(t,e){if(e===void 0){e=1}console.assert(t!==null&&t!==undefined&&t instanceof ArrayBuffer,"Data error.");var a=new Uint8Array(t,0,8);if(a[0]!=="D".charCodeAt(0)||a[1]!=="B".charCodeAt(0)||a[2]!=="D".charCodeAt(0)||a[3]!=="T".charCodeAt(0)){console.assert(false,"Nonsupport data.");return null}var r=new Uint32Array(t,8,1)[0];var i=new Uint8Array(t,8+4,r);var n=this._decodeUTF8(i);var s=JSON.parse(n);this._binaryOffset=8+4+r;this._binary=t;return o.prototype.parseDragonBonesData.call(this,s,e)};t.getInstance=function(){if(t._binaryDataParserInstance===null){t._binaryDataParserInstance=new t}return t._binaryDataParserInstance};t._binaryDataParserInstance=null;return t}(g.ObjectDataParser);g.BinaryDataParser=t})(dragonBones||(dragonBones={}));var dragonBones;(function(y){var t=function(){function s(t){if(t===void 0){t=null}this.autoSearch=false;this._dragonBonesDataMap={};this._textureAtlasDataMap={};this._dragonBones=null;this._dataParser=null;if(s._objectParser===null){s._objectParser=new y.ObjectDataParser}if(s._binaryParser===null){s._binaryParser=new y.BinaryDataParser}this._dataParser=t!==null?t:s._objectParser}s.prototype._isSupportMesh=function(){return true};s.prototype._getTextureData=function(t,e){if(t in this._textureAtlasDataMap){for(var a=0,r=this._textureAtlasDataMap[t];a0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(a)}}if(s===null&&(e.length===0||this.autoSearch)){for(var o in this._dragonBonesDataMap){n=this._dragonBonesDataMap[o];if(e.length===0||n.autoSearch){s=n.getArmature(a);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=i;t.data=n;t.armature=s;t.skin=null;if(r.length>0){t.skin=s.getSkin(r);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(r);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};s.prototype._buildBones=function(t,e){for(var a=0,r=t.armature.sortedBones;a0){var p=this._getTextureData(t.textureAtlasName,c.path);f.replaceTextureData(p,_)}var d=this._getSlotDisplay(t,c,f);f.replaceDisplay(d,_)}else{f.replaceDisplay(null)}}}f._setDisplayIndex(h.displayIndex,true)}};s.prototype._buildConstraints=function(t,e){var a=t.armature.constraints;for(var r in a){var i=a[r];switch(i.type){case 0:var n=y.BaseObject.borrowObject(y.IKConstraint);n.init(i,e);e._addConstraint(n);break;case 1:var s=y.BaseObject.borrowObject(y.PathConstraint);s.init(i,e);e._addConstraint(s);break;default:var o=y.BaseObject.borrowObject(y.IKConstraint);o.init(i,e);e._addConstraint(o);break}}};s.prototype._buildChildArmature=function(t,e,a){return this.buildArmature(a.path,t!==null?t.dataName:"","",t!==null?t.textureAtlasName:"")};s.prototype._getSlotDisplay=function(t,e,a){var r=t!==null?t.dataName:e.parent.parent.parent.name;var i=null;switch(e.type){case 0:{var n=e;if(n.texture===null){n.texture=this._getTextureData(r,e.path)}i=a.rawDisplay;break}case 2:{var s=e;if(s.texture===null){s.texture=this._getTextureData(r,s.path)}if(this._isSupportMesh()){i=a.meshDisplay}else{i=a.rawDisplay}break}case 1:{var o=e;var l=this._buildChildArmature(t,a,o);if(l!==null){l.inheritAnimation=o.inheritAnimation;if(!l.inheritAnimation){var h=o.actions.length>0?o.actions:l.armatureData.defaultActions;if(h.length>0){for(var u=0,f=h;u=0){continue}var h=e.getDisplays(l.name);if(h===null){if(n!==null&&e!==n){h=n.getDisplays(l.name)}if(h===null){if(a){l.displayFrameCount=0}continue}}l.displayFrameCount=h.length;for(var u=0,f=l.displayFrameCount;u=0&&this._display!==null&&t!==null){var a=t.parent;if(this._armature.replacedTexture!==null){if(this._armature._replaceTextureAtlasData===null){a=k.BaseObject.borrowObject(k.CocosTextureAtlasData);a.copyFrom(t.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}t=a.getTexture(t.name)}var r=t.renderTexture;if(r!==null){if(this._geometryData!==null){var i=this._geometryData.data;var n=i.intArray;var s=i.floatArray;var o=n[this._geometryData.offset+0];var l=n[this._geometryData.offset+1];var h=n[this._geometryData.offset+2];if(h<0){h+=65536}var u=h+o*2;var f=this._armature._armatureData.scale;var _=r.getTexture().getContentSizeInPixels();var m=a.width>0?a.width:_.width;var c=a.height>0?a.height:_.height;var p=t.region;var d=cc.rect(999999,999999,-999999,-999999);var y={triangles:{verts:[],indices:[]},rect:d};for(var v=0,g=o*2;vD.x){d.x=D.x}if(d.widthD.y){d.y=D.y}if(d.height0&&r.inheritDeform;var s=this._renderDisplay.getComponent(cc.Sprite)._sgNode;var o=s.getMeshPolygonInfo();if(!o){return}var l=o.triangles.verts;var h=cc.rect(999999,999999,-999999,-999999);if(i!==null){var u=r.data;var f=u.intArray;var _=u.floatArray;var m=f[r.offset+0];var c=f[i.offset+1];if(c<0){c+=65536}for(var p=0,d=i.offset+2+a.length,y=c,v=0;pD){h.x=D}if(h.widthT){h.y=T}if(h.heightw){h.x=w}if(h.widthN){h.y=N}if(h.height { + if (error) { + console.error(`error:${error.message}`, error); + return; + } + let data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); + console.log(`parseTextureAtlasData`, data); + console.log(`dragonBonesAsset`, this.dragonBonesAsset); + console.log(`textureAtlases`, textureAtlases); + console.log(`texture`, tex); + + }, this); + } else { + let data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); + console.log(`string parseTextureAtlasData`, data); + console.log(`string dragonBonesAsset`, this.dragonBonesAsset); + } + } + _dragonBonesNode: cc.Node; + display() { + console.warn(`Armature name:${this._armatureName},dragonBonesName:${this.dragonBonesName}`); + const armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); + if (!armatureComponent) { + console.log(`armatureComponent is null`); + return; + } + armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); + + armatureComponent.node.x = 0.0; + armatureComponent.node.y = 0; + this.node.addChild(armatureComponent.node); + this._dragonBonesNode = armatureComponent.node; + console.log(`play animation default animation`); + } + onLoad() { + // this.display(); + if (!!this._dragonBonesNode) { + let component = this._dragonBonesNode.getComponent(CocosArmatureComponent); + let state = component.animation.play(component.animation.animationNames[0], 0); + if (!state) { + return; + } + console.warn(`播放动画:${state.name}`, state); + } else { + this._loadAndDisplayDragonBones(); + // this.onLoad(); + // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); + // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); + } } } } \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones.meta b/Cocos/Demos/assets/DragonBones.meta new file mode 100755 index 00000000..e6c498f1 --- /dev/null +++ b/Cocos/Demos/assets/DragonBones.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "13dafff5-0ce6-43e8-be73-3924547dc03f", + "subMetas": {} +} \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones/Dragon.meta b/Cocos/Demos/assets/DragonBones/Dragon.meta new file mode 100755 index 00000000..136d2e44 --- /dev/null +++ b/Cocos/Demos/assets/DragonBones/Dragon.meta @@ -0,0 +1,5 @@ +{ + "ver": "1.0.1", + "uuid": "69b5cd46-98ea-4086-853e-9e754ace2271", + "subMetas": {} +} \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json new file mode 100755 index 00000000..e646dc89 --- /dev/null +++ b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"name":"Dragon_1","version":"5.5","compatibleVersion":"5.5","armature":[{"type":"Armature","frameRate":24,"name":"Dragon","aabb":{"x":-234.41,"y":-431.81,"width":693.28,"height":769.59},"bone":[{"name":"root"},{"length":150,"name":"body","parent":"root","transform":{"x":26.0941,"y":50.5419,"skX":-94.9653,"skY":-94.9653}},{"length":120,"name":"legR","parent":"body","transform":{"x":-95.6182,"y":46.9,"skX":-156.0107,"skY":-156.0107}},{"length":150,"name":"armUpperR","parent":"body","transform":{"x":80.5853,"y":31.3927,"skX":159.9921,"skY":159.9921}},{"length":150,"name":"legL","parent":"body","transform":{"x":-71.0496,"y":-60.2758,"skX":-154.3312,"skY":-154.3312}},{"length":150,"name":"head","parent":"body","transform":{"x":163.1145,"y":-5.8037,"skX":11.4957,"skY":11.4957}},{"length":70,"name":"armUpperL","parent":"body","transform":{"x":74.4813,"y":-93.6047,"skX":-171.7742,"skY":-171.7742}},{"length":250,"name":"tail","parent":"body","transform":{"x":-117.1092,"y":70.127,"skX":79.7425,"skY":79.7425}},{"length":80,"name":"clothes","parent":"body","transform":{"x":1.423,"y":-31.7416,"skX":-37.5342,"skY":-37.5342}},{"length":60,"name":"armL","parent":"armUpperL","transform":{"x":66.7632,"y":2.2256,"skX":30.7088,"skY":30.7088}},{"name":"eyeR","parent":"head","transform":{"x":140.2628,"y":-23.9957,"skX":80.4531,"skY":80.4531}},{"length":150,"name":"tailTip","parent":"tail","transform":{"x":257.8621,"y":-3.1008,"skX":-37.5192,"skY":-37.5192}},{"name":"eyeL","parent":"head","transform":{"x":133.7701,"y":-101.188,"skX":80.4531,"skY":80.4531}},{"length":80,"name":"beardL","parent":"head","transform":{"x":7.4588,"y":-133.6248,"skX":-105.5036,"skY":-105.5036}},{"length":50,"name":"armR","parent":"armUpperR","transform":{"x":138.7492,"y":0.5285,"skX":35.2088,"skY":35.2088}},{"length":80,"name":"beardR","parent":"head","transform":{"x":23.2753,"y":-35.857,"skX":80.4531,"skY":80.4531}},{"length":50,"name":"hair","parent":"head","transform":{"x":104.8249,"y":80.6309,"skX":86.9099,"skY":86.9099}},{"length":40,"name":"handR","parent":"armR","transform":{"x":43.3874,"y":1.1079,"skX":17.875,"skY":17.875}},{"length":80,"name":"handL","parent":"armL","transform":{"x":66.6309,"y":-0.4273,"skX":4.4133,"skY":4.4133}}],"slot":[{"name":"tailTip","parent":"tailTip"},{"name":"armUpperL","parent":"armUpperL"},{"name":"armL","parent":"armL"},{"name":"handL","parent":"handL"},{"name":"legL","parent":"legL"},{"name":"body","parent":"body"},{"name":"tail","parent":"tail"},{"name":"clothes","parent":"clothes"},{"name":"hair","parent":"hair"},{"name":"head","parent":"head"},{"name":"eyeL","parent":"eyeL"},{"name":"eyeR","parent":"eyeR"},{"name":"legR","parent":"legR"},{"name":"armUpperR","parent":"armUpperR"},{"name":"armR","parent":"armR"},{"name":"handR","parent":"handR"},{"name":"beardL","parent":"beardL"},{"name":"beardR","parent":"beardR"}],"skin":[{"slot":[{"name":"eyeR","display":[{"name":"parts/eyeR","transform":{"x":1.5,"y":-0.5}}]},{"name":"legL","display":[{"name":"parts/legL","transform":{"x":101.11,"y":-6.45,"skX":-146.91,"skY":-146.91}}]},{"name":"armUpperR","display":[{"name":"parts/armUpperR","transform":{"x":56.52,"y":4.74,"skX":13.92,"skY":13.92}}]},{"name":"tail","display":[{"name":"parts/tail","transform":{"x":120.99,"y":-0.31,"skX":45.22,"skY":45.22}}]},{"name":"handR","display":[{"name":"parts/handR","transform":{"x":23.05,"y":5.06,"skX":-88.11,"skY":-88.11}}]},{"name":"hair","display":[{"name":"parts/hair","transform":{"x":0.04,"y":0.4,"skX":-4.91,"skY":-4.91}}]},{"name":"beardL","display":[{"name":"parts/beardL","transform":{"x":49.98,"y":-4.35,"skX":-174.04,"skY":-174.04}}]},{"name":"beardR","display":[{"name":"parts/beardR","transform":{"x":61.6,"y":0.2}}]},{"name":"eyeL","display":[{"name":"parts/eyeL","transform":{"x":0.3,"y":0.4}}]},{"name":"handL","display":[{"name":"parts/handL","transform":{"x":34.73,"y":-1.45,"skX":146.62,"skY":146.62}}]},{"name":"legR","display":[{"name":"parts/legR","transform":{"x":82.58,"y":-6.01,"skX":-94.02,"skY":-94.02}}]},{"name":"body","display":[{"name":"parts/body","transform":{"x":-0.96,"y":0.62,"skX":94.97,"skY":94.97}}]},{"name":"armR","display":[{"name":"parts/armR","transform":{"x":14.22,"y":2.79,"skX":-85.24,"skY":-85.24}}]},{"name":"clothes","display":[{"name":"parts/clothes1","transform":{"x":32.4,"y":16.05,"skX":132.5,"skY":132.5}}]},{"name":"tailTip","display":[{"name":"parts/tailTip","transform":{"x":81.65,"y":-0.82,"skX":82.74,"skY":82.74}}]},{"name":"head","display":[{"name":"parts/head","transform":{"x":122.95,"y":-10.54,"skX":80.45,"skY":80.45}}]},{"name":"armUpperL","display":[{"name":"parts/armUpperL","transform":{"x":27.9,"y":4.32,"skX":-148.26,"skY":-148.26}}]},{"name":"armL","display":[{"name":"parts/armL","transform":{"x":26.69,"y":-2.88,"skX":98.3,"skY":98.3}}]}]}],"animation":[{"duration":30,"playTimes":0,"name":"stand","bone":[{"name":"tail","translateFrame":[{"duration":8,"tweenEasing":0},{"duration":22,"tweenEasing":0,"x":-4},{"duration":0}],"rotateFrame":[{"duration":8,"tweenEasing":0},{"duration":22,"tweenEasing":0,"rotate":4.95},{"duration":0}]},{"name":"clothes","translateFrame":[{"duration":12,"tweenEasing":0},{"duration":18,"tweenEasing":0,"x":-2,"y":-2},{"duration":0}]},{"name":"eyeR","translateFrame":[{"duration":8,"tweenEasing":0},{"duration":22,"tweenEasing":0,"y":-2},{"duration":0}]},{"name":"tailTip","translateFrame":[{"duration":8,"tweenEasing":0},{"duration":22,"tweenEasing":0,"x":5.13,"y":-8.06},{"duration":0}],"rotateFrame":[{"duration":8,"tweenEasing":0},{"duration":22,"tweenEasing":0,"rotate":-12.64},{"duration":0}]},{"name":"eyeL","translateFrame":[{"duration":8,"tweenEasing":0},{"duration":22,"tweenEasing":0,"y":-2},{"duration":0}]},{"name":"beardL","rotateFrame":[{"duration":15,"tweenEasing":0,"rotate":9.62},{"duration":15,"tweenEasing":0,"rotate":-1.48},{"duration":0,"rotate":9.62}]},{"name":"beardR","rotateFrame":[{"duration":15,"tweenEasing":0},{"duration":15,"tweenEasing":0,"rotate":5.44},{"duration":0}]},{"name":"hair","translateFrame":[{"duration":12,"tweenEasing":0},{"duration":18,"tweenEasing":0,"x":2,"y":-4},{"duration":0}]}]},{"duration":20,"playTimes":0,"name":"walk","bone":[{"name":"body","translateFrame":[{"duration":10,"tweenEasing":0,"y":-4},{"duration":10,"tweenEasing":0,"y":-2},{"duration":0,"y":-4}]},{"name":"legR","translateFrame":[{"duration":10,"tweenEasing":0,"x":-6,"y":-14},{"duration":10,"tweenEasing":0,"x":-3.9,"y":-2},{"duration":0,"x":-6,"y":-14}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":-30},{"duration":10,"tweenEasing":0,"rotate":30},{"duration":0,"rotate":-30}]},{"name":"armUpperR","translateFrame":[{"duration":10,"tweenEasing":0,"x":-6,"y":14},{"duration":10,"tweenEasing":0,"y":2},{"duration":0,"x":-6,"y":14}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":45.5},{"duration":10,"tweenEasing":0,"rotate":-22.15},{"duration":0,"rotate":45.5}]},{"name":"legL","translateFrame":[{"duration":10,"tweenEasing":0,"x":-40.34,"y":28.4},{"duration":10,"tweenEasing":0,"x":-22.52,"y":-8.93},{"duration":0,"x":-40.34,"y":28.4}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":49.67},{"duration":10,"tweenEasing":0,"rotate":-19.23},{"duration":0,"rotate":49.67}]},{"name":"head","translateFrame":[{"duration":10,"tweenEasing":0,"y":4},{"duration":10,"tweenEasing":0,"y":2},{"duration":0,"y":4}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":2.95},{"duration":0}]},{"name":"armUpperL","translateFrame":[{"duration":10,"tweenEasing":0,"y":4},{"duration":10,"tweenEasing":0,"y":2},{"duration":0,"y":4}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":-21.2},{"duration":10,"tweenEasing":0,"rotate":30},{"duration":0,"rotate":-21.2}]},{"name":"tail","translateFrame":[{"duration":10,"tweenEasing":0,"x":-8},{"duration":10,"tweenEasing":0,"x":-12,"y":-6},{"duration":0,"x":-8}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":-8.7},{"duration":0}]},{"name":"clothes","translateFrame":[{"duration":5,"tweenEasing":0},{"duration":5,"tweenEasing":0,"x":-2,"y":-2},{"duration":5,"tweenEasing":0},{"duration":5,"tweenEasing":0,"x":-2,"y":-2},{"duration":0}]},{"name":"armL","translateFrame":[{"duration":10,"tweenEasing":0,"x":-13.04,"y":-2.2},{"duration":10,"tweenEasing":0,"x":3.9,"y":-5.85},{"duration":0,"x":-13.04,"y":-2.2}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":-38.8},{"duration":10,"tweenEasing":0,"rotate":38.55},{"duration":0,"rotate":-38.8}]},{"name":"eyeR","translateFrame":[{"duration":10,"tweenEasing":0,"x":1.7,"y":0.5},{"duration":10,"tweenEasing":0,"x":-4.11,"y":-0.28},{"duration":0,"x":1.7,"y":0.5}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":-2.95},{"duration":0}]},{"name":"tailTip","translateFrame":[{"duration":10,"tweenEasing":0,"x":8.93,"y":-0.54},{"duration":10,"tweenEasing":0,"x":-3,"y":10.08},{"duration":0,"x":8.93,"y":-0.54}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":17.93},{"duration":0}]},{"name":"eyeL","translateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"x":-7.55,"y":4.19},{"duration":0}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":-2.95},{"duration":0}]},{"name":"beardL","translateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"x":-3.52,"y":-5.52},{"duration":0}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":6.04},{"duration":0}]},{"name":"armR","translateFrame":[{"duration":5,"tweenEasing":0,"x":-2.57,"y":9.96},{"duration":5,"tweenEasing":0,"x":-2.73,"y":5},{"duration":5,"tweenEasing":0,"x":-2.89,"y":0.04},{"duration":5,"tweenEasing":0,"x":-0.22,"y":-5.61},{"duration":0,"x":-2.57,"y":9.96}],"rotateFrame":[{"duration":5,"tweenEasing":0,"rotate":21.72},{"duration":5,"tweenEasing":0,"rotate":31.79},{"duration":5,"tweenEasing":0,"rotate":-15.63},{"duration":5,"tweenEasing":0,"rotate":-19.67},{"duration":0,"rotate":21.72}]},{"name":"beardR","translateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"x":-1.45,"y":1.66},{"duration":0}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":-10.45},{"duration":0}]},{"name":"hair","translateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"x":1.13,"y":-7.17},{"duration":0}],"rotateFrame":[{"duration":10,"tweenEasing":0},{"duration":10,"tweenEasing":0,"rotate":-2.95},{"duration":0}]},{"name":"handR","translateFrame":[{"duration":10,"tweenEasing":0,"x":-16.27,"y":2.02},{"duration":10,"tweenEasing":0,"x":1.5,"y":2.17},{"duration":0,"x":-16.27,"y":2.02}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":-45.48},{"duration":10,"tweenEasing":0,"rotate":-0.48},{"duration":0,"rotate":-45.48}]},{"name":"handL","translateFrame":[{"duration":10,"tweenEasing":0,"x":-1.67,"y":0.9},{"duration":10,"tweenEasing":0,"x":-2.78,"y":3.4},{"duration":0,"x":-1.67,"y":0.9}],"rotateFrame":[{"duration":10,"tweenEasing":0,"rotate":15},{"duration":10,"tweenEasing":0,"rotate":6.45},{"duration":0,"rotate":15}]}]},{"duration":5,"playTimes":0,"name":"jump","bone":[{"name":"body","translateFrame":[{"duration":5,"y":-66}]},{"name":"legR","translateFrame":[{"duration":2,"tweenEasing":0,"x":1.18,"y":1.03},{"duration":3,"tweenEasing":0,"x":-3.12,"y":0.66},{"duration":0,"x":1.18,"y":1.03}],"rotateFrame":[{"duration":5,"rotate":-27.69}]},{"name":"armUpperR","translateFrame":[{"duration":2,"tweenEasing":0,"y":10},{"duration":3,"tweenEasing":0,"x":-2.87,"y":9.75},{"duration":0,"y":10}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":-24.65},{"duration":3,"tweenEasing":0,"rotate":-23.19},{"duration":0,"rotate":-24.65}]},{"name":"legL","translateFrame":[{"duration":2,"tweenEasing":0,"x":-20.62,"y":38.29},{"duration":3,"tweenEasing":0,"x":-26.35,"y":37.79},{"duration":0,"x":-20.62,"y":38.29}],"rotateFrame":[{"duration":5,"rotate":-15.3}]},{"name":"head","translateFrame":[{"duration":5,"x":3.6,"y":1.9}],"rotateFrame":[{"duration":5,"rotate":10}]},{"name":"armUpperL","translateFrame":[{"duration":2,"tweenEasing":0,"y":4},{"duration":3,"tweenEasing":0,"x":-4.3,"y":3.63},{"duration":0,"y":4}],"rotateFrame":[{"duration":5,"rotate":15}]},{"name":"tail","translateFrame":[{"duration":5,"x":-24,"y":-10}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":9.35},{"duration":3,"tweenEasing":0,"rotate":13.73},{"duration":0,"rotate":9.35}]},{"name":"clothes","translateFrame":[{"duration":2,"tweenEasing":0,"x":-4.77,"y":-4.51},{"duration":3,"tweenEasing":0,"x":-9.07,"y":-4.88},{"duration":0,"x":-4.77,"y":-4.51}]},{"name":"armL","translateFrame":[{"duration":5,"x":-0.6,"y":2.55}],"rotateFrame":[{"duration":5,"rotate":8.55}]},{"name":"eyeR","translateFrame":[{"duration":2,"tweenEasing":0,"x":8.88,"y":-8.7},{"duration":3,"tweenEasing":0,"x":8.12,"y":-9.06},{"duration":0,"x":9.01,"y":-7.73}],"rotateFrame":[{"duration":5,"rotate":-10}]},{"name":"tailTip","translateFrame":[{"duration":2,"tweenEasing":0,"x":2.17,"y":6.3},{"duration":3,"tweenEasing":0,"x":0.64,"y":-0.9},{"duration":0,"x":2.17,"y":6.3}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":2.89},{"duration":3,"tweenEasing":0,"rotate":8.91},{"duration":0,"rotate":2.89}]},{"name":"eyeL","translateFrame":[{"duration":2,"tweenEasing":0,"x":8.94,"y":-6.3},{"duration":3,"tweenEasing":0,"x":8.12,"y":-9.06},{"duration":0,"x":8.94,"y":-6.3}],"rotateFrame":[{"duration":5,"rotate":-10}]},{"name":"beardL","translateFrame":[{"duration":5,"x":-19.78,"y":19.23}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":-50.29},{"duration":3,"tweenEasing":0,"rotate":-58.56},{"duration":0,"rotate":-50.29}]},{"name":"armR","translateFrame":[{"duration":5,"x":-8.08,"y":1.16}],"rotateFrame":[{"duration":5,"rotate":-13.13}]},{"name":"beardR","translateFrame":[{"duration":2,"tweenEasing":0,"x":-8.15,"y":6.75},{"duration":3,"tweenEasing":0,"x":-8.03,"y":6.83},{"duration":0,"x":-8.15,"y":6.75}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":42.5},{"duration":3,"tweenEasing":0,"rotate":50.23},{"duration":0,"rotate":42.5}]},{"name":"hair","translateFrame":[{"duration":2,"tweenEasing":0,"x":-0.82,"y":-6.04},{"duration":3,"tweenEasing":0,"x":3.82,"y":-2.8},{"duration":0,"x":-0.82,"y":-6.04}],"rotateFrame":[{"duration":5,"rotate":-10}]},{"name":"handR","translateFrame":[{"duration":5,"x":1.5,"y":2.17}],"rotateFrame":[{"duration":5,"rotate":-0.48}]},{"name":"handL","translateFrame":[{"duration":5,"x":-14.11,"y":-3.85}],"rotateFrame":[{"duration":5,"rotate":-8.55}]}]},{"duration":5,"playTimes":0,"name":"fall","bone":[{"name":"body","translateFrame":[{"duration":5,"y":-66}]},{"name":"legR","translateFrame":[{"duration":2,"tweenEasing":0,"x":6.18,"y":8.96},{"duration":3,"tweenEasing":0,"x":1.71,"y":8.58},{"duration":0,"x":6.18,"y":8.96}],"rotateFrame":[{"duration":5,"rotate":27.76}]},{"name":"armUpperR","translateFrame":[{"duration":2,"tweenEasing":0,"y":10},{"duration":3,"tweenEasing":0,"x":-1.49,"y":9.87},{"duration":0,"y":10}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":-69.64},{"duration":3,"tweenEasing":0,"rotate":-66.68},{"duration":0,"rotate":-69.64}]},{"name":"legL","translateFrame":[{"duration":2,"tweenEasing":0,"x":22.6,"y":7.9},{"duration":3,"tweenEasing":0,"x":19.62,"y":7.64},{"duration":0,"x":22.6,"y":7.9}],"rotateFrame":[{"duration":5,"rotate":50.73}]},{"name":"head","translateFrame":[{"duration":5,"x":11,"y":-3.4}],"rotateFrame":[{"duration":5,"rotate":-8.73}]},{"name":"armUpperL","translateFrame":[{"duration":2,"tweenEasing":0,"y":4},{"duration":3,"tweenEasing":0,"x":2.98,"y":4.26},{"duration":0,"y":4}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":92.45},{"duration":3,"tweenEasing":0,"rotate":89.97},{"duration":0,"rotate":92.45}]},{"name":"tail","translateFrame":[{"duration":5,"x":-3.9,"y":-6.1}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":-18.47},{"duration":3,"tweenEasing":0,"rotate":-22.44},{"duration":0,"rotate":-18.47}]},{"name":"clothes","translateFrame":[{"duration":2,"tweenEasing":0,"x":-6.01,"y":-4.86},{"duration":3,"tweenEasing":0,"x":-1.54,"y":-4.47},{"duration":0,"x":-6.01,"y":-4.86}]},{"name":"armL","translateFrame":[{"duration":5,"x":4.35,"y":5.81}],"rotateFrame":[{"duration":5,"rotate":-53.9}]},{"name":"eyeR","translateFrame":[{"duration":2,"tweenEasing":0,"x":-17.76,"y":-4.61},{"duration":3,"tweenEasing":0,"x":-14.83,"y":-3.01},{"duration":0,"x":-17.76,"y":-4.61}],"rotateFrame":[{"duration":5,"rotate":8.73}]},{"name":"tailTip","translateFrame":[{"duration":2,"tweenEasing":0,"x":2.8,"y":-1.16},{"duration":3,"tweenEasing":0,"x":1.82,"y":1.79},{"duration":0,"x":2.8,"y":-1.16}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":0.14},{"duration":3,"tweenEasing":0,"rotate":-0.83},{"duration":0,"rotate":0.14}]},{"name":"eyeL","translateFrame":[{"duration":2,"tweenEasing":0,"x":-13,"y":-8.15},{"duration":3,"tweenEasing":0,"x":-13.22,"y":-5.94},{"duration":0,"x":-13,"y":-8.15}],"rotateFrame":[{"duration":5,"rotate":8.73}]},{"name":"beardL","translateFrame":[{"duration":5,"x":0.32,"y":7.78}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":-2.54},{"duration":3,"tweenEasing":0,"rotate":25.13},{"duration":0,"rotate":-2.54}]},{"name":"armR","translateFrame":[{"duration":5,"x":-11.21,"y":-3.2}],"rotateFrame":[{"duration":5,"rotate":-13.14}]},{"name":"beardR","translateFrame":[{"duration":5,"x":-7.87,"y":5.25}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":8.96},{"duration":3,"tweenEasing":0,"rotate":-6.04},{"duration":0,"rotate":8.96}]},{"name":"hair","translateFrame":[{"duration":2,"tweenEasing":0,"x":0.59,"y":7.24},{"duration":3,"tweenEasing":0,"x":-6.32,"y":0.21},{"duration":0,"x":0.59,"y":7.24}],"rotateFrame":[{"duration":2,"tweenEasing":0,"rotate":-6.27},{"duration":3,"tweenEasing":0,"rotate":-7.09},{"duration":0,"rotate":-6.27}]},{"name":"handR","translateFrame":[{"duration":5,"x":-3.94,"y":-1.37}],"rotateFrame":[{"duration":5,"rotate":29.52}]},{"name":"handL","translateFrame":[{"duration":5,"x":-3.6,"y":1.47}],"rotateFrame":[{"duration":5,"rotate":21.45}]}]}],"defaultActions":[{"gotoAndPlay":"stand"}]}]} \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json.meta b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json.meta new file mode 100755 index 00000000..a66f9bab --- /dev/null +++ b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_ske.json.meta @@ -0,0 +1,5 @@ +{ + "ver": "2.0.0", + "uuid": "970e4d3f-6b08-4d49-9bac-7a331d13308d", + "subMetas": {} +} \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json new file mode 100755 index 00000000..3ed27358 --- /dev/null +++ b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json @@ -0,0 +1 @@ +{"width":1024,"imagePath":"Dragon_1_tex.png","height":1024,"name":"Dragon_1","SubTexture":[{"y":234,"frameX":0,"frameHeight":210,"frameY":0,"width":111,"frameWidth":112,"height":209,"name":"parts/tailTip","x":456},{"width":112,"y":234,"height":86,"name":"parts/armUpperL","x":340},{"width":48,"y":859,"height":80,"name":"parts/armL","x":373},{"width":96,"y":922,"height":78,"name":"parts/handL","x":1},{"y":677,"frameX":0,"frameHeight":180,"frameY":0,"width":203,"frameWidth":204,"height":180,"name":"parts/legL","x":238},{"y":397,"frameX":0,"frameHeight":348,"frameY":0,"width":235,"frameWidth":236,"height":347,"name":"parts/body","x":1},{"width":216,"y":397,"height":278,"name":"parts/tail","x":238},{"width":208,"y":746,"height":174,"name":"parts/clothes1","x":1},{"width":124,"y":677,"height":282,"name":"parts/hair","x":443},{"y":1,"frameX":0,"frameHeight":394,"frameY":0,"width":337,"frameWidth":338,"height":394,"name":"parts/head","x":1},{"width":28,"y":961,"height":46,"name":"parts/eyeL","x":459},{"y":961,"frameX":0,"frameHeight":58,"frameY":0,"width":37,"frameWidth":38,"height":58,"name":"parts/eyeR","x":420},{"y":1,"frameX":0,"frameHeight":232,"frameY":0,"width":180,"frameWidth":180,"height":231,"name":"parts/legR","x":340},{"width":160,"y":859,"height":94,"name":"parts/armUpperR","x":211},{"y":941,"frameX":0,"frameHeight":78,"frameY":0,"width":45,"frameWidth":46,"height":77,"name":"parts/armR","x":373},{"width":98,"y":322,"height":58,"name":"parts/handR","x":340},{"y":955,"frameX":0,"frameHeight":36,"frameY":0,"width":119,"frameWidth":120,"height":36,"name":"parts/beardL","x":237},{"width":136,"y":955,"height":36,"name":"parts/beardR","x":99}]} \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json.meta b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json.meta new file mode 100755 index 00000000..e55465fb --- /dev/null +++ b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.json.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.0.0", + "uuid": "1d0f2cfc-b370-4ae1-bffc-872cdb66f2bb", + "atlasJson": "{\"width\":1024,\"imagePath\":\"Dragon_1_tex.png\",\"height\":1024,\"name\":\"Dragon_1\",\"SubTexture\":[{\"y\":234,\"frameX\":0,\"frameHeight\":210,\"frameY\":0,\"width\":111,\"frameWidth\":112,\"height\":209,\"name\":\"parts/tailTip\",\"x\":456},{\"width\":112,\"y\":234,\"height\":86,\"name\":\"parts/armUpperL\",\"x\":340},{\"width\":48,\"y\":859,\"height\":80,\"name\":\"parts/armL\",\"x\":373},{\"width\":96,\"y\":922,\"height\":78,\"name\":\"parts/handL\",\"x\":1},{\"y\":677,\"frameX\":0,\"frameHeight\":180,\"frameY\":0,\"width\":203,\"frameWidth\":204,\"height\":180,\"name\":\"parts/legL\",\"x\":238},{\"y\":397,\"frameX\":0,\"frameHeight\":348,\"frameY\":0,\"width\":235,\"frameWidth\":236,\"height\":347,\"name\":\"parts/body\",\"x\":1},{\"width\":216,\"y\":397,\"height\":278,\"name\":\"parts/tail\",\"x\":238},{\"width\":208,\"y\":746,\"height\":174,\"name\":\"parts/clothes1\",\"x\":1},{\"width\":124,\"y\":677,\"height\":282,\"name\":\"parts/hair\",\"x\":443},{\"y\":1,\"frameX\":0,\"frameHeight\":394,\"frameY\":0,\"width\":337,\"frameWidth\":338,\"height\":394,\"name\":\"parts/head\",\"x\":1},{\"width\":28,\"y\":961,\"height\":46,\"name\":\"parts/eyeL\",\"x\":459},{\"y\":961,\"frameX\":0,\"frameHeight\":58,\"frameY\":0,\"width\":37,\"frameWidth\":38,\"height\":58,\"name\":\"parts/eyeR\",\"x\":420},{\"y\":1,\"frameX\":0,\"frameHeight\":232,\"frameY\":0,\"width\":180,\"frameWidth\":180,\"height\":231,\"name\":\"parts/legR\",\"x\":340},{\"width\":160,\"y\":859,\"height\":94,\"name\":\"parts/armUpperR\",\"x\":211},{\"y\":941,\"frameX\":0,\"frameHeight\":78,\"frameY\":0,\"width\":45,\"frameWidth\":46,\"height\":77,\"name\":\"parts/armR\",\"x\":373},{\"width\":98,\"y\":322,\"height\":58,\"name\":\"parts/handR\",\"x\":340},{\"y\":955,\"frameX\":0,\"frameHeight\":36,\"frameY\":0,\"width\":119,\"frameWidth\":120,\"height\":36,\"name\":\"parts/beardL\",\"x\":237},{\"width\":136,\"y\":955,\"height\":36,\"name\":\"parts/beardR\",\"x\":99}]}", + "texture": "21b8b8d7-3f82-420f-847d-f421595a3769", + "subMetas": {} +} \ No newline at end of file diff --git a/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.png b/Cocos/Demos/assets/DragonBones/Dragon/Dragon_1_tex.png new file mode 100755 index 0000000000000000000000000000000000000000..02cc390989b27934da368d08ce383a6abdacfb3e GIT binary patch literal 159196 zcmZU*c{r5)`v!c^7&W#GvXo`)lr`BRX6&*=%915($Py~q&5-O{DcOpUD6;P{vL}04 zvJDZkjeVQ#o#*!+@AK&U{^4N$aNM8!TF&b_&+Gb3jPZ3H2HNwq001yt)73Nq00`wz z2mn1r`Gw*Zdjfzx^R8*C-SP*m5$US#nuaXJjd7gI>vTQ!$Fc6*fegw1M^UE!y;%P9 z6Qj(<6=f^PFVAvg%~_K!(#qYC4WaTByjOk?d`Ua{>RAR^FB&N((PvS#m+WL+!>h^@ z%nki)m1-ZZ>olA`cdqtyv{?!H*rOl!!)rigDR8Z6f5sh0RB>FpH1_b*6^#3*fW?CY z>vDCJIuZ&6@$o_;&@dSIe?R=tn0<8zKk@CT#HMk-VGQp3p?eXqT;V;!&2q#?zlC)h2M`G_?~74Wv_$cJ57PgdsUb&x3~ZMgzu3p zT=~<{B+f+Dg^sd+TK~S-Wiv(su080 zUYaMJO)sC3Y%sy47k`r7eoB!B1Q9v5WTNZ>bzZR|$jJ^E@#jH*+}z>}pH&+!+*=v;RgzXxXfMgPO3X$wi@ z{Ip~})L>2|Uy|m3g3*{YtX}9cnLVy5CRqpS{LC41W=^VsjSdWTFIKt94_QtoDJ?EQ zZOT&XZ~|U93!}4h=8w*VF_@j7ZM-|5na3dj{h;Juu-uSXgNbdVi{R`d{W13{E$)-z z-!aT;s{rUg5lrQ{&P4k@UbU9936{QEe|zherrrH(^VxzVm}c}ZM%?5?bSfq~t+U^r z2_{gKqGx=mLmO@HR9qaf`Q(fAmXUqDH$Pmba+cZnn0xaL?UZ)vGuKvIl;HfN!BOykUGrS}-PB(4gI7>D%h_Zr}G`F&R`=xY8fQ zrgcgSzd?$g%_V-nc84h-Myh~5+AX|v%Ig3fYF-F=cam~Pm|_IK*2 z=g@`a<~UO^k-Zi*$&-^6YvdjjdG3ceerSIMLw;dP9y?0HV|WHQ>@->R(SzJM3F#o$ zn@pqHGJKQs!ofneM+nLN%y!3%80 zS3@6}{q4CbPEb|tg%Xr)JNai;A=&i$INyeEce4#%;V1;rjYBo3Z3daRO+xr&P4r?G zD}cTH-o3fXxn7XIwJu64L~BSG4yim)E(!r!yphSl>rJi`AJnEIOt4N z%T@j#;|dBO%RVPZR3r(%p7nYeBU(U6-e*4+Bu+&=1xCRk8HJM}Z%dEUN`OUPeJHGBm)Jr6~pT&aP2F|Y&2 zQZEMEZBne+t`)!8VRE&X zIBoPgTS7H7v?dh$W-Tph-)WU+JcT>-U_%e_={L{D(wLL-KvR(UkMqD#=EgU8Nk@Ty z<=a0XCTA#{;Vj#GA@`i}nWMF~Y%EJ(!=ybW$KBs4pC?ZZw>X}^pC=*m`p$Ioqfe(X z4QgkjG>_Z%zrQall^B2{UNH|Ny`#8)qPo}zaLL>DFp>-iJfO*e1zpaops&L`VwFh-c1#m-x zqAp5L6lvuxx7;NI@X@3)lU`RgIeA_l8}=)8{u^||{^;=jUW!ls%zR16*t#csD&eIfYJ3YaEh8xlz&+X>v)nsZL+`7N?eWM zV7L{K3U+K&3BJz(^XB@(PN(|ih~vn1ys_RV1r;ruvG=mJHuEs5_4I^3>`Oy9ATFZ* z3WxwcnwQSp*;IX`_cww-!-Scl?-fck+3L;&?hk3d(mL=8tAYO_Z^Ol%@EGq0>`dBq zb8;z$P#|`@eW%#+CyRKhy6G!g2)N*n7tI`FmjOpGlfm}Z)TxJ?uAOlmakcV#B$1bg z3VcvrNi=!JBPjZlg5mX-AN2ozuz@Uih}R|Uow>}BPNlV`0UrrAeu?FVE?FOg5eoVv zU==71xMn_s^{7=1=}VrKIy@#kmPkOH4=TR+L386EAET8)%01}k*cq=v(s9Y*vHNd3 zItfHRQrfXmMkhj$G}n9^60t>Zf-kxi#tb&tB{R$2IeCPf-_YKUa3a%h%=52^XNxx% zmtbR;SjbeU?ZmbBj9D+5f~VD^4mC(e9lAv#xgiAwV)UDSlvd^zOChf)NTE!ExtL?a zx~c{*WCg2Di#bssSGxfcyy2 zWXs;kuaYoTv4$k%yVy>+IUxN8#zIcq)8cu^H?b6)wLAO9MUSKF)!8`Ikl;}g4IOWn zYmd)qw0PbX_=`ui>!Bv6Hx3=@<&YN*dBdxH;!msGJn26q)PMo3pTDP78t{~0K5U|) z>S%e7K;RU7cetv-GsHta>|_ZvIHbE4s>zF-MaYsbZ8KhJ`rXzwHljK3_U$gmguI1` ztq?n{^vCB{K%R*3SA4YQ8J{@y>1SAQmrVUcfkO9yp>~~^f%+z8vD!OzgK3KhZBks~ zoG=;*Y){FnW4(g99~l2|>3hvCP9Xo9h4nab zo(A(11)T6BFq`CxJFB1KQq=VEUs^Bep<( zniU_pfUz&ZJZrs?y30MhagEo9iFvTU!=R(SHnkoBPT_bHiHk@-+G+OgL(XFi2(OBz zW2?whV^P1gevRz<)`={`7vR~uH<$zk zrUm~F=K|KSvqw@wli1#`Zp%2tTT7HR*P!A~&{~GXIi}?{*+$!blEW`xn22Q%^I~va%~QmbNQ3p|ZDbtZ+`*@FMRsw`UKZK@bKgY!nj9s$T&BG( zSG!T7f@zP`0QLCSwvvf-FnuObzLqMIp9$u#`gdN7SDPgE%&gm0mt>W@r}NOu=?$}C z1u?q83o}@SP3aqdEV%7IJO=+31`i=ExH-KZr{PN#2GEDKq8XGEWlsf}+|#BuIwZ=E z0&kYPYTD?5&q=|v19D1-EH68nW9&~8>0$`Hc-NsAma^^rukkF%#*a`?tJjMc@AA$I z#JtUG`ztoobDE&-(Pt)b9DJ)vr;ZfD^=JaPnXbt>FseoTm@j}ahuN<=&fu_u<7$en zE_}BNBls){{0~vmLI7_n$Z_z{@7?t^kvw(5aefeIIkV_0<0!{lZ{c<F(wiuov?~TKEMBqz}%^u7SOUswV>l#5d>$aae#qu+i=h3@6&xkk{`{2s?<+?5@;Pg?KEFzY1<^KqFn_t}50PbJYHSS-zq+>>bs(NwZ77Byg zhl2d0@;Jl-Bmd^kX=fpee5Truc&%R!69VAAvOm&3C8;Uf?4?7gTX{oAm&!C(^)s&E z)%a6``H-M(-W4B_}p(n!p-U)E1#F)oh~ zHJT5YF)Z9t@VKB;)W`5tIn&QGgLd0X9ncGhB*yg~;H@KoX2!Y4;wrPxN21wh40{O0 zk7@tT>Q30Qo@ZodHS^KIy+6`6@D$r)UPxLY>5WB&4eLnSZN>cRic-|YZg_jPB5+xo z;4{)9lNWucF{@p8Wc#JEb?eff0y5u?8X~uC*40-)F?%tw{J9@%GXkPyit(`#`JeP< z2$S4SO1fGw_H=V#K#81>jCgbpInraq~XtvFpQu*Fc2LwgpW-p zN1iP&z}Tbf`LWyoR9hGS+cAUrCOMjAm%qdu9X)aUMkQQOCZ?3g3dzTOaK@JH3WcW$ zNvx0SS{4#@Qmi#)-mg#1`57e&A#WQaAqr4$0>?*AoZ~V}1rP7vzKeW{KCq1{G!-Vh zemo7`J-wx)Z~Lm(yq@%Xl}$;V+8PoYjd?aEEj0Vw%v&=2D695`G;^5tPi%wH`~QliQ7%}wf31SQR6>r2kzsV!f>$Fw1a95d`^Lu7psBsF ze5S8qA8U2l;5p20YpdBBWT`;XRv6wBJej>=McOSXWIa`K+HqdFHgr(rNF>enZ4qkY zl${{vD}XB6@9ZW&&kh)CWUOvU9@PW0c&o2^6_8%!>vOd{;2(K)O^K&X<@9IYg>NW< z&pWq&kb*!!D)4dRHN78N11Fw11bax`QvH6lZ7lKcmrpwd`7GZkbJXS4G=M~DS)#%Z z-j0Z5pjaOgg`*|!pSgs2RMm8ZU+2%ggd*#Ok$8_FI4e&q9ooxR zdoyqt5ps>nwV$BGfWmQBJN(P{yB2xU3N>!9510O~D|Sf8V($xXmi^&JzG-;JPc!dF z;fA3GtBhN?F%Jy321($M50-ZkgcvN}v z-I0?p=@MbVI$1ZBb~t%Y^($G-Z()dt80MUYUnbvh!)G7usz3gXm)DL##F3K;Qnz(K z&&H^|17hy1BHp!QJHa@q{rl@2xU{Oo#~~K{x?6|Lr*jOku>Wc0kN7oF+Rm+=gU3@z z`&85q{2ngDE=g;BA6I-AjJ|@Euh}|x(0*ewsFH%L^nAd&c%Ur>;8&QzRUYCKKk`lf zZd`Baw19t_@{_3`MH-j0_@nMFz)Pevj+28K9N{G>j&o@@>2K z6jBjw-QQa8%UER#HBM!N@g+5R>D>m^{k)O+SCpnaK_?w1-42OOW(ee}+_We|blZ!} z+TK40Q+<*XT>ip4l<$tO^4Kz_C3iX$rYC#6uK|6IslIy?b#N*uoM zb*U#LLXNGQG55^ZC6#yG!HBN7@T;ni`%)!aJAxkIoU$@^LVLLzeVV#aJcp$Q$ziEY zeOrJNwRFFc-oRf<9tSJ<+X5RoAb8~_0(!fsK8T;gj_D{$@qwyftp&fG1MX`oR-2A4 zCaTUc@taiiFhV-=M~oO+<<%Up3x;gw{2D!fYY|uf&AmW)kJ-hkif9|F9fY;C^rb1jzfe4*5U+?ZrcaFN{*tq z=EC7Y0-2(WUjvN4fC0X)*1VD9pm1YCdZ(7R8kIDhIT{2N z`*Vx(=N|;mCx~jO(|!Gg^ZLUVUdIv9o+O|2;F)I;j6uu+=I=1k=?UF4+EBT0&aQk@ zWkHf7Ptk|~OjuB3qyb(wG0(%)wzJ8xB-;%<{P~}MR6XuMm!NqNtW4UY5{tm6UUoDC z9(rmLqD7LlOnA{cHpVo z++~|BV;IqKTl!k*k$Drd$Z}NQTW{SV@+uv``~7gDc7)dM_j<<#&^<&dJha*M2D+yl zCE)g#`q>iA#4Gydz^3-;#i1TPLUJk{kCg2~V2OF1;T;di={fcBH(E3?_(m}Wo$7CC z@1xoo&A}+dq=pPW`^j!p^VD4B$2EbqoauQO^CNNb2V${jL0&70!g!L7HlQ1FD3E5i z#7?u!(Y%@)0#W1JKN9&t%iw-!!*I;~6gwimUfNLGWCpZf6b)p5Z`;)59{=l(+^>6g zlKy9uBxVLGi`@EN_c=Y#9|Lnou zOKJB~jWjBrHsooG1^7TAg3W3#TVk{z=?{}PO~SM3PG9wLQ5IZ>GNr~SLqd_;cSbiZ zE`8OW+k(Ht>wM*s!A(9D>gC1u6=UPXfQfy1OYn<#kcDYJ+Om+la{@~?qnOzxb z8$<<8rKW1n=o#RYV7|p5Kj>R~GU$+vOwkmS%|PgFdqJpEmY+6dHnMe!KOYKzFGC&i zXQrZNrNSATX9M7(vkh27Ac|SGNsiQP^y*!J!??-az{5pJxtye zce9o1*m;XZ^iOGrX->P1ARGB@kQU!Y=94KY#IOMSU9`qHS;3W^S^4@%?M=g0_s*i8w0shM6!D{m=x~un`$}& zn}V7o{j_@Q(sh4wyjs`!OZ-=b0$k`;?>=yYyu_DaA5z1(CGx;;$RYIB(g!EwoM~av zOD4E#axzN!&BaTNQJb8nQj8slL)sD-!-bOIW;}W4r7AbGxNSXLEL&t0fabdh$?<;j zNEN?x$64aHo8~9Tl5`_9LYSO4c#I2PF&#!7w*8L4Mq{MNL-6&!#5-%O;0QXGef%J4 z;Az@npibBTFNEPO#BUUJT(Y#aP$TR+0Le-2*w>O&C za}V;}E3ZQ&1P(@9uu)e6$a%)Cg9G{c*N#Lmt~=DV<6G#_l055#F-7LAkQfz|4=s4> z@sSlh1qdHx7g$RE$Be>aGBnvfMhbuY%q#10;TPkz zNy-!|^4><_H70fRONG}dC5LSr@UGFRhj)sk(RSfQYvAkw36M8PmzvOK!^@_HO);C) zp1d!}lYO_lgxE5ga(ofz$o2^&(w6jq>zur{%A2mO&+?sMUR`@8HW~%AnPo+9YwZWs z6Xf2GpUJZ$YzGkstow?t%K%tMZ3; zlb##~Jt&)xQTb_K`+8CUBK;OvV&l1HMLkFw%uiFje`VkBC#peW?UlY`Kgzv~tI7guqqQoXkM4ML)qj>>a!ehC=vd-=-w71+{r|7?jj~rvcKY;gu^0_L;`23XC=7s`5Ea)a~CoOR+3bw`Tp}1h)Jtketr!rleVm8*#ko7t{iR0pi7 z$~dHd&Fc@JI&Pkj2a$TZ5gSaP)SFvP@s%u*h<7r8tkE%X9GhmxF7^@d;-v3 zvxCZhwR%uvw$o^N{H4~%s?19n@PrRHPSS*&YADB?RF4skJppC~9%uNLHBBIVi#`(V zpFg$v5Pl`kWoT^+TKmQ2#WSMHIh(^XoXi7~qqyk?KS3 zd8T-CMvY0Y2&!$28`i&yq)CoiD-Fb5`#JIb`+{6#0=I^=j6pE{`vQGykV8He z-loUP%7`wv=XmjQ`v~5D3q}jT)a6vJ-?FW>vs-$#gIgTkw*VD4C`jh-;3VRy(A8t! z+WBs*|DgvO#=#DL8iqHC=#wR;l_!P&*a&u$6(++%Wbp{p&wD?m?s%(5QKs#w^A}mh zVN%}elS&)iq|j&Bf&DqZf=X~2FQ6Z0F zMp`rX9G?yS$SRXb?=|?r`DC9Ewg_9+`NkNAjO*j~Ih&7V``8BEbWnEevqX@G%GdLI3%G$i@ zs9t>bGauV#AB{^)40!lt)EWyR$;Dn`6EpKL^zmUEuJ@nn6aOfJGrNx0iZDDw|B>3t z!YJ@|D)V45Wk>|XP64U9odl;~^^~7I#(;D&2X~5Uf7B3(GBfOAK!yP#J9yKNCkETb z>>vS>R43HaKmNy~H0Xf_v*hv0Q9|;J3<|Z=1=n{x`@&ZqI zk`@?}EkDXfj|({_tSOLp32Ooa8-EC@ME1tY$>wTh{J6rtQ`X0uW1^+&hce{3EAM;& z7`V7$b;=c?j&(??1}BUVvsP`TK*%Pq>aRHWKH@sfsk%_xt9ReyO2ME}a`U686P=Xh z6QF=(Doe_|K0UZ)ia6M?xdC2ck1k(F9qp-b%S=W9yuWd%Zib~tgze11UyeUp)Y)I1 z>b`&|=E~R}A@8}|5yE43T!Jc+P&=j`8^rw$aYC3C{eV2T71=I;4X6Zk>p{t9hEqZ( zQ?X>%0$LiNQv^V+&ZOF*iB4c+yZ)izyujEKCpx8N$AfVbuq+?$#p8vVTub=sT+8|D zlV{Xo+rtjQgL83BU7_Nc%ZYtPjjJkYMx{4RF{w@#|EM0Wi|cZX@(x zNQK3y11WBV4+*YMg`5Il*`eK%&TGjQp-@mywA0I-w-`j&acneM)P#|(niHIKM8brA zGOvU)hhmbFb7=Hqa%<##6T3;Kx){uC>Ow4H zz0By^h8JGhGdb8<+`5o?HuXhyWz3H2wn}+v!)v|MuJeO>OmUXk`$%?uK>7{{X;lH@ zdTbs7Ld!g&-~IFFWa82@f(S(k)F*%YTz)McGT z%1K`tvw3T)?xBWi*N6>#hUe}q%OA`^hseuJ#VP4+5c54Bl1{D&Zmd(ZRGG~g< z#emr$H+?Sjc z%BG80cW+ha-}@99@cH@=@(XX?QPr7u@b}EX?q2WG8N2B8%H6U3(@J@V)Oz1P0ChJ3bB{!`&n`gDU#45_JdNUV zg1?1Q{%_xoy~f>gUt!}Td{;^s59*L*$5B`E;&jA&86m?dH3Jh#iI zeZ9<*RyQ8_ZwIO@TkQB7?{d3y8ZQBvOyu%w#umeygF*3*ybXJ+2Q7ikFuv zDHI3U5qyB2iJtLIN3GkyF=_2l-U)Ea(BO?fPWpqYD|4T4dSd~ayF6}7wm^Z=wm%2fQ zMRne@Kzqc~a=!w{K3ZCNRelh1NO9!KUp7|!=WWxpy*Mm)ENGFz#1JKnOdnziMXLB7 z*i8Xb7_4_oMGd|$e}nMe20ECJ!8{AK?TmI51<)@#qiPf76I$HQTv=ea^D(ocDyB(+ z+xG?M6EPy_Xvq1`%Y2VpP#={lzNY@V@l=fV{DrHCIq-9c6W99jX2Jq zfmn?8OPfVO00va_hwCSLJzu8(+a@MB@FW=46>8kH)$~4n<@A*^F+SX406!VOU-^1i zm*0aUzr=7Vj@NEj0=&8Br8H=(drS;fbm`P8Rlaf_j`*d|= zv1I;;DWYucwTwK$;zn_zGe%?NM7t3-0X^(EH~Ej4<8ni1=9qt*E~e`}`JYmKq~`yP zf1~RcNIclb>zy5%GMBlqL$VQuiV-1(DvvH1 z1IdhpqlqWB3cCqFhBd;kedbxBoYA3%L038rr8=R7(%}LglrTFGdCz$QIHeWA_R>;p zu5bSY-&jCJhj86gmRE@{Mle#U}g0Y~IV5u*XSO-6OOTiTSs%Ax?mvI2XMpVDZSon2NsK$)Q^ zw$bc(ivku+fqVNsPYl@qYJO$ofM?&^s4eRhlW2g!@h)hPzn5EfkcJvkoOibWeNPGS zffhK9Atkk-Nn>(9m)?A6jjW*s@e*C}QO`yPqC-YxdO032=)j2%m9~*?Vj6(q zr#Yi^=7x@$*NJi>06HS+8?_y=*#U$U&3DWawQ%|Q>fO!>IOE_4&+&(TFXGI#ylOCN z$a2QV%MFzD4L$OjS+p3h?qk`K2JjXn#M8(W8{OhQWWpVdlj zyT8Z2{o_UT=b$yr0u$_giJFb`m*BHPC3>EW2aPdJ%G{Y}KrO%KJMJ6UpQ0@B$IRvb zy`zwaq*yOMeCgb?62}c&-)BkAs;M+B8zQ`RH!f11-mI}d$ zsgXZ}=&69kR3)i=ofrLo$x-y&VIRQgil;MW1Eoj76b1VOkQ0s0lm;q8Ak1wmjN$0P zy)SR3UkrvJLz084j?y-F1RM~5jwi0~YW(uTmmkbg1MXv=n(i;d<9J~F(n~ggNo(79 zcECe%t8TfqN}T13 zv@E%ZT1Nd;g#gFV`*w9c-w=PU@BzjLNnc5VDM129T0&b;b^6Z$+UM#oBb}sgOvt>| zYj+M4tFT-{M)p@ELCD)c%ewiSVF6&!@54Qf6KLS5%}Wm+H{B%_Nz zlL?jCjKlTi^tV)Qop>j8ihx&e1Ax(Kn=O#B+S{1zf``Jklc+xqjv=BffNrJYn{yIb z2nXzp`19=>`vF{FwA{gg<-(zAS1%cLw48@gd2{2#`@hok5$yjolQ6CHu^&~wAln5n z%o1oHe%1lT&Fvu0RH87(iJmO&Ub)l&dF6#i#}Q`*tN9zHTOhQ;rBuMqBV{5h8)34g z;4p99mEl9p5e4MHcTm(TT$2hPPXAYDD-(hCY}ekmX$1>%S1tLN5SZ(_=!hx&8ytFX;}rjW+ts zR5$y@S*d21I}&V21^;Y7iQ$JB&xIYDFOf?cUzX$Rtr=+)N?2!pp;CAjt$kZXy^g^B*eJe`*1ps33zdj93TQk#qU~CitK*yd$*W>n=NTA=qwg~ zYQBOx?Im51f**k}S+I2wchm-#96JsIp%2J9WkZj!Y&=&LtRC*%{`nS;kg(bc3P^5z z4j=o3Sz7ZrNV#|UHWn*f8^xmt+xD6WwUy`E^twGhYfa+-M)x(!OQbMRgSc=``wap~ zpSu^&=|SQR6Fog--TDBJtv4ih|ZX3?yzA?Fx4Aan78uaX(WQ#U~!}ls%eXlrMHfd0Y4D`wX?_SgZ{XvshVo1^p zXpu;$@kgo?z`-E^ez;(=PbWSZ2_49&mzcnM^I5vU5h(Efh|u2Q{=6`H7I+mle)&p& z0Ogk5_~kR0xp%Je1oI@%4GoAV}FhN>rT5tnuwz!xN5xhMkA@cJUK3 z>rq2s!=*s>ei%*(L^5#C<|o|cu<{5?d-tVq3T)9``uR`R$^vn?pybJ%zI zU>jhUOl_n2U20y?#()Kn*ZWxnjl4$K-uFKMbB-=Rpxs3V*50?w{Pb&L=`7q zt_`_?Sjoy8_(+l-yF55XgkP^{ZYn?IWyEz*;`?vdXg37BL5 zolS);GFim#k{#;m_@_+}agI=l{7N{+PoNJM{^26EX#|ee=C7Pq$&gV?jXFL z!BzJ*9(~SQ?vg&A`pcxz(+gW~3=&o5icBtWz_AayKiAGMlaZUu;| zvK{CP3qS-lGrIPB?>pVyY=v)k)>4ccuLlK^@pWrO%z%uPl?mt-#ag{3A<)SD%=w_N2u-GBZRfl%VtmY>pK0isbar$$ zCbGH{R8$S!$c&gEKkblaQttY#9z;-AdniZnkHS;`8UP9HJp)!bU#T=i;!8+N-g)vO z?|0_`X05Bb2p)0et~!pIu1&B=i*9(lp5v&?CTzZZbuzH`SZy-ur?&2%%uy{bN}?Lb zd3`}#oI6KX_oHy{n=6!Y%E;GHkK)pxoO4)IG1Ou2eIn}-Q2;PL-)|P;=NA8O%t_Ng zBMQix{rB}r9?;Nd`XKeFAFVzwx)NlA<}@?=h~LV}N%WPBha(42z(EZty;^;s#KI9@ z*6zmllv7jlsB2PgvP5~MFrq=Ts>&J^f z&j0()c3>FqZ`-;;x4Z&+_wW}%pd}N!?i*YR6&?#HE=v^KsOzY7$=$cyal?IAJ{7I_ z>0`=TIh6_y{S6ye1L+;Jp{(xJWY5F*b%O+dV5)>|DE0q4b?IQaWSx78(JkGYPV^~$xJo~^? zb5c(n61mq~5qK|!-5_2@5~Rtajve^*c_o*NuSJ>)e1GZ{o!DnK^2FsJDiHtK&9V4< zLB9=`1c|AJH;W#j4f_oGey~`A?51z+8?FY|zH8wvAWvC!jbY2A=#Ebxna}n)H#3d= zmwuE@CzbORDvSjouRVR_`(=b696I6vHuZ)p@wTqi)xgls+y?kC+--4OgjvBiapyHp z;I}K&5V8VW!&9J+IzDDMYQXR=6}k+mw{U8(fu_nO@nhysrz~t|U3SwmyVploZyeMv zl2oeuh$W@L`cOCZZ?YJv@8r=C7q{e-q40U5TR>_%?qY8GB!6+AkQ3H@x*Wn$P#Q>2 zXGFSotvhtBAvEzBd*)Mx2_mIs-ALQh_^~S4x@v8!aM2Gz)SIR%+TfqKBnHSps*q4) zC+ZvzU_EQEH6F-Mao3Me`JpfrIZr$!Y7o*f$DRn>U5cha`xQa1bh`Jw-^;M%KmFD+ z5$Q@oT*Q+9KcRMwBD|!R1kb+yY0ubvS$T1Yu3{QBztvn0BeG_PnD6>6FU_Q{`&Tr;fWAg{a6F|^n)Xz#RI4JTZRgGDG*Yw+o4b57 z?Q-+XV6Mkj$;_K6%9X6D0xd_JmI46MLhaO(}JB|+@Btz&k?#s4hl%<%tyK>+1cCQ{{#0i;A#YmYxvkkK6F4V9fe)}e`oUirGkf^y@4>bmuW!q z0~R2;a)vE+UUF!^(mPS2P~WSW@OILwKPbrMGpT1XsSlc{EB(!$CgRJp<1bT~C%K+9!z2yr%D;cdEe3xHXIszfF1dTG%)8QQU?ZTxBf!8B#JqtES2I+3e5qP!XKlPz zA5*(NV@0Mh0sQxbM=HP^J!j>;-`QWh1>Gp_q>82ir458`v`to4zi;*w325_-((p$Os5*sCvrCG~O^awCP4z(#n!D>7_#{^3PhaAj zs9Uuv6(~#w8J1!UMHhMd_m%CZ+y~&(LlOYxEG=_>Zzi8GMszlp2PdXyj|3F-5j&OI zW}dyQlSJ?*`aNc>6O2CyH&_nz6o>BzXnW4o??`lr06H_)= z>`d;(DOA0D!mI?P+yn4LjWl?(7rN0Hv%$Q(^6JTfk^qJCtn7TeV_v0rKW-5<($uK` zglM`hH8$jet*tsef$Y(ILgcF{c0p@Sc`<*LW)v<^)V}}@2;^KB6mb`{Kf3`3G zfrfk%JD>MGQ1UF{2#2jcn z*s0d@qq%-v?ET;5XM!F-?p;?73gr?3hosX1OCK#jv!@0h38STrQzarMO&mTkMz-+^ zsrG*<3r=>J32c{o!2zW@Jqj)P+#lvy03kgZV2Ig!yD(GnrEkgUom zoO6sqgeW6rG?cQpjB_d(k)6#kGP3tM$64Q3pWpA(yU%}czs7xE*L_{j=i_pf3R{7< zp;jD%9DUh1&4P>*xE7ZEe}ymsRT(PCvh4BnuO9JGON7&t62sWfAZ`XXksv{Smk41@BH! zGP^o>=?lBhE4&q%bRWz(PhHu5?8WCNb2>f(+PFLzfap;}W+~g7oX0FK-~74*#=OCw zadS<+vvNV##ZjXljJy_4o=>bj>Ezt))?gHHFmSZi(*?Wg&+Y&jl2GrlJefGe>YN>_ zhCc6mSl{TN1PTgc4ee3VlGlD7Jl4SpF+M@MpL&!bzDZ2PYFB;Nl}Y_Vj!wLS{By^F zhjW}l+Hdnd<8dOTgp_GwgN;v2S#q#qh7V+4 z#O>DYZEsh~2=VS?W$D0I3Lkd6lHPXRK=um-kt;v4aJXgnb^q7ugl^xvm|M@NhZCRL z3OUC*Lo^?eqi2)-EQGXRz+kd*?#2|1p>OlIz@Vjsruh8^$% zDyD0hc;=;2DEy4g3;H>a1|2S^80LN+4s!tmVVFkKRSyFMP7zRtEIJLZRo;i<)WiwC zFZ#tG=nfwACqT~A*uGRcRn%$VKG4KUa3l(n@~TQz-s@N*-sW|P0l9$sLHKISH5?tW zx}MTba0^SkQTT7*hr!e=cAxE|seDjrt>JZKY9!-V1=qSTTRnDV(OJyCg~Z$Tf`xL@ zFk}e&{UhD%h3wb7cB4ORkM(6g&}5t&du|29;l4(*$L+@z`|S62SZwG&aaA6u(USDN z&ak9p&DhBR1P$aJmK-8EWmG#A`&r|X#Am$$x2FQo?apEwV_UtXyjJ{=NL+3w4gKDj zX)#=V>FqHo$l4X6TZ&^M=*;==x4x2yt{Ey6sc-=q#@>JNQlft*OGkD=Dysga>M|) z3y)gCO_nL@nT#P-N#9b?vCH$@vZcfYTn+m9Shx~%-iqZKM-o@j=e155qJjJO3OY-g#BfSH*Mj4hXbEExt{Dq&L#cL3!13+W3FMOr9^m^-f0z7)-cMG? zIc-m)uUx|%7$hBiIM4e2o! z8S|;h<-Nxz)^KxHn&E|&*k8!e{z`KverV0Ha4yGquXhhe9Paqo=ocv>nTHND;krfG zxv6G9LlM8PX=|Mc3Y%7%OGUmL5Ky(>d$T5BRik zI{j#zD*$ZnXcg_qc?%VBv4TFng)fATl2@l=1j^xPIBtJ5w%B{rAFO$ac%wszPpJDMhE5eg7PtA@AyF_m z`|>Dv`PA1aZzC|O09yWHU{_36%QUcl zQnWTnoM4kz6E5*k>$q@oqsLnJHw~}+{^v)%TPT6C{Jl>O?cbS9y`+tH!q>Q*Na9o> z@4ZU6rz5F%n}r8CuJl(J(2|}Mt^xB*u%ZD+M)OfLL>;A*(=)Zt*tiC4#CP6Se~Z`F z_6B9uTKYZaYJ^-kAaI@OF%zwz6zlBXlB#|u0@OQs$8wbTJH}E_rx`S!aVXAmZiCm@ ze7!x(L?|*T22s&rDszoNkF%=q7f|vLGytNs87Ipu>;bqNxzjyBk_VF_%EDW>bjcam z+AdL_)ipvO8eNrs{uHoU_g{GO@8OjJmS>8T9?&AK5Ws%Zz)FE z1KqF1(XWI6j!nz=Urt5HXoaihix{Tis^AdLKIW-SIRaC1itsIS+O3-^q1Zj-*7^AE zhxu-JG>pGmp%!+h<(m2jpf_4;R+^w^5oROK-KT?NhUIzz&|4suXt(atmp|J+90qj| zh0r2|l>JQ^QWX|Sy*dHw9cOh@p-`<^w(j)iMZV63PqDkbKIR)s+W|I%`a74qc3^PX zqDbN0_}`k=pKADfkMfJ*>^I=4JbPt^}(U$Zs9agdMyIQ=Id$&r9!oR`Ld0h+UF zsZpk$Qu4F+Y3_kAU@&XA6zXwA94!L{D*8L?C#p8^zFZV-dshQsT6eq7N@Bb5{0b_M zF)uNw3^;LDbkK++k!YEwrc5E%^Y&}){Xe`7oqo3rrJ}9^1Q56|TCDeGo*q5pY)z6{ zJWccMUwoMJfs!}`>2FwHps={_D40E>;0ZmVe5V(x@3ncF-8U2a(q6a+ zjih+tKy$*;UjVxhaN3+XYR0TN;vVOfTnctZM!7x$vtHz_TSDZ8ayk zNFzvoIO4$y#dL13rF)M-I~zhm2Q=vd#B<}(9N32h?OV^|mD1*+ogdD&TaTA1j*`1q zM+PAEC?#E5okLyVNC`}SM0Y`9SID}cYac`0{|%2KM$Y$g z7QfT{1^?_m9j>8p4T!8cv!}!^WYqq_FvR#5rfD-O1CinEu$Y>Q4u(;^oqU*30BgBtH&Pm`hhL)#`JBdK-DNx zHecqB4R2A+Pfql=mU9R}^I0>F0B~i3As-**P(DiY2sCDsb@nP^)4b^bo(Pj~OxyS;WY zH*Tydb||m_&=0)l>JOv}KRkqa<1pwz%oHoN;Aei|gp^pX|AN@=ON=;n;GUVp@zR(M z=D?ZpMy6m6{VhrWxR~XhxAXbL7}Vty)ItOu4?sHhjhlSZao``CV){7{$!ihS&ms;-_L zAPljOi23OlqEe*cc$?>TpadV1hQCe~UprZMalLlu^L-UFi3#F=#C5-fRHwNSjJ4HUom6;u~^gy7Y+Xlu%tdsSV*`zmQcctzFSrjdhf4d>n)gm356GL`Vq{6Dig+f^Y+)~1-GQI ze>aU2@->>j!397qdSy@3Ri&BFxh}Bq_HpKP)3OOES+w%;%~s~s<5CbptNVvDcPGb| z67)8uLt7rL3qOUkz$IeTaChz)Z4DlK@!_QKWhn;ZSBY7>a zLnCgy{jImnPLCert^-QS<;7)%R)eM0r&hzG;>XKK~K zt@X)sOI{oRl!%2gZ9@(>$W}%0!ENL&Szl6i%cWpF_AC#8?h$2;4OOo=CE&34XK}BP z`QH_m>LN8@383{zz3P)kywj8nS;72RIn6Ch#b18HyWfj@o$o$Ck$)z+WZL_0tOISC z+R!!HQ;RCZ%bVqanN@{#bwh6Doa%+kAz~X+-mgNMkP$IwAKX8L8h&}-Z@<0k;DO)w zRRhTzOjQSS$I4N7UpSuA+TFn_@c)aY;1vQ_MKp1f&(=$xTry}$%3 z;)3t#CJ4U{mInUOut_ym?#v&t0qdBQ+gVQ{)HjFM)L|@c;v%zrT=!q@y0~EH9PTbB zIwxTq=QV48^d#3^u*sWK)8)PDEEzMeMz*u&`Ri8}(S-V(I>u4E;`vJX8=HbzpC#*v zbj8oZQR&SBOMF6KEj~gfCD$rv9Y(JL=pzK7Op0(Nk7BgnftLZAWk|=VbCw=`6ut9Z z{CaBD@^^ch2V~O_HyQ;czc|@L0S!nL(XVC=@A>86RL7kJt(|{?dg(r}=Kx^gH`=D` zJw|Vdd<#|D55O2N`-Et!p(B&2f|4xPRl68p(j80W z;`lrM1vm?snz4`sWL|lza@e;9oqN*ev;f7Sj?3JDSRG=$p~Q=W0k0$|_p<&RCEYOS z?TLMx`S^Q9An|6ThU`&1pegHoje0--t0K3>bvFp8xac*AD5JK7ND-Jfb1aF_xhcfVgnUoZFw!2m+o zsYSgP1kCFw_=cd{Ebm_O$MHL2Z*G)E0660@FiEX)iJ*htX+YgmD*}BYLoo8nNgo*E zz$vv%HEMLcFG$jTSMm*8E|iogkP<|_8-D7h_{*+JkG9&uLEC`36!j+Rl6J#Ecz`#? z@hQ7xL9g-p7EyB))Xq>9d$#^fsrTR=B>*VAeV&silo6i4P+`o}p7wonjYYma&f(gp zdVj~P!1fr-`+6PA@|gYT#nAS|78)}QK=*$9!ITeZ;g(i&kIK$@EY-8@E~&UL=EUpz zZzP>gFC-{UdfFwNPpOHWDFtw~MuY^_-H+={B|!W7$=`%%DtE%A0NX!lL%Ij}vp9{* zO`z1Tucn3WRI^_N-&NN9J4l;WFUI*NUsdt1O!=%4k(e@TpY zEc%3g9?9kf`n>DU%115TA6>&W?-Zh-6PaD@)-Z^}<*T=itJISlWbXg?P2Pe66SGkX zMwM@P zOmUwrIYnp`b{(1d*b=|&+PijP{*CF<@dVdP*HA76Wa2X_$?Z+X&^)HdLzK(``5?jLTy;uo{-tADTE zoC7F< zqn3}RK0H77wXyb`MC5|u`sMLDUES?YsmyhfB2crqee;^nB7Uyt>ld$242If> z9oRB)caKZ#4~io^g;sMil|!U((oF4Lh5Wx7L`uJxQJ2p1(g+2f@tscqAdX!L;Kc`) zEKF6}1BXokoRf_4d$sSory+&wHjSPqE7W1}%Q79F(mE(NN$f57VK@8=hMNAZI%8XW zxTOIXX#Hp*dk>>dvgF4$dV4a&sTCLhYAIU7Zk4f5T|f{HeYZve=}k_U$O_SL&{T03 zOj4~PTA2z=XG!^+Z6?75*_9Gk#lz3KVUE=&(eunHQdH32p7_|gf)28MkJ1)stk1AA zB#$jmu2nV|Z-od;{+ilA_K^B?z`74DXo)o#BW}jWv3&z;`SH}Bt>K{z6$A^B%i@<$ zSC*9Czq%;G)%H%|1M8zJpRXY_PR5d+0btjQv+hXC+a4%#)+8QZBFFs@F)=dSDW>I) zq5c+UJ6`zDGhZVr-@}{7ZX;HXmbS_HAPQ4(u4hA zG#VdwD1~`K{P>YSM;TZYq`;N<$Itu|M4E6{k%)O-W?CQ(q|2H=6VM`G#Fc)%^8>Wq z%$}BhX_VdXnoq#KDE%41JSG2xQS8v?g5GtMmkztsc}iMc*td>|nf29_V<0wlPV3iK z#SdNfZqFHF}GSV)~c(lD(LEyylJt2HW zkP`%$dp#vxRlWwMgl)<%&vba}ahHj-#0Q^m!wju{@zK@x+~YGQ2a4yTy@r0y=YKpR zQ*!e&-`y{quVRs5ea5?V?MI?v_@-=Xx*_{U9mzYt?vXVyC5*{4Qf>3rtpKrfDv$9L zukG+JQ`cMxil^*`8IzyMKK@eR)shm)1*|JP1t#&v_w}_T7FE7|S=z|pYukRk(ieTu za`_DB^Yuf!rw!+rhS?nR9L)n#l;US=d<8w#By9zL%9pi*RsE)H3LlEPa3Ecc1e$<< zN%k`v&xU*tmBfY>sOz6-u(rY0-?~MaZB01090+oji(9Wk$u2_~?`3 zXEdzcozFPsFHBz+0uFj1nol3pa~+hx%-0I40)(eh1KPR|YD*t;{$s@Hi@9N_80W;= zJ69^<7Sb!dIT|cpVGnX-xuqpvP^FtBr6B$gzYMYMVI$J3@AK?E(Lc3~wnb%ZW)Vw} z+@9nI*hb2^_hNtlA`0;OAbKDecnvzKqs&E1G258K7LK4T2^5!pt3T66rtS)~mc&%} zsl-d4U934n*|r<&JTWbQ?D0K5=o9<1r>R+xGT%{Wx`+<{e4~BVu6)rS z0qVlj!7vJst#&s-~7X~@jvK##JUtfv6v$DB5MaAO(FY>)gz>^bEtD)l;H2K-lG>&zpw-7zrNFSR}1@c(>X<^)@ zpi4)YEgfTA0Q}g%ba8!vMI>$h3RC#x1C011jq5)(W{QpXC=he6C4dbW>#)u3@X`nAAVuxBRR7XqhzArjdRB5MyrHmL@-z3Eveyc_ z-+RWAXLc{TttOh8$@jlE*xTr9xx@VJS9~0?af!-y=jors010bOBqWOye)m_vhdxW| zz5g^O!?Vfd8YtI!+qo(L&?bGadMHbLDUn6)myJkt^&y^68<T{eQ%PlKH8*#^H-9mR6!@J3`sNbl;Q{j&6{*uf%W z_;3j;5KUYCHQYttty&hwczadN#m|&ij!szb&FB=(H)c27G`Wc8mod{yD0l+oFfIxm zrMI+2x)Fa#viAo?0*NC^tG)w^+SeHGcUk5&NAUl6(alrL2&`{Ldg9 ziunGGHD8-0mA}`f2CchFWdpSZpR`~E>L((jW%-F5J0B>XDbPq6p50OrL}x}yYk8ks z?{_>o$RB#_DFlF4ZszIbLH+mNps8({up}PVmkp}IQ#-tepW-Q5%cXXxRQh^;m)kHt zq-cy>$KK8rOWb%-Ya#^9Ze_Iy>9I=<=Zfln7K0s) z?6(b6-AObg02I~CFNj-tBbJ$;T4sDlo36=YZ+|rSlevMzf1K`t;&aw+Hbq=}wzxgj zQGuLY4Zt-Z6>SG!dV;O?Iz~pcE)g5Bqj6Fq3975XcG27kM`Z~6u^2;{IPde$ z0gpq9S1i5jjsr7IPES5RkYP+lG}D-+AK$q!5(ly?LX9g5n$jc%>HAJe&iapWzpnwW z4p#d3@W&0V-!SI8hIr;FC64$UnV6i3BqbR*fzzqKDLYVEKMQNfdi(N`hU^`Mxjg8c z+04bC_|Tfgzuy|D=1z}hjD=V(z#+}K5d2cHgl`lr&8XunCtDG*_9m+ump=d+3BOBb z^}tszRWMN@!wC|FsOtyAJ6!w10cPRi-f$Ai~~S!O0;YptfK%q=GEpu=mf zM<{*rE97RRKFcXUl-;0L9)hM^Jd<-eQTz%?r%8vKrfrHm6~$3%!<)oBN2Q3fh3XpJ z7W#>ACE{af?aTPk(EoiwN>Go7Ht&kZ_Xc>?Wl^+u9X+Vc?}|4bL+$jUudPgCb9H}L zbcCShb>hGr6RsDCs&#i-=EIjC-vNt>@h}70==%*-fqe)W+%jZ<@7vgoxvzr<@BTD8 zs_S`ify{4mptQ}^T6;foj=^AH?BVHh=fgLejTju;(F6F_pN>EApMkzZ|MMHsr6x54 zUd6NfEjdnTs6jMO5%$9F?%PZ19~{o+*TxdSyFXXN+B zpdQoW=8imOepY{z@;|GHl*S$IQ>|hq5{CzR5PU~9CudL|&1*!VQ6o%+QQXSxZSDDU z%c|H)qDM;$KbJG;S+p=>5;soktVmize8Wf|o?&SVa_5$^1z=7*h-Nl|7+PUqx*V}# zL>t?z4AXYQZ&k*b-3Oc(@tDwUjyYjta&?u`^0@s7Tc+KfLaC{AiR4xmAtB-(b4c3)rn*3-p^>|HWD@fVVe5BFAeO) zhE3BSk?K4TEDew%@pp6k@P;TI8^Y0J8K93to9-AyygS^MmfhPk;i83Fe1cJ!p4j$> ziil;reqx4J%U4=?5Dxg(F?tgYwT59gdJK}q_n4#<1GR!L_+rdr+~Zq~tZ-c+)7MDl z&0l=67?3CI!IWlhY`p#7W%9#Zpny;vEY|MsY`*9f*H%}D&!ShE{nd?+!+yqEy0zF> zrWe-T@(LsywYV#Gg_u=M7ibGJtR2cu*ww6T8+=B;ULK10I8cfdnKbNT{vw3&s*B9) z3xU-=HXcUxVi9Q2YGZ=l(=?f6R~6#1Up{tW&S0NEPr5kBQY|;2rw+3cKkL7tO{_!J z?RBZdVg}ca&pSrRL#cj~0X}>x0jNQjak~2JeR$wE!u)0A)?$ z_Q+rIDjY)o6!H*&hL>!`jt@@_W~K5UFOoE%2@|Q+!@d(3hrp%~O9ffVH3OhiM#*MN z)v`4Z!+0+5DZf=%SRo$-TK2df9KZPqfF3x1fcHH;@eS>Z7?1{RRb!S15|vZxs~+#> zjmk)&H-1KVMadBnLrlt-mXFOXe2r9-45t4?%N25KH1YC@K%D2V3)eR*-gJ<%Td5w~ z|EU};7r9{R|J?p2@X6944w=hIAsrv7YQ=7l`)vOT+wgEW)CdaLS*hyzodwJ8pjhb| zELl;yz+(@)(kJN|^*d?vlyExv1|oof*4WxdEaq5c`DxH9i1^5Y?sVhu^LxoL1L#rTSO#$b+$N4L;(z$kAokP{yd4COz7rrqq>@sEF?2>tjj_ zLpoQ2b27VMo-tFdQj`S0K_7x^QkAh6!s5jgmR#c5i^elIYsl-n`JB7+Z5~g(IUv1) zXGPd27ZaJrppkwnajd^qq8%sRxG^=W?(V9pw6Vt5R<_bI#sMGF=Cr^bXCiN^P1z2y z@A6-~IZ>%FBFvHAJ7eMgKl$Z9h~I>XKs)4xW}#Q5uIXSw7h}hkYw5Xo0<%yz@ywg{ zW#yz8)#gR1>$R?2A1skz0JuPE;(;$657ap00DI9A55mJQGZzEIw=ki!uy3dW$TGw6 zyTzNg3cc9g_C1`mn%1E z+}TJ#UJstvo9 zX!|MFivFzfL4ydiQ+}hc_v167#;u3DB}R6VZie(G zasfYe_rE~dFANM5GXy*LN*#VT z^CuV*l%&xTD#y+OO+fDR zey919cvR9a)a$P_hJx$$b`t%o$t&4Tc)wDbx&S9f*4Gp9`q94t%dwC7?#oRDa>&n3 z*6)s{x(tcu7RdmU88%QgNp;2t8$o}bUo5f8h)&lj{U*uV*z+=1sG)83sHIey^1X(4 z#D5=*TN*uCkVJOeSmim$gGIeY1@L{w@nw+)I-wwUzso1<)UG&ypIqVFNQ2b16cC z$(G)j85B_Dqmw-yd?2|9T-E)!l_Lf?SBZN+KIfQ>&X+-vFnP1cp$bXt_+AltbNt{Y zcIbz0*|=q(okdj5>s`>#z!#P7#Rz+bU%%qX%vO@kOS4aZo7&D%!2GU}%Qat)W$vJ^ zG^-jhcyy-~FYbpnX=vD-3}6KuneF0f^8!)8$=hF&^Rj2a@r*f2G@oxVDDS5OST^Rb z5AFXx+f8ZU6r4^0M}6(=i}jr*lYDigzMRB;l}iP2SszlP9q-Vrl%Q&K?P;%M8H6t$5-N1LhbFkJx*vhy(IYhpeF{h@tn+qHre&%*egE#R zjEb(h8*a3~NhlAAX%K`4L(nZSeeHRN1P;HgyAJt~L~lVI@% zUf~DjvXd@VLgfX3b^XOg$2b{f1)pZ*ty($SO znN#z=F#JEYjI8ps(da`F9FU=^dE3}spNxLp%`WvQmcWCD4mUUq3Lw@tFBbyHVK`(Y zSt98U)|jC^5rW_&W*-^-jSCw9C$uR)O-eaNs;Wy>lLk?c2EKZ$3>^9-A`Cpx0G4l7&=qq>exhSv=iB(VSW z4H3}t7<3mn9WPAbmj3%0xMas6-2LU+pdfbQ7MCOb(ZInaKxXQR4XmkRgG`bP9RF3> ziunhLQwtBA8M);%! zENm!Dsw~X(j=Lt(X@L!q>{6EUlL?z6o8aD@4wi8KCj*2-0DxJ<$F)%?X8D?zj3Q;w+FpLXT2`q~c`HCB#`Lf^&h(QlU;z_T+RvLe9E zwdNee3XMd=0g5q8w)Damy|XtA;w;o+=1@)VJhHbv0?zaoI7%Alb!p;NM`YE^4qabW zaEaf4F~-Q;3H=N`&Gx$a;$r~kKKO`b9ZbIQuB=~a>{G-$ix19!#}p)bP=9qPu}5$d zi~oius+qw%?tfyaHK_Klqsr3{k{MM>RKB-?^y5`buQmC`!8csAHV3=%%RYq?7n6`t zRXJZPDq{{jnD^r&KnXBN>160wB%7pwZ&YJ;?|Im!d5FX{4^~`u$R#dd#P}W|Yl$Cf z@4u))c@ULy&-dadi2q3&QY=Z8on{w2>4a`tKX|M*@x+~n!M}oa6n`VW3a&tqv=U0w zH*l=to_n{9Y-LEyuB0Gr=&qt6=|};5G5!)1k#~M)_~`jVLOic;eWz-m%$Q^Sm;Wc> z2EzT$UGdmu-cKoK!7>t5dL=m_L#Xx3wMZns$||Nr79Ko1Cs>}g1w^94-aXUARl{Pw zvJ##XsngM~`|4P8a^(Wi!QVUo!=^90g}36G4k4f{QJ^49MvW;9LH+ABqrJ zCs{5DK%IDS)|m7w%-;po_Ac2U#01rS)MfF**3v+Ja#2SS>CjwvKx<0TN%?&-HjsLR zIoHur@y;;TpTzYA{?vP)d2&ft!mtS|^~scV5g*Y@&DYQU^Qq+QF8`wR&^a_JB;fDX zBNAqv!@n8V5~2$F?MI}T{DoL^pqn2`%e>GVa6%CPazeA6s0Y-Mb*& zKCP{azsV4Vxe`q<{JD~@+Tf{g4N;c@2KlB1oO}RhW1N~Igr8|xhynkiz?~YX4dRp6 ztvD9p10Y#*I+OSW3A96DTyslZM+azAqLmlu&fn48Fy__8n~HnPQwEOr(R*Gl)4&@-9F-uhNiHBIkF#L@7zE*?(_Am^b z*!a;$e_A;86v%1rCNc4=niR{&Slx+OK133I=x8@X1_%b{Q)(zdT?WanO|YS|sqgJ^ zE)kA*H$8f&>a&)%ER#^DIf{`1?h$GJ@Gkx`@eq#cA^7?J)A@#L6kE7tsNLWi2$4V{ z)(4|TjYMJAlLF|F+b*kEM4&y(-XnfO*x1^V-uA0n)mz_>VLfQ2E;bo&wO&g)6W_0f z80Z$QWQVRjUS@`XrTeeNq0-bf$NKk6Bve*?-t7dh<{ynO=O0)D9`WveV$UN@NisB> zXDG+@)Act)IEa*W9XO_^PI>?xoajlOZ9zr8vUd3EP(h>M!FX)zopbN;EVWuh)36uG zR6T#y5o2m1fFrgKKCOcx-V(SVq2|CbW>!V<-j}0kEL(RY?si;?Yi~L*2w*#XGtr+0 zZL1nUe`e~^mJmDqVExxq{lzF@AZf3wT52r8miLaWK}2zL1p&dq@n+09>M)bueMXe(WTt&Btonw9k|i6}vBSbpO> ze!+C}A$(G;)A^o6@;6)Al*nhTGJ42&S7WZ#tg$NP?gs|%4Ti6WMF)JJ4q2SXK41N} ze+}N%YzzpQjb$}T+te-=#t$hvW8|z7j#CIYEP_Pla6qo^dDNN#DqI+U^9e7R$GLo{ z0U(ZgFRcIM3BJlLYvDr%Q5wB#U0Zr}+5M5%z0soAr52=DS@VHHeMQ#|mQaTp&H}t@ zS42|gLUDbWu2s%siq7nBfvfO_b|Jo!hYMITM9u!d2DaI>ZYwf(bFY9zB3`FM-G}3V z&;dH>!YB5tw>_Yc^S_)QtZi(Ag0-Z}>T89?HN4f~Hedk|(kQWNcI;I2Umag0EDF6Z z`~;p{zaBrsS-BlRW1OT^d&`h6wV&0)9Wn!=fa0-p%L0>;&@wCir3ZaFKQ*p>^yS|> zxuHjUIg`e5&$M$zCv-1Xc@pHDYe6_xFxlZaZ{4#Qo4-t4SBtr-r3TV_#Y+>OJ~tU{ zq_&+D<=-0|54|2pt{jK3TrdENX6~)dFxDxTb{ht=cMEIr_2s_ufWTf)y!cR2&d~D%nJBUp5wj5)D5I8Hy482h}#3dET<-#ce zZ1+$f|J6@{!TUZC{*v~2t5y$iOn#2S+#-%JuR#cD@2|0xXx*8H{A|Jw3xIxYR*(xX zT%}szcv$0g+sM}B2L>ts4hBZriV{c(we0?a4hsZPH|?f))Y^R>xKRCmLT8txd7AK} zb>HY`bde4COVZz$D5 zIv!QMx%cd^-e(k{NeXd;ncaBf_7!Tj;06ovmnu11m~FYM5Uy8S{EBZiux1h{T+_*LP(c9gWjX^XI`~J0d?(U{pDL@qR^jgYK;7PpDU+qA@R%? z`K*8LMd0XgO=xavEPPL4)4PRwh#n{@1hc-3y4JBjM_v~V`uQ*8c1X`1JXq1sLG3(= zpX$#MQw!}cg|1t(HTu8+ai$+tBR^U`dgQj{#D^vpoSOC_*m_q{-6N}e8Vs@!bgO{+T)h^=fkt$5<`8&F_fC4t9S z>NMnGejLiI>l_Ynes=1EqEg!dCz92b=MWg+Jf1Z7MC+gcFG!PqQ`K?^Hd$+tNqxIV zj$C8(Siz5;u7BUm#OvQOdLYR}g|0Zdt756;?I^PylQ#dC4A*nu1Z8T2+xYV@D>*Um z_?GOOcqZ@fes?PWA*}>Ol8sPNtmXF~-c$V7e+HHkIUqtQS5rKSm@bH5_c>HtA-lb3Gla>Grnaf8G=*TK;7dOUOS)s7q@hjk^c7W%rE`vDZ# z4bvfLGB=}U@A0!m!GxvIN0gBUxc9KS);Bpt#`xvEOQZy?FF^V@Nm%kAr>)8sHG11s zs=K&ZBH0%jZq=>U*#W>_Y~7AJ|NYXlD*^vX+rWbx{1bSf*U#=nI1ZINe5FYmoHRuc zSg`svyF^pEqINboqpbecQtUY?!s>;IUZd*?Ov0HrP@L5TzF!~#;xjJkUAg0RTc^*! z7-AXI!6>}?k0d*xC|C9d#vB0*?+)(wmQj)~lb4s-y*6)>zrja65q}&o%42%$^~{AR z>*bHMj$(*%s%xjcFJm{aH7|PWLuvhn-X7P(Z%xYpS7#mGRt%EV;9g718Tr zpDsFnp22Q4Q0w5ea`OSz>Vqx9#F(0=>8qJ%PysF~iCwhSqtyW%83s~zJ^CbR`5YB5 zxh4>^=Pd$iSPi&|*Wa)xJ$HROEo&{&^kB*X&v^GL>n#0vq9Qca?QY9cjNdU|Eaq5Z z&xJpg-0)aqoY6DKrWroweZ`51%93IMIx$9Df!6UHf3}vH@%7zxOzp(j$DGx`UQT2+ zZ_JN?DbbdI9cm46=*kgrA_`Q6ac)&7$?F&8D-=55&$1rQ)(~!d#Rp`6aPOzOR3T(9WIvpqi z9v=r(&u+WDYc}D>H5EJ5?S7PoluBlodQZ1mnJ|FI{qo-;CG9^4tv|f@@3b?u7x0pI z?ZS6dhg`hdA7}@~pqh^NKloj6I`{d2OwR$`^}-7`I3P9pmj;n7nI%xNW3hhWMfl{a zT|=9O{pfdvj$=VrJ;UbMCSAG7#{oEifG0`ict#xfka&}&M%by**P69d;4>by<`s5t zx9mB$FjlF2d`d9%7hf^#vGw%XOeDlbFQ$sv*jCod1r2Vj)+wptuH&8oewM$1Pi)iL z(+yJ`wRo4Z=9#?KFfqmNy!-sTtBn6*SA(O!r(Ui;Bl&iOMlmx{CHZE8SAQ_E83ps< zG__yFE)X@PO<(UbS0H2j)lj%A6)-;6R8XF1>03jDrwuUpj(j-Fx=54xA8jRoykgg5e za;Qs}#)itnF-J{790!!QZgrb`5E7#ZBMLJ6wV?1ZzVo6i*B#{lQ`asa;&ACB(IbH! z8}#&8Z(oqDd~>VFVi<%B1%4aS)IEDbA%v09rOcF|E$0@XI}#D%w>lIWM}_k)3~!=FdPWq?|6i zJP@F66XA@pig=>pRw48M9~->y*=&-qJwkTZ^yz^wo*MnUC(!u={2s1I9827gA;zoJ z3SP2W^`adLzyrT==A1>M1))~Sr@(})KQRwX{Nb#jV-VGS1P$O6VO7=IlJ&UaXNWz7 zG0!I{ZgU${);7wW@f&zvekf$dB+$*B*z5h&A5<_UlV}T6OZVY8;tGR~?^3B2?0qzM z^6;HWdr?o{O+8N@@2rwrY;T8R*KWxptAc)+!Rg@O>Nb_&dWQYy;Q6aCXk+J)mJmea zS~2Q1w^{8}f6LjR|B|!QkH9|PcMzqRjQVnM{3AVM32jsLnn^?j80_|%RBh8rcw@%J zn@_2kTfYbk-93uGed8hmaUF)_$&s7MdqmutJTaW-73fyn5Nfx}6`~bHXZ$M8PNxt{ znVScPdoKI5Cr~j@g@*V4vbVfW z{MORuPJH?wme?w4HNcP{O=y0qx>mRH%m6#URc%u` zEK#)Y+uiGSLH*~b&+^ZKuF3zVGbu6X!OunUG{Y#v6;cJr<-J85kk|yHa<;zT`HOHw zvq1^#fOula?cF%{n~Tz`#y^S4T=4E&8zD;xJi{Z8e2>`wyz=7GKSCWIJ>7Yw0BHay zWjzrkc^MXW5T{9ar@`Jd(l_7=hwS;YldG}!Lbk^l)2woCsI82KgPXrE(BOo)g)-h> z_4v5D``%h?ek=>6fSMEm%M47V6R`q^$OtS<;QyF96Gy1p|NWmCBZFd)rNr1Ngc2o; zeJP?Od$w#LNhsTlEy`M{s2D|B$dWxVwkS*XtQjG)j&)|3<@`?1@7wcy{)4mJ=iK-E z{l2c(g+z3iKxn6y5w`xxbKeQ~BsS7~u$Y73JEBHRyhI^T%X(4xtnJPyT{nv;-DG;= z_rG$)=mot-V_JI&reJ|9EglY-K!~6GRRVoI{tasCmq9v|mWz5yjkk8FT5oz^ce33H zaK$OW!YbEMkN*q^FFXMp_aMb?jjNaZ7C&mNbge6jJaf7(k-!f8VM~M~0K;nlhW>rV zN4ycFo`bZpQe`FfHbTg?epA#+lRK{3C)?3PrBKio>}%Sg%pr5>7V*2xzRijdyy$qlqdySGUvU@gb%b z>~RjU&!9d7a5sJ?vEf~By`BJyKW$A{0Dvz}fF1UyZSJ8!<+>81sRACG>n%+P5;TZ# z++-Ix_cj22mbLatYx^ZR04StB`X6$knLONyv+hU%hzc|N889*aK0ZqZrXwrlBE_X+ zEOdS7aq{NjrakZsNKa9N^;J(t;V_q5g zi5@8UiX95zT`DN`UzRLQN9Bfog5Gy&2P9;#zhL~|4)oSQ%y9%7i>>Q~ijPL_e2iai z`!OI7$pABH31ist*Pyt}Pi@;tXhPVDm`tP(*g!Iyb?f(v%^y3-Zz+E^*k;xEs29nY zm70oBYeCAxD3Q62sR$@aDdQ@m9>A@9Rtn~n+YMp)vx;foO&AO-Jr>NKCtunxetT~< z`1Yu{3dwKK6ZF^wh;|C`&`FuD)n(pSCsZS^0>e25?zv;l|MvsU6hh3=-9EkJ#>lLp ze)h%HH*MKa!;nFH+_O)?7kBNYlaboub9ESJA44Ci2MKeV^-Vzc z)5b~sqv5Enem8Z14^Hp4X+Me(V~MVOb_}m**lSN$lHAX``AuvhxPhfEq+PJ5=R0Zq zp~$8sB@Hr4;PET;jh)D$vkY5FDBB`&B80oxRw2RBazl?|{Xc?`0^aEBt_hwWIZheU zv^e3w#38d8{1G1Bi%otL!>D|eZ(K$=PzLk6U;N>AG$6z9h{J?vo3Ur!U>T`j+PVr^ z2wCWLvhBNnB${+rgGGf-2(bO?^io)M;Qk5k_#_ z+vk1HNEb~6%5>gp80*k&emFo@XZAg)LoO<%w6|BAfic04EOI|)o62|^te)wAFLnz5 z(Ny?9@(nW)xCw0qjgfAcwyqe&G_1#Yyr(K4fe5VD0(W)UJ?dAdg=N6H^z$@8;V9y` zt|Ybxwp|c~VGgoq`xXw0T#h|~!-7@j7fJ6p>89dDfA4vfG_ovka=B^J1xGG!-YDyt zv^59T@L)s{L@(mc?N6^H6VIlR(Xfk;NbFYF3aVji13t)>_aYA>?(wk>wZQAix?3%^ zv5|IX4z-&6Ykr2_rzNN55D31~gg4wLzK&w}J4t=GDk6Tse^Wbua@XNiT#-#M=UN<| z_HGdWagVN{)1knf#9D+2viB1w@RWYcAG=8Z_WI-a!;a|7Pq})hfpi|1-+gRLo^tj zqBDQL;0ivNssz~r{{Xq|f#`n*>KhOO*9(db1rGo2Sj?>0w4Mg?O-?mG$RJO0UU)!x z-H(zWU}SU${y48Z%88z!agx$ktJ| z=$plL0lwscgmdqoLsAqj1NwL z1F8=cpB@~_n7BBZcDSmiKHO$O9YXwf)9CF;?6S}S7B`|xrkYg~U{i!7`qwBWtFr$4 z^Mf*^u)Ed>Kt^SC-nqZd3FP#|qgYk;NCDmy41ZUnzvlT%eaxAM zXvw)eO{2Ex>)NAHzYaTr_$&SwjsliyxDYJyeCn7Vuyr%Eil?pCIcx$x)FE`Ko@gqW$D`< zh}TSQ2qlRY0+5tBnxqZsSc%6sZw2fvZ&4ORSt?0=kHX)?=55fF_~cyJr^*qn7vOWq z9zW$q$<&i>RwoJNB&SBGb2b@ZY4NYOSQU!f(&3*LEeEKvP5~lotLyUGtu8EMY5gW#+6y7M99YL0$eZGRZ(~}Er>94s8!^aZ@>L$~$ zHd(J|@<$S+fDzCO-@!#+yQ{|uOt3_RLw2rqFiCk0O?q>WjLn#BSS*it+Ndl&rQloB zGMM_weQvjxarPRpLX{c%S2vvkF`1_PAk*ospZ(Xmn^ZmFIJqZ26svjhu^BO{M^Ed% zXy?U`g!;|aqYv7InmELyUK*KLi%QL_C_F_0P~~r!1w>Kbw|D*km;=LSO~dY^v5OPT zl8A~6^-;|GKyKgL`jU=b>TYPWnqI+(ExCQH00Nc5j(8t^z?Dl$^%qv`*N&Kjk}P*1}q>Cxt<$GoLf=HS5kJ{H(Z^V0BwS7toW zxWbz`K8BqDyiXtAW95Iv?A8UBOTZ0QIT>1x*eLl=>TsMa(sGxv^Uu}hVCRB^M^7-rC4%6i}*;x*hq~Tll znsZxFmr@(9V$VoF4l;IE+O@;oYaufm^Whl-Eu$@~_BD_QRxZg8Ese{=bb>a+&?ma% zn_VXN^=}{Wu5v<-OBCW(1S5QXy!xUkt8IFLlHpos>I{S+6s}!+q4%Sq9&+NZU<@

s%;4`m)y zkMnW)wMW?_R_Djx5#yBLPrq<09fI82cxG~Y#m|A|J?Xp=t=Ff7ig`uL)dC1Nhx%z< zof(~anLLd#FukkpS8Uq39^7n+QH^4tm}{bVcCo#Fp2VQHz?3nu$e>@VR%u*&jbU8Q zz|!juTmw9YZ%mGzISgTGKtbuR*eoI;W!{=HSFCfY=^Bl+R#*1}px3l)yUu<|TaUKY zq%zAz%ITZefb!?Z0+UP5r2U=zDr+KaZ_!wr!~%haz`)SPnvv$0-3B#p{1F{z?=wc$ zGb|$ej<*GWYY%SxEcrbZn)){+m1YS8vp46h>aPr&#B|t{!Sd3-Q0hnn$`E<d0x1ZoRb26E$YuTH@QB{{HCw$>|Lx&dun_`E?m{hnie3 zFp@OsqySJU7S<9AMyrJxRA#6Ga0KcNPzSv}jw!-$-CtT1RpzkHKdSIiDoXYh?ylC=LEk*n%ZuP9M(WfQrjke#CX% zJ{DH6J1z;xDd%yk_;p6f^_qT$ixtPB<&Dhv_pXWcQ4CrF9yau>9juVb%pLmi1X_kn z(876$2U1B2Xo6qNo!m{~INjIl8#H~_lE}_rRZwkJ<})427eW%U?0A8Z(-e<0CZu`V zi9#EaBHHzTEKpE|)qE3&)+D_@uUINuB<{0iaBHjxSVRD=){Qf&?2sEQVux=%8F+gV zA}80v^5cOzu;$bzwv-$wsCUerlcvXs1Gl!@D#1B0ja3KA5Pc;qyhuo@&0J7-_gISO ztW*VM0A)9=!>=lzZEO`*hqB{6KetEzp}F}-m45g#oo1#TBH|nOBGuCRzhw4gf#{Lu z#@DQ8?%O85lx0?l*u%`i6adxf@6|7F@b)u5PkNX&@^J3CwaNC;UDH-f$KAO9HQ!KJ)e#=XJHOPP}O^$@wo2 zYA+9LgRzSxTbqO@oU}*mXl~TYw!h$S6fC|)YxQYMQBX4e%DwxWmXw5Z!rXmD;vBbS zjbk8L0mAjZ(~s{e{=H^gi>Ti>I;H~hekMn@n8F%MyTB)OkOCz(K>Lu_YF$H;V;2Xz z@brGsOImCNYNE}&inj>F-yhjzBpLYo*fYf8wP#t6%4~)}Vh=59;>$iUdh5TLbuP_3 z(40l{i83pN6LI55dq4cn0oa->okj~ceN|GJGXAInvup?te>mq*|^-suIoBuoO)R9La-vjsPELzda z)b#nj8GXf#U$4=_m0wDD9U6yEudZ;Zq;3@!;?qI4bBleCX;m}lbPsCb9YzIQ55?Nj zmW=B~+JIavBt1o0Mf@DGJxP z^=ZyS@Tnay?O}5!#IXMT?9rE6S&DVl69%{m;QVZA=f^saEQ=EAkeJ{%&Ove?QL^CO&l6~gmm_94_3iaG)Y$Al6L%sM6at@ z$Hzc6MPTd1<8I(*N;^(rK*MuyEoZ`gA}~?EFn07mU%;HT{D6+YBi`zKUMT zak{6c*q+Ac-JA_(ufR<>P*wkHY_H1+9(2RO!~fU5&-FpfwXk}0V9{_#qYUvrZ0XW_ zr=&;$aRVVP!Gr!ICH=2$u4$=^g}BKqL&A5h$nB)!m;S3FC-xjxXAAh@>d*210Cf1G z!RO-!quMp!nE^(sU+%fos5*r`*M}BVA%y=SXxiM(wCS6q`TjX{`++vvVU_??^F7Kb zhg_^qMALzXBdWv3pB`uCexKBmZeYeDcFO|~J*Ey=z!xa~t^Q4r3d^$~d$6qwT%wn( zF97UPC%cJ{cmJlbx_I)KC<1a$5evtp74A*A}pqJt8Q#tw0# zWbrSqI8B0(7fn#Dk>TT%YLqR!Om@#6) zzgMX+WaZojT8WFBCljvR3EhG!veh9b*zR?NC&*&8&<{=h#^{_ybK;IruBV{SmQTfM zeZlZ`6=ywUZx-P2(n|GnU$qD$aEg-1;Q@=nj<;!7*a1BddmTWhjsHR6z0{qw7$>a^ z(}{CY3S`a8x3TkMlU|h;|9VG$v%mzNG4a~t-uo`-0Ro&zxZ5=V2}@){@xd!TivW0v zty*j|2D z2-}^#>thw?&b#EJv4ZEp%ByP!_V!E205u!^Np(=}%k_TvvRKO(Kgk%@I5DyOSXifg5yCUAun;v;YMl`}hfFfhM!n z(Qjfu1I;}j<;WT#Vw<~Fmfx%R?_cdtnbIljD1$%>az|kdAGh-hp;E93hczsiQ6&TO=s8v zvZt>$Mson$GRo$lxpe2U{DYjmKnuhaViIO)#KVM;NNL>`$nZ-%G57ihV!UTN+k{ba zb;B7+phc0*XNdWD>=`6Zsb2j(K5hk~7&iD%R=)M6{~~!!67qb;+CGXOvayEfcA!b9u^8%ii4S%cF--a$nWe{RAIs~Z`(g>YRCu4b@qn7VhLrt*7-4=$__D3)@D8x?g zL3T?pBskw=g~W+p9EuDqr$}C9zwp1ReFP7NxhaW#%6*Rti(+aJQpVx)wGCa?vA*4eUyLTME}QdzH+Izi=K0_6Japr z;1G;q_Yul74W=_qkD)&o(#{rneV@{sU$bcrxP~l`Z23IWD*KX_l z$y1|hEoaU>^H;mF&#urat7v=g^V{u*WrLrAAQ5}vZiXNad9e1+f#fV;d4hFHS}=#W zy<&0uYFTY2cgV?rIGQ)P@8URjv&E4=+v?CZlVK|~N0ur8$9I0MPGP6`K6aUv(@YiK z2i(7Y>N%}`+kuKva-KDNKh#>GI5mj=TZA$sENc?uyYhHS-1%{+Mqhq9yawGA<5O!c zeEHIyr0gTKic?Z8-&g;{bqf@HF4Sj=4PAQj$a-4xCIZGTc&7u7b3{Gp@Iy67R)B|L z?cZK|9^W_h<_l(qU693MOD|~77ZbLi3v0wOH(%TbS#DQ=M>nw-fJSnho3$`IO7QH*zdw)0i{g!LUzOl)WLxISxW+cg-Z zjl_hHrSVY2?zESt?m(O>&bwQr-_YJmc?V2kBV;?73@d#;V7aH80k!EZoUIq^FcFK# zomR3h?ekN3c&}czVkd8HG+=sMa*ddOAM3`~S^<`kJnp@>nDhU%^WoiR(eFX@5@i?w zN=9ngR+8)g5k48;)r$WoW99Z!aoHc$&a;;cthfap~@f5;7ZP z2TDBW2Yt+N_L0<&ZYRae-b&=J4QJTtzUVDk*)B( zV+Xq~>;Wd{ORX63?um?E5Cbh8KPKp$BYbejSQ%G>g@k&WAZfyRA*-%u;`@oJ0!x~-txkAL%>b2Z?b-s^76J5gnpRVh2Cqt+6@?{7t7oNm_J zv0gmkrQonk-BfsRp%t%YZMxz$yU)#8T3OWohc%7Mo+UpH*m_3ZcNT@a{`qzIhfquD z!lqPN?yCjkdROlBrCPeUlfw2(_mCqY!cE9a5Tpcf4{f1gjm(J&f-#Wpz`EaV-}Ti$ zxQnB3m6U@cBbwCBCw>m+@Ww~9K(6sBbDCJ6(Hq(KQns#ptsIZ~X_p@Z1=Sx#FT1VE z2FHNwVEX*MX*GItOF((4?s46s=%~9YoX1a;7ecpF>&Dzxnf6y=rwv@6*SXD$pRzFMg)OS2dKRq1AauXsZVSXKSFjaPPDq#O2~b z%-_-b%JC})2~;^7{3V&`j@#hAvU(`?=R8b@$Id(jJI&_u6!Kxm1d=~>{(SlUp@ZZ} z59zt#I_=PN7Gkfj_x)&%a+aC^4-O zm_~bg%L(IKG|?^8krXyoy&g=+*~2gko=uH*m2Hv=*rN!4Hy8-9V}jX%e+H9lo-g`_ zlQ9+e@bAyJ$$B@OhBSd{Z z4ttlf0?vip6CD_HfvH2TK zhvr2tPl<=wlaxhu?Sy@ZrK(d?`^z&MC0<@ljytA+l7k5Q-vfh`9Sc6w(M97fivcye z#|D{@CV>3QkP7Mi?C#=h#1{;Q4^bx@Am9NR(}T3UiJnI?t39l$<$Ed&QQR|l`b0vt zAP2Bp2G{XL^SX3VPKkDg_o$fB@BYSojb=1!k896j__xwPLFVbQ+t2_&J`V6(vgz*L9_X z!fw2H$dz)7rTyBH%z>yEyyI0aaR`a6xWW##OM73qH17`GWIy*-tuN%5Y;NsqjCB-J zqvka}Dq#g_HE`kw#dX;D@tw?c>E-zv@(!2gp5#y^Y8W)yJHvkKfNlxo#AARR#`0NU zLKB#YK2wl>_q52K%d{*D{DA)Vlp1?GgUgK5)&2pjF2P+l>@v>72-pDW7CK?JTw6Ub zwootj*%|}NyORRM)`~!9jqcU`{4T@N{~iNz;;5rWYfTk~enoL{qX8&?4f}~al17QX zpLlhdv(rAvnV{S*%D+yrt^A7CYK^Pfsj7+;PSI%nXzs}rFIeWo;#5}Fw`96)m~-Jq zdQ7VZkVXh}e>G1!S^G@YEN`?_)(~Q1xu5-tX|2a6L)?MV0LvGKS#xOd(E=;=n>^N& zJr#D@BcMZvC18kUzv-LbaL(s2(9Hov;|RpG;Ht>e75^#nx|HERV`i5fzAZ}}%NbOy zUy)pBPqhBw?p@p0oN%RRA>_#rTcE$ZkBHQ!t{vgo$)3ziL_ewBQ_eePB=ZvAg%qDi z{uM^U+-zTj&a6jSkiz$(X0FSN zU3b0TgS|($$m{*8{qp~(YR~jkEg3K=2!a`a^6bg-Y`W)K^xud52B+iAib`VbMU&VLvzUL1(euQA8h06V$wQf}E0}>7^@1H5P@KeQCOLtmQE9P^EBK;4%gjt5 z-;An}9P~-3Obf56{u=UX*BEGdsm3eZR@XjqI_m~zyVmgy`Q`RdM^pr8j)W5SMyi7{ z^3yBlEzgx-f7N`!_{ra*2L%_6?&bKC({u6i?=g7!+kVHr_d1kE?5%o4jkNqj*m2h- z^MxJ(tm6B6rn4TJko8@46pG=2NB#ODA0dh15ddc88eyYn_m8UIuqqurw~+*ZJSNT22qjesPJubJuf-^;Pi_8RS~W zQOWK}oo0EOa%2(H z9L>`6LsS|>vUbF=m3;vRiVkn(mlp$nHjmzK4dKNL2?lu!N|L?gWSKJ`xK;08Lrte8 z8QlMl2W68416FudN9!^}Ht--R8=~;=#;l$o2UmAfh))_)Uzccj-)#-zN0xf?=Lh}$ z4n0xP%94%WIiXJ07psdW%6h9b)(GhMIpG@|?DMtW6XOTdAX`Ud@B9Xr{u4gZK=LU@ zS`NeS@Xk@mdFyXzDl;!|!&zk;4dc){oOOwaeb!%JIUr2@*r0Y^sne@R-DY?`M`Ni? zs4+R`mZCM*1MUDf0;O7>UrQGF9 z#)qDufR)?S>@sI{Dq4HT@M+NE6;UHGUw4HFuVBhL;q}p|D}__W9JUxDUnBPoH0{;y z>U!hBJ7HF>X!VExP?++Be9sCf2IbwlL`@z6ttW^7w4{%nr`Xdp#*KC(cOHgUg$xO& z?qh}TC8qytzU?{*|AV8&J1du3DhwRjF~nCDI_%BW6^+YqzZ6igYb(%d;zQNGB||ae z6GwYEH);;jV^wCm8iZdi*z`@P2X;fJo`GsIdH_^jBks*~D?!fJ;Av~*F*wjgb3eTL zom4n)lZMAqQ+6YfHx+DiQYu{^<aTs*?UV7^3u%W61mI$*qHqA!~Rb(RIB`v|V3Ts2!b^>-Z=ut(>Zd{+3~{Q0sl zMdhvstmEaVK#7NR<@6>b?<|E5w9(5YVvwf^_>wh*gj3?k{dDA>5GB-ca;9 zHh&hn`jQCMqrjUf+8^LtFb|9BhaCeo0mTJ5*$(;w(*n_}N+=)5x8(5j9xTwFS&-cRbZxwa|*INoXtbRwRb!DbMj z<@|@Xfug^?k#x6se}Vj9(>b}~c8wQbx>T2q`?T%lzZ}ww3*=xiihicW5(=wj{Zu$8 zAu)HUX++=Zs{7Rp9`JMlcsq>1sKsNKL#OJv1?gGaXEvb%a>Rut zqmyn;`&07IPs^`FJ~Pc5jx)s$X^^oqZF1`*Buhg`q^kq+T#a;^)f6F1CCfO?SLQh- z(yI=C60l~+-V$lpj#3y^o5h@X?V24u7xL9l+w|or5*B&7rU&dgG})1PH!RVDKpU*j z4?I_Odn8tDKehMCE46*weN)0MDUA_^`3>JrNirIwPUMzInz5Rc5?_RT%DwR!Ee9CC z{yROa0HQ^0fQsxYTM--f0~Gt=5jf`!eGWAfyU_qj*7(On%OdU5Z9!#fYtbLt;#-t+ zk^*S&BDeeZoI6rh(tpiOx|PmoNu103P8Zx^%<$@5!exlT2;lXuo_h-fyj4rGYy#Le z-3yI4KCp>7ns@u=i4}?p6ZW}o!db`L&UA6|H~SZvj_Hvvcv8>C4><%O5L>+j8Znf2Ooi#Yu~8RYImwhE|twt?6$gg6VJe*TdHEF^uyTjhTsxa$fVHTt%a1Imx zYeAn6?iV2?x`KweQO}Je=%mKxOP4)2MM;7R3xgCrh`e%jyVuPltroSkGwTe;oC_;m++U-j=v$kgvo zQq4Bcrv0?SFVyhFc@BJkZ0qwKHo$wj(G6i1RH}mzQJGEyI(!+oiOHaTXjKtfq? zx9dZ?&|?(va5n?9{D$#f>s0L4P%u9riM?*<$>7G-ApEy(>(BR614Vj*Y5=Epg9p!p(Bl%>k}5qos?fri)vRT@`At{1BP ztutDTfO0KW=_v8&0^tX(F;(ooxcv*$S>8^xbrM=YH&1cy2<}u(`zt?TK@PKyg#f;q zlsv9!1WNfj?|V4Pr3kBFPIrGSYnz=sHj6LgER!vDRv5yI$ZybIcmJf$o_>5_weYx1 z+&H$R%O@dXxyvXHP=Oq+4@Syw%epIfijoN_Wy5Iu+qS5NKgtHLZ=$NAIwm()eq11X zg9K*ka-+J%fv3RKFR=mOEn8%`kq=|060C5|=n7g_%PTg)`zD&jcBBgungeIp(* zF%y?{|LvU{&+Wl?aD*dkFW2y0VIB0{0O05I!4a4zzs}UBBlox4gZHiIj}vCT)}MdD z>7FjcRin>X_iBo*b`JE>nYt%Tj^tBLT)@}480v?z77(^!Mea& zbq^S-0B*KbNi4q9pd?@-WOl?Rm-D~cc3l!O>`tLi-{0lgvww$>w{vIhgV?#OT`NI? zsTe2@Yq7?K@a6aJo`0pf{O#kVl=`*uP>TGajGPNFdk1=>wsPR}v;i@hF#W#t#^nNoqdH zt2X)AtjFsIzvS+PrzeFtLUS6fZXR1Ol1I0({2t~P>pJ2}dIBX}GOuCjEIm0JP}jCI zmK9Lo1wQT1hZ`VW{XcwQkLXLwQRitrwK(F9FFWc1b~-A*|4FI_ z%E7l$)K$M3)F%=a;yhpg;$RYP?WuOZn}p6iUZ;S--afLD4|rMtV7Ur%vI4j58}ZsV z`)@c4FM7RK7o-*JUD8%A-u83)FI^G3iRq)7vJ(=Yfv zi?X?KQX-Tzw1=-%!{ujE`00bURW}*7?AOs4vz@+W{jH=5+6xrWpB8+ktBcrngyeb1 zJq^js+aDgG(Pt-eC0ZLlU|q-I09U`|5k z7b!1VeokxEFVy6g&L{T0ze{4fhHr-mc{MKHy9x$DR0%M8eh&py;sc;`f*BN$A15&- z`O_wwr@;5`%Bw&|9}5K>kk*RgpYzU?kROt?9t`Gko!MBL;C9uY;u#nb_^Gx4k4}Hi z?TcPwPqaP5$=N1z^We}3XM1~e0MY8;?*Kb7%c;$@N2Y#ViF6yhs(aK#z~z%iY0la= z!d{>nA7bNfzFn`{517yO3^|(;ZSLsqi0!ICIU@2pDSmskRwc>%pszmYA@&OvYSOa7 zk}F@WmR;Nnq!MnlH&w*eXxr8m9g<<^j+b~*7=H}5rBxK1_gA2{E?FvtxYZ=U&&WW5 zfmC~taUB0`41&k*=dIYc@8%Dk7?)I?MmHt1m+?AQa3D$Pe8B?S@kFpjmHCO3S_=-? zSP$$zTqM>n`5 ze@(6v`h6!o&VCP0=<7MeSNW7~ly(afG^_+`zY`Gvjc}|6#4s9%F_0_#E#R(~D$W6f z#YrIbHQPE6%DuhcyZ;`i?V}qVh5Wt>=)L8AkkrQ8FMQR&xRQGZEJ<^`{|CR3`hMTr z2E9e(?4GhhUlCwV29-Ixm&H0B?!B|%)$tm0D7MwDal`FU0aIk!;ws^YE>oc&E6NAR zM~~PxT@{y6=G{SiUpC`_37z$(9Pnidrm7Iq4p*2l*}~9~KMsAox#c~ZEw6(=xN#fI zVTAOQKPRKb8=0B{I%cTz6rnyQ^wjVi$}+%j^(oiUPGr1<%--5L2HU_dHy^7@Y2W@+ zIPl?gfW=NlTDeUhRPiThl+_u^i!$8ZDfE!eeel5dYS{;vs_H!0Oc3 zOYn*xNbG$Kp&cgPQNwypBn2x1ZQx?uHFrE5 zm!@=6OZHH?et$E?8zj|lQO}*0ixl3y{raQvzootR0r-m^X>eKmu)lcU+YmZM>GBW{ z{1f$&#T6QM?bg!xSq$n8>U8ckPZ$Ak7gm&++d%H2^2ntP-m$9s(TJK(X zzIm#RLK3YrVPgB?5kK!$QzER+!k>=}%(v|N6Op7FjM`d47BiF%ZtCDV=b!WIVcPFO z3i&-$jrWn4j-{YJb&l=m~jDV*%e;j4?QxTFEpFs2;{|OY3sUzx!yWr>m;i(hD>&cZT zT02-zLR9K}225GO?1dxkSbB~;AtMbxDbJEfq;L1ct22+JFCP4R zwt?1R7YBeL@4xNe85qRcC<3@Po+aL+Iaa@__gE>##W31XYe}sy{U-xmI!k-djRcIvK=q+Y;zQbp75KD8-GXxmkzh2q!JcV2_QL?Fz4;ux zyH&lE9S9jn>Rz`~Fui}?6k);)XoP^O&i@ciFRM?^QShQ!nxQvXRLpAcZ^f+rh-GTF_mNpVQ ztIlSrqjSm`YX{hFSYeR_P~=N2>`wlzbOxGuOYaybpz^0&$OLi^|8)JmD>%R$upsV9 z@Cj17eB!Sa3k9Ficj;an3io%tA`KhWjJ`Tk70L=ZxXjK7v7Igo_8XutoPgv_a{aTkY{GV`D&?1`g^pk8qS!*N-?Khy?Wow zSC#4*`l%F-&|7mm(rOry-=S6F(~AQF?B{+g8!a4Iz(x840Pz&Df+j>{zDaagjW^RAjVm+;VV?)=}* zsE|0k?Dweu!1TeN8?QWAm0`F?Sg`B0!&$RPnsKGS0OHd?RFuCmu_R_FnzXW%PHr%# zi-Y-_@`;P2@#r;aX}_jf!r}5CJm**+ZoRo}B6_btuwE86%W9_6@T>(ST#d_^y^Icb>^`EO@XyQQgv zQE6nbY=VM$`RDJEbMlmFs+Ip?jmyRWYH1*slu6TfOw3EaS{}ecd=|<5A7m~1upY2t zRih&mFAvyXv?%C(^Sw;_*3LM71p!xu2$=)>#gvWCH7SKe*rx^GkCG%Y9z*AANuAtp z?{2xS;yJpIqkhd7L+=$lGOFX1RQdV*(O7%O;Q%v5|Jz3r9TyLTd@4Y>9QFL{5^Syb z#KhhL%p7j&1`k#w3;kx?ky)@l4&3U0%CSeNW#9WMLMS*;-vEkif{t>%!A`n|V%`lu zVh1ko{(k(+D{RA`F~!&ikR9b(KSGe7$9Tb|*nn6Bz#>-S@bAe^Bzh!<(qM7GL5X1q+9d8A?Ue6&EFcW?75Df#eaA2a=;>F{@%T9lQ3dB4pT~bYqJ-p-CvIh`g)= zEcBSu-{jXJ~6dfCxFmx3y-!frn7*EXrV|03$FiKR8n-0x_`eA|VqW2fZBC;3aW zlWLvMx8LDQJ6o_^;T0zx6GzX=R;jsCyQX(5WkrASo!j{r=tw6$;rCh@(Cx;>@gG}S zGWCB*oFtyj#UQcN(`%09Oi;7@B9Pt=E3LY{;U9SbvZke~D2U&y04rLmb>X;%JJr{C z|8HwkK80+pI3KLK5p2TWx9lIyC%=S*t^MOpV@%s<-(LZnW-1e%vzf^o_FcW*U_?fb z$WS>~#5}X<4;B@%+3AG%g0M6m2w)g|xnMwlBGA71a5LWG@>zZJvTpuoq5d7`2w~wN zO*3`nq2SlaUuc@wkL&hTPzEp8{i>z+jyL*D8p<nl!gAIfR3^+(%xrT(ai+PNK~v>D1=7W5+&9eRybCpA@b_xniIoHG?W?QG#!XFQYr z3<^IblD~3T&hJaZ}l>`|fdH@FO~VG)7Pz4a z(D%cWCqAd0trE98VP4O+BjdF*DZ1&As1!H;CDiVKWG8A13VFOON)oKlG({tE*7I-yU7YlE6IdCQ4$c-1;?+H-#$}FO&1j*&lw6@c( z%rr5>8%e)2APyraF?eEyJFt1| zRUFmgMsKA`mrSe{?|>J^LWlXs8R+p~`Rm5?XNT~LxpZOGKHCFpNm`SI}yAv<~ht z%)Kcp3$I00>HAPozNc4Z<}Unfe?@$Z2fw^7zP!)V{Ma?A(K8iuD!MpqPn2*{=yDdv%Gzg>zPh2}lNZU3T(O!*JPTkl?Q!5vF(EE$=JRNpXX~wVP|W3=aTnUrVN+kb;JV zzx9O$`NpJE$D{alTRyl*$dawAjSmBfc5Bw`^m!U&x9!Eiv~>ROW^}@N60>+N-}t%1 z!U==U+6o44Nwt5>0vkazez@3PjcdCy;9cmCTsI}8u{=@t`- zyePy6q+GRra9IX$xqkzqC~arn{4QRH3hbhpw-5t%oYA!}t$O}pg1tq5XQ4k0k(QGL zKP72o-jZM*-f;eRv zet-|c)|PU;Xj4TGFptDFES^AtM^sppPZ@7Iwg*cXGF5!`33_>)6s(UOspZ;9=z?lfZ@R3WvAPFzn4NOIBr(|9_yaF0pEMmUw+HlZ8ygaw6?XR6O->8Tg z_R+KG(FgQ>S7GV9Xpx}k#7ZSi0cP65u5#sHXb_ar_5Y}P^LQxV?|=NBF*K-*lqEES zBxP+uS!S|jD`l5tO9zC#GyZo$cuT{~uen9Q2gva9{&29MRT-PFu)(&DDGM`N<>j3R{qtKpCYpJAHJ zlnOg-2B5waXsmvn+34PN}f@=eP!;Mc7j*xZ)GH5foEmNC(kDz|!e z$S?Gz0L*sGf0M2I`1JNIUw@HUouVIk#5q076JU)(bZW#%SDiF6Fa{WJOucAD9vFS{ zWhGswIzq}QbcCar@ZP=vl{I-q(X8>`Eg`A~9QYu9O7Cq9t-UC9US9&1l7EC5Fd_Ur zh)S%{mu;(WtvonTuZzBf>$xAKzFQ#pew}ZZ|Le!5kf55nrPV|}NgxgM96WcR??w)D zuqZ^b6l!~Q*FsfWePdOWrt>b>EdA93Y+c!@n1c*}QMF{%57t9SICl!$w#vjaDNI#X zGac%KPGP@sDO&3u_oHk*Cc@isJZhr?4$zHv$ekPy=GNYfxfnB_o1M=tG(Q25)JSt5 zg#Zl)`ur|!oeGirbh`6WLGI~xtEUV-e_oF`WD#$WkC2|N?WqdiR$)?-Lp(F!n23G$&}AESJr%V zc75{3)hs?93j7+yxc2-pc(W2KT`ZxB*>7(Ya?MzvrNGgt%7mvft6BQyzMRNYgZ_E6 znVLW`HhW_ZI55FvG9>y1>o0O;!MGV1*V#2|eziS1A=R#* z6DfFf>*6XbNAXddLYFlrcyZ1SEq=8%s;AFTB$t#%=a;ifJ)+`q|cWp#$ z==LKx93+m~gOQZgXL-tlv}fyN`$^_ona`F3=p{Y`#?mr0}Y^Ahr+* z+k)~jND=z?ZTM{1{q5oPx^J3`&_mBsZG9)j_w=yw31E+LGoE7d1#T%(6uG+m{bqgh z;D7*##`m26;s}zsz4>BFo$o_Nr5m4L`a3v04ikCy1IQzcvnGDzSnQ!hrY7ydh zrPgo%Oz@ScWy)cnt3%Glk7ukl-cPk_7<{A)H33RyTlbM|c3e6y&*w?fJW;;_hZL76 zqytt50xZSetgO?XIZt*)p>rOR4|pHsR#{yCNm(*hS^DPgG?cWo-r9fOFe)T*!$1|x zY6TsP?Q5cNX?Oh=E3N@jV&7dfZrONXgNM&;JYxo48wT|_Ly^frNdV)q-J-23e`Ftt zV?_`KxbZ;sjOE%b{aiLW80MV0`A$)C2JR_;N7x8q^bP^oB#<{W{shy`ILtZO;CAc8 zl+L=LiS)ZXiRDAeZ*t!7D{Xr$_?R$a?sM0vVbtTUgvSWxie;FznxZiqYR3^qd?H&D+2Y++Ki z>M%(+7!RM0$V%j9dTOIHOd-7-*b`K0Ari@>G{rF&rv)qPC|;PV{Qi^NiS2BH0FE1# z)dN9Oh7P8hig*xutZYvLvm(y~JVVAT^p`vOIFy85uPbNNfGrUWP@6c9Jy~VKg>pqv zXdz;ecOdd**}i_y7osp+c+%Jm_$)8eo+7gCY<>ci47jhop=42tfRs<}{waf#_6wly zz>!>hYSTNMG2Dw@Pt%g5((OC+Hu>PpbCa(E+0SM>YXn58pSI{WbS4si_@9dqRAti# za3fn^ec{$^d1C~B!_goSDtSiuGgiezC;Mai5nPP0uGqnSH}vO_#qaE=1)A+^R0?T< z%th>L*OHELoP;=tD@#+)90uxAjNgu~@Ls8og+;be?COGvR&VH8P2`{%wu&R%tEKMv z6i-rH^%a-Ka3Vi+^7rWjYr_?A!V2Eabf{Whd1s-2y`bdic)+~TAG=kye8_$h5@B+E z%5o)G3=zueIsh#6i>+8Re^0+-+RF;wGdZ4tx)&9v&SD?SLbNV!c zs+A~8$xm-vaUk9c|IjW}KvuCxNsGBUU-@x)yep{3F{6K>D?m!A=3Su9tjfd1`J&y{ z^DtHzKE*C{yKjJv5$KLWVT$gb%szYg1_o-s=?UfJr=s)8gIdcV+a(t*!16X$jLqNA zOqVxD{K|{gG4(B*x1}o+KAs4`^BcDI_E=~?*ttSpqB!`skB98uxgh^wZ-wb z)ZwJgHSbm~k3zMk)zjWn5`rbZSWWRn1|)|=?&oBL7R{faNXO3@CAe?z_Y`u^DGR84f6tRT>I zo@!NHf?WUzwr~Iqpv08nOJk46aw*uCGyUL;t3HOq)Kp)Z2gC%^cJqDQ-@M)hh(xp8 z9(G8=dhYJ23eFI6M$>Yb(o@y5kq&35iUrQWM^w`qSiXoIdZNYo@uv1znXHlBLW0Oj z!MayY=4RXcRz#5$cD?K-FZH2R$)ctbt2#R^2A`r&AzgFSp+;Tc3zIpq~+A`SdZGk zwz{p^uDhs0=@)h>$nAVR2!y8%w*3y|y;SlYGztafZI+8>@p(NQajKN4K-u$V4Hm^OYZU%Dr+!*cS~BgQU7gtn$6{} z-nr#23UeUFg1ZhbM`qNV%{$hzy^xnzxv0-0E}8A#$+v6J`>FK9ys2e9MAye!n;VEI zIH;_!&faUQr5kBq1fgf%+wH37`JVfR3_h-SpJ8QP51Z)N;BWu)98w_cMc9eW-UiRh z{KafA2>HsIYO@)3J86dFxb)$aex)x*K0Py%xk9&3>bb&0*Ogmwa(P2Pf%MhMw~Pb! zHpkM}=N8y>sZS!ZUgLolKw!MV-*OhjKh%q7M#K>( z_61$r(MZG!<-Q2KHMc#4q;*NZLLcYFX|y^Bah|_0=Yc`9oY&AbX{;sX9xy+k;BYx& zxqz8bezZ9pddmy0ImmAx4LxzLQ+_xk3m6?Lz*?S5n#gr2xyo zuBs7}cl(Ri-c%Ra)oJO>rBY>6TLb4mE-wo#OT&O0K90KY)0bseFqi1m;po0GcBz%u z?ar*PXE`1c63zoWoc`u0FGm*++i;hYIGImXl3@-oDabdpj!2dha_RWPxfTVWz%76v zqr~YX>t!)#vH)I*dHEU-I?XHx_$Zv0X8Mn;wv-hz_{Qh<1Ay`p7gzd#ul?Gq8%5n0 z4mxbHo+dsM#wAx+_j%1VqOsc}QORskt2&(KKi!7#qO!yy8NrjY_EgrnhJ`Li+bT}C z+R&)P(}-PlO!qO0B_Vy_6i`eGS<-JW$%Cszb(u;5y8?x?Q)!q?`O3* zpli-p{PDu_JPtQ6|7@!_b$jR-c7C5S4F6p(Dc~i8Go@mna-$p=*Uo3TYf;_i#Ax6OsKDwiMWkDvWL|GQ53Bs*ujQSfm?Mi$Fy z>5Ut8zqzl^g`iGe#;D)vFj2YnzXrRpCLn9xgKicPb6cpTU=2@SDY&W{fTT{;k9b(T zxw1|-b(&;C-C@{C&NF|lxb`W^j+4|DkFMDmF{eeEGO?qi{UaCur#WmY_tX$TX~K}2 zkTYDlc@tO>$Qn? z>)NG!W`2GwLcE<_!atn{cK`0ND3&bNBJhLn?uAkITl-dRcPv7qFB+n2{lUmYFWB$x zr0#$}$&_Hy4toMCS8RH@b>oJ##cclgPD6cC1?Q0jxhzi1BR*XRv+P4VD+4ubwnhkb zx_(e{ZG{a573hjU7ts;;wFv2wBhe1jM;7ATXn6GON>YEobV(%2vhkb9{QybnTJyKR zMs<@f>LaRVcSc9#D+Zqn>J`up0`6$^etG+*&7&1<#mD8sNT`3*SgL-pUe8{IHS*Y( z)o?~Yh#5#|^!y1%fiG#2k7+KmGYQOjw88<2&kF0S`?&X|Yis`2?q&QpkqtoG*Z>^a)tFJQYl6LjuPmKaBDQNW(pl$A0v=ix z%&vVoM1v2zY|r;8RA*jOOj1KwpID5(gMiWfe#cjZ-XNRgR|!JMH=%Y2F!uf3s3A8i zVP5l_@y336u0vj_FwACEK7Lv~2t%4|^ooTyLflCDnZ*FNCV=Bw4grPL3al3J${cUG zZVf>IF4KwT6W)d0#+j3UhmYF_Ywe&tl#ZKbn|NyEKjtUnB`)!`40c7#_kE_&edIX_ zbJn!(a(}D32`6%VsSmlPF5|IU+;)K~>RK^+=Z290Ei|u*sB}@l6%`a+H|RalBJBO@ zk*wh`3*&zE=x6uiU#4ROr{mEw!iVA4E)RIf=|(G$&74}jq`Z)Ww=$J5RLa2C?(R;be&qQ)0%6un$O?zKuZvI2cpPeED!Ld!9Acn8VJIfQbjb)Y#IeiZa&oV&fs|k!aT2fnpU!D~UytmlpXM;2s6!#@K|wa|!-_ zHIY)+ZpGYD+Gxp}RN>!x+w7s@_~^5bP|-apZHAOzlve-l4a$Ns&>oznbP8xHJXojU zs^3`UnE;|Y4QL;HpL9-eGJkNpylz8S^xxmjnRZ_Bp25Gi&30vkb)p=Vs&asB&;{Lp z?`8q;w8&WeJ4npzFlBL?T^2w4u_z=lY8I`@+*>RA@dR_wmJsm!z(~x~CMns?E{4jn z=4>}W`I$dIOtm#5TcaPfJ|Ovf{`F>K^PaX}V<&0rlNiVG7YZW26`pWHs9yUZbxAwC zgcijuOn!Gjl(pe_`-gdFwP@7Bp>o740cf|AQvV>i~D|o1{iG`UecsF|SplM$E zuhRM(y019sSIx^G>dG_fGw(AmtlU@?7 zs?nt-y@hT(`Cj^o_?n*OmTUdj?l_}va7Qag?|wCSNMq8~sd@F5BYiUnB$95Xy2H3b z839h%BS_n=vM;zk^90EMMMYKPJD7XslIIT56nxjLUi2TZlcG{epnxMMtc(eBcxA>~ znxUD~#C9fvQ#qw6^N3YUC^LS>yRUcQZ5_OM%x);bEUx(1sCJaa(sF0U-K$^Kpm9&L zV-DQnp305n9KCUv>DL}NEtI{t+5iJvXTO#}ISP~G!FAP5AU5t^v{HztSiKl`GxhM+ zGu->YB^}6AFUXm)nF9wE{cFCr?AeVXX6NMgVAZuENyKDCYws2vJk-?v+ z90galRJu9q^SRCIB!JAk#8!d)OsQteV)wGh(mPXdZLRNZiRsipp`P#!iFs_q{Bwno zql%EDIY$6)_ZR)9p;oJyJ+?+}yb_$W|AmLxx_q1NvkT~YN*7scFk+snF5smNMH*YC zZ|@>+L2sr~uMp?=Vt_r)3=NSnVrh|`m69KHfK{Kp!oYZ*h^?jn4la!azMlT= zgZLX8+cIu3vmAp97HG41Wr)PuyM+9JT>>d*U;w=q^)I?qNYwtPo z8a?=#U^(3FL;PF4B0$y{O5$VH=IqLfVdXlykQrb`@_WLaviFa$ZsD!UcmTac?&;M%(i}4OW9y9rFn>9T+n;)A{0@I8 z83?FZ4jAWzeR*v?CL+pll;}1da;uD_#ZLarcpcIrAvP;0;a<7eY0z!824*ZfoRuwG z_o4;_xe({C`jahS_EjU3Kv!#2N;m|DGnoQ2pqo%FC@;xb?1;MB#)CL~pl){m&C_T| zlThq+-~1B9?!^HQsc1vjZ`KuR(#B4$gKP}IT1o@;_wUuew-4zBgm}Nf82#k^w|c!( z!g?JK-=Ac{nHtPQQ&lio8zUdglr1??3EOX8It%^UqZN32o?ms{1s4Ya)a?W{iv5Ia z+o*GtGdcEPjMx2xWJsp=Y#SFdaEw>SW(?xk#AM-ghr$x{@|z2vC(nl%i#`*brq%><01967jTJcu%Cf@W)OXU|+Vt+0 z7PM;DSU7FBzAKNz{)R_$?4-;y95Q<_%FLC|bh4`CYPEQ|%oer<0k?hVcvHI8`)oL` z_VP@o(BEx=tVJ!Y(cnmGT^6Uq&x!Yt7r8@^V)_Mj+P!dU+Y^Bu`k#c}$tLB|`U0`f ze(62zP-M=ehUsqgs|{9H%)FZe7jcn^K&= z_4mDjLmH@K&f#sPA9__g!So@1@TeD^)7xdNQ|zFA-&*UnbzMK(i>74Hd1V19HzY3W z+41WV4&Y4U9P$pWhVEMVl-dl_8 z_b3bJsYhb%&77*{H6XP7Zj?S5LS^>eKfvL4J|G0zBwchUZJAI4db&=q5PW;b+xo-P zv+ZMg@)>HvFx*zK@h=Pmq?=FdgN(ja)^v#IJn z!omOCK$sAK)ts|0@Qd7g6rl+ed!olGD8_IxB1@?WYr0=Apu-K?vMe@OxNp}W{@R*H zinFoshW)*vg@?Ck1!vTQnYU&%iDRRw`_>{x^f$RZbcTk$7N;I+}Wr;fn&!%6<5?;0LIkFh!J z$iic3t!K%rwxA z-(eBZ`}(K0jtu&J8E}ph=lrx_j9iJWTr<$T@P&;Fm#k(G_}WAIC&3&X7U8VWqjelB zB6NYA-73&H)q^02GJ(+`shCU~xAG`^DO2k8(&vei?k;VMG?hFH>Jl?&@VLHpUcs5n z_a3IM{D;7|0oH?ui-o2^Nym~v^^*VSEFM)OJ-jiH5%U=>08AZ|g)(s6ZU;_65J91h zHakDjVx!5UB=s-)wvbWk?1$gkM3D2wm$A~c&!M3n_HtZ9H6pY?UUXn(*76xHsf_@a zmSBeI-svlJnhgA5Moj}f?@Chpw}zB|Oc|E7C>%stb?n>0YqDyXdqCi&U_(IZg<9bA z0=4H&VDJIVd1EBhg&CdakYZMQVYsb6Q2rH*YqQ`EMX7J(gyJU=O2MLFgiOlzm-W#> zq5dD(Sfk1q9gto#!hI^sPeN=+_ zCnCQ1B_r_IfMCMVKddk>{Kd)U%^3RhSEN7%UStj2&NLkQdl(^h#BgSq2?^KT!YTjL zr&Wl80redchn~cLREN%tR1fmO=Wkxk4;>R;0kt4QY(*5FC_?$^)jINh`(=X6PYNcY z&VUW~H$6o_CFmgZlnHwZNuN<^;X8#I72BPYew>%P=HlgFW#T?T1hAH!D2#o!NOJTw zU9I?1;`4)uGHlco(ciqqf9>)>ZuCkRWskmJ`L*?L&?xU#bwFpsi@|^5YOP4Pr~oO% zjxU~l;6Zdq|B>ZU%oJ?m@`- zb^N{iLYH*^yi@A0;*hQ9;Hp0wuw&swNjK)5A^A#uu%6RLbWQR*sKX}ic?$}vnb?t^N}f!V z@IBai0dWGvGLJuwWo5qS6qy=l197j}2wdwP3nqj9kMeF9{sWyUTb3a)2n@bN1d>0< z&U}&e_yJ51{2Cye{lAPU0EZwAxcizJyBqSIaDsw{jJ%_M^ZWk@BMS_D|0R?RD%272G0Z2x*^?!4hVz z-$XMih$m6wePb~-E>9Q%Y(UyWGF}34k_8CwQQN`l{ssqk>))II{b`&q#K(T8tltV2 zYzCF69if2lTfb<+2yobz<)b@9$d8i+b!?`=s`wj{dR+f{ zHk8wxkz)0X557pse00)YA1jglu(fCQ;z%jUuyt28!%oPv6R&7A&IXVrV^V# zuv|d~7mi)^$g=hSfc`ru$n;f`&=L>yD4kSC(*JBHGy*3Faxyw7uDoM(1KhcS9E5iZ z0ZHS zrHXkS(V_JYIZuDb*~JN*<2&DO_i*pWGHm2*iMu1Y!6te)Ua8`(0e}l7 z7=T3A`XRq2@HrX0$r>7x`2U8tH|LHP^yqw&}{}ttM`-7y8VD9`D?QC8( z;3Gi&n5V1q-v7{)4>QFJuY(Ua@C9k5yC4^D`o%wx9mxL*!^M<;tz%#286`uAoZmglk!7G^I*}Geol@S(cNZuS=R6=F%?XqR&7yz~Cf*6O~wxevR+U~*#7m;{AQ2|#cPy@NfF>(gH8Ay|q^3D^&HpR(|L>0?epu5xF8FwA z%3)xfX=Ty5!vso#%o8#wSwH#eYMztvg1gw-BT>c9E%4k$i^qfiSbC8`s{&G`cQ)s$ zsSSMyMMyF>h!Z2Vy?2C>T&EtA#lJHnVv=SOXyL_r-MxFIj<)cVwx)bQcnuq1Kh$*$ zx$=%}>I>-JMenpYhLN(RV z4wg@XwDta2$p5w#$v$gO3CKclK0U*Az^bzbl^~9&y&!P>WdRMYO(3uALiF>mj~7In zWzdtR$KokOspKF)eh_5&0OlXu`4+Is&0=|UqBSta^-hU;vF|^BjSS*}0_&}?hz34R z2hi@m)B7Q1pqBdwv*A|6x$o(?bPHL6!vVxj^YN zP3LL*YPuX5rJe-=t26iy8C&2>)fM9M*nMRKN|agOns$5We^M~Pqz$2KS&Q2d-X$KY zZ^RSnR_VuBf)2yYr+1^NtjETZt0}r$cOa4bfLFIu{I+v{$js3Alr2fB^&a$#CEA5B z1wXAQUeY-xcuqF$vPSe8jRnQD3(AoRnKK}0ri7KaYR99X_Npe2z zr0aGduNm)MN5P4{=fG$@MF270SQDdT!HEQnf(HPl2cu@O!6hp9(enqGG@J;BnN#W} zJ^exU!*#nmP@fBT0N40PBkDgSp?mhi@en6+p6f(v;H6_jqplNf{OcntH%E0HK#?ii zkFS(1xskYWT9s?>fp_Aucn-M9@4UiA2nIUW^RaZu(@6Q2&70mx{+&B{M+nJDp=*t@ zDc4fAqPhu;A3)R_?vxraWV77U^vsKY(OWQRg6hFITW4%dmDudI!h@@A53dh`?A79m z>c}E)*fdO6u&w4->w5qr6Xt3W0}$?o8EMMmE%nm@OZ;)+@gf9#!5$RYJ`yOph;QBo zH!t&V-j4`-_5VNW*SKIs@`lB~YfTXgH<~*w32zYltzkOa7*ag8;M!v!RCddwa2S0m_ft<3{vLny6DoL90w=XU z00IWKE3p~=Yq3QJNg#Z~l`bUEYM(9!!q5Jc=VfYVnYRVMvo_j-6pC)M(XG;tDp1$U zmi%f_-JZdD=WFjxkJ~`iTz*$v6vPL-!h%p& zf1|rP4|Ocs6vL@ z|286BPzu#i8uCdJLV-ED89IY`RkVJm9xVRyR@6NOJJS}l5RKkH9knen_*VRspAhuk zzQYhCrG+g}(V0ZYyga{5M(k9vLU)kYF9 zzEbIJXTRa^moLG+{~}Z^4ki_00H5u3h9zZz)l%9EAT5;1cN813c*+QBko~-q%}COZ z&~zU*x`gA0mfoEUmK(Jh(#kC0wa`Zjyb+qS`wwG>3{pmfYHfJG_E+AjS@*tE>c3E0 zxR-98;gaZ-D%cd~%PN85!j~=;Zgy=M1)=f}T}n!zGnt@_P#&Wiu;7A$14v-E5N^`U zg3}>zU%0nk5TEyvdlRCfp-g0fcs$s9bvk$j&r10T#*6Z0%su~)SIj^@eKCuLgaAyp zmQxnUBYVyXd{3$1^Kbkf zN7OU6lRhFny!hBfphkIKQ?!XnGpua;H$kHBA|kl)H;XeK-r90OECeduJ|m+yxX zLOeH?WE|J#OAaVo^em$%nldc^}api{_AKDSH|DQI28PfkktJQ z{I`%9Z~u)wmEMIg-GHn{C#?E31%iVBX0MODyqsDD5p`=P_H6M&xT+BbKVLoY=lsw{ zi+;e~PDsF2qqaQ^ue0C~3`ti7i}Xs>8jWO3d;UI{ml zp@6e-IZZR@HOVe;ZS~_``ttwcwIDBy)Js)Judw9t4tkdo7Gb?LmOtst?~FY`PDx|) z@cT~l^F8NDlV~53e$&0DI}{p(n~l(Yf#-nQHUOu{q0g)R60k{Nz2)XCi)($Qtj?R$ zq$m&Pz$2;n&v5ES(1UEOhv&&ByU>@d{F$@=z3JXRB6&M3_-s?HI)8ZHnvoS-QWKE~NU#6x{NUXZlcTH6Joj4Lbv z?u64mQ&u#pyNwDE2u1!SJ8& zKQ4&LNR6d(uSyDnS&J4vBM*vb>4cx+-YL~p8m09WI_e^;9tKGvq!sr33$@Kqm^8u; zf?(7SEx8&e3O22vO@7Hawu>znJ8MFD&jfh?Un-n0y(+htkbD=`D6e zo$(nF!6YXE6y2r2%CYM+)P@0v8mvT8%F-S0IX!!L&~r^O)UsbuxM!sMECa^_^0z^FTL$II{&Plq>(ScnZv~^s?i< zx)8}XGL=#F_{;l?(5Be4!P83uRwq93!vG$@niF`fO9SouJMAM0-aiXdS~6#K;pur@ z4G`J<;f*{+26gd&oYR9*xH1w)hweV|*-N;mRJ31nXu;bJ*6&n(3OH3U+Kne8lU=}* zhOE$K#k~)1HAP!APU&O^qG1?L27omv`o&P-SLnPTs#wi?Pl%tzy~3oy$?==La!UIZ z|C~dab+)yFPMbS}TW;?IV;nOra2>1fpzY}i|wY_-pn?>%R1R^vF zM+bj0V(m;=a1ej?IYQ=Ppq=8t2@j{T;r-{C|5*N=gF*kJx(jq`+{)Qm-WD1Tj{)(! zxgiVak^Xy-y6$-D@MzL*6ku^ycD83PvOgt+qT}-c!k&EQBGui6lh9t@G&WYmNbnSV zs!uvAGIEGu4~nLO!i9JTx-;CdGOo1-SON zw0KAZaaom%WiJQN3IOG@Fkn^HX(&ErCF;zOh7J;Ec0&3D?s_&h27E<5+~e?P%fDk# zW>T6IG#8+AhHRG}2=#IL>4B^CBp%J|y(+AODy9f!)?exKY6IjYllvqD^zSsKIQ3Njf)hsG-TR#=e^~$kq*6GTO4YdCAg6yDwfMP- zlBpDx1ea!24q~Qk*zCy#HC{w*xc*r}8=q+OWLQ)=4Qe_R?+7`Q=&|O+zN_@{h zf2_aDG-r=DH#bC>wb>uh^7Q^1)@BoONJoOAqnCVEUjKMqJFLtJEK}ON>>cj^{1IC* zopPNS0EFZC3G_XZzEA9M>SD5p*C5A)69s9xmfOm-{*JtK7W+lC|t{F{bHw( zo>%%>o_z`p4v*+oA5E9v_-ei;luQrGJqE?6Qb_oEAl+sNiJb=Lw>Mb;SN43rlGK%w z1^&tk+5ptyXEL{=aA`f~icy9$L>KzqrVv45`8myY|K084lIwzR_`RxvFENEK{S%#m z%6aWM5Y=ooJcy#?LtaykW87nty-j>Db2}QJ0~f*j9^l>{L#kmloXc= z!8{{MTz)Y|c{@^<%gg1%Pr*ZiZgj7FM+|72G6V;>xTk_&-M`%3vCY2t*SaxJaBUB- z4uX%e!1OU}O%7_VBsOrYCfOqJ{2Z2bO=@#&D`b;Dw)dJ!JzNeg?$N=Xx%Y}_Jr1|Z zNst0C%775vC?%lfl{vh@EKiQ;h!-t0A6j|M$~bxDdBB`?Wc}b>&7r*V5@#XY;-A|{ z3d%OalD%I0KP&>Z2SKzVWx%N=>sd>L;kg-bV|4w*6NuBzk=3m^q&g{{@>THgx}pCK zW(~FW)5NBir%6SDn{)A~S+<}Rka0=1^)x3SRU|XPCk>}otqp%4;WQLK0^A3DzYBy_ z1u1o@2R<@kn%b@*z19lo+}M_--;e+Mc4-G7isfmDmi`2c^c=9uZe}tSzQ%-gkH{jiAG6+E>9716710$h3W`4VR4qQI_EMZ*w z>4mkPB(N>lCkrA%?{`!=N$5Q$Xt8DH{x&hHC)4JSGo^zIG{1IR+koW=z2a=W;!iog zg(LH9^I|RWg^?#pN%tz!7g-O@M)sep7>Q~4b#MVG{ea=(jLA4N%fyqz zi-NVvxG&Kq?3wn_+>*?n+ZXkYUl8qGJz4&eRrYlJuOD;XDXXt&^gCdKi_+wo89tjI z(lgW=!@?BlM!tAE|HgHN<#ifeA_`g#{mTTC%h*?62dfvfX#?x%nxFjTny0kQe`*mo zXM;vtmgJQNHt%hj505@L?m~-N0?TN;2KK9IM)1`Z_9upPiKVrB~=(sz-I-S(saHtIs zvyfq4dMJx4s(U*OKBmaF5GB8{TDIwGCTR558mYV3UQ~guXSGWhdK)GcX(M3${+SP? zy2u(8jb{cTIt4fQ{%mV7>81e6<^o$aOz`m6*89t#lIOIr>TuGvtu|)u7ulN z&&mO%55^aNQ2ZS=lyh)g4LD=nX2@V{3&mabhhbuyfjapG?42%?uiGwI+q}W`LnXWPyDnvPNP#MOP#*+>+*iP(J^;TyYnFQYjJSc^G!0yE4JJy_oy`HnX}vQ zLjJ}Sx`TmFK|Jy_6(*h+g-3f}dIc)L z*x@z~YPNG6v@g$k8xPaf-6g1y{uHKx;;}y@AO@1VD!t}IV)waQ;(F(WY zFw8H;=#XfILfnXQ6r>P~V}xIqQ#ZMNbK~(<=u(^f@a&VUdAW-QU}9liG_kY`6TQ!l`X{(8AmQ_g8?<$LEAT_6VlFHcNSc=F#kf5Otm#Ca%(YwOU$v4fRE?%KJPY; zt->*GX;-F1O*#B?)ZfQKzmXt|fN;ZhIt9{^ZjB9Makyfd(V?rhGY}<4X;h8PN-~W_ zG_f=*ZTC-{f`YFHF?EUTZ)RE;$5{dY-actl_v&kYJ`kYYM`=X z;P1(XkX@?dGx#mLyiJb07PbZRyKA~s>@n0a4iCp6=opk3~Ii5rv1n8de3)y z>LDP|e{4%Y68Hr_xo~gy5>jkGd=}Y*6%qeqI(=r1;XJ|YNa(2vbUmvm0Y&!3#Dvs>B%?dv;Q+U z6Kg~UtBB^Z7z6#x3rNgcVWVnvSNHXtSPod%>dQ6gR;pi6dZhwPLZ%&o#XUfEWJ-#| zQ>bT+j&|UGnu|<;>}Q;bF9VrLw93*A4&eDdl7%ju)G2dXvFxwkXg>j$CZiuO#|7=I zKXn}Q$uHg7;V++g){8gm8a$EPbt=gn)a{A4t)Qy<9omM{L?_E5iAxUeQg$t&gmK>< zSiuXax>|M;A~*DAV+EkEeUupK;R5c_zxT~FunBV{k5u*~|1Ez6)vH<7bI6nkkXkT6 zjv{$=v>?y_!K`WZCR*W+6)mi&^f$dtb%eOBYeDo8ggyv^4zp>Wsrm3yrU(bTB?5Py zir=^;$cJHx31r5Jfx!TE(6-Wj^7&f0n9ERS?7!NzxWI~sWWetuDaa+FYadGBma24` zE}ghjbL&1B)eD;5rrTxkiL_5b$2t7;)hhB*{MZC7wysTs`sUXc3#GHNkBtTM;x6V% zoJQPv3LI0SgO{&ULCL_o5BSz>+A~Y5iX{QQVZVF#7It27RgE7x8>l)0VGRDByoiwh z^C!E^!)K0zUl-Ai9D=yRvPg(2u(f$tccR8klZchPGa5>5oH9dgX+nR2t7awBQmuz{ zl;SrNU)IlE@I5NfegQFS^RX-ENWf4-OU4eqA+roI&WnwW+QiT0e%!TL3#uM+w`n|= zsSr+C+7@xaC-u>(!fG&H18|$=!j>=s>(v^J1J`f4=x~2H5R9vp>ADbgFNZzTs0{ zoVUF2iMHyvuTS6|fr|%oLc6DYBVXB)3AvNtpR@jS)w#T*aiu^p%xkN$#b8H|PyRx0 z!#*<@!EIpc`dyw5o^zOyf8rP>_6VaY$_b9#cj$7D@WXuqJ?ri|*d?^Ke(i4C*>RW^ zNBfmZ+16m{+3WY3Y1oPp_r->I&~Kx-y4YoL4j-v_e-sB`-jU)C z`N|x07h&YIe_c5J7HVr@)ow|vG)IyU##^BXXdB+ULaK>gL>{i}hM8Q2_s6#1VW z!-*p>Hh~Wx(0yjaWXQ68pblW7Z32D^7+F{(+Ab#z^@bFWu8_1 z8EtNIs@FEQ5yH;+?jPRh<#@=_e^=S!qvIS#K#CpSQP>jY=%g~7)Reo-cpD9ZUFen> z$xEnk8@s!VghrRP8H?*{?T-_KuKuUgjXM@(Uwy&9Fy7oLs0VBX)-8nT5q2rBPJOXzX#Qk_C*T5Cfc-GFq z>c`B{@rr5bmxrWmPU_u+jqlsG=t8GreQ7~K$d>bcDx8DCntR^v4=94Wl@x8NK#|b(#_3kh&Rf1SSYD|E|#O|0k zxlI`s`om)?b?neLAhpHU)W)r;rNd_Pg|g*2#00l4kx2i}>+9xu5PR&kd$TAy$B#>u z0iP=#e{>S$iI~d;Tq!Qo@k~yFI_XR6vvPkgdmK{i9K0-W_Z#o(a?D}L=I!ET1-X2> z5aLbB$J5_Hz23svt7bEP*Qvy|D(B!dNaREXrW9{VUetfI(dc-JXIz<0#JB98pwx@0 z%`J5IvFQ1|KLb}LvFyQxSl1J=S58G$4y$=2^(BXRNnY2r( zGppLZ?4nTF`4IihKY1Anba%wf_Mye1YQA4OGo3f|zCqct1{Hp9w_|dj0OpCuhW>NP z%TN86MuD+Z@0;b-x@)T!*B~;*Zj-uIFQqrBzrY;~Q-5GHS=p@kU)ClVcbPrhQ5Nk> zG2@J*Qu;v~3xA8X3wcTjQS!n{o=0zEM>93IK?`cPYp3|qj7Xo8$RyZjz9aNFOw969 zQJbO51J9_PKuVpXaX_Ap?Seg*UU4v~3X^}7Vs)4{JG1fY0pD1JDxl0rUF90tt)M4p zj>en>-ZThGs!nW4!Ypqk#?JlYJ82b$chJzRJ5{Ee^S#^sseH$DBnBd9ev-#UJ`b_o zOJ*i7$FA2+UAUSx9~h-sS{9hR1KNMs?mt)kNw{X(edpTSnf*a!gRB7xzv?~Oh9$l$oWJha+{g5v1>O^TMZ- z7e%uZP$mFk!aZOkAcro>KK^0o#|I(!6g|xHd+Dll19(=ZKrD@R_5Y*lI~=L}+yC!# zIzlPO$cQ+$Yz-R5$;b*JMYcmKE6E<`kh1rVC=JQpWG2}qWv^qCb?k%VocniszQ5=5 z@%#tx`+Z;UYrL-4>$)^b(28@E-31?NOc`D`?kg3}BKp4>>S0sXf7)|8E4Cq>Dnyj(D?PBDd_485hLh@uz zuUwta`^pw6gj>nBsWl3`_fG9!z&QwAL!&bAS=jUvO9l3Keoo3tc**o zz0!Ok#dAW19w3CyFaaeig^`0rzRu>lN9h;G8A1xu!qdr$$p`c>R3|l(3a9!EY^9P- zeAZbrcA;I+6&tpey`zD6Sj4obuk_|PylRAl{pGWZ?gLlyw_+Yv6LVpCer|S!#7uX) zs|F=cpalpen(B{J(YYM`zBK-NGzO2whKp9ZU_C@y!1>ElyrtrR1yMxAPmnD9|4WEBr=Yaj-QE*r`cuc)Hv4)vdxoj!#x69{FoE zV7G@q=}Xc-IX(m?oQ4tfJNWH$MnR@d(2Iy&D{{+o%(|9e(&om(tN1hc%IKXjHEm!a zG{8{{Vf4jHnO;sA;Xg+u>G^_T>P{$9>T$Z<{I30;${Ty^!SJ*>fZZDAf#IZa%>k6r zbN8IMBQEC@pU^`^sg5(X3jzGP;SCi@K)ThpKlw*ee>CpBzJFl(rB%?v7ay~&_y80- zZbkG7DVxKo< z-2S^F^)Nx#L>9I4&R(bnxk(+t!3bQig153$$)hDB-S90E>HP(}Y{5Tn#1DdF<10x- zizEOkic)D5Bnd6PMTTUU_;V6Rs=B77Z&M+;j!|k&xo{5bXavsx z0-BYA!Qga{hp5FyVkB!M#jRI&yPinIWg&3);YEu-{(AfqE73F&ICT1!cnL{y9oqH& z47=B$asc*G)6XCPlh$FuGN=r52i5o+-=X^P(BsgNfN~mBoXM@X#kb8qVjgd#DBpq#t z7vS5_LT(_ykhQoe5tNu{$8K8~U(UKnVtBKp>K80AY4nO8*_L&t<{NMn)J}hfzvn|Nf43Rs=S9yYuo${FCN-x{?Mrn6xsFZT zg;2h$W%5&>Y4Hn5Ukli;G8z5~L2cp!J9$*&(Nz9Q8Gw*?Yz5RfMuxNlLuiX}8dVU{RlW88HxT)C>n6@RTzi`1WS;OV6A^`9E7m3rJ&)#-wL zQr;C~N0LwMY@S4q28z)*-5DC79 zPNvU46@~-K8Gs(J7HFvnpl#ORxNeFCzqOOx1u?*3xX$XyYhCMyhqUHq z|DD5m$QTKKj_%s`Jq#VZ-)~MudlC1#y#1H$xl=`@ar@r6zlWzi=;ZD1C4r(P>1P;7 z*GN$D!AG;(et9HzS*StLmzT##QM9TF#$tE-SA5qwxC>{rm7LLEOp^b;wF0;)$FaEhR2vuoB{L(Ejf_Kwk#YhrcNYFuh zZgjqf!>5%p^Tb)4L6^Hwx|2|KK=PjMn^2EXwpmZa!nETB6(4c(bwIl|Hu254Eu zt+m?Vd@bmyVuaAi-erp=5j4$GxGaB8%r-lT=YXqJ7~oHao6^ICT|vqFO$o)~QE&Y@ zhfCHYMz7?b0S-obDvmf#L1oLncx)a%1DRdHvlpxGqwgoibgU?kkLCSOXCH2_6Z+LB z_P0+rsme)6fb(X?(?R7w2)0S3yiYCcu;*Z?2jl|AWBv8sa_5aK5SDJZu8VJ$IcbzT z&Kc((yVW1-R)Gw$0=CL;SokieG~5aW#y^`cYR3qGn^%Dr7tqeQ@rwU`qI$uXOB`yW zM$qwk4@qnPMbUpD;bOG2RKOH|3HdC<^;tHNsp6|U%Y|R8$1Z4H@840cS{lv$DLuo# zFd$UA#x$RKO-KR^zReJg*;9^g&6@&8o`7m7b%F5>Cg%+KFQ@5gR634X`r%_}V!Vzg zycS}3^Y(OJCk-qZZF&lL>O?N${y2Ssn0=Q9x9eJ+2@Yk}^+!LimbNm3s>HT+1+Fnr zvfjty0|_fa!3*)$&3}=dLjVYvMP^=D?rL%QzgZ0Qq;InZ{Lzu$zM)v`y&ro$_z<3; z_$czDn)~S68cHW-c4F0VPhho(3sVYV!i~j#Jd>fHm3jLk3!x*lt9co*w#Ie0oPbDAlg9IIb38 zgr+p=pA$kX@*tVMSpVgw0gSPxu3Xn_$%VIoB7R)!g=l!($$gO9tpvRIV1+yy@Ybcz z;t&z_;I1Xio$!G~IT1Fw=IkutO2~ zjb)8yt($2YB-^;3eUD%LI^%iA+Jfk5{d7g)u2bFC^61R4-GR);?V2tzFeV~^X3b`< zV<|6c{aOq%No;c^#_`25Iyb`=B-{;YwC;C4nR=pUdzQ2izm#!Zcg+3gFU9~dS`K;I zT513eh~l1{+98ovu9mq<)icjZv0tWe_w?iW=0rao3yV4eLgSEaQ2N6=ikIi%^5Ebd z_o(bv_u?PBdeWCk3E(+?If?&P3kZcrX$qF~HUD{gUhM3n1l7>e#khl#X?NcTgBx>Z z&Z!R}Koc!i!U~mA{TiW(BBe}Z07=+usv!OyL_LP<9IqF}}-^gA~DS%iqsVmGkxP2^c zGWXZ}TPFfE>Uh5^vHV5q2urV0+od#ba~>&ZAGtqXa&n&Ps@9a9-}UkfxX4rHKv7JF z=K&P~e-R0Ev=n{b1-VDD+B!fLrR3z(>5`V`E+#L3{&!;_NB$8uYCa zL2{>p>EFF2-nA*#2G4lHpK29c0sW5nUeI!t?qe^V0@Z@kSWbMUgXgSemmFsL@ALH% z2Rgp$9B#tk&4=att5Ctkxz}p1MGGv|dqHpT{{s7A1;~ha@~%vSb#{_tytoLC#(oHl zaR!`^Njk{6%v5~kXO=rGO)lw0G7ZSoCs+T}(WG2eG_=E?Hagp-yTyUONrU3>qB*rD z-OdQpyjI}P2=AlGW7&SxIe{lO(?U*mySD>ClCPX@u7xRBoRFrdVhkU%|Nc+zT4zMU zd`iNy2mpEhd)JhX7@r2hI$ans$TX!oEU00beuq(KB9j5utb2(ZB%}IjWO$%|11rN5 zz5U>a6F8cG68JgHrtt!lU_cEymK)IYDm4-xF>asQPtrn!(8S#TcyXt$Hw7tA#iqt) zvL+?s3hI6b`6}-FVGh9Q%K6O_VVGt9K;iR$E(OXZA^@j8nZK`W_7ruqYQBu=DzM1| z8U9y<08_uUMoY#M5~b=u+ssgiw}~w?P)ic;e*J2hzD-$sW4w9Yh&R-%Lgw*@CfG|- z$qr3G2)c`KVIkgF=d>1LkQF$Qw4j10QkYk!sfq$4F}0PwEqvemu`Ok6fmE z_GGAHceT!E1X^Ts3I7;75=F{rI`+Lho<6x<)6n)pvPV@)U6P(r#-j7okLv?cJZHgbzxBMEhn9fk0fLi3kjpl=Gi7%XoSD{Y>Vj0n^$7tnsO3 zEKM2tTwuU_fOEXz2qWwj8||}5RaMjpKp`9)o))@0D||oc&;Eh7^VlHk+_I0zUS?#X z4N;OK+kf34nJzLX=)SQ<16h_xPYdus+taNA22TdiFBUnFjkx_hDDsqvr(^J&)zdyV$L!uH)8H z((9c6#C+&r+LozE%TVmlLQ5R&FHx<#vA=^%%BnC`!oR5{mToAHS8 z*0X|tvKh!fF$PrK+O)mzh7(kufF?j`K{l4mNVossF)se`C4S3LKDLTP!`Ic ztKfo;u~ip}RKGNf{(bVp;eQOLaSp>g=-a@`nx$I2Rlzh><=>e9ml2^AiB4xz*y`b6 zF#+19$WS!Qj+)EZ+c@Uq$~0mO;goScVfl8pOiOzHX^8-?uR*MsyMW9~){+vr9cK47D>E?&LRy>%A9g!G9$Zjvm^;MhsCCGtxMcR_fuA6)W_aU; z@8ERt6S2-+ZYtbDd*g)=naPjo-%kLJtsozBml6GWe-D$ z`TeDP57XJF> zYwKX@2gNuL6FrttO7XCw!aZsRyOjWFsQXgVk3J@G0~5%!acI+ziP9W}IK5ww?gJrO z;GR^@=NYUgwaSvB`Q4oc8Z9hmHg|(OcT#x_3>17q$bt3*Okf#(%3<-Zi4IYU7xR*$m_mgl4&Uu)v#>RqnB{!=t^h%W;Sx{Aa|)4D!aK3xjgMFVhEhb$@_hXnpHy8;(q9r5l0%pCI3k*xW1qJ^S(J^ z%E%GHN&o5^FFFTU+kP!{7uI$c@riM3D(24EnDZ(sAnmV?R!aBKFxC@rZ=HQP;H9`2hW{?k{6SNJ18HyCh35NR(;k7I63Kn#=za)TqRR zj=Qy_n8O%ovD2srpu!urM=nbOa=zo14dm5Mc@y34ZMz1g6FjPh<7z$R%uyJ{E91-3 z=dXhfm@VyltDWcG9Ud$H=&^1?DsI|3qVfPsoVWVMuMID;Y*{sHAjv=N_Wp%1g#U$( zip+@$tM%xC^t%UGGuXt0WTvqujoejeWN3YBS=cA$OZOnzHsmol3o$JI`)sYu0YM|R zgy8zZ0zdnE_vr0rZ@Fo?Q&{bvnGfRdsaHfvHfl;^iG(02&nZ0q=i<4gd7)Phx+VbXX2oOPv0lP? zdfdarx_;IBlgBwVO%wj9>yi5 zl`+_XLcyfgj|Dwj3LA_uZPBv_9ZF34qQEmpTJ$I;jhEkL$FqwPMLLCiN1D)_!EfBw8W~K&KZA zaXHYReJcZ5@h9m2mTCiUq7A)y# z4Zrz|K5{aefN2^P4}FLQrBe0NJu?L3rEAk)C_slgVWXt0(5EXx4(L4vfdOm`0qRrQK%=(eOSnz0gWR;F z?qDSMz(MtYfLeItz3{QaGewxVH6^J#oo)SfYD8y-TEiBc2WgsceXskJ4_qJpcLw%< zu!T2*@a)&#i_c|pvYIzmLf1ZxRE=Y13un(D^Vi~i)l@!JU$W9nfNV)Ar1iT{byz%< zkSn(>#SsOga`^zuz3}43cfQg68pdmn-Sy82A~@mD3}h|Gn@-C8tESDinErAK!U2a6Ioz{n zp~=$2p|LMqI@sPVhiZ)Ne4Y+!EaAH?2(3|imza?UzBInIyMNer^!q}fCi!b0 zD_k7g#RdiTHmA>D!(jaL2`(WGubGlXG4h+Qv<-tHGcSrlCjw|}__$2OcKT}TrHXuK zE(oDa`c9cPMi&0Pr<#*iijagUnwR_z;l`|1uSROXCO&IHtb^%gy}JXGw~y#150MyH zp0K}CNZ&~O>?0?7#{Jmd!i9^+C!@Q6v2yFf(QCXZ9{_a3vT#31FiM;eDB9SQxqzZ$ zZ)bD6eqV54+VkFG#l6Eyu2DniyUR%Hx=Ch4HSmNS-4vh;RPCr0uAJ+P1BUmCBL>2u z;v)L9OGqEgNTBf~z*>vdb@Kh%r#K5MvYlpsK5cD&tQ_i19VrT5(O3p-&qOtQ#7apH z6aD=Ig8*dapXnwUCPPIRM^}<9QQHDgx1F0~Ph*B;iZ@MXJ4{MT7mKP@8pR0OcNGMk zUZlr2cE|5jEgpY=wFR6HdLCyBeumztd=lHhRMp>B*1UuB8{qEBy_uF%8SgaY+{BL@ zKu5_jZqJ8z`n+7nKKDTOAE_m2=7=a?Zgl6m`%e{L*(LUmN|k>%64R4=OCdE4_U(Wgel z3~iypz4Hsxq96^n_U2;s0slEp!7~8rY)@93Tk+$ckM8N0zd-ZAGxB85tSa5bDk@B7 zDH=6NYR%c%D5#FF)aH(_Eq--z_x&6p>e1YH8#-0HJ!5O~sga+Y5v2nb?l+z~K*jhA zZ7s!rv7@dEue%q06U%lAcYDY{R(T6-1!OGzPj>Ex!i1z-f(IG zo>wxZq|O+0mCp`ezt7#@Go}WaY1z8q-TF0htYZjin5o8_Ytx4T0Q?w(%LvW6tuQ-yU&gXH`%- zw;G-~XCQo(YK0GvcM}GP9lVcsOxvn3%h+lED+F9xM{PUk0XSy18=p*em=gT1Ny1V5 zDiN2zIu|`((tnLcMU|GVYpCF=p5@wZ1RoHoaD}T~+uaYp&Qsi=W-#wqhVpgSX;i4P zkU6K+AC`$Y&H!qZrbCh6-mo_r&gz*qLJ`bkp_$ zDNlUMq|VMQO#-hLx<}q*?Vsj}VFVt|Plo|Ujrp0k$G7?;{hAb!K#2{mUUH*GF=OSL zUkc{Ht7?f<{I*~_v-lxleq&nm7KQki1A7?~Ns_Uju09Gra(^v1E&Fs=e<~8vIbjmK zzc%YZh(V#FbBW>jL8&SXrQ=Ulsru_UYTGKX7N3#K2&nrnjA)+Qn4ne1UWfETv2VnR zdyQgg(CMxmTAw1vFwe3eTqA%NhEup4MT1P zo!&Zp5|^gg{;I0Rfrk)D{PfdjptDGD6I-EP_EGbzX9%JFPg<>plV>-7?`TRk&;X!e zlSxhC@q;q;7mG6znsuN0pMy1uMcE>Fw>h|gm;^l)p!UwCznO&M2SfH2f&dC0@#^4$ zAW&v|H5`Fsd#nuqc?aAgSr4L3ccO#*-C9$7QxCC`!TTvORWG zd^URWjXDC?#++|b?{wZ!z0s)7Oy~z=07PgR-VL`nn9{zyRJBN396eho3fwUU-?aiZ zW0Is`b>ji8^W|H32$_uMFo8}rd1fN>%;Y=4o7Zj~0oRmJyhx!BHqa&qEo@Ke`#f+N z;|5?)Yw_;4&zB)^dSdoaF_iP+%i6OwqX=$Wh!5`MT!|k|fhFs*+dPuEb86>x-{{D?8vb{vJTx!y8eA(CSo<3s z&-4SrXBu{M_T!gi5Wp(8&~oGnAeF{)DUsC+jygV3!5K=!4`jWs1(qCD*S_)sO|aL@sNA>Px_X?(001?FvWiBy~-W(LZndA*HZV_eUHoE zKM)DUDwA*Px<{5*3a9L@&0SgzcUZH^iSlX zhQL{h#cz?V_#;pAGt#IZfs3aBZ1SDLW|GaaogS>n z{Qepx+4Jr2VI2-432vsKn(>aLEjd~XjGb&yk1^ZcP{?czOE}?nLHV@1xFoxx3Hg}WYXFlmKM74jLa>t z&W+LT*l(EbV5+9+NTOgO#v6P((F+r);ZnxUGVkn;GC!wjn&02C_(GiH+}l?1jD?1= z;C9pfvwrMcLg4B$bGa={l7B^en?l*Hna9`XY<{{@E#o&4Ym)#nMNH3f(VG!=mixrB zuSpCc)}l^3N724J1; z^YtX?l9p1#)gMET> z=;oXe-NF|@YDoal7E`AMT=ohAL|x>-n=z-OMm@x8_EfoRHS9I+{;SON)N_k`%5#7wBAHeETN^~UUo#*F^T=2 zZEUafqotl>%5ZCDdZ;#x#`~*A9V82=iaCn!9~E0FO1c-;N zH@_3NpX6GQ`u!3I*0P%ND#A^5hPanzq^*6GnaBoaeQndfpR*755 zk?VyTUMUHSy@G|Sn&aQJ%C5^Y%`@FT=!$LXhEA4wJ)r}R# zB$ie-NRlqn=nlk9g%Knjh|^%H6wBu0P&nG5wQSP!6cfWfc_sXv9jNQ|qgeo4SbFz` z(lC=@wS?_Du&^aJ98v&UQhFcLz%YLQgUWtV0_Riok9?4=l!*Q7hjzeWGHX8(0nEK@)e`xgo)3F_QK{1r@uJ?xuQkJTo*)?8> zYc-grK-i*|Y-fOPIxV~caF_q1wNO)PO8M0_T&;rJJGXSe=uMNXEk|pEAAXq_LZ>|+ zx#l*nkaUSD7aI%U-rVhts(#shKtIWCD%6>%C(v?(!oahfnqRxnKQOz$|H&9+_gP~p zl5XnI%Lk?RES?AIGX1zYa5S&?<&|1I0i5SGD=U;dp5m5~2oGy>Hz1YzY}L_b_*cap z7}!DDglR7WCU3!=o~&d({>$Rqswz~0P1|7#&EgzA!TjH6J0pI*?_e3Lop(j0Jip&s z97Y^gDaYKZD^Gr@iaS$Nkf^vjSfQXHl=*^z=zm3PLAK20dTX-u{7bW7PQc9?G-y&1 zDQxdtt+9Dug-tr8dP!=^*_KnZ!y4SPV2B5Ex@CHX-A?^eiCg|<2yx2c_Ut}W-sZ~i zS8^o!xw8%fCTWf^}mZ7Pk&<{C;t=r9rv+}-Vupy!M&1409dJKU1us~b!pzBuU9nM=xqSk` zj1{m1?$#MBsA+FoAGb;VmHZ^5Rn z*gC=raT=%_=py?wiP}{eYOw)QiT(|1PNY=i1S!msFX{W2Q$H<;ENn)gF)g1bvYBxH zM!r%3E((_}+-(!%Dv?icN(XQgYpny1ZVd*&P% z*!U^oE12K5q%7Nv6wfxd+HU^U`J7)=rQ`EcAh=up!mo8e=nG|f71A|DRzc8s009fF zfs;6RC$ZP+8TfEQ6;UDSHL-nFj)!QNVFBfyq8>W^2mIqdD(Dwi{{clBvrrSs4c2jc z%l8zeV-4%VRT@6&yrTgQv#Ze{=DcC^<3(B!435%SUhz49Rl|tSz&^_L)bNxrcV3h4 zlX(jv(o+WWgn)K=HRkhvKGWnHWwr5$&c#%mTOWt{>m@=e6->T=pz zBU`oA0^%P7hjbevaGBz=k`OV;DT*EfP~xNG6HV3tECZcqP)Swv9D)iJL-7e!uS-gl zwphwD|5mpsqvnK*-5<;bIX>tszzA@Olo_hK(;2cGI2hfKD_SzJenB8o6DW|-EXe2q z=}Ppz5!nGOzICaQj9sgnID5Vm`?y+hUq;3M&PMms4=$z?K6DKGTagX-H7N|oPp`^* zNM)>z#(P>s3@ko7N+xDug-|EyF|1Wmgh*#pgIH#{^VmH(_EVjJCZMjnmOA5nNM{PF z3yT;e1&>_?wRBu4)3v#3j6MlTTwCo70f7 zNixl^XTh1JOR=3_hl3KOeQoOUBerc~v}z=56$5NpbP35*%FJu65sxEv#xbuOOHDIr zfmY2BIfQ}+r4D(!==Gw7>I^phJ=XI?`cC^~9vB0@J)`8*kmXqmz2>qlypguC(2*ei zh6~W!#V2V3dwgMH!<8sT@_N(krU;4Y7?Lo2=IZ>YJQ3J}&g zP2+v@nV$*9C;dxy0baL@xM1%pvE6ghlKCr7RAFyl9C(g26$RU~V{a^>NQb?dD~w;f z2c2s4J$B~!g4ClVV&KQZv9X)L0B9%2&VRij)}$eG z#f3{ikfp5Imw$E|L(GaW2i#udq*%ttI1RkmqR#^%1{f(#xZMI7&lYI#XC|{aOPzVk z>V_L5$a7j{2~4@l+Vbf1|B&fB1JGSMb+@#D9c7@Nj4n3R{1+t`CVXwi>r#d4W?F8g8UmuQR#fDgg5kFDV{!?$HE8ZVd5Oyu=PR=&y z3KjnKTy7QXQX#u*zN#~s_1AS;ux;2L&nJh#U0vq2P|%3ova{vl@%elc@Lr2&<+cAI zBEO-5F+SW2UHcO~T5ZY&Fr5IJ>(vGZ1RJ8$Vsg8}6x*Funfx<`gh*lSy>c#AW1ICa z${U#g0t_!mmQiZ_Bt59=XhEt81!jgDTr1wG(e`^|yFTeMzUaQ;^J5gGzU#$m5WPD= zxF@u3nX|3P^z}Hgef2M?m475?yqQ0=H_h;xz81O1*}@&azz(u2hb2+@P224dzaRe= z9ziiI01x~ReYlm_68I_qK9qF-<7glqM$ZrTr1jm>Dv!Sxa6|8V2hNwDXe^-xB)`-I zBmx(vqDiibtJSD=V}@91{Tnp`H%!g$EuS^J5&R5*jSD4N_;e@Cy@G78QsS&C%re2f zv6!;&U=k?r+DWL?76Q;67&bJ!>3IeWl0?V{d3r4wH!?f6x=U|RcxKOA#m)Fl(*!EI zwNl2%yFYvjsNf!b#kX+?lzsq^`C#w$Zyx1z81ny&EtWbC_vfv({nNrZxjo~dSEJb%{N->nNM| zx*Zoc=rp3>jlu*4Z~0S)=4g9&&p$;I30RwmF`Rpu@f-=~BMM%4BH1vEBP%?nRbZfB z;GA5r8*J3x*|hRv=JWHwUPI zq}j8rN(22@70JbA0t`#m=?9otF}{obr?xNxPQR)wvKe3PRV-Dy)V27f+z!wSnVfpI zwC5XlXS5+-@Wx<>P*?0)zh5`!{K$!s=RODPv_$MG>xdJb_W2X48scVytkOtk-#M^Z zeo8*K-hjA}YT12HPzU0EE9^<$-=LQ~#(lgDV$|QCvFHc)mJ2_Z|5F-C1=BRQuR#KX zHi++gRiyO3S9h?nCxFfy;oY1zmz~w@s()+SVA`_D%lrI;o247s+vO?xry4{AObc_7 z`E77#N&q*@8W(z{G5CGpQnOw`%SEmR>sty07ZmDhXKndAX(}8~r`$lX{hZil=r88B z3TKNPw(Tn)pB|vFFmt-p){`rBV$?7Dvh&0?qj-k6txfe5UpH@9FcZ7$T3pC>=>j+2 zv>Nt<>>f9dXsV4&5mPpaY#zFv$yPN>T)?foR)Iyw*Y}u7T4p@lGO5JQiZgNS>anaa z8d@WdO^Iv4MvvR9ME+Ed)i`O?di8%30J@%}Xc>2rMHpjdVUNr`I=R&V^)b7m5?pj= z_lCjyVXj=nu6v?7BBXIGLa~JyP+rKzTC@L_Zs_r`9G~7HwfaC_2D)T0%Lcop8|N8y zT_WK-*{IM!Q{_^x zjJ2w-6L{--!KnGQ(~)T__?Fl#f9_JsfEzh^8(ZP0>+x^!OhQ7~t}i6eq_**3&jWWN zZmEPTc+w2IltO*K+9CehlL8XWs)4QQp};_X^|6xpS(p^--}>*eo5$6^Thm8H&)ea7 zG(4%1BDZfQp>&Lbl8Z(>=3;Z(AlbR50y1cg&e#HmBXZ+cyoJ?zO7o}wPPT8L*0~+q zUa)PwcnM$fg^;B>wSD3(TQWBd-BJNKeV@WmZ4Flf#hS+~e2Mi<3K|x#6AqHaL3Y)K zYsR2sZQ^#rr}qD0P25MLTE>)~L@rAhJc{qRGeiZ$eIR~8ALO65wLuBOIhz%Q+Pvf1 z>}EPm>#1kxlb6N3?r-d#9r&)?$Rt>y!91vx{9C}DH-;CiDo>lu^mu*pR6FC=9ueYT zEmyp-;;dcTrBD}u>k6J3%w^{nSqi^Rf6REXKjhY5GRopxi?eD-Ohker-AN+3;9@IhSBTKnY{P-|5lx&Awh#O=}iaISX2 zOT}mMoR@x74TuI#^kc`plmPX+60=E)>JsWEF2$g2Ki1x^-m&yGFIa7NqpD-L_NANk&Cixk3=Pq+Bi`>?6c7eJx3T=#$Vqe^eg5LrM> z$v(Hw^2ftD4p;av+=M;P-QMEOFOoVsWRHxIjHNwiu6AwDNIK@&$&Wjw%l%j4i4{M2 z_}?xM9q3zH-U;4f=89(!&da`eoTLQ2g&93&N*yMdEgb^1E3RmAjiZdk=bfC|mg@bYQ=v z@tpJTUpzlspEnl#?PMc1KyBu_Lyoi~4A6x|zio2S7dIjuAtwEjg8Rc;Dj3Wx3grFO z{PlxTYY=v5Z@eLg9hGzDCT;xKvwLO^$TeUqLfG--=BmgQjSC)?0&r%AV;R_`4|}t} zpC*mHvUwPC$u?CXg?oDGGCKU)#I@#vo_(8`LBIlU;H^ z2m`k-Ds0GqDla@qLo0t|+%x+(RWMRrpbfJe5QEv?A;{Rp>Q+%)#pZX5Ps(Dkf0*}L zF(?noWJ@GZj#CsZ)}kRY=0**NoR%?%Ie04e^Xc_M%z8HdG6SL8Q|~6Fx_jsO-YgOl zds^&+&zbb=XrPo}F}Z&GpC#>w1Ql`K385lYsD|URZ^&#s<7Ah#RW7u;oaceoqft%; zaE+5xr=n9G@7Yf1828*9q8@SzZ;SRBD^bBsSPkBedQJW2c<4q@IKQKfIgwc5Sj|>> zC5G9;Tj0#|?(3obo31n=P%ib;WcN_XqZG?Hy4;6Nqs{)NE{;#f6XUw3Y`fiCTK>2)`DKpP zMOa3XI1qIDe@Dt3F#%5R|19v9GoX6mPwfbe$wqaqgsZ9)t-F4W@0u;5iKL6rWL43} zFW8{jpP%HuS{69n2-+apa(vBk8WEI3%}Im|6=T@7dV;>nt&GmP zr(tm?{7C^VwNxk)*_Wy}+Q+jvE9f9v1eiF_AhhCm61dgu7zlmb@>DEpmmp2wc%`_< zR;9~dv~)jy#exqIT4k(M>U*~UF7*9prw%OyB z(@mvDyVGBfx*z~7e|eyGp1p#W#6SDK(`zr(-(bWx6!_X4!aW<)Cu?*!QYuoP(bY^P zujn}D3|F@ELV6E_FdwBBt4@mfAZJ7&74Octe0s=%e1fmgA1Mpx3H(Ve`2{yId(#l7 z^1bf!qW)Hmz)tRG(aya{&4aXx{fk@)vDi4u_e6OGNVO6rM`4nfz@Kq^u$A=j;t}V7 zLbNEM1m`|a!zMzdMw)w>Ht`l z0gEW-08KE>nb;3{JIcH+FiBntGGf~k`~6JxKXAHrO}`c9CHaj;DU zu#vqTr})a{&K(h+!+505!ufx0FqIr?cEwAU+l%mmdX^S+A*)1a={sK(&wHC zOvuwf#PM1VQML=Il4)q!b(46PdT1b&Ve{8Y$qF@%1eSL8&_5xS5~ZJ%L~ORX9XZ*y zAFip&i9M|$5^ALsGCojBW;uQ^Dr&M&KIiSJit6l2J^v^UdY-)#sy`8Uk{l&kNtA#f zDZXe{BQjKq2}FkDOiLYn!`Q*XFPF4_UYSbCxWA)Ie%70jJ$>{!@IcSO6KXl|#m;H! zN21W_imTg>;qV~%#A4=H>1XpC{JM>BS}!kh(92WPGwz!VOG$~wGo}VNm-FbU=*|qs zwx=l!yXwoG^#cNToA*Uijq+hu0*L~dG7+Bo+o3D<3)fdEFRXQ0TnV9yN@%?ba8Rab zk(Cy0G#0)}J6Y)?qd{4}`3bWUyvxM+T-47PdwxIijI7bC!t;|q3k)jasNF(mu;8jV zpAZ>i8rezdIc{Hm_uPLL2>lmI{>2H0p61OIzae^d)Vjs3!C*A{Bjs9>K-9D+BW=ly z<;`)je9M?bjYlE?Fo?XWl`U@w*MceWcWeO5SIaI6B~6^>(s&J?{`&lm)l~`Cb=fHm z#^P-{F!Bp2{>m>&@d4Aqw3WoLwuZ^88to*Jvfb&&(VZZ7W?MZyPpe3`KmK?}g-cY8vbLOs9_l|g1&JQHA;fx_}w1OlasA}U!ny1irkwUddBCbhghX=vX9bz`>1KU z5idhUe`=6b{L|p3Ob6j^z;uVi>G>Z>jCt=IiH`U(Ys! zuJ341xr_6WM@vu3#NQ`Ds}>`6D_<|WLWp81M7wKg($f^6*e^9y798DnBaIBPX%rjn zyq_dtpAvfPWhVrqr1B%)NzB^z*Xwmuw153HlR2Hc0mPtsn1sbDZh0{%I12 z8^=z+zlGw6xe5%|$FRI79GV?`Ym=wldMNw!-yOoX(Sym>-}JPtjEbRD3La)cCzw}- z@+|4X6}zKlHO+oI_fuRjq2~tNz3j+{(ot?+SSYxY?s~U?AS*r| zx$dm{KTIAk253;*9xNw#lo)@8#S@5eZG@%`>Sj4`R9d9{sx*u%v*(N(-?{3e=mAaI z#&AKB?1$`Ld{*gJ3!N68d!3p5^$l+wCUaxx#mJ@u`0R&15FxNAqTA%r_d?~W`7O4L z*A?n)5YJv$NilBv^5pvS%k|n&a3anyK%|iGer1oKf!c4Hv7Of|e;pZec1{%yM?)m4 zGbcMnO`uy+zhTmhFF0vcq~Vv`aiMbR4i`X^4C#rA)HMz8j|z>7ibs{_Iu($93h7K{ zB!dB+6%*(t-wN+QxcufaSt^chhU6T|W&vE`Q;!dgj6_eru#+AYvF{(i%7 zBjw~~Xg-SWkI@OFsCoK?$0SK>^}NM6-MvS;pHb%H8|fXZtI^J`X&Z?2jU5}zJC;broH}E8XyaOpMDLpZJ~ELHpd(?BIoua7m3?HBx{PQkFmVP9ypz*M!k5 zq<8ZjVIFsQh~N;zjC13)DEI|8kS@l0HOg7tHv4g1-(Mk-Ug1flt4$1`(<3A(vdx>z z5y?-?8r51g?(sS=|D_jxFD~|P8)=j{lUj|r1z2HVQyw1rw}A*khUK7`*oMu*SPWyR zQJ^yO7hA0yv+q`j&!j|oh|~3iZ>JSrWrYK+($5hGzcnR#TeizwSJFxN=H!7;-Jz1rjn6Un9?X(x!y zNyZ^%$wfjmiQk+g8;N?p?OnN4ZcgVxiSTWuvGrXLORv?s`i@pV>h`(HgWIgYoe(>&5pG+iD=iY&DsrS^X-f1#cZXDk8B&E+oF@-vpDocaq zh!5tj;i5*AYiGknOQ$3%L&OubMd9x8h$!W4QVaQNA`=Yco2$E)BCF^wq8-P2>Gmb+ zG}GSR4?g5Du{cLRLwPNB4M_HZcK>j1kaHef+KdVFPD`T8J{cSJ#38P3q}pDz|F(rm z5n`O|WrQSN_RY+<;epcggAFYyMSad;OlutQS34l$#Ir9exphr-w(*myvEsnXcx_V(jYTHho(PxBc0${h)Tvxx6h|$<6q0 z91wW0`rE}I6otzeG6c+cfX@lg9~dPPJSu}wqVJO;9{eus(2sjqV_wv$O5<5KVoA&0%4;ngc$bDNc$qc7l%h=B+?c z%4F{=5AWu>jQMsmTBd87f<*kB;3@-jU3N=sIZYyO(IgYKdaO+c?i5wj?0G4JYs27M z`ZX||H$!*tiG5;dFUoTEOai(FY$taM&nZQ_s=5UGFwXc@=zD zv)KGAgiYnn#)4sa3}vlhczQr*wOr7IsF=MI{3|*?N?q#%Mk`BpJ*C3?RgG~to%hUg z2++QzzDXMS&AW{*r_1TjUh1S-_3kY-DDbWD*D%}!6zHKjm}g^O!@({IivVCM_+vci z%$q|pt`7zx1gR>iUnoe} zeyPvhE(Xxr&%^C4r-a$=sn30ERv*iA63giG_2|xU3Zd&$#!i@EM+^-<1yLEG;x@9e zlyivACt9BVg~y@xS3OH*(=K9YGZ>@?l#zd=4Y|ka=KDK(;u#ZOAts3?==HJSr~Yc3yU@fJKd;` zYq(AWSQursEcnghT1%6`DPcbM{1P72WBc7z{3pV^rDA0MP=(FXk&by1<<_8Vw>(TX<@VVHVH}R7ZrAXZ7Nrm0*7(9pL8pi458j#&@M=}cQd{J)2kl}}7E6iYeIJ`J zLoAB633aEJG;bJgoQ$QNEBKMY5iSyp%4NJ|;Jf+u?7>Orq3M4~R{+0kMo3bEOF8Az z^jpnQQ#W;%X~9Z&ykt}w9cD|zL2~u_2fWXD4wNx3AUiD}H`u^7+DLZKOXRTCK;s_c z18(IWBo;7oV%-UIy*c#u{vw`udg_N#{Rgw8O1r`2FM~Of>mAof`ZU$XVcl!$&q!e6 ztKY9JPZ;{yo9LGkakOoP=qpgdEkyLoJBbzPd%sT<8~A;KYRlRRa#?*|AhBj-;JPkL zeJ}iOqT#&1wBdlyLL^D$@+^KcW?+NNJ@VS!CvB}=MN)}R@lyD=4epJSlFFAXz?&Nh zna6_a^CQF!SBTBu6!3G(;ksN5OK6Y7SD-W%<(Xp@6q~m?8KAq|%is|!d zQ6xIGvJcQ2T#CX}-AmtU>pHDEH8NBjU_PyW}Cw^&-8fW&HB&$9wHxUvYaHA4Kz}o?o`XEJBnx# zT5RI-d#iOBFSXlWE|wAx<-l-GZRml)fe_{U@j@5fTGCU@*827>QZ_tBens#AbsA5> zh!!GJ>*USBMe~z>*7vyT#aS(W=;zOq(Ed-%5~}mw5W?*ONuE zkg|+j^s`A5(*En$>Y3>sDQoHDl*AA7e|%0aghyF{L7m&zoem4j7E3twtUA<>aO>2v zLLu;<%Vy>47AQWvyHlm8Iy8H19wrdE>(8(kM=AR2*m&o4wRI$c_N$bRFpe5n- z@xv{Jqo9Q1^6FcGYaCv938FTDNsRF=izK-_s``56rrgYwNZmMF#e`% z(&0fD;PqOzZxM{Hg6O;BODxSh`7QicJwDeHarKyJ`o1CR^>#bT&e%cm4IQD;KCrLv zxcEG{6vXE9H;T)2D(AIu-JE6yR=%p$L{Q@{3jP-4p5x;yjeQX1ug14Y3{X~&aC(sQ zCYH+F<@~9QZ^eeP)8>}ka=e^?kfwf-;5-?zqu#zi3X1gOclYGegjnAvue_(W)LC6K z14BEVR%X&-f&_i24UL_TR%9e-Zx8xb9{M8l=em}}1Wv}5>thD@-C5LmBq<|2_c)uu zXD5)o&o&EsBR=)pX9%%pQ=fQde)~Q5lC&0%sP?xMc3Qtj*){89m_~PvtQ<>N?Ui`; z{1!Ga%|OgA>{{8QrxwiQdIPe;yridiN@m zV0{nm!wfWCH$Gka`7osReyTA9F8GQ2=qSOwLorxT7)qvVL|u4Ggtn>I!=&e zBqQ!hb5aC{87Y^GbxvPosAfwNZlp+6UhXyh_(=*n`V+^(X07PdZn4QPC4;NPa%c~h z5lYjBk>a=Sp}E+19_GktXM)=b@SDrJQ*{Z%hcjm5m5hMDGnpsyQ##tYgy#Z%M_(_v8Iq#$7de7u2P16M_%1bj>@4Kw2ko*NSAfH6- znMDRZg;PZ^aOp|B)Rs&- z_S$cbT;IH|FPm$Z&2D+TOr}LP3e17T$hhpDB?~{LArK}J*= z=bZiU(sX3}q@1yw2H%2t_K$`qpkYg)K6GljMc!kr)I1cL^aOjY6cfcMW%|@$M}NuG zX@!AT#|Dz{0XxHLErp&R!wF_~wFBw#20Oh^7;T>)?|DmaqHx}6?!R@n!T1ni4&2iw zP=CdSopYqP3eII*PhhdV*$QdX%E9SGG^yQ(ILp+;AA<2&Y8U!LzyPmD1U8ygPqe_2d#ta;`%5ZCMCfmS(G%S9dwl-ECot!E`;f?r&f2Dv?9j1vlU zETiAmzg_*V5s48nTRr7~?$|GWZgV0KRZV5!HefHLWT=%L;{W#2AmDSo^$aD(3W6X0 zc6?a(kQxik7#f_Q$f>qa73j1)n7{i(ABz?k1mHV1p24 zMO}<%z1~%A6R$9S*mNuD);PYa($U7^HQ*i-=zs9^R-B66jobZRGi(#^>_;qcRC0H(qc?eZZuI%Hu9H179Cs!ClZ| z_t{C#W51$#_SN%UI!>=n&v0(aQ3;dNhD&E^hJS*IGFL5R*_ctsMl}a4ScYv?hUUo#J~pUgU9bjS z>|Q4(u-Avty?f|6s7B7PxIQPz9jA7iqx+U;p9MljcjqypJ^}=n20I@$cHBER@9^Vd zIR_OUoB3G5l($;9&yA%#sC*u-=A68h7v}3wE-6b;*KYh$AgB=hD^|a`X2aERzW0_Q zV+Of4QUhO3%&7PfYKn{5zG~RS08=$W8YG>lq%EY2F?x^R!$`!I+gz#@zFf#KQDV0R z1JX3(+`jRg9^6+D-kTaK57^f^R7ciuhr077#9JMKjK^YCS%Ry-(yQhRE}l*9S&h>s zxhGHx7CP@pc+ZfN1{4jq#>P1^1>(b^yr?#`k(Dbr&p0T(SI!c2wf~y;aEc3;sczQ20yp!OELGR$Ra0^eiih(Rf*3 z=sRf!(U6{_*k3Aqzvh{D^G-YE)DCZ^q$xyDl#HNyCJe9fJ}olZr2FUkJLJtJ(eaFh zFV*@ETVU)Z0SvnVAO7fOh6uwb5^YrCU}d=HbQ5y0WYkqAKAeTLONWl(I8cxt=!;j?*Wz&h-N6%Qn$3E8s~Qh6?!k#VL@#Ym2O zDnM`jNU-ud(8R!3uYb{W zh;G7uQ$r{2IR%2|enc<3B<6T*7FuCnW1%>sMPdm|7#jK(_a-bKWjP2=NCxC8NwIBg zKvzd^`I4dtDoq^vagnvw0A^Y})~!jx&pl-*_SCCCHLjKonGn#ucd?3ne$=Lm<3n|Z z(@sOdvgSYv0{XNzsxnp38U_c9MWErVg!^;lnv3X3!o#Nqdp1F71*jZmB~ocSTsgrt zhGDPd{Bk4dR!u&v#_FQYb! ze?MvgKLt6#B@~&k!@X@Yj$M6tf6sNnz#O;9RPlubW5A5E$)u+4osK`tH|n6Yk=GFq zUfH5gGW9wr-vtm*p(=3BF?a;B6g1VB`5O3dlOv!j!P~Xg#pM5t4r$Pf{kpi41lfHx1{;8DFh+B3A+{bF>lY2*z5sp zJh#QKH9PEUa4j$n0xk96c>V<5h*C}tt=scLrM%vbCF+kn}X!IG|*@l+mUH%%VU z!hsjKaGn_5si=h$3~;j`jml-5*Q%N|b&tzSqDDFThv;@X9gh)zE^ZXq=$*kKmLV31 zpzW&UTm+AWI`V9|jFSs$CJtP=e<_Vtk}9ZyN}Hf5NC58=pw!5>z3V0JgYsSb2Jc{7 z>Gi@ zag8L|=bgjYR1NG9Dp)XKytJX{Iq}vOpZ=nmUAY92&*Z_y47)@E+9uc?ZYeiMraFU^ z$92WAjK#8h6h!&DLjy=Dn&r>@=vc1SR9(KHxh&~9_>n`SuwaCuuD-OnmT^8E$H8ga z<+KHgrH8gARyM2kRJWphXb(A5CsYvI9z`>A1A88Jk^_vsk@-=5UNXuo_u1qQ*CV&M z4$JMS6#vH4b%Q+n?!L`)(I)raaZRaMx1w;$eR96I4?Di8o5M6Sc^7UEkR>wTH1>F) z&seCmF8+KB2k!vT0O}$d&wo+Nltf+4Mv@=Bh)c>_6c(0XJbssg`0W^OdU3zzVCdj^ z*{xg2p;e`05jH)&*YGhif~B-BkGD%jTY*jf##}X@UA^ea8qg7z)EPDYU2%`ZnnD=0 zbeM8KaL>E@Ljn3$n%V3qWrib=0^elB+zSrFe83Ft1g2dZ zETctTq~~CqKw%>}ajCleg=$Q5jeeoY{hVjI)1vI7;^YMnSd^kRu4@&e6T;b9_}bR{ z=(n%CDPXUL6AN=nUfiQeE(y2>#`9yG7=|0oA)Dqsfh`jAb}N*LXdf)L@}M;{2HUNe z%dq~n<)dW%@|XpjEm?=sskWym5rR!03d-=GGt67odgBJVO$M}0)<3hlF?{s=B-q!h znc?ERYmXZ*+SsBTKWVOCe@DqloIlths1_DpU`eW5%tIdp<4`( zR+?Zt^c!m;BYAU}Gn-+87A2asyA#C3{g@YC?$-E?71PR4z+0l<=2Rz=x%xX`Y@MQPl7?Lg83E)2gdjpTRh(C|B7y3s2gq!Iw;se6u8pIS$?@HU3kt#Qz2!NoTwnxUhsDT+ zL@2JbuSjjK?=gRkAMmvDC@!4K8-~Nv>-_!k5BhT_`!0UK#$btuPyKN;($Nsgg`tKX z@{P$*axz4PL`R$oR^l$#v$ca2;yb*Z5~FbD3!!Pp=7ya7NyB|%-W5-)6u0?3x86## z>cy&yQf9Cv!$~xWjH20_3c15^b8p&T0o`mE9^n;nk zt?U4*%ffPkspG=GY|=U8AbLCR?3hwL9I*!A_|+H z1erU|Mhqy9kHI(ZD0${oh=9miPibO7ny`iEHd2-UWv!UCL+?42okef!VTN#T2^TJA z)03O*_vTLTn{`kLMyU^W^8Px7KjAm^(0^eB$=R*9x0bWTfC*IJEfn3|Kr)5skH}36 z0_C+3`}lSqBUGU5=vdSg7+ZPgNt3p{?sTC2rh^XMcjygPazUi#@m6)DY>zq}Z`97o z4NNO+XT*4-%ZO&fi&cfcEw>su0qM|Mf@;#H&fgUPZP3sr#VyflRU+cNwayZesu&K~&U~0(VJT${)=4uW$Qee?omP8ZnfzbyOE2MfJF>Uq zRM8!u0VMU?H+^DyOobw=mDRN>w?@u~S10fM^tWrS&b=SNg}7<)+RckqzZD|iE&ygy ze2VkUGl0o+AwRR=o``~ASQAF6&06b|iMnjl)LDZ;(?1vgqdNb~zLDgK6N9D(tIE}t zgB59Nn^*Ldtn&J1>7mP;U$HmKfrMwXiE1P;r89+%Q%Hj7R+Mwsec&w&M`-aofExXo z^~ykc883Q_I`uJkjx)iQ(wa>#qsA>4jM-W5ErEAM0^pgl=R1vO>1aPKkh97Edi#|Z z9HXH&WjQwh+sum7g`Wws?#zN(fc<X>SCm0C^#?bzvRwO}Su2G(=^<%mjN)vNp*r%6V#>~zL2#@?bA9`s$q_In&# zNs7p~)`w{|@aXTtGw{y0N-bY?SB9BFmTCi zRKP+pU7-s@ZOQbC6D|IjJy?*EX zvAKgVj#>KvP$mRsbX@^Z?7Uo%!uQZT27zFyw@=8=y}^h7>vePKv(eEVO%J4<#i3gd zFKLR|yBI8OgLJ;9S`T!EyWIs`TbGgnASh!J6O8ElQe})^c*)pc>)jY3r%?6}a&5KD z;};ly8`M2(N)jg&!H+&Ii_ABLqL`p48`#z+Q?&!%ic;b7V*(@R+BNwDYsY$|e`6$hQKcS=8sw9w*8Uol# zL4LT3pzw}_6Z({E_31FoEgC~E1LJdY8@sT{$SDOKe02}L`Gcj`aZ3Bgy>m!gbIvOQ zxMn>}yk6mESI1YbASC_A28|c&vQrg_ou$ch!+NeSM4K}pKgma?w2%yS5|l1 z{eCjp2B)p+>bB_nN32rjHxc2{jqDR#^ zP}o2U*fDxsZ^CIsvz8Uh2K_RGh^7lf0aDpB{tEcR^A|JrshfS{bR4H7e}IpY)MOyF zCfdGWW~o8WNDO=Xj*0?!Mz=j#<4FvzWY}QlU(z?OH8X_hzWVP5Lb1*f8>CsJn(^MV zbSntM|B3ls!Kkx3Ux-~ONZBb^K$yi)@5R~#b7-`HJZa+b)&yAaiv^IVD{MbU2;zda zSpz7?vaO}SW+&)J@TF2z0Iy>e7y^k61+433_5QJIcRR_@TCo+dZzsuui=s(>CH%y1 z?_84;7%}frPxo7iw5f7QX5`KG?^zp#U>Ba^B#*iw!Lbcfp+^FdKB+32kLVY9lST6j zdWGHr#R0-18@o!S!vGld4aO+(K{7(#I*kfn5X+1^c5UZb$^Bt@R$xa~rQe#1N)WZ*r_KW;a+K z4wkr|Sj@8hUU|DnrntM|zSSSqnm8ECY`ybaO0}bGXEf+oIVlvP#fc;N!W>^i%F5)j zcz^kj+Uuho%yy*o@H|k=UB}$90#HD*G_!tO$$bE3 zJTg+(3XcMOjGr_?Vztj8IWYHjN zb7|e=1;`=n=-&;4>ZSTbM(Gm%Gr5M4ZA8t`RJOtu{E=b^qFJB9ZJXB}C&1REDgqJ< z3ZKMyq?Dyt9Lu3czMiqQWWydGXDa_}0RMCaw=+4U_b|oji6p91Q}=SxH<97#qHR|T zUO>b+twc4_!G3{3pwlZGJ`+V5V_2e9z;ac(AS0s0Di!PcTF^*I#AYP~2Qr$Q_d}ZIEA)EN1@@us-o)7~ znsl7~Ses_ zUbVI2MIFPvLW}HQ&-?0K2n&3$=wiO1`~A)36SZLFmH_;Uc@HrPxCoOs^%ISJaUc?q zDodjfNnnu9Dfb}7#=y#H=4En5^#c^WdBDbL`y)2yCu3;%oBlDiTu=US#%?IebqA(w z**~ljLa>Tpz}1YRzx;Q$L7nG}VEmBm;7T+nSKL_ok9+psXJSD*VA7G5Gmo+g2U-D6 zp?Dc^BQV-n?2{`eoUPMOOBj z^XTxU$6MiBrrg*lPLddi>0B&o8+kFf70m-kX?jQvpdd!)v36gd; z=vKTBl{hLpxIUt*pUJ2fH8PN)s#?=XddmZl52g z?@ERjDoieG!j{{+56b~WDHD1>jWioacOO)Iv3dNPOu|#Ye*fDB*)H?(#0&r5iy8Jf0c2zT|D1`>-k28^iVpi(H*19i;_ki6M9}sv}Q_QxbEWtGLW4Kx}Fpz=tS$s zrHaq7^}A1K-87CK*0K56B6P$mPGRyR7|_ci>i1m(3$i0zWh8MNp0#W^--iTi=Pxuc z@@%d^OV~Risf%_wcVBEq3G(y&!T;}qD&g7ntn0fx>n7$aFW3>T_?XeFhU0!eU4hn} z;;Mbimqx8`b?7F2GF+cHBXaj{ngpCPp=ayhxKCJyDnv(eE~Z#%JB@57yS7==lhZ0? zAq5+qtI%5heP72wp?0YJ7w24y!a7#N zQ@57SNi_T*pU4~7L#Wto9D2iqq%rn^U=;Qw3K9G?GVdaJ~pjaEsAzxQ|#Ei z!=kisOW}aoL?FYwR9WdlO?^CsN*jQ)Esq@tyFRhsLVHH|lq!aDxO%r~PXhVZ8x8v7 zGYYnY*)*fvreCv$UElvGP=isXh+6w;$u4lJA|nYs2AX}}i{YYi+J~S6g^CREWa1>iyPVZ^+{mD>e--4a`xbH2_0h`>z>iyT1BE?s8^yssTJ{^O%Gl1W?JqaF=+X|@KIT!bEe_l zm#Vp!l>ylSE=Ywih?);1*j4`IeDi}J=ijMV0#c(n?CiM|c12k%?Z#kW+}~XQ0@BIO~e3e2|x2U`2aV4QFD@uDI5H#Jhsh#fJLw#UadmVfKXu;0Q&OXJ5WaC!0{LIpuOsfCjTP zMZKARYwRTI(<2$QUYgnQ+WEfsT%~gt_$24& zqoqezkqO80m(*S=AH4XaYJcG-M>PgaR{P_#Rh zud>{<(@&e&?smpg?j5C4hohuq)_SSBqMfB&5P;W7ai|O5z z){7SLf3!0Z&^RGP;!*xp=vLd~CkeMjKcC8Kri$?vNLvhdLtoxJn#; zY~e_)qg*K)<+2r@^P(kRvDxD|G4rBQ3^CE-wm(LQ2xfk7(kyY%{aYlvBnaKV0#PcwYB@9?LJ)ZT%t^o9NDkg|T=m^>E`;O>~f zP~>D_;j)r4ig@jh|54+W3rytV*6(Vi8Li!=!~mGZ0i)WFbUplB2~w|aPXXbOZz4dj zAeuFymH!EQJLfj~ASc2r{WVEET738|A!=vL67(>5t5(di#spv%|Ih(~FO85UF1$)o z7{!4+g76#FPnW?=pU>`jmCx?6YAlh~u%(67X-%0b+QCF1{;LMb!*9<4R zw=0ijH2k3k*_AK^qrBiZ9zs-UcS(J3l?-6BpWwFkfcOZ+n;9}RVm>&c6$CniXhUI8 z9zt~%%UQ+zx{e@Pswh~2vl|80q=6$KylE-u@W7bph_uHG3i z+<630#cTVhc6UnV)BU~@oL!|~ZCyO>dfss$lIhmfJl7yOm4mOp=JFV#XN5P)=CAXp z$C<4}HdQa;skI{l`tmEdg1{H`Wt5sXi&H3^LJWt#Agh0V!2Y)(Mt4=i`D6kf{mxAj z&O}5^{dKwg<2xg>6VC=v2aoQF#`zGAT8Hj-@(zXrjWq#9TDbFvAXO)pC*G143+jd5 z0O?Tggrn=hzE?{)%Xf1f0)I0=yjzC{ad)NGrTdvk%y%w?R`hmpnu&jekoexDv#PgW zs(j{!7JULg2#4|Q=VJLVa_EECx4s%*2K-WIdF9exZjU!C>Hbc5bAl1S|89ccWtdrK zA&yN7mn6Rovd6#39XwX$i{{8uUaT#R^c!v{gY*z67 z)C6&jROWuc_YB7kVqU(jHB;oq(FC$f!~h_2B_yIDWy<~N!+ZZ6lsa{Va)l3?uY%DO z`(FivzX$b2L%5JTJ{&F$8f~EuzRt`)X4w&eXk6r}ht}`UYTXTsB~+jT-$qYmw3c`> zqPV@x86T1RzT9u57lw7To~$AHZMB{0i;d(n5s8#Jm!v3X(bLw${XDnC4{NpeATJQq zt$beJ+%QV*LFct-TXb0B9ThgR{5{pn+hEqrK^PPF!4s@93J|+kuDUzDQ`Qq*9T}Q> zI1h@MP0@4VM^n0?pz|l|WW-DQak)ChV9wVOP69Iv8`AFHSp&x%qDE$ZD{`on{oe~1 zG$&f?_#1sC|I@=a^_!rS9;ER2$>IzyI%q(IN|I%F&F?vU%29*OJ=kNkZ;M z2L{I__!efnojK{`7Uf-|d2HpNS-bGBL#Y*)i{R|x3zg>ANA)=1xoE8BsH zK$Aq8S@GhvrX{r} zxBn~irH?^9V;}k7KlS`(7L?kf5h-L8vmk2|Y6cwkS`e{Ub#zY z*_JG-><2ssS3ZxlJ_=i{xTe~e>pWH>|Jb5j@q^-E5LSi zKd!duuXh9_$F@uW<(7qK>6${W-G-bOIdn_2Fe}X06eAgoyBiD!DUystOMzgn(-#Ci z{5@~;G2;j$KDS7frfJ>&oh6;24R4ecU7p~+yRbau`sW)+(*{bfB3bRy)*VmOW*h^Z z2_f*mr&ud|6*hu)Qb@sP?ia3D4X=!`@Zpic#rE5cBeyp3v2KpZg zKQeMhM&Rg6fegm#oR4JGVysa9W_=pl93=YYriWU?gJg=| zOh($4H}YV=V)KSj^U2k!zbMP>LOv*qa9A&Q+sU4)_aj%t!I%Km&5~#FB7nP%6s&kX z_P+T)Pg!I1U7Y<16xhOdB~;|Cy?byJMiFF;R*VqT0^CWux+BAq6rG)%RF+i&8E8s) zxUR4knV)7rZFIbO=gY9boX`iItsKYmcv*?9l!RGaBa<*ki0*aqM|n+7Dzw+n0UR7< zjjK+{ietL{1ovPhF89>GA^=Bt{S{mmhk#z}w=Yl6>cl>4rR+8}c1-R{kNqw0i=LEi z#5X#h*m>@q;XGC@w29r$oH&9Jr4(rKo~SVC-CUF930kK(3q@&*8NAf;@eebM!Ag%t z&aWb$<8Y>^&Sob43zBx({WVuj!M|a2jla_7+*#}IE3U)-`qunEYff1i{X4>GLh#-^ zJPHD#Q^dj=Yc^w!H9ry361gy#uAv{Qbf`>{ZEY30}9)CB*dEofbe%X?WN^(u|#)K zMDd(9u5Xl8U5v04j=E}6`k7GHWBE`;8Z@DUTVG77mK4)NpU~1SU(r>pOO7QATx?S3 zuT!SA6^T!?e{erYOsbD{0)7tInDjKW;mky%p0V0QU;eMC4&e+7F9QRM`$Tgu+-ZoaSDC?#T?)2Q}smnI-c8oG2;SrR7KWKmS{j zMC%AmGYRFseBUj?XGv*$tSJI0EE{{Su1Q0e-MrA$G$BsHoGJ$NA8PvM%YU>e+iW`; zq}(w2J2#2Z(Trz>z$JtCbqVh{HKOFZJsL>I!Ki^SK#V0jjt8ZGtP!hw;rhRSx}GRX z9p_BdDv&=ZB!Uxt;pT8yQejkt6%x!QbmzzWEUYh*9{5vqjO;CYk7hcKzu&l2Hxh?d z_lpv==(C=7W9W>hoZy7MG&_$nnO=F=@(zl7!b)x9Z_7U9b++Ld`S~6?>J=PN5MuV2 zszn23=cgx`0X_@=)d@`z94kbO$}gU5omj=xBW{eCfuLrV;u5&8olmeuD30nzBXP--e?;s&3vJyGfu*TajiMu zz#PV|pKPxVLv{RhFWmh1A%8;QSYKrz3Ta>qS}(TY6lZOmOKS^yU!WGGwTZB=oZP!^ z$Te^;IC8p&e^zK`zcD7xmPir*c;K8k^hL~dZn#;6 z$M1Ga=Xtqsg50;fB@b6Ld*1S|bB5S#4%Ui5eQYb3)9d z@v_8`zTZJQM|Dq%L%WFQJY8Cq+*JbYA+^Cw35TTpox^~K=#7!MJ?Y=Kg-~^`mA7{f z80ZDoD~X@x%Luo{rR~7D$ykzn?2>FC`a7*tacalrt!Vpf^j~}+)e!W>iP<-m*+E1S zyVE2emV?h!2sXr+HZ`4Q{-tb2OW$K+zrr1K0_xUZTmZ(gAGcSR`RXtN!*Nv2M7%rf zrgpI8mSK-wr;bq3W%UW>daK@r=nV#kvm{hVC_116ANSe4Jh_*6j#Ia2RLNK!+#RZ` zQ*6w4b{C;)pZEVk!h(*%QN>i4u1IYF8(4y`j+L(fD7RJj_7Y(U^Uio8_8DCzQuECQ z76kD6m%T;XfA1;(8OD-*1SO(FG&Fv{bJLq6!rt_HJ;5fl3h?E5Q7xB)xI)X_dmkJ@ z@h712tS%x7qs7@H6;a$WHK_+DW@B5C-hQBMU{+Z1y+qYLznorAXYU)waA2hRjlT*Gc_jog_p5e|rQ$9SF1VrRSFda=~Oy8R*|f!d`U|H11^d&Q(>> z3aw2CE5r+`1Pa5o$rVm$8((IdEc^iYlkOp07?J-s$jCqpz6Bop{-EgEUQ~)VaBQ3h% zPSvpnMbCv|y|a&(H-^bwofK1NcuVxl0|Kh=$7xPGsKx_nEE1 z<+r1HkP?x*8G{_eT*-ivoGPGGoM!E4?oWL_sZ!u`CWmVk&A(D#=iyp7u$_ziWcwqy zW};=03z+^vLq?o77QrR#J9ZYUXhQ2_W<_(ZyDUnzvc2*=M;=-K4|JRa1a2T8oP6nn8V;+}<_r`-q#9BVT! zdJ!jOSWQ#u_NvDQuw;^duh*Pv zMQWWUp3O4s_nh8(ofCCER=Xzb(rre-ekLdIDb1>mcoux7VD8eGoqwEVudTD>avj`3sC+S*O{~G?+fn08sD~+>k<_(ra0XM4^9+ zcoe(~^-5k07yf&<5x{YcH|K{ddg!DFPC^^U$BiA48xwT8!-$4|=kA@odR#S_JRKed z!)+I@e$>Mbk)=ZA7Pfud2Myr9RSu6H+i5ia4!9Mb;cYGk&Gxs_hs}=meLnTiIXcM# zcK2EE=yrIFJNJ?0-Kp{sNcx3=P6G&c?xE=Noe5)3<^&gPC^gZE@=@l*nT??bq_{W4 zwOrQ+AW;~i23%qvr44K?8nXIIrqwG?E6f@2;=(z!MR2gx?c-QuuYYdJO2=0GrY=>B z_0bk+mJDe+B};5PbVUB98LS@3edUAE`gO8s7gJ0lo>(TcN|?H1VWnhWOH+vl^2-DO z38))Lnt!dHGnq!KDIBNNO`pMJo)G}0=Cvn3rmlXSAITN{_xpzk%ZosrMgY)<$bonQ zb^-;LK(m`bwdYxpp?CZ=Rm&{RdO?Lu}rtS|>7mR%k^sa{`8<%qxA0I$iqHR)~v*RIuSAAPqW{m(*H5mNg< zr@lCAvHl^xNr%GP_v`Rl%In8q_&ZX7-zk~CXw|Yx_#&We9#|m(R86MSsu>iE_C9Ld_-#Dg?#Iz1vdQ9Lr{=Rh*egrR2S~GWQZsRFVE18Vq`y-E1Hth_r-KHY!L;$0pJ!2ujCB zBQ<)1jqUgLc^*EW@9!Vj>+HPGxzBxH_jO-aQ?G)lfnL_4l_W&t&l^%$;i^`VLCBb- zIMi|?(t7@H5*df+X2iYCkh&k_W`rn609e60c83*Ub;@rS9=!EW{+ewMGk0Qp2PP+f zLAUq?4SEUEVL3=}QLmN?fvR04uhf&bPi*dFWAA=^!7YrCO2)r&j`L3NFt-f?t&}2W zl7Wpr%H#@Z9F&qodQ(N|?wS{VQj>4NgI&01?2w`1O!@nY#^u_f5Ef9CFDR>;RnoE? zLvX6j`0aE0#V3IyCs~9ti^ELRDaYKDx6PF?LUxc#Ml_3~(l2LQ1^eG!%|wRTSHJ_` z*jL?5-~^S}Q@&cIj%7^-b%EYqi;v}&yl3e_;`1s#k7^YUcs6C-)Ip?nq?<>e9U6?^ zY7fm*l+mGvfSDF5Q~!#s`9J?&N*`r3_m|G?kZZ^pp?nrMS{mtyJCkgI(ALG3=hO>| zDA4`={!`p~cnsbZ8lMond1^>L0fj;?$}kUe^%vL6=?b<`pKSMmb;WQX6AakfR6V@- z2zK+1$~rzck{F1oZGwA-rMbpY8|rJtUV@yDFzm)aQfPAe7a;Fnb+{|hh_#8)_D7-J3Y9DwZc|ogfQfXylwUt)N+p^xb2h@fMs8o^GYxKNqKzx zj_z(k9Ks$RN1y5O`nvfHzk(P%eDUkl7<*9fRhG_7#a8vNi)WW+_CRmwl_-1OW=hSj z%z$*l2(WwQ8@#oVKjo`YCs}1NZKE%ag4PK3!p|>y@r2hLnx}C);1|Ky?L@E3BJOay z10sH?;np^LF*kzS2wlo<1aZ#gJ^{$GQGKqGu(BUM9DWeQsL1ePACYBt$N?7gLja2C zo>^7zT1ULXJxvVZ-f}TL#$!PvG@36tZaaB(p2kco%jM+YZt>CXEC7%hlX9&v5ydVg zSoR?817xx^Q?^2xp?C|OFx#8jgHz2bL&9}&y%)9Jik=K{NeM^&68j-W*nTT8W2(6U z+aUE++xsS)Gu)fW1LsG=uBzAsCcn(40~{xB4G6AO1#L_F;e9nZ5U*@KkH4<}*8xXC z2`X**`pwEaNvTC>4c15#Vh>Yvh~y{Zo-w;2A>qR|D(KB-<&0pk?BF z2`G7{5Nv;IlY&a|>{&Mg3vO8h3O*>YsBUI6?2Mou%~V4o^Rpg-V^MYFpLML!K$tt*QM*oXaFSUL% zvO3-5MuHx9JicF_0Rjwo!KS*A+sm^hOL35D?`LUbfDPIXzEwPk zp|_c1>Yd4X&ZElFn#?X|I2=YTf_VJme!Cs*c?{+YYZ(hf=6a-#(q~V24Lxlfj6!qT zd-fsA*N9GUg(P<*!zru7!b#u7*~tEZIyXY>$G@HuBwZ*%bl;NdhMuD-ifQL8=xf?6XP7g?&e2|=IAosj``+GwzivEd)r~35OC!)L)q%<-n8?!nn$MMQIGUq7M#QVt@~J3_Fkv#N)$W{n5wKn|MqHR z96vY}UX~r>cl!=-8iKR8i3sOp)PX#0RlZhnAJqtb@|haP4cCq&TLmWgd{3V4+HLem zZ@{2$=q4U}e8TqfKLM5nT6qcOQnYab0g9~UyNv5Iv2GUFs^@m7cPOAh3*+1;ZMjU8 z)CuZuI#aPXIp>*#?8ckX8zqODY%CzES0;qp1{5;CJB4|D>IGTc8jJvWmdwf>9hItL`6K0PNsWBl}p!akzL8WR% zHDJNj-DD90Iseo`zYFo(~LXeIxdivu z)6!fIFbsV14E^^_>SR!bT<^FNCU}QtP6l^L4$`S?N0YKy9m7^~Tz?`VOyug@{Dv;I z6zbO+8c+r=ep`bPgxP$o5Frr%@bl)oN7oP@H7bN_gESs%M4)yjO`naAEC|H0PJ~T5 zR;ry6^B;CW2-Rz(b2iKR_5=u*oYq;{2Fhd{ma|LNw{@cEj|KFIMBDEc!&yz53KP5{ zY_9^A%+j}G7X%A@29y7Y{W_O$ppm%+jVral{*(NH$ty1ydb(ebubA`a$-?vvfYh$^ ze3J&{^ZGJ3U{!_yYJ<|3W7;Y!3cs0(bD{7vM{zXIu97moaW8;MNwy3rf0 zcVp2IP?^eL)oKJb)V;HjU~@(Uu=7e#4F03~&;IpW60HH~d(2%pk=)az75?DcL>PcOj*z2~_b8U08bG%s7GhmLzn(1;~Ou#WD5v-8Jf)VxLs#=yO1_B63R0uBDMcHelA-NAA$fH`+} z>GS#ImnBmF^ddmGL!l4s55jzuRNJpB^)bJ%XBK6#_&VZu&(-PdLjM}y)@@x}1P|bd z==bSqwufRKoXUS-dKEU_u%E$r=TLbXj8PT~x_~Ub${qLqKmWu=kfCxOCL(-(%X>al z@w8Pc*IZj=>)R&lZt!M%m;h47uq6wcmjbp{Y-R4zGZpWjn^1U!G`X>@4_q72m! zS^88NYRWe`MZ$zBACG%}Sn_lrFEo+;mP9k*ulmqaXZ?ZwmWF{=E>-~a6_vjn0%39z zhd8``ujTK{ffo9n07le4mUM_nC==ur|Nq$y7O3B2%qP~6%W1^X$0HHOOBNhhe0-KC zHf$x+4lf@_$fs%t?p1qqccl3y*Il}|!%&J7@m9&qsAUTy-xwcVQ$MA~ngwfBMO;fT#-*`W7Al0UOS2Bcd;KuWOu0 z+T?>}@9Ns*vC-UfZ7%T)f#gz0w-o;KzNlV5kY~;>ia|XOig{#o{tu*V3=? zm1$wVbUPL8+2Pnm%|UHWeoyZqcvjDU&A87xCi(9PjQS%~cHjK2VT8X?B72Qn_+zp* zX_ueoua<#lkBJcXV07!-TF*OeXl>otfU^#2vY*LvMb|d&^)TWJ*HtdwOB}h)n+^dd zM3Om$IZT2bA0)2P)hrxbXt4-kw<@;(gKXBOfSm~&LuMcbXgy9XjyaSW8vp(4U!+gx zHBIT{7R#%I8N;zlsh{JanN4c@%U-f*#6^T-=!drHOXz!SJ+?n8uA9~n*H))N$XU`g)@!UGr6aqCKeL9 z$fvZ=X>HbnRR1P0FwS*mO4?N)7k*yOQg%O}d<)DKu(j~A-FqQC;L2Xgt+MZHuOG*? zJu|9aq4~>BOcGKM zI*g1~?N!nhSZR>lP6;OI8b`236*wdPsf(&=(c7(q7*WyNkTuOa{GOqz8l5}fz-Cx5 z+epNd?g06OkJiq0rKRj%GwCVcU;Fj60N3pR8CEICOH~M}dI`H-VHNYHrss7#HHQwE zpZc+{Tf!(Yca=;&lJ>dLO););V=%G!Avqye* znTc(o+vl8EZcI|&v&RsJHCI|7nU)^H$?)?jfRJMZJL2Mxtatl*_x`R604tPmo`H&x z2o5siu-8#OVEhmvx6W%kTTg3vHflEqb6@PT&-Jb#IF)Xy;p1cJh#WZ*OSl#b8BIP2 ziHN3hBWoiN8=9lwDbmsLrxxb@eq7jK@LuD>)WMYUP6=r%vWFN!pJ~?pv;w&mi&JlEp;5*5-AJ6d?1O zgv=#x_X<&w)SXLB1myg(Sb6k=rn!9Iiu-dJ0b{1fjWhwri~J&7$x-(#9v!>l^arD& z|7Ds#D$cQ%GlNS0Nqgz-ydJvx%~s><71@@^MoGs8-g$L;Ss$$OQ$3foH<>W2(vC2?eEEeDoNu~DMy2Z;Wzd1gNbxpbz z@Y%yZ+*SqH(l1OXwbkEBW*;{Rg9xR)ElVKHRG@kU7!*DN2w!8W*YNm&)GW?M@KguN zs)MRcvM&8|xJ&9=*Cb4TZbCQA=1yr(RLSm76VOe6R^!d3Ybnu<28k4GU%(CX`J+th zw~j*`upcip&N6Y^;&#Qu?qZ51SyGrnB~H$6?pyBWd|Bd7J^UTHMH9>nmSrNHl3AZmqB3p&x+?bZ)(VU z6UM3YjlgoSIST{ur)KfJ&4L-qh!&OY=Xg>;+;%^RHH-R2_J<;cS~^uzM<7r8g?2h5E0BD48f84OS`KQXocu6%?wYUnmQ{)m4HqhR0ZvJg>vpc zem0YDw=*3i4}Z|);|If4@Ehe+UF_!i99%@v@|b;&qkUpjvm!ABF(E(DIWOcF_3@3|HbaJp#9lZeQJgvDL<-}^>d=IAbbHIId*{h4*%ACAJwmAgnG9i+9D`UG;0qy-En=UG;#th#hv?c+3+AAm?Cjn#-B02Bb*By% zAFNaTSDNG5YBL_u7BdDVve&rY#CKt6|D(e#WBWoE=>#rJJ9KZ8;6baVv0;2YW!F^`!%ueSp_8wf?6x`s`r)J z)39?*!=I|o8~rAtp2UODX*OIamRpJbarp+1L5bq!r)@nKSb66Umn@G?lFmzE z*vwlx#_CkdilK2`mX+xWYiKZKNrXWwQ~Il+?=|{O{ObhdbAV-%YSsL63^p$^7ZcY- z1>39+ox9j{sw?^+e(J9^z=MtK5hdMVkX}#XiYT5jv2I^sxz|Wvtktah-Mvh^R8fn# zqI_5!&;$q(gPn=>WhQZLiYdr^9~u>UEPP0O{jhd_n4XbX zNY^X73nQ*YxGs!+O$&)Sf4*|SjzPt{h<}^2 zPF8CxEC)VG!pewLWyB47=$p6-5T$t@0zpLE2VRTJV3_(*F-OB=0APB=N+ilXTIHWK zShl#DtQs_F%TWThXr9FbL3agEkyqUBKb0a5f0{gs`!SgFAc-kZhLYcTU<8a??sG+L zBtG%^!o(|gOO7hGN9s!skW5FX9@L8)pE%e{fzyY`eXBTYv2_h=e51pFl_?D`OR4@5 znMN~4s$rWs?>0eEX^s5t_au|ahA@-8qbVYx<(h5A)~s-!zbEPO$WRrCs6onZ;uQb0 zUc-e+|ouAG=sX!8(9^wz^68Y*bPI8D}0GgSX1NZuI^y{=A+A`z+$Pk2d-8ROQ#l zF{p1MV$?SUBkENHaI`#VhXINJ#9p-`^}x@gr(X!lHfbo&MGU~A`i*1xj@{bjoe#=1 zB7an0{tQQ%q1proyzv=nZ&3kyF(I1kdO^vV2t}7e*NLJ{ZRa~D;$J=Z!kO7xBr^Vs zlBdS{0+rFcJS9foI$+Pmg{na`UbSI(z}nKt_5RiJ#iP>#LgxNqSL@0_JF(on0z~C; ztIqW%#jeAKNI4OMFHGC3x2z~e*~)$9NKxvu7`b2{(R!-sWuAtCV~(V~)&fs9sD2Hy zS(JfqzujB;vaf+~>#P9d^myo>(MyLX`G!76I1$!HTXxF>+q`+|7~6eC!t&$bkh{lKik26t{YbYE8A40fF+uD=(4wbFdx{_;Ny`Vq zKQ0uyf?~naUMG8jn%--*%f4i7X?Eh-q9m4$prG6vOZ2EL1QYGXa2BB8RWuNCbf(on z>xk92HdM`5RcrE-${O(kSz`Y1C$B!~8mE}Ve9~omaGPT*`QEj83fj=;)n3x)9Vn(r zuwF@dRDuqbicBJrk>sBfAwckTlW2s^?%HUCsux==kJ6>U5M-ZGjVa0b&<0p&FSyK5 z`#}UF1x1`u73*m^ar|jQlT%wwST!E$SCtUqpI5LzQ1r$eshB|p-dKX!s^#rc8Dvn&qHryEer zKyE!jg|rvBjYIo8bBB{PK_@1LC&i%EbxOe_BagBUA&vuI}UmIi(tNqMwZ7gW$mp?(+HJs|doh<@kdq0eyL!%`p>C1 z3|g!=d{11tt&ODgte=`>e0k3WrDrXW5;#|W*;BNWL+qi=hh|&X+$TkitCQqzKHj9c z25D?l#?-+ldEw0%#?}MJHB<3pSBPM zR#fY424%vY=>GjPWlT3Tw3OC*<#+Gm?@g2?m#f>;U45EwKWzV?9R)Yons|pVhB@Fr zf0zi@4^{p43>3}u}RW|T#v%=IlE=+Yqht1Ih2E199) z>>b+}MJUfpn!~@PsHBNdR=4fgV@Dga`ZS;SQIdIPHm#nmQipKYjZyoHE;+g=eWKHT zjp?CX!HCWXn2bvRmhsXA8C?MGct(kjZ)h^geV4%F1^Xi-`u+_?Np9%lJcJ5XVmn#K z&#x{v$$axAef?ZV@$lp~O)fSqwnST|`L^X_yGuH#VXUva88P{%Gkz;9z&4Dbpd^0U zP-(}1Ux=tSeZaWMeX z+-ynEqK)or3CO$&kMrgZrqu;0ljs#@tW~|fCfD7WAND)$>Y>yvT-_tVq)oX$V4s-! zeT#-;o)##25fLdqGd5R&nhk{@)^CVl&>_2jnhFkZ&2_!>C{SlX{0R(TQ#=S_p zGu$t(A;%cUINyk(_lbWSLw|iT7->pL&`lTNTXaDq+iMTLy_SeMvvsVz>)bw|F`Yc# z7fvF?#)*otS5UY7eytA$uHB5+dojOa*^!@uvJ$74VWj_%E~F4Ua=u9hS8E68i2(Tf z0^cC_L|s}1F9Mt5gF_znO0lKAJt|W-HQ!`)H@1T40`RKi2X^XJhTg2zWmuUwGy#Uv zLwit$a)G{Ay1fA)ca6ZD2; zX&+LzqVr}+ztw9@M$-e&evcC5t9c6((#A!g#5vS|>K*OK@Gw&-g6`CZPe=11pj#xF z&A_tGX+~Q#>?09rdUtgGalzWZcExHxTOYuap%4c7xUc~l4|WSI>)<#J8xah1VX#NJdIUT#;5+pS$Ht2=T6jv!k@WjSLcl%%8*fIITi$Dq;Mx-iO^M59$GPKZ9 zT?a&XLZ{qWY(Qrb0qPK)B=nLVr+?oSV=&b$94<&@MJR?|3zxL0NLyEos6DRvd}o;5q90f zIauIw8oABYN0r~)kvcoVa{?ua(gaP?v_svF=%N@tVcch`49RuwLZ%GCLQm%n9WX5P z{AGc^zYI6#6LZAIF5mDxcGjG(^30V6VnZK+MK9l_61J~&Lkvhcg%Mn=DPOvDAp9dW z`v-}jSmb-r3w0~`__#@^;uTQHv&&SL)lie#HrQ}i4q7JCI`oF_evK&X_3L*Oa+qbc z)*3a!ppQdw`4l9-rlOV6VK84cgIlOd4d|1DV9ahDasC{7SvH2KzblaX_qulM_4T`$ zag)@wMnjh8mVv_hjh)M;hx$Ljx%rblc;x=X_3zyqt6SdiQ+ve@^Ig%EQa`Lrc}nXk zqc@UwI!0IfX?rqRi9J;hra&0ei7Tjez)%BpM z2Ma&_Nba)Zwc4S^{}R*Hz&U9y`@7-w^+FhqfPuu?t9jtudPSWv7y)co!D(9V!7TV1}XXCri?>KX*H@=Q}Beu+4 zkM+*Y+^> zw@SPc!A&LFv0i_|cD~&eM^bE{j3e0oPGc#1(Bl=SO$UEiudg*p!pSKtbkl@==2e^S z*8O9zF8^CSOM?bDfzNjZUt4qZP$tq#WjT(ET$E_UnDTg>V!WSVKFcW~VYgI9y4_Wo zT-j(J-c028=q_H`Cg*SiGYo(gNy*sD;zelDZX9eHWYkUc?Rc;CWX(Ypn4|t8lLF2= zUrg-=L<7g+^R?o`i1XPoLi#NuLqWa*9IV%3P|vbX#4o@2WD05tG|Hy|?Tgc-M?q_A zCcdTIQ&niB7XHh9dbFYkrlEJ4wfVE+-MjpfuAE*~q5(TIalZw!^jLs(q@R{NbDsek zH0oK<#;KrTuRB~uW3Wj|7XK&;AwVZ0jw~yxaJ6$pa!f`pkh)_YA^E1c;5^Y&5_U!7 zkC@jv&W z2vJUd1-Lg$!j3ugOZFf=v|X?{m*FE{xB)!MhVFEl=QQJ~WIn<&E{{8c<>3o9p9i~w zkBJYpogX}(r5s9eYKC)N1TfN=2E28FvDGH)>}rrSJ#Fx+=e`TAI6yRi<9YOz_;oSq znMLwg1tCBEWyj}ifPOiJv?8qZwguwhdoi8|BZS|Ko zHg@@g)E|v%q#fSOi|D2MHrRbaiC|s?yH?>^2LRWyvh2* zdr4`W&EKC)40)#`wEa_#h<%Pcn8k`5i=*pL5K{NO5Kyvrl+c5cSr;+sb85~idUuVOROD16 zDb$hCOTiyrJUzfZk9n(g#q!WcZ#?dVOA+5wl8oNsI|bv^KOqy65Fu=8&zKNBHJ`eW znhR_!%?4FnrDz(piQ;zXWYG``OO8rSw(-{@0%D0x_E#f~#ZpUeg58ZQk4UePD&##wax7uokQ6u5Q!^`DXU+ z-_Ya)BUiWt6jNCys$qa=-*1|;Ev9EAMq_u<2hm;Phs7lUJ@w9^0?Fw>3cl6n^8;+) zn_WQ&4pbP;0Tuh`f#y};U_=JXPmn{%wsL{@$uuoc{a5I*s{OppUOCPpqVu_#*cqad z^0E?@y@E@Ydp*2n9huM?WS0pcQyP?aBe&w$ngk~+-ra=7WrmNPn6-jF$q+G>)YxY0 zaL@W@p+9M1jl1ZptLW58JW{m)R(6^hXlTxeIp*;BabtQOx+Dnb*wm;c_NDEN`^jvv zq2OGcP|RiSv4dwTWoaU|pd2G#1tmur(~WO-TMz-F5n118x?_OO0I`YLaLLVlZheW- ztMk@87y9pf;;*XnjyOH!vRYXc8g2KY#a+o9A4!_@-Oh)*TK=Ueym zMlLbrO2vX6%!qeM!&*o8PUj^Joan3tsuibJfMSXgm)Xog z5<=m`AHw2!@FW;Up_RsCq`%y$B3M4HOdPMCIV_@{4(p$IaFz8>$vSD%pn6XaXoOrB zhG2ha;KBAGuVT?@|9i@@4>RC2ADycH6^6>zgcj{FpISMP(#>|kim2v_(K}3rSz7{J zl=?;g=~@>y;GXeNiB#4tATCpXZ_oY2 z0rDV8i9idmLn0q|YN-m@0p*^bYx>0er_xil=Zw-~jMR^o{GBf5@=o9L+X4!Y7&cY~68_Fmd;}+De^!~H zo(Z8`axC{tiUn|bz{HAV*L!crzt6dRqcndef3{`Z>`L_UArts%@%w z_$C=5&*e=eEIKrS1jWV6e_sh52n%Eb9;XT^0f}0#_N<&o3q22%hMBtSpZt5hq@elP zDN?0R8@UcM8E72rmxI|hr<<8W2<)^IZ7VWebkj9{tkCO(rLATcF5n59;f1l6>Y-<` zefJ2UzQX70;8ZPg(RUxBCF*%W0;B zm^5$@yf5+b7gnoz^|9x+RoA`n+g!(hX-OCWK{3ZeB5Edt0o(=ok4OF$)?=K#|9FAQB(9 zWqNJ>As9yOm~Y#^7ZPB@g?=}?gX=QiP^yT6mQXR9PDg2%Y zfQ@Lfn)z8{Qhjbj=8Cw;NXOeNVsVm74gc&jm2-vyr_W|Z3-Ut_E6 z|AC%BnM^MAv70i7%xGV`UPe^*1F*>{QcIml2Q zE;vilMw4_MG}8ziSt%p9%|Cr{@ZDSe(|=}^`|Z#Cd?0`zhKS6K7iw}a@_cRuu z#POV7ff$Golswx}lNAd2{b1AnGxRF@U!uwt_QPWOJ0c z(~vMo3}hQ-_y}sbioE|($C&9}ABS--zj8;E)t4NpEEAv%lqqnsl6}#Pj?x=F1DI<2 zx^ktR;|p@<8Il!FmpNx)!Gd7IL?CbKST6?0pcH4uGYwGOkQbeF7{A{kQx#56(jd_n zL4202H2-WHH7U=utZH{xPbc z>^!e=au1RNa>B-6BSC?S@<|&{i*a_MK62e*p$Ugyyu!8Ar45A&AEV4l%2skgGED$P z@g`Be2uRso3`QHl*;d4c$S5yn-Ug-$fyK-n8B-d}Le&v8Gf|0pwWj}2ry09R!-pqcZrA4L*0C#@_ zdK}N#mp=OCU=%wjISESu?LP}2w_zKBI1<70#ae}~^>n=XMu~%!V&?P{$4iY~>Ne|3nTsO%Cn@}&!yuiLYUdA1B6jlw z_9zP`Fw7d34RXCgSIC%_ttI91vFs+AkV5~@!k@H`PLT-o?gb5P>k=t8!h1AzezaHN!hpGxfzB1ZH;pomr>5fGtT$bspeVH|X z+<`Vqq6zw*p9?ke)sHKl|5gjo+Eh}69QBD|=a`h9r!D(FGs>69DqWuZ3)C6-%T1)) z+_CMY14bY3gt4N20!8QOPaG1XmQ)Pz2Dkp1;0uRu^o>zMobqHvKAEheNtv@HH4`=8 zFEf|d)N^LkZjCEOTkdXh;BGATZ83h~+%uy)2TRQs^GR){E_U?(s5*^?!tnl+X?5ZJ z-iPtRbE$FZ8+dS}#PP#gO{#npX_%A7@P$Qnczy`&`Dr%hYg%jRZ85cRQppVkxj=Zk zCOY0Z9xmuY=nxf6dT4bnjT=EQNPY{)G>{V~OP8(t6R!kSk-QzAz)!gu^`3fcH(SuxznUGbkMX}Yo*|eVw!8!`ehe*Rb`QBV5q`s%K1~>T z(g<2!Hv31x>pCKhm|;a&p_uO$pQ?V8y&`_%)$_`;Z_HpXO@(3M$~||S-qyR%SE6@c zU@sD5xqQt(V(*4B z^~6Z89r3=Xye+pIKO{}Lov?@&g=vI8xFq=qg(MUAa^V{w9p>1s*xRq#kH?%>OpKI| zXmJVx(8y@4`Ife6;H*+>zRMxG^{aQfG_KCO8C2|4#lp2l=Vo__URDeAj8dd;-!SVJ z5?pKQ<=+4-nyT+jygF87Z>YMrh0R%#a?ABRtGcCuqMg6**0WkAVHl#UhiyKCb@5uH z=N=UfgCYyMF<;?CSaOdL8h7K>1Vyy`%jZc@(m+brAcUe#~}@!4ULdGNp}S zv`5ZE?iJT9=^WkJlX?zqj>*D<`i6zJY$qJd$vLHyzr(QJ9;=g-W|Jmu;$$VMWD`pw zS5Ik22DzdmwW4fT-8!T(5+Y(uR}S|#qTR%_WWM?L)1uJCZ)=x4rAuHhv-`u*`YfAX zL|axv$EM-}Dw9`)jq!)oYKT$axR0dsf2}3Qqc|Cv{G=EeNt%)Xy#bD+ayDVxl9M%1EcE=GqDehzaElb^Ff1Xrt7IO*O`3rxMyEXt5+ zxQ9pip4?p99_gS@TzVal)zuXLn4$@qVGX^5S74RnSrBPoE1vFCv}V1muL9lIO8Q&x z!!_&&HH|Fq1>XoP&-?CFkaIE5;!_KBRTDo!?4H`?&g~ann3BQ&l5^q#x*#7feW!VO zHsYA9QO!}u-|P`8=wj{#dL_qu^GIr?ZIfW6i;6nMy@H-4{gns-sb0WV3e5rg{&FeE z<+`U(VC@H*z0>(t*dTuL(#!AB@yZB(Ml~J4{IK3=i|iu?FZRtU6&Y|rU!ttU@lsBT zY3~H^1%ZEer5z*=`D?5$#6*K&DZ@qx023li%4J0-X7eJ!rMjbgQyIhd6Z>{ONE9x?XBt@>>s`d+e`j4ZZ|JA zg|%l1zY@it+x?o?eD%uV(3{!EwAn0Xdie?9^m=3q@AB`wZTmp`b9Vrn!Vg;2_I1GB z30$Fnn002Q3?UZpml9S?&eTx2`=`dKgB4;)!H?hzl!+RI>Dds#Q3OE`+_=wIe#qM;!i(Ff22@*VKH++a@+%38B*o6~tOp5(=Rde_2r|Kf?A`L`>qSXi<67aaAYEn=sQ>_v+)wCqei{#+L=0 z^j^)jBTD&@>NR5-BA23>dAkNc-NDp7+$Qh-K2bQr<}ZDOy@t3waa6ACcEOW1GUHD+3#@4+QT1;uAr%^uL|}8VU7x zAkJ-qK~<=0G10G`d^$=i+HNt=Dt;PFuE4`?C4`<3pF0Go^b?G@xl` zkQ7)BT;sG1YLYXf=#Nc}BkXM1n@#fM{znaeNe^q(JJCau(hZn!5~gN8 zLiQ~DXeuhL{}e>r8>cJik#F#DNHiRb-}dy4mc-QVE-i-yz;_x2x0R7Eu8!SXYndu_ z)X!O(&ui45z6@y$lNm`F5s7vu3F9n>JFH}d^hyjS9|IR7p+%;jS{=2Q1B#ML)B8}I z+{J>|x(~*>A{7QNA5IwChd%OV_prW-GSWk#8$=7}aHH5z6MM@IX$a0!Wsq*@$I+LD zN8N!n-g?=+)_l6fV<@bX%8n)KgN2@u1A7L~EZ(-wYN)i>ZjJ#*{-*4;j(pEQV`g6S z8vEZpP6bdnCw$)Zw=T7PasvX5kZzj{dd3fxa{@87A9cfS&8hFI6C|Eu!eC~F60%fE zbBx^E)?;X9QwD6-M!n_R>Nl>u{1EgQvnP$OS7xYm{5Yt-@2&0;_6n1 z7Wi>+R({9g?YW~he@OtWV%7>Ycy|-vZt0|mt!6McS8F?@BYkHV8cO^LEb|krHH%sp zRlILIJ|1*?R&gRKpWp=c#bGDi)1UeBdIm8qbr1U7*mHdAP2=GWPBM(`L++l21*c6d zDCN`TuNGDtnej9Mm^x{^&2F|FG|sc!o>O+egCYgp$a_bl`G+vh5{YI55z@%hhR}oCQ*6BW2ZaMQjW))4Gfq=sb#DO=-Cpv}pp&NX-aJa^>;UI4^ z;LA&lKS9vBf_pd&LHjT{>fVZQ-6S=plhk%y-#z50wiBAsyvXqQWJ#dR8K`vRm92=8 z>Keg`+wOlfi#JWg7(CKjO+(kz;u*j8l)ZVzxc53RZ+UU6E7FZohGvOAeBx?6AjbH# zV;>KiZ4y40d`vn@l!Rbop!bL=Q=wk034nS!yuTfA#q-h}E8PSB#WAi+b{uvakx z50w<(cUheMlTtw@MHGKx@wtgyw#)Hu(EmFHj=DhIlvd763yF)cX-{@9>r0PBudzek zYXB73q>5^m9aVJ>?au+2M%F}A?ah!SoeL9qMNTIN#I*- zIudMP#7B%)=GU|nh{_mAe$Yc`ZSo);F!pv<30hwe3g`vd;+`zWFas#QOX~oZvUTg1 z@=+MlakvjBwp#xZ`zki)r1*fcKACX>NI_Z)ft#GVXgNezFyZ(hIm`c^?8%ZBvf2BpYx|3>SS{CvlSCz;2>*S}fQK~c7n zp{!rFpVj}XvS#)O1FErK1^u^L7PB@UHf9}OT#nE@RDwd$vz(|PU|5GGc<-^cOv4;b z83t>x8@vqF)2&K8WCH>T?B~ZCUfrDVy%l6f#?muxyng2`SgrYl1!aIK&OE_4JX4@n z+It@qU6U!gr*f^k=i*+O?Jv8?cN@8()zCnE+1WWv6z7y_0_)$a@c$EryZ z#mPcjzt&uI?kV|`75c47dzbE24LzOQbieFGq;UoudJ74s4O~A@o1$n#G=U-(c+;jG z@a^46L8otdUxp)WdbVhO+GQHSKUAIs{$qyb7r}7W<#Oqjn&-mMvzyqdAEkUOexgeO z#+giCHnSBu^*4s`+6{OJCJhy6OAnm$0P3rbfV)c=)0aLqB_i)ks7c%?@f9bLJLchW z>gEx}B&B`_E0qTHBj$}$q>t(?D0HT6>19A6>Y^|(ewWJ^HF5{9lzDCAE7W7nVtzoh zY-?MaR5{#Ud-v42a4TgioW>$tg<45>#t%{^_Oj!V=kCY0b%V2;g7`+6r~=l#*NSW* zCEQK)hGc>%bM80^?3ow=ma7Zz3jeDP7!{&}n@cyHnw5;MtcV25@U+Dh+Ox?4q85-2 zju6?AlUv0ADgilK@QAzYi-TA}CHZf!Hjh`hG`+F3%c&a%gbfc#2!(I|?z=hsQK(Eu zN8MdiZ(d3O()zp4Itkc1$srExkY>|RmyfArD5(|YFo{#XMceDHudFBA0XwSlP$3`~ z#3>V7z7_-h5l5F(Miv^`qVZ#us`vIF{>?bam?(T~Ls$bhWnHs#-Dh8d=b5c7PCX5aH9l671~IQL+gAs^{+=q&2*^AvVuOl2 zuW_fguUqW4(R%OKxVQN&Fq;fo9+lzYqA8UO-&+pRaT|l9-s#6X@APl7gsLZ*L5)us zMk5rdq>X4r;a5uso_Ko+2+CEq<(Fi_7lJC**0jp|RFv92q*(UO@lsJ3%gK!jlH8v! zEM`Hfh?o=NG#(9{finkn)a@_(HyfK-cdqr+ilBB+vqNTf#Q^`;CLjKni~Kszk}!GuY*7X=vQ>c=sal6y?JBOTIWHB>oPq69+=&`Dr=`o#;EGj zIbSHEAj-h_tJ1x&TMGIBiJbTX=|4Prv1QIdr6~muxF@kaokCp)ACSXodl`cvxmYnE zcLUh46Ko8dhgdF5yOUi7_23vi0clm;y3QxPl*44cr2w~iR6Xbo*zy0EIul2z+W-BZ z8Iy<@RFtwWWl8j82{XtpX|u0cl5F9zFEdIZJE5|*DB0KSTe2(4zK<=+Hny3;Ea!K8 zp2ze3{Rd~}ocq4t_xpWauWRKCC}m?hy7_bHm8Dwq((dfJ`6AYPq*D};O8&jZ<85nI z4z_hu#&DHXvxwz?UBr4%|AE=;V*0liXsikC0R~hZq&!P$W~$fgZ)G@wb1;6pt>)}% z@Sbds&#+T+g-fnxQ9Dm1u|KrpGCTb`1cz|Qgq)P@^o_sQ$3&PRJ#jVUfc(|T-E%?q zS=q(EE+ZHcp3i^i`+-AjRyiLa{FcUV)=S|?Zm5eW3(S|(HFl2l@op0TmWVcE$PMXI z@2TH0Vc%k{Z-KmFn>fbz7hQ!#NM6BF-v248dSDBOL6$h#)Iple@+-Iq0 zFg}3~>Hw~H!BwX4)LZgD`ordaL1a0+FOA%kpi=N<`}#)yGL0%F1?l5BfQ^9jUxgQ8 zH;1=A@b;cLirqLL5h*I>Fk#ZCWvaO$OsWt^@cpF@ndPYvhw>K!Amq2F4c(RMByYQ> za8W)+g#7fj%l{nFCifAP1)G$0&>k25W6vNXnzBfba?fOP zXqBZAA?eXbe+?)IS0XJq>m30eJ=eQRJBY4%?y%k$Kr}*{m~z5B)w`4O27RW6=sHjS zNHGRR3I!;+xcP1SPeqlF3oed}!TriwefM^gxy?BNBt7J+kGOjtt_?i+eBt-p;o6H8 z1WdQUY)931oAUB^%l<|-B{RY_0Zs)NpZaLQT+dw^v?qQ#0k|AtaPH_fEBaZekI+1R z{Eg+X{uu^H&Swm5glDGq-ED!nr-Tc-lbsW-h9hoAVNx60Jo7R^8qmj2oOha;xJe8X z5fIh@7=g74nB^hV2ughGOazZAuL%XjgH+DUPIwShsWd>>kOFX%@OS}wS;R4qfug{Q z{;Iv;(^DYZRljvH3*K5m-r`jW{hG=mDYZ8`hzO_H$RQUAF>y&J8^a0$DTwy?_KE*VV{*u8p5GhtSR>hc`P9(83LP*(V1+8x;~GKb2vL^ z>k45`EMQHZyDery8R{WTySaM%k5z8LRf&RJ(XR<;VHR~5)WAVNmPcsMA%V*c$_b`U4A=(&llis!yOE!OO*xNHJEC=v$LudQdiiHd2EVvo zp4_Y=&%yDQbEzKWJ$J)m1lI551fBFa(})v6#p@}M?Qc;Gv|?*}7|%Glm#If=1dC}* zE-pJr+;VtdjTT=)3ji%o+_f}>vKrs1C+Q7p6F&X3A}<9au6tBrzFlCdP54o%TjzTY zh7AJzj+s1Gac`(v$=2OEI-`1Xr^9=#zUV1jqHd)r@|?F3{7sC&+-O~P^ybF_yhH7K zBo|+aOp!6*dRiKYq6o9rHySl!b)Ew3C(1lS38KSpyh@R>wXw~44RYd+4pc3`52CKA zD!xPIWO#Ptea@*29m+GB)dZT+_tMVZ?0rlbr>-yni^a!J!N zD=Ta{QCDU(W%ri1Wdi6**B1^_ObEKb%qufpnU#8Rrm;}MO|Pit>inaleomP%@1&!# zg7h=~Hl+6wW#heTdL}c^wN^j~`<|||+Vm8-xnC(H?G(zL#q+PNyEaB8nl=3?xlY*a z>uYOb_>rd0IadD;aR3h(?CT@Xm(wPc72+6mIT2Wp=2*9{hkHdZ|5Z6nLRm}6X;`q_ zZ2d4{_oHltB{d-8Gi%$HdhR;ZFbQN?bNQwS1=ENc8NFqp6n9P!EtfSFEBMofM%~uG zsm&>!&T1o0fA_~1FzYdvd-cD$tN-urjYO2F?CG>fOoFAOX7re4wP?&w-i7HA-xq6F zc>qf`ATx05a|0TDY)iZI?r0Y>zg`4cYCD0okkqakvXi(3r+z>@F*b7P@ot>2#1I?x zsgFV-)XJ3hyXGT!+<@Jc$9}vL-Av3>HD$A%)vx<#rWRiO9^@pI7@Uc%YkgbhM72e!+ZQq;jvkrXpyw-OJcdP&wv{EKN;f_8$uHz z$M~2}1V1loS}&4xE^J75OU>U@zA>>6QhnWZkFj`jz0~C||+%F7faG+e&RvR9c7ge2-wZzHm~poydU@ohMt7M3J&DGumt`gQ67-BAe& zGDPy1vHnKBdVDS9iNZHhM}3C99oj6go6eEE_nww22DqD&-D+F6q_)uLLdl}#Yk}3^ z_klPn2u=RislQVsuL(5Uxlg?0PThR;iudpT!?t!+dUFf1UO&2X%oo$QRUg2z<&6wr0Qb=O<=`~4BO zhcOoGb^?t~!Du3RiI7R&7=BB3N6n{tS^*hHjZPj;I!YK0&Zh{Eb816vb|w318gFk< zH|Y89HlyNOJyKBiuTbp$Y)KczG22EonN94?=U4Hy=b2Ty0M2_S1};Zqo5frkR|Vxj zwjZm%-`?8rKL~K>Bvo{xNqgaSm4pUhPB}M~+V}D9#L9yww?F?=>)VtfBR1b_loGtP zhYR9De@xihp7H+D4}L99&uI!p*3cVx6sEz7IrIcbxvSL!9~D&~Z8 zp^yWEmjLau2u%bLZ}+yBeB&wXhgDf@<<;cgk7@s_M9nncI731+^g74@QJt)SAGfiR za`cu~|1KyMb--7#xRC?23fJ}~yp%lxq^#KGq69O<93gYjuE81lH^Q*_&Np~FzLMLE zMtDq5k#f|_eM9!W(!nzbX~L|psZEF9_PMLV&vrJ!;FMBOlUPa-1U5FifcL-~`=oOZ zujlnwX!zS25efUC&LY&oAp zltPI_-yK5vdbv_2uU3BLX06)aui;}>G5l7B-t)eRc16WqMJQ=U*P5sUYDrT7ZZQ;? z`3kH<9%9$E+Yo8?ioBumKfiO46($luj7!~mt5_+knVu#v1Nkg;U@EOmfkL>>kh}tJ zdK)W&#;Nkc$R$dQ_2s zLlDNYgeC}-oOt68C}DQhxd6hpw-ugM@?Eyx;b6S6S{RiF-kFfv`T z_HDX}MmX01b{ub-B#&erAkSED46Yn7Xx>{5210f;<=D^LK^NHGl;wWg!Co{6-vbcg z4N69KD*yTYpFRt8SA>uXNhaT;7zpy@+z!b2&GkAg@lCw&v7Rs>tt3_qh@UYqr7orJ zLa>%pYjknS#+`~YK(OstJ51S~J+v_m!}hk)eoVfuEeR} zo}v;jICD3)n#KN7Vkh5f6g*Rj_UeUeV|1ZT+qS3@ynv?R zou)R|LgD^drHfenvd=mOLL1g`s1bR@9_L%$`n8d&7giWFb@c!(cu;RN`!Tf2-;!AO zj<}Q75%j0g^+{y&L75zQP$ZAxQh9J)k$?76r zda=#$Hr16Incwh#^+V)E*u#2hhu%K3FSQv7aZ9)7AFq8?<}u#8I{d$G2E@qK!RMe; zOmXOdxvwP7sfH#}Vj%ILwUWAnPQ#UXKd{K-j%Dxglpujsq)h9mT|s)v4%J=kgtT8T z7kdeWJ6S3YEY0IRl7G<*`e-)hIwxTe z*cjHP(w&+O&r4?uzFBoWtSiuBM{KH5gOLO*ZQ+1mA5T4@;kr8xQ*|B`M5*9vT4DBC+C{ENO4Dx=1a&lW@BV${jqv5D>CQn?u{!Ki{xAj_;kt9zzCE1u za4;aPA zDfUDHm#KmQGdEM|P~UINaxSY;%xU{=1BXpgwqN?17~2e{)*E+ot0A#9P+?0egM{*Q z!gIzomg0xAo)bu9t1TPltv)a4rqOX7ZYo!M?F80OOK9kFPr!(77Tru1kG$_q16<|k zI(=>4A(ABYh#FrlXs1xDH#l*%7lHj+g>wt4ub@DB)Z-SrrIT86H2JqPiXC^U{K(Oo z6q6gjD1|IH<(QiTGe-lfZX5Nso!-%2HR+f$utle|afeTiC@(pXk^|xOJ8Q+~qE&}a zmCH#BX=;q%f9E#e#z>K=a>SA?GHYv7_Zk|-G|OtlscYNIndAL!DT(j?o^J~gl4?lv z4Ot3;gW;{1%45KXA!$@cP$S#WVW5bLFZ8v6E;@}Pr%H$>&m%uT#K zMEfINUgpkSx4i(f5pmU!`$wI2P_dZB@S(kR0@6BO0VNLGi!BK3{e}*`W`m&H6DDNI zE?(i5$JU0;Mag1o0T6V*ZwudWW%(Iwcan{`UU=49q0)iZx^|0VLdlOn<6lP8T+JzW zgz65!T>BWSOMkUHj28I?QMWT7>1;l9*H(!LB{1pwckWh6Pq|9bMipzo@5MYOgLT@p z+$03{PbJ6HA)-r#H}p5X9`oO65Etq*wH68ldGJ&2UF=ETgk}-t_b_7E^a(kg6GT1yWB@i}q638Wa$AwLR zn!nXJ2x4{ZkS6M)F)txzY$xXB*Ki*Q!eTw-zZC~G_hStCft5_-a+tC2e^R~(NXj>4 za5gfuNUwha75jmq(9LA+eGh73(w5q_Y;ekVdFQ|m$Xez*TVzb=6Ai_E$1CSUDchr? zU`YY*Na4KYBZ8qZA#Tc}_s{1^5Zty~A})tK(j%RE=vpOyDG0w!xMu#m1$ZFmJz{6w zx@mhO)9FYQI&82#?(W!;IXt7!-_$r<{@gnCvTX)w#LZc;i2hBZ^c0WUs0M`>#aaY8 zh-Q)iGZrB6)P7~OW6$5WhNk{&U(3StX}ppXCesrl#P=5HTDvsvCWob*-uNr|BwTQy zV_yUzG^+Qvfe;@p!6Ho_i^ayr?{7oBxHA^qj}30u956(b*NsO$D-k9mPWE9|K0mqI z5wILs{tht7nZ7o;)Rr@<^%wuz>YHjftWbc~y8FMpX@viYx$k9|gdH-zb?S~Ujt5#~ z+VsCka;M=cv2awb;}@?MoN=&SUa;MjM9g#>bUBjegbF~Y0J`HURr~62qe{BbqPr;S zZW#&2*?-%D?bbpXt5Yay+kDX!($nB&4+2|<-hDmUN`PjUUBYaC^}*M-Q>c!_NR++u zaA7VUdB@t#_&(60=~Oqb8(-~R1t0^k=J&=h4N%IWa%Z% zoRH>m#6_)NpKOTv&WLsddj=5-3hDwvtl!=#jwF!zHb)_MxoF8Tb^5)*VDmZm>53`@n+)DRfY&QTXXpp|$tJsR7iT4kD*jR1h7HyFaXAnj>)mV>L$; z1}dgef72Zvux$*jjDic}N&Wt#?Vc>TdThVMU~e$fOO*uepx>e;F6DhnOyljU!{82C zuVFxhICPw@nlvnVZLMXTF}u9l@lR?Bn~A=Ia+R;0u-iuK_c&cY=z*gPc^&OVF>YcvU`=vs>WgF z#?<4pC$xt#Uu0a0gh<3>BsMF^HV`~*%Yq$DOzk1|6Y39J(`T+V*G0>CJlUww_era# zc^RbCedlBZaNt%AwVEulBD4P4elP3do|X!9Y;8cY&ugvi3@i?I=RCrgX02j|Qgx)M za)epASX19NtJAYv8K@Uak#;E<-pUw_GsfTvQ^^Ufbh1;HlB!>fA35>Yes_^{m%BFt zDA*^azo-tK&=cfO2VMIw0b%jAeLM}o0>7R6ho5Ef6buQv7TpH0I}>6+1dM^RsR94Z zf}3P@G3H%v)PHwtO$5b0!Ihz}THR-SNp&u-;EM=AX~KCMp`CCBjU!gf;HN(86O}g! z*Y|@xzr1ndQfc$V_USu+<1^OU8IBCDT2;(`yVqrf1 zk?kaAId+RHsPmFgaQe!KLQX8u>^T5WQd^SHp%^ky z>Ebl5@R?#B@fZ@!Q4$JuSb_F0oACpthaW^(GZG&1u9K+50HF6ZQ3DvEP>G+8($hj$ z7HVptO6{c7oY$W~ug5UgY+c~xFEPO6#+_4m{W`gw^5!IlqTkmh11-{&iC#s=bGgnS zYfIl71)*EBK2S8j|8^IGPB^KWobfsL){#`7n2&mxxazf}jW*J0EAEuJC5m)Ka;uQuQ z*>34gqSLu+5$+tgT=QkC%02|3#IxF9`s#tH7TSWV@mC3^Gy7rv~`mw{q2dv(yj`2XOu(TW5A1``$dXtC#er+t)d~ zLBR$8`R7@&Vq2#$_~!uM7Mgp@pbWhwNtvqhHL9fy_+(P|V{iAMi-yJ?m5lGi+ekMe zF$KiTPghhg*3geEj3=b;Ndx^be)sv)=kDjP)Es}t5L?VNF_^qd6I<~ODuPX{< zSM2h+B~YIi@PcZ!=wo214@C3;r%Xrh6wTj4yg?bZTw}Z8z$H`<{FW0hI{x5tOtbFJ zbP1}|YhFAsuEBM_B_0!jx(K3<0{pPmD#uEhQ3E?R=YMv z(tx50Hp3?ZtNS}xjfhv>c3scfdBgE{<+aBY=j6s|Df<3BNd%^D?;gzj0`G`#QQXtI z<8!<^qNMZN^d*j(tId}I0Uc(yq3|U>nB~v#?8tb-x)4(xYWsI9e3mb}xG&qL1LhS| zeG_ULI45cb+?&NZg6gf|k z2-_3Y2YElfNk7^pUux1kNO9Q(Yj~uNL`x&s=Q&Y8oxeE0v?-8zu4R?cIcY*4qNkrU zgp$^hQgrtG{R^fZZq#K zqi|9-B&+>#jZ1rI=pZJ~_s*8D;!*Yo?;cC7kvwz@ek38MOf#ZRHZj^-9=*)LnAeS= zxG8heu99{-l>Y7*zMYR=V~Xt*AvIk z?2~19=m&aFZs`2zxIA}ZuC$oVy6L%GI6B-pdz@L|+L%`d4teqRNNKP%>_ex8o6rTz zwK>-@u+G14%U!+c69ocdvLdictXWAXfCYs_=ga$t=yMxS#N6wj_9zk}mubRJc(=>> zVOqeoIlJIBi!khNT5y%!?GcT?52}f$OXF8;72Fqi^RG@H^Eml**CJ}`TtY|d+rdCb z-jsn#nFZ*yX&iX8CnsZMD4;&WgF0RetV{QH(`)nro5j!H#w~a!;x!0dzL*UAAQ3=) zWdEvOw#RjsrQG^st%NxCV>eTnkrKAmaPOD5%DTEhQ`x_dw7|eD~hl&jG5PLsZn=)Qm=aQ7`(Hj$uVAbzXoB6m=w3yNRqQARD75?HubLYbeAGpCis zhfMSG3(_*oC$@x#`_C8+l`1MCW>!H$!BV?$)POuIrw7AT0S%#ap8P!5-d|^e9$AJX zWiJF=Puop<@MA%7=JaZ#M2 zU2AhqiU%p2a*_RuRA5Rqyt%x|TM5RecXpq6TWiKF+vlAl8~mSjcIi06h=Mk+>?rjc z5$0B9Dy% z9J%2-pNA43q25}LN<*t@ET2B*VSR3{FVMJZieZe||oKv9q9O(63{(h>|F}hJd`-)3Itkl;hm3DTYlKq+& z#Hy;TjY@5_HrpPRu=h`d)uBgTa^gb|h`6C-5Uu=ZU1gVV_U)|NSPJLxoUDTKf47J; z4C?vn#x0P)%@K+}ZCb`3+!plDP!Nw@!w`@_sUtRYfs@LAanwV@3ZeOuA2b=#;-4#* zKb4P}vJWA;Y?}=W(~!AN*Z-=r*n6$j)0s%69~0zBQ}>~5CkB>XnJFjC@i+Ud$|T2s zzq-DqIXEGf)>`jY)^Z%*=LkAloN2qNORg-9PP`O7=oS5%Ii8eI8;jF=5ZOe62f_+A zZtzhz!8}YzW$ErU3U5ZGElt`4tP>by0@dr*t_x7DZ6T0^p#bkYTU(@c1v?#9o{^O`vCt)}Znm~p8t z{fz+d9i8)LzJ9~d~v?WW=9<_tyY>wafi;#fuAx4sX2H@zU+LI+njEFjDK z4R_UoQbp5O)M+Cln!E~k+eom=JNM4aGXRENz!#B=*7EKPEUd@Wnc8Cq`=7H-?4HY~ zWW3@uOA}J6?ZbhKK6tsV@)@GR78+0EO$E+sE##rsekL3qVJT-rxp=!5gf)C}G-x$( zjDWWi!1w1p5~G+R^w^u`BEu;iN-?M{3btfN_j>f$5F8n`*~zAj41va_>I-IZn_17> zFqg7jl%0Ofg%eS)1R~^i&<7zssuY8e@iEhtzExbmiVzeq>#{P_Z zcBAHZ=Mmm$p(uPjC;&InBu0gNRc<&g?wz*|VOt*AGU6Xcq4Dn}oty4G8#*`F@MqY1 zow|LElNp7iVf;5Hr+fOSV3jXXI@OTSkd+-N{cO=>o>$~bdg;CRSqEexi{RyRHuUsb zHqS_px96?}5H;X#PEr-TLc(!-8J}^zV@rfRR9DxyV^+h66}fJBx^F)OBPEXh`-3CfIsda- zGCjJi!xzQ#MTDd0OC(P75t7dKqjQuE(%(AX?^YbQ{~hk485Crm?{cl#1K+V_^%Q~; zDy@^M!+2aX2fN{|8_=L(3#qiRI9E?!O-Tc0R(>1;NOX)DXD&&uuh=^5&(+_QTHzOrGO5V`$=47&p&6;Y-OxPb;gCJ z0Y&^|O;1F!ROBnSL<;xmC+hQ8@x@mRCKyg2L$rN3GFg3a^C=Oc-j6P`vnIsl3&wBs zrl7K;jqtm%gBingO}pQU%rU2D&!vtUE2D*hnIo4NSrOV4R#biP`D~b6h!XE}1hV%U z5V54i`mDfx!f@ZX>krU;oO8#R<_ZIM;A~MG<_t7J9BVpB9$HB zQsl|GI&o0?ohqvKe{|)EQ^emkzwveJvO=#Bfk+nyH@2EW-CU7Z}OP|N$x~jfpIU_ zxX9}|#Ox~m>0urTs(a8^?podnM+YnJ?GVx&Kq!0h#-Hw{fc$8UP>NvJSv~4^yOt)0 z@_p_<#fd-SP%ZC9gl;{YJMw66c1rHsV+!}Z%a0Y0^8<6?N6x)t4NVXKu+JQB(qAby z98y4u4@v1MCpF6p;|&}wk*IZ9ZV}JkpJU_m6jR%w$Mi;D8ZDYx+t$Q*%+;F*J53 zr3o_$`$`|#%?;f#n!sXJhVEB9?#r?M<#^eG!>EeVfpsfTIjve+3$jqjT- zlJG%mk9#o`LT`=5vb$*kZRZHpB6-Jd4WAHRxrQe z4Atw~{F;*%yG#6TXh^XUG9LN4={ob5{y4+Qy4(q}prH(XY2IZPfA=%~RWh3a8Gnk- z1ITwsjXV#vJMvY}wVw7JxupND@fCW3MXIn6mNE+WM!-@d$OnlSj zO>V6(euUziz|k@cO-UF?|C6uEc^Fk+a$i65a~RjEQX=XPH9klUP7&2uwo`PGN#yLt zI%H7*pY&uThT+dV1~fCJmK&ZHDAEtgG01D*8IUr$Rhr)GOnemRo6Qb>e`1&}t1=z) zts@b)`b5}|XM8m>Xv%fmfI*Gz!j*n}VLy>2LiqHqzZ|h%fANN2*=DM-5wz#qo{cN6 z6?n>Nx;3sCN)@WJ+@xOZy1th=bHjN8mxgoON9hB8%f#()1i;&4O{kTI&D8ts>d_~ysuOP+C$;`gVB{35%3zKyl-w=ujgnv_*;g4A) zzEf0}Zxtd}-9Fw_$iFulm@X3lU`q5M_Wdh%FiU;C_+xApaSKn%TZ-4c zCGWmxnXQt3`k_f{pL2Mh<1!eRbhnUErgGKWW-Yv0^RW|7@=24gLe=J?p5q_uapS;O z0G1rWF@Hn~TNcE$!)nVM+zh^SdXmXrg(l^HH|-R>kU2~myp0V>mrEY}!32N-Uu^_b zq=4P{D5W5~Ew%momkkF=6LHtTp@dThlMFuyk{IXSZJhIY(nGwA*( zk*6PD=8#ACI5N2=!rrKqxXrR6{MOv$OK$Hq_9MVLE^b8Rnqgi6L$fYZ#oMaC9W%_G z=0;B`oLdFCgg2M<*%qAGXnq;>AAmJfkHltaV?90&=V^tbgLIQL`9~Ei4(Em{Yp(G$ z-m3T=*{r`)y8M3@vvyVNXqWuGGR)QsA+NxNG(}Oj-1d`=ERk}snXRba0&lAf=V&j9 zFt85ep?cIk%)e@9pvf;d{;bD|mOlAX^@jt|$d)^tIxQoSHsA$PaH{wY~H21e&N}*}1vDv^(s=!W5ET@1{ zV}v9Pqe+Y|y6Zo(%yl@QP_x-*sGy?%23aR7OOXa*T0kkqaGuz-G3&L@5v`N3f49L; z?1!e>Nj@@~ma`{JW`IY?7Hj~syy2?@VDxcw&fxuPUb4o~>tKOm(`y}aHHpPvNTeY` z#mZw_I76(5q$(EB+H@uDr!=pzeu8Cr>z&7Y)znjcXxc!ar?PDIqJnQjkyp!NDh{m| zR{wOIhPm=e8gt^Ya<769E6sA1 zWk{|E(vsErW-45QZ6}rHO+>>OhRa&FmY7K`Q^sc-cV@D??g|re;#IL#p?z zcZeBO<}D4o6LZCWbB^JzuYgOrn=evX0gt0UXF08^3b$Rv9m|t-k3qVaDv4}SEJkD_ zpbP1`7d-zArnFU5P96r&1G{Gt4C0M)4J1BSz`B(ISLsyDFguas`rli5Lk~9$1IVHV zMj?sqv*&&++3G*qM zQOw)2if}8hh3@d{Ks*_vtS6&G-FRu!rT+C&iv4!++@kw@l5c-MOC_6o0i-3`d8vWe zm_F-b-uZRB@|S7b6o#N=m?%{1XRvr zi@$R0w_YAqdr|I#B;zN>ImFMb-7ysT@10!dg3)GkBrXtH(S~Z*J(ROrb>T>#f-TJ; zaAC@kRf3Ky^~eIbzHXVjhV(&npF!fi$ZtIY>*o8ET+C?>(v>Z37wdtoFvBr0pAj&e zq(tIzjo>6qE$K|os$KfS=u>gOBQjzpoT5$lx%>N${_Id<$@Crg<;4%!cOEZfE{V{A zQDuU5qLWb%G2Bx&TO3H=ANi$Ql~dz8-mV_+ln*P~rc}Uz4DRyG~MV zxA@6gS;lIEY>0?!?lSh+t2H7ikDvrOC+@0Xd~Kg{40k>+`K=!DvL0KosDL3=b;5tC z*HSb4e453L@7nz`$x_u+6IqNq8*#VPQm_$x5GP-ePa0iTmO*VlBmafKwn!_XEgvWE zf9m-2eGC*f@LUR36b9@!Dk;kM{CNqeOxj>MBM?X1B!(!XV0@t7R_$K_f+lqfw5;%# z#Q!97mk@l3Ld0Ci3zm)TZ=v5ffklj1y2YPG4AMDe8uz;+vVJgljb$Oa_FjjVlXt7s(iiD^{com6C>_A*=qsp78+-u zq<(Ls#h(NC`oHgF{f^a5&+)d31umVS->9)x&L=7dlYFa)g*yL@LWstWqg;J3T!j(n zGXwLH7DQK0QXR?fH?GRTn|UotFw@A`uvZ?n4B~VPjKJweNw6S> zoql6ia)|)3|6tJ+OwN*nBf+b%jJBi0891%vkn{ULzlNI4X|`rhESWEfPJ|}=)?`iC z1k1=PqIdlUhiOWxhxRwB^6AJj&ntm|i6*A3o13SU^2_|9l>TZsUuU2SkN9^Mj6tnm zPNIDRji2}H^@h7FRzcUweaEl6E~IXNfqdUvYq>Ww9J)M%a#uJR0B2ipW~B;E|GJG9Sgd-Q00^{??j{5A>s9CB-+H0QirUfehhz~*CKwKaw97H>q`Q*l;< z(k18D=p8|pN$>fm!7%L5>H8w^Z@EXY1m_d5#d{6_0t@YMV?sfiGf@a2QyK?Goc6IY z{gVoAuY(Jk8{Weda9B)->w)E)!!Y)PXBlF%QM0xElHFZ!rEpoYKcOcK%Z3p*?vcSV zoO{oXDG2f0%%a^v9sxWrjaDnu2Flq0B+td&NjJnBf0}a}g|Xb~Gyt24jLVW!pJ@Q% zJv-t^s+5q^drPFO>0nhHU2`2MDDV=%0;s->PnCxg?tkj2&{DQbaED)IOn^fx_&iOj z%d(sG@td#^JJy;6aTVZ7nPv@P?t3uIX8vu%9TLFjh!9}cbBYbRGoa|9jd=MBdIt-F zBIrb4DPZR5saaLOZM!$!$}>(7K3sAK`vDPbS+=NEL9qO{)c;?^q0JxUr8)Os-%{_^ zdCR0s&ZA0mzBY^nwHpkKRTGqN*`DSBm@f37$O zf7t5_YxWfQA<}q`bUP|gO8nK!NA-zQl1o?0? z}QijkY*MR(nEXr=zf>0&fkW^wv_y}aDfOfKrS zX89os+Fei?@7)Te1u?_6CygH-axh^0mjvL~{cP#)p&4HiWs_K1VIpzY9|k663`bPu z41_gnGpyEoEnO7sFmh9K6v0RHM+U`~u(fjQ*^oji1wuK9X;V0@<+dxmu*+{xz<;t}r zaF($-#OU~jKm8}IVNfaiKiFk6To9-sa-2i^H?wPRNr`x+Hu@Te+uJzs7NE}d`3Kz| zR>#C#ov0WH3(e#%)9!-DHPpE86R$`L{$+GyJnyHZE zd!}k@miYL%kJn6|ccSg`NSQnj=HCTH@|-j*Tju`4^O^D`Jj=U>dFr|Jy4PvM2*DBBhngd8)q?$^2| zRBT-o&Ur#mblcaDx!iv0@yj9oKVDiAbfM9Hr`iU&6L@ke5ZI8@Dn)-lQFhtXb*f$9 zdj|E}Xq-qn%}dgpD7DBn6HrFud|QA!{1hel;QlF?0#b-t>iG1YBU#aL((4Ub;g{ag zt5W+dD~c~5)cNlX^X2sFK6O};<2%Tfm-Rck_IqoR4stz5K$=Nje(6(J?j@{<&fPoq z5{9e@NvWT_eS&>9%csA#d|J96OMmbCN51LZ5RFF!yfwSZ$9BDp;0T)#mjrZ6F<0qz zI6J7t+^18-44gI){v}9hE;2CH{Pz9<+gDB`r}n-hG?E8j?iPRRd9xTlIQxH_j1pfn z+7F%EY>4ZK+GiA;Fb;9Wq%NSBibi~ggNVkuXpv(sdt0IFHKmR3@P16lq-go(Y|qJ? za71XC&VbTRdgHDmLZ!`U`FtG_!+hR|11PK^=JPo<4~$ry#)WY{;EI0hS!J(KmCOv^MGXKTeF z&8p(HxTT>o?*eUgRzvHbEV6@G>~ZH*Ru1;JRpWr?`fccM?tHyD6m7 zBY3@h+#s#qxzfGdb-TX9SH;k_^wGI0UGB5xUj}eU@96|tmh=3C0+vuNBsxCCs6qQz z{7i5Z19!(Q)1dvwzFKKN=JECuZxC-a3`X~x{AFr8Q}{^zQN|IdxNebwHL&5 zrUKpHc$Ci+ zNl^fa*Qi&$4br&;nMc~pT&9p~N3Hbnx3lbEOaUC?bS6ZM8W1s{rD8Lt8t2t_)!NBk z^R2)$2@A~TD>`qljJ)Y1$!FgDCv;*6-BW3Hyu8SZ;!sJOF=c#J%#QE#@VPO>ZX277 zIb#bkbsz9DvM?oPe%CshdvZIbnRum8e7$<-6EA+dOh82pHBptc_F|=}<=$do=arwe z4~`SF`zzU=Z7@ghYGalgoR)4CiEO!3XP+i}B*E2oC5d3}L?0v|!PR@kXO9T~Mp=Z0 z$P|a2m#9WnO#BzGqQU@`zCWqB4w_v}vFX3r%b0OB)p7b{Su4(|98-2zBWchgReo(Zs11K%1iX5xtp>1;;W`~UT~;ifSuI!E z@cde?83XS#e)}l~pQ(OPFmR_~$!8_93#`5|ytj6hjxYHrU-FKDm5TSxq0+;be2N*C zR$x*?&L`KoZ6o)U1kRDJ72NUIk6`>6(CSO%l$6ruM#7gX_$zaNEAqn_l z@Wba^q=TWyo*-?W7VFguzU|dx_*L8{J2F4|K$#GBB#J7ub);3+>-$|L@zRX#pLZU% zDG4@*DTwq5-P!lZdbyql7(%-Y;l<2T??;)^MiU}YfF0LkuEN&MhP9?^YK)?tX2Y*t zR!-&kWU>x5tPvgE_kFG)QMM-H#bm>;^v$K1VmAwF-Sb0<Dd|D z_RBbuEZUVRx_Y6?786tN+Ihz!wtHly%E|h=1Xq*bnG%b82`>}aVfH77u1Sl*O;k>! zt$wH>{JyLWu)$<`^6u}6elh>HkMr7djSIkEb^n8WP;6P}!}(Zcc|b7hjFiIE`Zg^7 zGpOiJ{m>|k*4TH=s-l4h&4?w4nTz-TUK238ZZr+r5PMb%k&4vw|F%$U6p$N9Fb+Uz zto<|E{SR7(cCCHQFT&tD%V%1DxuR51hj2z#FfN(e*Jn){XCYHRyQY1}F1cZrq5oo% z&K@mHug-=IjOZ~Xh?ti>lI)1j`fZ7%`{uP!{>geTIe3aN2zl85UuRbt7FFA=_Y6p? z45EOdbSX$Fp~N5|4T91s2&gnj4lsk#AstGJDAFM%UD6UNIlz#jAPhqdFm=ZFJHC3Z z>-%;1$Dh6Tti7JKpY^OeMr1iepJijWO7KJ7r6f66LUR=O^*~trx>8;$0rfq?@ZKkC z;79Lq{07Mv?(1X>v_ESnLd|Xr@2>BjH3>=?fW2>|dbeftpWeVo92^WzI0M8Y?0#T9 z_Wh_KC2nnneWb>c`cqlUBaXNm9CKfe!YI~G>9{^*;{BK`*fiYmW>sd}C5jt3qRkI` zlHxaLC|7E|C)I1j0^`5c<85>qw~grdDg0Hy zT2N*<&v4Fl<&4+k_(N%nQRu{QzYrrBLhmeL%f~C1^sf0}d`_T$ypD&WF zKS>KRxw>%%U);+>x$p@he?bPidZp}VpVl$w^+0olY332NlTICv^@f78@xaBw8<8}I zz4e#UcSaZe(^o4NpIgVSn?VS2#_m0;sSIfkOZx)^n0*2!dHS}8=uaT_;3PtC8t&R4 z)b`fUC@P^|7ddmST>92x_J-QOXP7n$jFDRiHP@D+FGo=8OUHpfGtn2hFO3TDn-V~qMUKrQ&#bgI`JWs0k+=m z?X{rwhQl>^265?#+RGHB^2T{Z;>jv`TKF<_rZ5b%93aXcz%W7=?>%k^g3#mro#T^^ zpkoD+&FP2g%^I&>2mP)`X%|6ycQS0`h?`x?D=5kk6e*^DPZgm~9GQh}DMlg$_Fg+D zU*EPzTFHxnY+tm>J^j*6j8i-PME+u+WvMnq;Qn%>jmS~L=S}jklDj>cLs?Y`!2#28 zNk(>Aqv|A|TdG|>;upbTEZvs#iX=+lCq~lwB0LL_6l`5D3_(K!xyElTNSS*R9lLr# zk_N`>yuZU16Q`(cuvh1VT}}E$(#7H8y=i4Uj=mkl+lz~!)ZPK*`@&tu_Ln>4LJ+e+ z=-H|6D9_$nB(-gECbxzWgNq~WEu3z@WDwibaDY|XmyhhkFU~f(OEa5e$ zAwKMv-+QP=^@SOxc^LO90|q_*t>q0@={MI|BQIAlkx{N^;4pFnFW>20+TZoSFE-U5 zl(2^$@UoKJ`}sM(tM*a+zYQEG?@rKL99ivzQ_@2iW=VJ1`^#pb4Y{+ziN7l z7-0btrJUdvuJI_mXJ8^8haO`>_*{GSNvqU>>Fe8p@49oDD-$YK5%eLFPLTL*Zp?_y zv{XJ|m+R@SO#-UpIO|MD%}@Ccgq)!4YYJ`kxce{q4{wmiF^z4T zt!{qjqBEGnoes`Wh(M<#w?<>O#^@LJ*BHW^LSBWYTv%AY^E*?O@>oNzY>^!Hu}u9D zZ3q1puiBGN7$_WVCk|(B;ZnB>n5wI{k}Ec%fy)xQ%)v}Fa%7iCKX7SN05T!0d&ZHH zHYwEU@p#6>y-WjKW%o>NX^N8rM&?V!8=5Eb;OZ!%KHJ^oEA~gCn=$q`@>YA9*trb5 zG&!*ll4LzI**Ld5XE?13hGREq7QJg_a6WI-9#k8JixdI}e)sP61d;ca?mh71%Ebl} zzw0gUKY0)nP3HLOUC+mnu1XUoAk(XUdOL%4(Cz0NRO?gQY_in+u{jTt#l+4Ko6*0D zYPb>2Ha2NSYVfkiXJVswz1@(IjDuZX?Ym{g%^WsLGsu(Dw>iykdOYWXV)esHhIF8M z&0M!7`ppd-_D5i(TU)ui7+Xd%T&MzQ)3)DJN@Quj<6Dp49gHTcA_nKW2cXi+~g@W|a+VISnn3#q$U{BX4GXk`WEDHWUR^Kyo01MWD4z z71_|WbV)3l6~T9P;;JY@UoC%lP#NePZs69oxpxa#s;GJqvAwe;Fnw_aK5GIei?GUp z4uj^hM*_eF%>@z#dNb88`;bt7 zQ;=(+sJ}>$Im40QND{p$;}#i;JKk`%t18aa7UMU4mS^9Rud#Kgd{=UXXH-HTapNUD(>p;7=nX zBC_V_(sd2wJAI|9`XbXt$P>v?$>M+D3Stsqf!5=0%gY|)OnZ$;Lr?I}X6$q~LYxKB z2~ag%3s{&YacU-#Zk6u+CQKqA52-@xa^1g92jh_uLbO0A-Mumvr^eibv@*KwYL}57 ztpKgbtqOK?9RSp!u+i$5_sqCs7z*>b0WCifq9$mQ|F{zX11{lHOl#Ksl|hh8nxE1E!RGd+?{t+$4K2!QZfsYgWp?M&jIQ#T}@1Zv0}zPnNJ#+iab{AcUKF z%G*{WJCb6BMzFeoEE#w`WaIRJtAuQ)cD_?1X&5cvJi~L^KAWHNf*L}Mem=;4IlXE~ zyjgFJuVd-hx2@n3%26jsU;~~=(@s9mGvj|ZgKNY*H`}H=FB^X94bfNFFQWM9_hC0$k45sy@x29F&&eO&Do-+1Fz|aL2tRsI}g_6w__J?=Q5ISQExU&vCOGO)K-{ z?uvkA8eV3&B>PsIvJypZv&6;QC-r^FUNsavEvG!Luvr%o)!c2BO8F|Nw!fzT;2I6@ z+uhn-_CkIm2@>ovPBG7K(p(0q>DILx)e&{ z3b;H2ItF?~?UKb`N(U2ypW{Buj+|%h<)?ZuH}z82n7wI05^Gg!us>&rZKx(|KGJS` z-}d-Qa(ltgzZ-b9r~fhR+qVzUuTsAYw^o#54h}A=@umI2Iqq*!Hzx?{#{{fLe_I># zJWw=*CuRtqU6{#L!*d<^w;d5^Kr5WvOw-kyGGm+mcZ63DX{E=j#TbQOK}f{~{Y-*L zVsCub6yyhBRI>LrdLiK_($4{ias0^W49^5)AtB@@b zQlB=tSg0bGr%(cWY1i=6QgRq=?@z{AK$t)~<*Y7KBKxKkB(L;iU2m`7$rMVqV~I?L ztCIt8e~`a2rC}dd%~4Owu-$7s-4m8ei4g8e_m%5i(0t4Rw>S$#8!@!c!3WbBo(Re> z>bdYRJIi_IRnsKwfcrY0NM$R8lqj8!Q*0sWnD=lKFIS(4>b#%@m*rASUS-5dsQO`A z0Y_4Y7e)L@FBfXq@F$U`vs2ifO}ga)l@e~f)UQ*ejqw2;pXW`#aJDZ)@YP-$WbVFx z6|69;hY)}0_x<|sXpokA zk*TyhYPi`Ylp?dn$b+Q_xiA73WB<}9AoTN9(ElOkHOoEf@a6ivYvv!Aa2$zmxD|>kv^Lv)4{e>ARZ>0du(vy}={Y;I2|;;VC4PuP zsB>=kX`ifYEbDe@Svyr}z;7$L`&HQCYGja~_Nb#t(ZDB0dKi)}cs$jT zfHJXFt`yE5m4s7_mRC0e;@{3O+TSM3uGr&vqgMhOuBmyJbHS9uW(*SaUS?M=ai#x`7?b;+4_qyzGl-l8^(HtLK22b(IUeO z^wx!&-{a7K{>m(ioscj7txB(z%b`%Ab;xt$X)~_CD;W7)_09rb{oeFizu?+I-@9f|0GeL?#xet0hv_bKUr!5lGFY%M%QwYCrtnLu}ia8 z?6|(slD}fE_8?jK8f)o&y_GuiFt}$8`PO(m5oB5%;1DK#M&8wbefTP&&gQWShvZk z%4hz>-0}N66eXypw|X%)Iv`@A$k@jF*Ex9Kk10d%^UF7GDrxO812A;dE$CRpZm8@C zgUYp4f{k6c1fSK%s?~Tb(q=tOkYqmV5coNb{V03DD`-DaXsaHppS+66oxdvxls0*x zM`2?yK+I^Vy(f(L!ZGKDnM&o|wjeYNg}kuwcwLsA%6n#yBVHlk$!_>5ENL+j;EbTs|T;IQ;JVDwzmO%&Yt8ALVa| zvU4Ue;Ky@Mt_ZZ7FJ6Naa$fZdCNDmGr3SHqMiGmn0o5pw>0G;AqT@dJJG-fdZQMJF zN4|^Ai>|!UxJc%&XFb->kcPOU4X0@m7`?RE)hvZ?MRD5NstLbN2%QYEY!i}^(W7un z{PuEKGN?9yqNbgtI?9nU<4GA_-q`z?LhHH*p4g>;zHCES8x%QUetAp%wu59n>IcVh zUG!+G^!&@2k%l){V?X4>Y)>-yrH8_*VegX~n+u~|o)uk6Hh!rtp`#b2!3PfP*!&0v z*unblk^cI&)^?xt81dCXysI(ZWX5E<8rY>}@wnc57**r(-D@KJ?rHnY$CBex<2?U% zMl>NBoTIj9EDwHM{qglJ2yz3Cr=It)Oiv)K)lpRVeF=7#VEm;XCm=<~1Q0dzm{d-adAkg%}p_wZ>&>(w<)H5p!V50e&>i8@~tBlSR9 zjH%jgISnR;PV{34>9a~21n9Idg`Cv;sH^r%3>3@C~m|3}s%;|p940=eB zBmCv8UQfeFm2Pb?&vZ7UNhv;3MyjU+%so&=ROY~F!zwt2wP-<>=y+jinc8m-DNGQR7@sxo)S<$L=gzR$5ucor441y znWcC!h(IP0mSaeCMETmU*(0g0J~1J*&?xRGp+wqRh@b6@w2%=pHiPH572GXL@%HyY zp{EZIsxNf`0cm3jTMlyvMqLlXuG@ltNGhHB@G?cHDpBx#9df^E>$3n;eji)V^C9*KiDd$r$H;wo7)JmZ6 zLU61ZG?^_gmjs%HaVL;HHf{&F%+3(Z+3cqGtvpsZ7^q~a#s=h!Ses~g&xPMEi7^fr zU1Ob3sreWhT0B^8)L>Pnyd?W*7F{@Nm<70>1?A~x1@X=Xj(9a;3vlN)CN?WhSopZF zo7v-9G3}G|Cx97VJw&7YtL5LPhBP5XoIrm~zwiSDt&h*5(b&hTgy|b8sGImi5O?sd zH9dAf9olBkfDZ7P}=kp)8nbLlcu%#~A-9NXllZt9SF>QY5 zb<>k{yg;OsOF>Wqyhl6P#cR_ob9LPOU4+G#XJYq5Gd!{dY(6*%&o~U`7^|1=gO*FA zZ_m7*g~*(r_!=hL9H%Tq-E&)tA9CXGQ;ecvScLve-;Elk9ZOB3a;K&qQQkrR)jLT| zn4cawBjd13g5HuI!;)&{fr9&17rd=a@lY^e1+F6ILl6=MmItszWJ?r~;=Q~*Se|*@ z^4Pqt`R86L|FQ93M_EdFmnj=V^Brr8wb=(K0h%K;>7)5^vT|QrJzjawuI?fKD8!RL z@cZ~J?ouhS&3&P{+}*}jNt4_FAUq_@*I?Sgt5=t1*(M&* zBqze(m)e=ed2HTpF2J9qj zV}LUT9<4q(ZTtgxC-gz^3^M56J|G}c% zRnChB6cqsT9EQ$#`-eE9SChtJhVWWYZ0uSXSOx61lDpG`!q*13B*1wHRk7ZqY1wYm zV+^$Kl<}J;TVtqXfnEqDO=_Z`xp}iF_(3<)(F_|J?owL%?bPUd2_t4F=R1nJl@rQ& zfwL0(g)_@#Z(HSQ&LnheFv>f*3F77f8)sY1Nw)SdAy%&1gQZjLgs1SkyfPOPE>F1k6vTH<8G+g}yuQFp6tZ@&Z zc!UMzfq5cevk3UnPGM3SFl5h*FK*pAWC8V1A(LT%l<2hDx8FIiFGk-2X#}BaZoUa=w zKz1W?XzozXT}Wds)x_V}Lb3Z7_{grDxHEO)SpVNWZ-y^rhBmC4Eq&z~9)5Hey{X$w z@bF+Wuv6(GIamQjsg(I-aZZM>WLzhx@3LYr0N-qO8PtOaG!vVk^^QgL<<7gA{vcNW z^K{gTlr&pEeM(cAmvw{oD3+AitGINhBY7rFMHLl^K@J3wqY+v)u`}|tG4Db5UOOY@ zLqP1bH6v?O-@h3(Y?#yqbbab%Ziq0YWtH6WShz!Z5n303AyV{eFVQa#rUOX$?XFsl`Y6DD1vjR~F=t3te7`_)n=Jep#>;x~%D>ec#8qiR<0sKs z=iB9&`4f*}CCT%gqnO@ou}@!aW&upGE%fkYFk)QGD&+eqn@xMtTT&hD;dJNM73oBp zN>mkdTim(1NP7E8I`mR8PDSoP19q)4&i+ej*~G-Xs5f#wxWdqg@}?)8pDcPi83I<| z7bPZp^P^66pW-Q;zZt95c%M}n+`!^>7t3`)r^fNAca5J_shi^{gG+h;eh{}7Tf7yS z-oPS)w=HmIed&T92&||-n6StYyCd6Jts&XMy{StExJIp{koR}9lI2zm^m;bR#f#W;IBxCNr7+QE{z4Z zBg^NcIRVA5oJS^Sy@WjyvR)f;yzvK#h43-8CGK;B+O5-9;ABKg(kxlL>R?gU3hYB{ z6lGU8YjIA>b|gr&$Em9_0^DB&%0(D+KN`b2nd+;8d8ll><2bw$v1{GDj}lfLtHpr# z^T&2qeHuYp<+nzkObZmoo|hBe_Wa)X%n^f{gK32tHr$C$l|x6pWxM$}XkOWYY6bOj zu3C&)%wg!r?+6RDLiWZMRwvRA-@*%I~-LR>( zg)SpqatWre+nD@!SHNOvcunT7V@#IZ^DgS8v>_Hed^Xc2daI*~V)V;CKdzFb95Nw* z$;8MKZcuZFvKz~RikT1j=UC)zU(j@`8+^k&mBuIf5Emp+7KAbC5;9acn6ks|&M3`7 zSK!DVV;^0456iXCS|@4+QFFM#Bep@6$a|SJzh(Y^p{l(?5Q%4mT7d1Ipl2G#85u^- zdkHM<P3==6JG>n`QU@8@&sT6)?Js>7| z#21oR`%3M~-THYJkS&=l^mZc$_1=n21D!VAs%{&1GBwq*1fD-E$MEa~pFYJ0P&+gI zlXSsG$`FTas%z@Py{5Uhbl;!OWc%F5n(wl!NOa-MoO}Nz;nvT3 z3Vlzbg+@l-rm~SLG<)G{m*hJpMlL5ei(d3k!KK3^fhJ1+1 z1@>5S1tau2Co>}}zJ4HN(A#`Ti=%jft-#L^PpixdY;|qsZs45M&>;TCP)2uG%O$s7 zuiz}PUbF&*&x=WlP8!x*ezvh*?ESZBI6E$NXBYV1jyB-)UeIsHP$+>5F7tHb({3{C zs5Y%PI8Xjq*5DXql@OA^hU_0bOw)UnyDgUZ9pVP?6lTdXC?WWWnF2d*L5}^P^G%V$ z!52?O0_VA~ZB?HzG};T7pg%`=h*_CKmWgp|xer`PS!%HFZPkt=TXrur`=o>tyL}DD z(cVcUE+ETua(<=O@7qtN6TmjH(-DeGNZh!x%F(*fV=&mrh`(Z=$O4ETt9m;VKBhC6 z5aJHaqh#(pQE0o&&@LhG-N^F087ZLw{Q}E@de5O+&2J2tVWugAKMogmzxk?Xt3l`2 z32%7^FLN=kfAULcqK(Wmr&v4OWn_$8mA18hBOF7hKQ_ILkh0?|leu_ouY#!iJ&aGfMa?GYphS=PQ zS@|yABG!fbTzpDtiSQW-^o>h9+ZTPIScT_+d(T>l07)5G@Pna`KIdE-5Cm8|h&>e6 z6`cfGon$!8;oC2|AFeVub%$_+Nju4UB4+^z7(yGpE_jA>XXXvzuOr)x8{puiUa1uh z?k#M*CijbWT)A*R(F&Z4!5Y|Y56UO zJmt8W)qrIN?k(F%CgbATk~l@m;hL*_fQfM6dcB$POMHh56KMOQ_!-o`O@C++v4L_; z_*xsms`h6<73WjFPGd+LjY|mLoVE8cAIVg@{(K=>FlFS(&l^jU1KFVGo}pI-0q2|E zgj;>$rhEPCxmcF;X`aRT@buOiHduUWHp2samNC(mYkHVx>AaQ3t@u^&?(lthBCd^$ zNMNme_q>{qR)EyEPWM-wSV1A`qsv&2xil{GD&5kJ+clSinp>c0l_0pq_+~adZT!4~ z;mB&kTbEHY*(k&-A_N(i#GHzMR$tKoN*s4C}QZtMxN zvrQcOixB*(6JkL6d;)D?rITEgx5dsoCiooFj=iN@Tw$e=cM+?0UY3klsAs(B8Jww> zfg>9{RUTrZ7p{vLUCUww@ATx;Qmiz7&&iCN3)zJ&XE`F)I+95jtfY4%7foEM-4pds zAg)Gin35O)byikXyalR9%3d_~9o)^_%I7#*pw}(v3!7|05H8`th-j5sXG^l44Abjnh@1n?Rq;)QY(B- z@daUTh6$?G-QLYKik&58EN<)>?w;Cv%#q1oHGb?@pS(-4K zVho(eN6eC7T%b^fvwWwz*WEnO@*QupC*Sf-Lm|xVEu`fL3G9<}4n!cWe?tga;Za>A z=uB@=D%wiDkEb-@?FnuY;Z+DHn948duo;NGRl2XNqQFF9U?=TgN^4;%|4l;?&YIIA z78h)8gbb&(cufZwrW2nXA`7E|1*Z0wI5=;&KZ=V4!E;x;w2hNbaXNvQ5MW@3tT1ol zqF1=}zit4b?Ma*oYCb)+cxpeh+fNDmavge6z-!&7y^K`lH#}FBUv26Hy1Wo-n1dFa zi)j%sagZ!CuoeHVY39Z>U9q4rI8rsROiYapqX>UD6Bv+K>PwD5>K9 z+J_`?*{t+y@-MaYTa{=aV((0Om+}rmlXZADc?rw)_YUB)4hHrV<)k+Ws$?y+bKp?P z3p=#^ycV43E^&v=H4B=q$2>&F2a!C>6Fv7Pc{q8}8q$`}jq2QV43!kBGFnd4{jQiJ zXcH=(HgBe5-BZ_qj#Ge^&p&eg#$Wf79>n*c4Sh9XaVrW+HUk`U+?#vM(KS&d6;AeU zTNfs*oj`oWU8e))uf2}7fOV4n9ujfI_NG5uDso-AhSTj`Nm?EOV56pEY$#Pbp5veyl|9tYueL4fem0tEk2y~2-QuX=u$ZwT3Y&}?DBOum&pAOEUb>+ zsF01V(p)?PBN@qAfT|4xx1TSRKda%lF3Z~*{YKtp`Fi{o7S(Csl`>9sr|e- zer(MPm{^;>cs0fH*x&)Q)@^Wbgw+%f)M{U=NatSiJ8@{Y+rs&OI zWj*5**wU#?N5U@Z+(0LIT|08);^1S-lCgZ*%&nYhLvx6(aH+$`=XO`ovb}mYuRA!r ziw(ZNTP^drfs2YWtvlWncjL71xs6s4o*k(xv{ zHrs@l;@!61+8nS<)Tad2`{?yJDPIj8j~tx=@b5Hs=0yhTf>1}pC1d%>4F@lB1 z4CCIekMi9Dxaq1!a5g{E#O}>cFFd#*yqy%;&G;F$o0Sn&sDE^6sF$&s;*@OYNHMrw zhD_Q5A@CIB1UnvmeU{d59&1Vm)JRuY29pOQ`JDQaw6A(qkblJi0_Nddn2RA$eyw8! zuk-h6>J(JDo5nh2%|0J>&i)S`haRMI1~xLz2=r8uJxiS19Q|k&oAb$|;K=vHZ*n0b zGdZs+j%8bw+0V9*l$pk z4(E7#?oF&~|4Q@r3>r?A8QFf(7_&VEWDu(LG;eU$$S^G81h5-heXvKCXz(>rIVQNh zX9lFQeFj`w`U z_WC*ug;n`?h2wVnYEaf`kDxvCICR4*t}(ifJ_%DBJ-l4+gx%Cgf-_M-s13Xy$Rmp< zn*PO2|A(5&OR1i;I`=?6k;6Vy1FL>&Oyk$v520d=1Up8j^ak|?*#>Svy}JXB*inTT zqY^p*vPRwm+!rL10FM2UhSl3_;-U~>BCB>WMcK!q7+YLXR?xt%}(8{rP=Rp7RO7 z)%8o!219_7MNP|(y;I~en1neuejYyfGQ}xQ?P6pv(zg_6NX%zZOkB8Azx%InALv)Q zC`wXlGMzZqsC9X7VQLiAG{g5K<=2X`sixt)J%fv?76vWkRBUd@tt~H`lW0Ml5sG`j z6q)Kw!44Gh78%-Y#66tEfMqazqCdV?5#9W!e+b#jr>s?NZ@LAQ(2>xAt9^;BoVP6P zC%^pR+x`k`vT~k5Fks$p1XG9P87kBn(OS;{sTea5H8~*? zV4mdr!E=B+d_+{^&zhl)V!9uCm!3f?S63bPph&4!Pu`ujqu4L()d%;4%@sHl$1ehI zr2YEY-0|GK(06{8m;S&c|1AEJb0K8pjDI0)Cmu%%fkhIee^(E;NU6+7+4{lsMia}=Xx6ZACM%l@TRJJJ_P+f zXd1B^x=Z=plvGA*m#(L9w8917bj0_hQ_pJPZHTeC=U zr=Yuh^OWYN8InoA7EU{%O%Mk!UQ_Rpru$LvRouO#JjzHbLyaZelkJ(tZg(-{5?jzg zZbG>p>ti4OdgR~f#7Rj7i3B5jNx76qz3cJDA#KlHdRO2A*?vo>DB`XjRUaIUK!dXG zAc_YuT;NK)jfU6WKg;*Gx6waE^H+g9x|OF6aAK_QZjri=(aq92ct*e^K&*~WxyX>E zNM9M`+CX&KJ|2Kqk4|o$za;u+H2+U+`gNUas+>t%85Dpg8B?OhK+)%gl`etu-KQ3Y zen(aZ6ONy~1}obtcx_ae8F`bW!xX{o?^<5({)yAC8uyN!hLnP4$0JN|Wbk$eHBzTW|L-x}pEzbPgIz>{%9bO%ae6dajG^@>w#C>jmE%kfw!;iQhV)Gf zu0uoXou=3P6vRJRTM;avP8Q26DAe{Nr^&4WdiulB4u%Y0_@kmjczki)zdPH1U$K(S zB1GLEyux_EkBv{p!0#ns=(clFNBh>OFemtV9DJu=fFUkGCtKjZsP=KXJ$h>@{+O7JiV`kiWmpbba|Qy|dZomCv8L_HV@6*Kg&8 zvD)OO=eT!z|C8$n9rh@N>FOY%%Sj`_vQ$FQH3J532eDzkME+JN8DdU_-;RJb-&%q1 zpA4QW`Y)@r6imqu`&mVR1S>el99BHloxJ)-Kk?ri|6VPB;_>JG|5=j1Q|`Y!`Ty?% d8GK+8hpF~AK { + console.log('加载完毕!'); + if (error) { + console.error(`laod error:${error.message}`, error); + return; + } + + let urlNode = new cc.Node('UrlNode'); + urlNode.addComponent(cc.Sprite); + let urlSprite = urlNode.getComponent(cc.Sprite); + urlSprite.spriteFrame = new cc.SpriteFrame(texture); + this.node.addChild(urlNode); + + + }, this); + + + // let urlNode = new cc.Node('UrlNode'); + // urlNode.addComponent(cc.Sprite); + // let urlSprite = urlNode.getComponent(cc.Sprite); + // urlSprite.spriteFrame = new cc.SpriteFrame(sprite.spriteFrame.getTexture()); + // this.node.addChild(urlNode); + + + // let id = setInterval(() => { + // console.log(`texture`,texture); + // if (texture.loaded) { + // let urlNode = new cc.Node('UrlNode'); + // urlNode.addComponent(cc.Sprite); + // let urlSprite = urlNode.getComponent(cc.Sprite); + // urlSprite.spriteFrame = new cc.SpriteFrame(texture); + // this.node.addChild(urlNode); + // clearInterval(id); + // } + // }, 30); + + // texture.isLoaded(); + + + } + } +} diff --git a/Cocos/Demos/assets/Script/Own/ReplaceNotify.ts.meta b/Cocos/Demos/assets/Script/Own/ReplaceNotify.ts.meta new file mode 100755 index 00000000..8f353c26 --- /dev/null +++ b/Cocos/Demos/assets/Script/Own/ReplaceNotify.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "955a85bd-0db4-4d3f-bdd7-8c8853bd2768", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file diff --git a/Cocos/Demos/packages/dragonbones/assets/dragonBones.js b/Cocos/Demos/packages/dragonbones/assets/dragonBones.js index e3fcdf6e..d95dfa76 100755 --- a/Cocos/Demos/packages/dragonbones/assets/dragonBones.js +++ b/Cocos/Demos/packages/dragonbones/assets/dragonBones.js @@ -42,14 +42,14 @@ var dragonBones; /** * @private */ - var DragonBones = (function () { + 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/"); + console.info("YuPeng DragonBones: " + DragonBones.VERSION + "\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/"); } DragonBones.prototype.advanceTime = function (passedTime) { if (this._objects.length > 0) { @@ -64,7 +64,7 @@ var dragonBones; for (var i = 0; i < this._events.length; ++i) { var eventObject = this._events[i]; var armature = eventObject.armature; - if (armature._armatureData !== null) { + 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); @@ -184,7 +184,7 @@ var dragonBones; * @version DragonBones 4.5 * @language zh_CN */ - var BaseObject = (function () { + var BaseObject = /** @class */ (function () { function BaseObject() { /** * - A unique identification number assigned to the object. @@ -233,7 +233,7 @@ var dragonBones; * @language zh_CN */ BaseObject.setMaxCount = function (objectConstructor, maxCount) { - if (maxCount < 0 || maxCount !== maxCount) { + if (maxCount < 0 || maxCount !== maxCount) { // isNaN maxCount = 0; } if (objectConstructor !== null) { @@ -365,7 +365,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Matrix = (function () { + var Matrix = /** @class */ (function () { /** * @private */ @@ -628,7 +628,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Transform = (function () { + var Transform = /** @class */ (function () { /** * @private */ @@ -812,7 +812,7 @@ var dragonBones; /** * @private */ - var ColorTransform = (function () { + 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; } @@ -883,7 +883,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Point = (function () { + 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. @@ -963,7 +963,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Rectangle = (function () { + var Rectangle = /** @class */ (function () { /** * @private */ @@ -1031,7 +1031,7 @@ var dragonBones; * @version DragonBones 5.0 * @language zh_CN */ - var UserData = (function (_super) { + var UserData = /** @class */ (function (_super) { __extends(UserData, _super); function UserData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1144,7 +1144,7 @@ var dragonBones; /** * @private */ - var ActionData = (function (_super) { + var ActionData = /** @class */ (function (_super) { __extends(ActionData, _super); function ActionData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1206,7 +1206,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var DragonBonesData = (function (_super) { + var DragonBonesData = /** @class */ (function (_super) { __extends(DragonBonesData, _super); function DragonBonesData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1334,7 +1334,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var ArmatureData = (function (_super) { + var ArmatureData = /** @class */ (function (_super) { __extends(ArmatureData, _super); function ArmatureData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1480,7 +1480,7 @@ var dragonBones; continue; } var flag = false; - for (var k in this.constraints) { + for (var k in this.constraints) { // Wait constraint. var constraint = this.constraints[k]; if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { flag = true; @@ -1490,7 +1490,7 @@ var dragonBones; if (flag) { continue; } - if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. continue; } this.sortedBones.push(bone); @@ -1501,7 +1501,7 @@ var dragonBones; * @internal */ ArmatureData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0) { + if (this.cacheFrameRate > 0) { // TODO clear cache. return; } this.cacheFrameRate = frameRate; @@ -1710,7 +1710,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var BoneData = (function (_super) { + var BoneData = /** @class */ (function (_super) { __extends(BoneData, _super); function BoneData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1749,7 +1749,7 @@ var dragonBones; /** * @internal */ - var SurfaceData = (function (_super) { + var SurfaceData = /** @class */ (function (_super) { __extends(SurfaceData, _super); function SurfaceData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1779,7 +1779,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var SlotData = (function (_super) { + var SlotData = /** @class */ (function (_super) { __extends(SlotData, _super); function SlotData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -1851,7 +1851,7 @@ var dragonBones; /** * @private */ - var CanvasData = (function (_super) { + var CanvasData = /** @class */ (function (_super) { __extends(CanvasData, _super); function CanvasData() { return _super !== null && _super.apply(this, arguments) || this; @@ -1905,7 +1905,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var SkinData = (function (_super) { + var SkinData = /** @class */ (function (_super) { __extends(SkinData, _super); function SkinData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2001,7 +2001,7 @@ var dragonBones; /** * @private */ - var ConstraintData = (function (_super) { + var ConstraintData = /** @class */ (function (_super) { __extends(ConstraintData, _super); function ConstraintData() { return _super !== null && _super.apply(this, arguments) || this; @@ -2020,7 +2020,7 @@ var dragonBones; /** * @internal */ - var IKConstraintData = (function (_super) { + var IKConstraintData = /** @class */ (function (_super) { __extends(IKConstraintData, _super); function IKConstraintData() { return _super !== null && _super.apply(this, arguments) || this; @@ -2040,7 +2040,7 @@ var dragonBones; /** * @internal */ - var PathConstraintData = (function (_super) { + var PathConstraintData = /** @class */ (function (_super) { __extends(PathConstraintData, _super); function PathConstraintData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2098,7 +2098,7 @@ var dragonBones; /** * @private */ - var GeometryData = (function () { + var GeometryData = /** @class */ (function () { function GeometryData() { this.weight = null; // Initial value. } @@ -2139,7 +2139,7 @@ var dragonBones; /** * @private */ - var DisplayData = (function (_super) { + var DisplayData = /** @class */ (function (_super) { __extends(DisplayData, _super); function DisplayData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2158,7 +2158,7 @@ var dragonBones; /** * @private */ - var ImageDisplayData = (function (_super) { + var ImageDisplayData = /** @class */ (function (_super) { __extends(ImageDisplayData, _super); function ImageDisplayData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2180,7 +2180,7 @@ var dragonBones; /** * @private */ - var ArmatureDisplayData = (function (_super) { + var ArmatureDisplayData = /** @class */ (function (_super) { __extends(ArmatureDisplayData, _super); function ArmatureDisplayData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2213,7 +2213,7 @@ var dragonBones; /** * @private */ - var MeshDisplayData = (function (_super) { + var MeshDisplayData = /** @class */ (function (_super) { __extends(MeshDisplayData, _super); function MeshDisplayData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2235,7 +2235,7 @@ var dragonBones; /** * @private */ - var BoundingBoxDisplayData = (function (_super) { + var BoundingBoxDisplayData = /** @class */ (function (_super) { __extends(BoundingBoxDisplayData, _super); function BoundingBoxDisplayData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2259,7 +2259,7 @@ var dragonBones; /** * @private */ - var PathDisplayData = (function (_super) { + var PathDisplayData = /** @class */ (function (_super) { __extends(PathDisplayData, _super); function PathDisplayData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2284,7 +2284,7 @@ var dragonBones; /** * @private */ - var WeightData = (function (_super) { + var WeightData = /** @class */ (function (_super) { __extends(WeightData, _super); function WeightData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2346,7 +2346,7 @@ var dragonBones; * @version DragonBones 5.0 * @language zh_CN */ - var BoundingBoxData = (function (_super) { + var BoundingBoxData = /** @class */ (function (_super) { __extends(BoundingBoxData, _super); function BoundingBoxData() { return _super !== null && _super.apply(this, arguments) || this; @@ -2369,7 +2369,7 @@ var dragonBones; * @version DragonBones 5.1 * @language zh_CN */ - var RectangleBoundingBoxData = (function (_super) { + var RectangleBoundingBoxData = /** @class */ (function (_super) { __extends(RectangleBoundingBoxData, _super); function RectangleBoundingBoxData() { return _super !== null && _super.apply(this, arguments) || this; @@ -2382,16 +2382,16 @@ var dragonBones; */ RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { var code = 0 /* InSide */; // initialised as being inside of [[clip window]] - if (x < xMin) { + if (x < xMin) { // to the left of clip window code |= 1 /* Left */; } - else if (x > xMax) { + else if (x > xMax) { // to the right of clip window code |= 2 /* Right */; } - if (y < yMin) { + if (y < yMin) { // below the clip window code |= 4 /* Top */; } - else if (y > yMax) { + else if (y > yMax) { // above the clip window code |= 8 /* Bottom */; } return code; @@ -2412,11 +2412,11 @@ var dragonBones; var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); while (true) { - if ((outcode0 | outcode1) === 0) { + if ((outcode0 | outcode1) === 0) { // Bitwise OR is 0. Trivially accept and get out of loop intersectionCount = 2; break; } - else if ((outcode0 & outcode1) !== 0) { + else if ((outcode0 & outcode1) !== 0) { // Bitwise AND is not 0. Trivially reject and get out of loop break; } // failed both tests, so calculate the line segment to clip @@ -2427,28 +2427,28 @@ var dragonBones; // At least one endpoint is outside the clip rectangle; pick it. var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; // Now find the intersection point; - if ((outcodeOut & 4 /* Top */) !== 0) { + if ((outcodeOut & 4 /* Top */) !== 0) { // point is above the clip rectangle x = xA + (xB - xA) * (yMin - yA) / (yB - yA); y = yMin; if (normalRadians !== null) { normalRadian = -Math.PI * 0.5; } } - else if ((outcodeOut & 8 /* Bottom */) !== 0) { + else if ((outcodeOut & 8 /* Bottom */) !== 0) { // point is below the clip rectangle x = xA + (xB - xA) * (yMax - yA) / (yB - yA); y = yMax; if (normalRadians !== null) { normalRadian = Math.PI * 0.5; } } - else if ((outcodeOut & 2 /* Right */) !== 0) { + else if ((outcodeOut & 2 /* Right */) !== 0) { // point is to the right of clip rectangle y = yA + (yB - yA) * (xMax - xA) / (xB - xA); x = xMax; if (normalRadians !== null) { normalRadian = 0; } } - else if ((outcodeOut & 1 /* Left */) !== 0) { + else if ((outcodeOut & 1 /* Left */) !== 0) { // point is to the left of clip rectangle y = yA + (yB - yA) * (xMin - xA) / (xB - xA); x = xMin; if (normalRadians !== null) { @@ -2559,7 +2559,7 @@ var dragonBones; * @version DragonBones 5.1 * @language zh_CN */ - var EllipseBoundingBoxData = (function (_super) { + var EllipseBoundingBoxData = /** @class */ (function (_super) { __extends(EllipseBoundingBoxData, _super); function EllipseBoundingBoxData() { return _super !== null && _super.apply(this, arguments) || this; @@ -2696,7 +2696,7 @@ var dragonBones; * @version DragonBones 5.1 * @language zh_CN */ - var PolygonBoundingBoxData = (function (_super) { + var PolygonBoundingBoxData = /** @class */ (function (_super) { __extends(PolygonBoundingBoxData, _super); function PolygonBoundingBoxData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -2918,7 +2918,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var AnimationData = (function (_super) { + var AnimationData = /** @class */ (function (_super) { __extends(AnimationData, _super); function AnimationData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -3030,7 +3030,7 @@ var dragonBones; * @internal */ AnimationData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0.0) { + if (this.cacheFrameRate > 0.0) { // TODO clear cache. return; } this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); @@ -3134,7 +3134,7 @@ var dragonBones; /** * @private */ - var TimelineData = (function (_super) { + var TimelineData = /** @class */ (function (_super) { __extends(TimelineData, _super); function TimelineData() { return _super !== null && _super.apply(this, arguments) || this; @@ -3153,7 +3153,7 @@ var dragonBones; /** * @internal */ - var AnimationTimelineData = (function (_super) { + var AnimationTimelineData = /** @class */ (function (_super) { __extends(AnimationTimelineData, _super); function AnimationTimelineData() { return _super !== null && _super.apply(this, arguments) || this; @@ -3210,7 +3210,7 @@ var dragonBones; * @version DragonBones 5.0 * @language zh_CN */ - var AnimationConfig = (function (_super) { + var AnimationConfig = /** @class */ (function (_super) { __extends(AnimationConfig, _super); function AnimationConfig() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -3321,7 +3321,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var TextureAtlasData = (function (_super) { + var TextureAtlasData = /** @class */ (function (_super) { __extends(TextureAtlasData, _super); function TextureAtlasData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -3388,7 +3388,7 @@ var dragonBones; /** * @private */ - var TextureData = (function (_super) { + var TextureData = /** @class */ (function (_super) { __extends(TextureData, _super); function TextureData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -3467,7 +3467,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Armature = (function (_super) { + var Armature = /** @class */ (function (_super) { __extends(Armature, _super); function Armature() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -3494,7 +3494,7 @@ var dragonBones; return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; }; Armature.prototype._onClear = function () { - if (this._clock !== null) { + if (this._clock !== null) { // Remove clock first. this._clock.remove(this); } for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { @@ -4361,7 +4361,7 @@ var dragonBones; * @version DragonBones 4.5 * @language zh_CN */ - var TransformObject = (function (_super) { + var TransformObject = /** @class */ (function (_super) { __extends(TransformObject, _super); function TransformObject() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -4513,7 +4513,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Bone = (function (_super) { + var Bone = /** @class */ (function (_super) { __extends(Bone, _super); function Bone() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -4766,15 +4766,15 @@ var dragonBones; Bone.prototype.update = function (cacheFrameIndex) { if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. this._transformDirty = false; } - else if (cachedFrameIndex >= 0) { + else if (cachedFrameIndex >= 0) { // Has been Cached. this._transformDirty = true; this._cachedFrameIndex = cachedFrameIndex; } else { - if (this._hasConstraint) { + if (this._hasConstraint) { // Update constraints. for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { var constraint = _a[_i]; if (constraint._root === this) { @@ -4783,22 +4783,22 @@ var dragonBones; } } if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. this._transformDirty = true; this._cachedFrameIndex = -1; } - else if (this._cachedFrameIndex >= 0) { + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. this._transformDirty = false; this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; } - else { + else { // Dirty. this._transformDirty = true; this._cachedFrameIndex = -1; } } } else { - if (this._hasConstraint) { + if (this._hasConstraint) { // Update constraints. for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { var constraint = _c[_b]; if (constraint._root === this) { @@ -4806,7 +4806,7 @@ var dragonBones; } } } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. cacheFrameIndex = -1; this._transformDirty = true; this._cachedFrameIndex = -1; @@ -5012,7 +5012,7 @@ var dragonBones; /** * @internal */ - var Surface = (function (_super) { + var Surface = /** @class */ (function (_super) { __extends(Surface, _super); function Surface() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -5153,7 +5153,7 @@ var dragonBones; var matrices = this._matrixCahce; var helpMatrix = Surface._helpMatrix; if (x < -lA) { - if (y < -lA || y >= lA) { + if (y < -lA || y >= lA) { // Out. return this.globalTransformMatrix; } // Left. @@ -5185,7 +5185,7 @@ var dragonBones; } } else if (x >= lA) { - if (y < -lA || y >= lA) { + if (y < -lA || y >= lA) { // Out. return this.globalTransformMatrix; } // Right. @@ -5217,7 +5217,7 @@ var dragonBones; } } else if (y < -lA) { - if (x < -lA || x >= lA) { + if (x < -lA || x >= lA) { // Out. return this.globalTransformMatrix; } // Up. @@ -5249,7 +5249,7 @@ var dragonBones; } } else if (y >= lA) { - if (x < -lA || x >= lA) { + if (x < -lA || x >= lA) { // Out. return this.globalTransformMatrix; } // Down @@ -5280,7 +5280,7 @@ var dragonBones; matrices[matrixIndex + 6] = helpMatrix.ty; } } - else { + else { // Center. isDown = y > this._k * (x - pX - dX) + pY; matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; if (matrices[matrixIndex] > 0.0) { @@ -5348,15 +5348,15 @@ var dragonBones; Surface.prototype.update = function (cacheFrameIndex) { if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. this._transformDirty = false; } - else if (cachedFrameIndex >= 0) { + else if (cachedFrameIndex >= 0) { // Has been Cached. this._transformDirty = true; this._cachedFrameIndex = cachedFrameIndex; } else { - if (this._hasConstraint) { + if (this._hasConstraint) { // Update constraints. for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { var constraint = _a[_i]; if (constraint._root === this) { @@ -5365,22 +5365,22 @@ var dragonBones; } } if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. this._transformDirty = true; this._cachedFrameIndex = -1; } - else if (this._cachedFrameIndex >= 0) { + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. this._transformDirty = false; this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; } - else { + else { // Dirty. this._transformDirty = true; this._cachedFrameIndex = -1; } } } else { - if (this._hasConstraint) { + if (this._hasConstraint) { // Update constraints. for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { var constraint = _c[_b]; if (constraint._root === this) { @@ -5388,7 +5388,7 @@ var dragonBones; } } } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. cacheFrameIndex = -1; this._transformDirty = true; this._cachedFrameIndex = -1; @@ -5477,7 +5477,7 @@ var dragonBones; /** * @private */ - var DisplayFrame = (function (_super) { + var DisplayFrame = /** @class */ (function (_super) { __extends(DisplayFrame, _super); function DisplayFrame() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -5597,7 +5597,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Slot = (function (_super) { + var Slot = /** @class */ (function (_super) { __extends(Slot, _super); function Slot() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -5640,7 +5640,7 @@ var dragonBones; this._disposeDisplay(eachDisplay, true); } } - if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. this._disposeDisplay(this._meshDisplay, false); } if (this._rawDisplay !== null) { @@ -5775,10 +5775,10 @@ var dragonBones; this._pivotY = 0.0; } // Update original transform. - if (rawDisplayData !== null) { + if (rawDisplayData !== null) { // Compatible. this.origin = rawDisplayData.transform; } - else if (displayData !== null) { + else if (displayData !== null) { // Compatible. this.origin = displayData.transform; } else { @@ -5855,7 +5855,7 @@ var dragonBones; if (this._childArmature !== null) { this._childArmature._parent = this; // Update child armature parent. this._childArmature.clock = this._armature.clock; - if (this._childArmature.inheritAnimation) { + if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. if (this._childArmature.cacheFrameRate === 0) { var cacheFrameRate = this._armature.cacheFrameRate; if (cacheFrameRate !== 0) { @@ -6015,33 +6015,33 @@ var dragonBones; this._verticesDirty = false; // Allow update mesh to reset the dirty value. this._updateMesh(); } - if (isSkinned || isSurface) { + if (isSkinned || isSurface) { // Compatible. return; } } if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. this._transformDirty = false; } - else if (cachedFrameIndex >= 0) { + else if (cachedFrameIndex >= 0) { // Has been Cached. this._transformDirty = true; this._cachedFrameIndex = cachedFrameIndex; } - else if (this._transformDirty || this._parent._childrenTransformDirty) { + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. this._transformDirty = true; this._cachedFrameIndex = -1; } - else if (this._cachedFrameIndex >= 0) { + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. this._transformDirty = false; this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; } - else { + else { // Dirty. this._transformDirty = true; this._cachedFrameIndex = -1; } } - else if (this._transformDirty || this._parent._childrenTransformDirty) { + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. cacheFrameIndex = -1; this._transformDirty = true; this._cachedFrameIndex = -1; @@ -6643,7 +6643,7 @@ var dragonBones; /** * @internal */ - var Constraint = (function (_super) { + var Constraint = /** @class */ (function (_super) { __extends(Constraint, _super); function Constraint() { return _super !== null && _super.apply(this, arguments) || this; @@ -6670,7 +6670,7 @@ var dragonBones; /** * @internal */ - var IKConstraint = (function (_super) { + var IKConstraint = /** @class */ (function (_super) { __extends(IKConstraint, _super); function IKConstraint() { return _super !== null && _super.apply(this, arguments) || this; @@ -6804,7 +6804,7 @@ var dragonBones; /** * @internal */ - var PathConstraint = (function (_super) { + var PathConstraint = /** @class */ (function (_super) { __extends(PathConstraint, _super); function PathConstraint() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -7359,7 +7359,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var WorldClock = (function () { + var WorldClock = /** @class */ (function () { /** * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. @@ -7608,7 +7608,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var Animation = (function (_super) { + var Animation = /** @class */ (function (_super) { __extends(Animation, _super); function Animation() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -7714,10 +7714,10 @@ var dragonBones; * @internal */ Animation.prototype.advanceTime = function (passedTime) { - if (passedTime < 0.0) { + if (passedTime < 0.0) { // Only animationState can reverse play. passedTime = -passedTime; } - if (this._armature.inheritAnimation && this._armature._parent !== null) { + if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; } else { @@ -7743,7 +7743,7 @@ var dragonBones; else { var animationData = animationState.animationData; var cacheFrameRate = animationData.cacheFrameRate; - if (this._animationDirty && cacheFrameRate > 0.0) { + if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. this._animationDirty = false; for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { var bone = _a[_i]; @@ -7772,7 +7772,7 @@ var dragonBones; r++; this._armature._dragonBones.bufferObject(animationState); this._animationDirty = true; - if (this._lastAnimationState === animationState) { + if (this._lastAnimationState === animationState) { // Update last animation state. this._lastAnimationState = null; } } @@ -7782,7 +7782,7 @@ var dragonBones; } animationState.advanceTime(passedTime, 0.0); } - if (i === animationStateCount - 1 && r > 0) { + if (i === animationStateCount - 1 && r > 0) { // Modify animation states size. this._animationStates.length -= r; if (this._lastAnimationState === null && this._animationStates.length > 0) { this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; @@ -7929,7 +7929,7 @@ var dragonBones; animationState.init(this._armature, animationData, animationConfig); this._animationDirty = true; this._armature._cacheFrameIndex = -1; - if (this._animationStates.length > 0) { + if (this._animationStates.length > 0) { // Sort animation state. var added = false; for (var i = 0, l = this._animationStates.length; i < l; ++i) { if (animationState.layer > this._animationStates[i].layer) { @@ -7950,7 +7950,7 @@ var dragonBones; else { this._animationStates.push(animationState); } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { // Child armature play same name animation. var slot = _c[_b]; var childArmature = slot.childArmature; if (childArmature !== null && childArmature.inheritAnimation && @@ -7959,7 +7959,7 @@ var dragonBones; childArmature.animation.fadeIn(animationName); // } } - for (var k in animationData.animationTimelines) { + for (var k in animationData.animationTimelines) { // Blend animation node. var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); if (childAnimationState === null) { continue; @@ -8526,7 +8526,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var AnimationState = (function (_super) { + var AnimationState = /** @class */ (function (_super) { __extends(AnimationState, _super); function AnimationState() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -8630,7 +8630,7 @@ var dragonBones; this._parent = null; }; AnimationState.prototype._updateTimelines = function () { - { + { // Update constraint timelines. for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { var constraint = _a[_i]; var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); @@ -8650,7 +8650,7 @@ var dragonBones; } } } - else if (this.resetToPose) { + else if (this.resetToPose) { // Pose timeline. var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); timeline.target = constraint; timeline.init(this._armature, this, null); @@ -8661,7 +8661,7 @@ var dragonBones; } }; AnimationState.prototype._updateBoneAndSlotTimelines = function () { - { + { // Update bone and surface timelines. var boneTimelines = {}; // Create bone timelines map. for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { @@ -8687,10 +8687,10 @@ var dragonBones; if (!this.containsBoneMask(timelineName)) { continue; } - if (timelineName in boneTimelines) { + if (timelineName in boneTimelines) { // Remove bone timeline from map. delete boneTimelines[timelineName]; } - else { + else { // Create new bone timeline. var timelineDatas = this._animationData.getBoneTimelines(timelineName); var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); if (timelineDatas !== null) { @@ -8744,7 +8744,7 @@ var dragonBones; } } } - else if (this.resetToPose) { + else if (this.resetToPose) { // Pose timeline. if (bone._boneData.type === 0 /* Bone */) { var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); timeline.target = blendState; @@ -8762,7 +8762,7 @@ var dragonBones; } } } - for (var k in boneTimelines) { + for (var k in boneTimelines) { // Remove bone timelines. for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { var timeline = _h[_g]; var index = this._boneTimelines.indexOf(timeline); @@ -8778,7 +8778,7 @@ var dragonBones; } } } - { + { // Update slot timelines. var slotTimelines = {}; var ffdFlags = []; // Create slot timelines map. @@ -8806,10 +8806,10 @@ var dragonBones; continue; } var timelineName = slot.name; - if (timelineName in slotTimelines) { + if (timelineName in slotTimelines) { // Remove slot timeline from map. delete slotTimelines[timelineName]; } - else { + else { // Create new slot timeline. var displayIndexFlag = false; var colorFlag = false; ffdFlags.length = 0; @@ -8866,7 +8866,7 @@ var dragonBones; } } } - if (this.resetToPose) { + if (this.resetToPose) { // Pose timeline. if (!displayIndexFlag) { var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); timeline.target = slot; @@ -8900,7 +8900,7 @@ var dragonBones; } } } - for (var k in slotTimelines) { + for (var k in slotTimelines) { // Remove slot timelines. for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { var timeline = _s[_r]; var index = this._slotTimelines.indexOf(timeline); @@ -8919,7 +8919,7 @@ var dragonBones; }; AnimationState.prototype._advanceFadeTime = function (passedTime) { var isFadeOut = this._fadeState > 0; - if (this._subFadeState < 0) { + if (this._subFadeState < 0) { // Fade start event. this._subFadeState = 0; var eventActive = this._parent === null && this.actionEnabled; if (eventActive) { @@ -8937,17 +8937,17 @@ var dragonBones; passedTime = -passedTime; } this._fadeTime += passedTime; - if (this._fadeTime >= this.fadeTotalTime) { + if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. this._subFadeState = 1; this._fadeProgress = isFadeOut ? 0.0 : 1.0; } - else if (this._fadeTime > 0.0) { + else if (this._fadeTime > 0.0) { // Fading. this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); } - else { + else { // Before fade. this._fadeProgress = isFadeOut ? 1.0 : 0.0; } - if (this._subFadeState > 0) { + if (this._subFadeState > 0) { // Fade complete event. if (!isFadeOut) { this._playheadState |= 1; // x1 this._fadeState = 0; @@ -9047,7 +9047,7 @@ var dragonBones; this._advanceFadeTime(passedTime); } // Update time. - if (this._playheadState === 3) { + if (this._playheadState === 3) { // 11 if (this.timeScale !== 1.0) { passedTime *= this.timeScale; } @@ -9070,31 +9070,31 @@ var dragonBones; if (this._parent !== null) { this._weightResult *= this._parent._weightResult; } - if (this._actionTimeline.playState <= 0) { + if (this._actionTimeline.playState <= 0) { // Update main timeline. this._actionTimeline.update(time); } if (this._weight === 0.0) { return; } - if (isCacheEnabled) { + if (isCacheEnabled) { // Cache time internval. var internval = cacheFrameRate * 2.0; this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; } - if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { + if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { // Update zOrder timeline. this._zOrderTimeline.update(time); } - if (isCacheEnabled) { + if (isCacheEnabled) { // Update cache. var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint - if (this._armature._cacheFrameIndex === cacheFrameIndex) { + if (this._armature._cacheFrameIndex === cacheFrameIndex) { // Same cache. isUpdateTimeline = false; isUpdateBoneTimeline = false; } else { this._armature._cacheFrameIndex = cacheFrameIndex; - if (this._animationData.cachedFrames[cacheFrameIndex]) { + if (this._animationData.cachedFrames[cacheFrameIndex]) { // Cached. isUpdateBoneTimeline = false; } - else { + else { // Cache. this._animationData.cachedFrames[cacheFrameIndex] = true; } } @@ -9176,7 +9176,7 @@ var dragonBones; if (timeline.playState <= 0) { timeline.update(time); } - if (this.blendType === 1 /* E1D */) { + if (this.blendType === 1 /* E1D */) { // TODO var animationState = timeline.target; var d = this.parameterX - animationState.positionX; if (d >= 0.0) { @@ -9217,7 +9217,7 @@ var dragonBones; if (this._fadeState === 0) { if (this._subFadeState > 0) { this._subFadeState = 0; - if (this._poseTimelines.length > 0) { + if (this._poseTimelines.length > 0) { // Remove pose timelines. for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { var timeline = _a[_i]; var index = this._boneTimelines.indexOf(timeline); @@ -9255,7 +9255,7 @@ var dragonBones; } } if (this._actionTimeline.playState > 0) { - if (this.autoFadeOutTime >= 0.0) { + if (this.autoFadeOutTime >= 0.0) { // Auto fade out. this.fadeOut(this.autoFadeOutTime); } } @@ -9310,7 +9310,7 @@ var dragonBones; this._playheadState &= 2; // x0 } if (this._fadeState > 0) { - if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { + if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { // If the animation is already in fade out, the new fade out will be ignored. return; } } @@ -9387,10 +9387,10 @@ var dragonBones; if (currentBone === null) { return; } - if (this._boneMask.indexOf(boneName) < 0) { + if (this._boneMask.indexOf(boneName) < 0) { // Add mixing this._boneMask.push(boneName); } - if (recursive) { + if (recursive) { // Add recursive mixing. for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { var bone = _a[_i]; if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { @@ -9417,14 +9417,14 @@ var dragonBones; AnimationState.prototype.removeBoneMask = function (boneName, recursive) { if (recursive === void 0) { recursive = true; } var index = this._boneMask.indexOf(boneName); - if (index >= 0) { + if (index >= 0) { // Remove mixing. this._boneMask.splice(index, 1); } if (recursive) { var currentBone = this._armature.getBone(boneName); if (currentBone !== null) { var bones = this._armature.getBones(); - if (this._boneMask.length > 0) { + if (this._boneMask.length > 0) { // Remove recursive mixing. for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { var bone = bones_1[_i]; var index_1 = this._boneMask.indexOf(bone.name); @@ -9433,7 +9433,7 @@ var dragonBones; } } } - else { + else { // Add unrecursive mixing. for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { var bone = bones_2[_a]; if (bone === currentBone) { @@ -9746,7 +9746,7 @@ var dragonBones; /** * @internal */ - var BlendState = (function (_super) { + var BlendState = /** @class */ (function (_super) { __extends(BlendState, _super); function BlendState() { return _super !== null && _super.apply(this, arguments) || this; @@ -9834,7 +9834,7 @@ var dragonBones; /** * @internal */ - var TimelineState = (function (_super) { + var TimelineState = /** @class */ (function (_super) { __extends(TimelineState, _super); function TimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -9871,12 +9871,12 @@ var dragonBones; var prevState = this.playState; var prevPlayTimes = this.currentPlayTimes; var prevTime = this.currentTime; - if (this._actionTimeline !== null && this._frameCount <= 1) { + if (this._actionTimeline !== null && this._frameCount <= 1) { // No frame or only one frame. this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; this.currentPlayTimes = 1; this.currentTime = this._actionTimeline.currentTime; } - else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { + else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { // Action timeline or has scale and offset. var playTimes = this._animationState.playTimes; var totalTime = playTimes * this._duration; passedTime *= this._timeScale; @@ -9911,7 +9911,7 @@ var dragonBones; } this.currentTime += this._position; } - else { + else { // Multi frames. this.playState = this._actionTimeline.playState; this.currentPlayTimes = this._actionTimeline.currentPlayTimes; this.currentTime = this._actionTimeline.currentTime; @@ -9968,7 +9968,7 @@ var dragonBones; } else if (this._frameIndex < 0) { this._frameIndex = 0; - if (this._timelineData !== null) { + if (this._timelineData !== null) { // May be pose timeline. this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; } this._onArriveAtFrame(); @@ -9986,7 +9986,7 @@ var dragonBones; /** * @internal */ - var TweenTimelineState = (function (_super) { + var TweenTimelineState = /** @class */ (function (_super) { __extends(TweenTimelineState, _super); function TweenTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10094,7 +10094,7 @@ var dragonBones; /** * @internal */ - var SingleValueTimelineState = (function (_super) { + var SingleValueTimelineState = /** @class */ (function (_super) { __extends(SingleValueTimelineState, _super); function SingleValueTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10145,7 +10145,7 @@ var dragonBones; /** * @internal */ - var DoubleValueTimelineState = (function (_super) { + var DoubleValueTimelineState = /** @class */ (function (_super) { __extends(DoubleValueTimelineState, _super); function DoubleValueTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10206,7 +10206,7 @@ var dragonBones; /** * @internal */ - var MutilpleValueTimelineState = (function (_super) { + var MutilpleValueTimelineState = /** @class */ (function (_super) { __extends(MutilpleValueTimelineState, _super); function MutilpleValueTimelineState() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -10312,7 +10312,7 @@ var dragonBones; /** * @internal */ - var ActionTimelineState = (function (_super) { + var ActionTimelineState = /** @class */ (function (_super) { __extends(ActionTimelineState, _super); function ActionTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10362,7 +10362,7 @@ var dragonBones; var eventDispatcher = this._armature.eventDispatcher; if (prevState < 0) { if (this.playState !== prevState) { - if (this._animationState.displayControl && this._animationState.resetToPose) { + if (this._animationState.displayControl && this._animationState.resetToPose) { // Reset zorder to pose. this._armature._sortZOrder(null, 0); } prevPlayTimes = this.currentPlayTimes; @@ -10401,7 +10401,7 @@ var dragonBones; var timelineData = this._timelineData; var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { + if (this._frameIndex !== frameIndex) { // Arrive at frame. var crossedFrameIndex = this._frameIndex; this._frameIndex = frameIndex; if (this._timelineArray !== null) { @@ -10410,8 +10410,8 @@ var dragonBones; if (crossedFrameIndex < 0) { var prevFrameIndex = Math.floor(prevTime * this._frameRate); crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - if (this.currentPlayTimes === prevPlayTimes) { - if (crossedFrameIndex === frameIndex) { + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (crossedFrameIndex === frameIndex) { // Uncrossed. crossedFrameIndex = -1; } } @@ -10421,10 +10421,10 @@ var dragonBones; // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem var framePosition = this._frameArray[frameOffset] / this._frameRate; if (this._position <= framePosition && - framePosition <= this._position + this._duration) { + framePosition <= this._position + this._duration) { // Support interval play. this._onCrossFrame(crossedFrameIndex); } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event after first frame. this._armature._dragonBones.bufferEvent(loopCompleteEvent); loopCompleteEvent = null; } @@ -10446,8 +10446,8 @@ var dragonBones; var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { - if (prevTime <= framePosition) { + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { // Crossed. if (crossedFrameIndex > 0) { crossedFrameIndex--; } @@ -10455,7 +10455,7 @@ var dragonBones; crossedFrameIndex = this._frameCount - 1; } } - else if (crossedFrameIndex === frameIndex) { + else if (crossedFrameIndex === frameIndex) { // Uncrossed. crossedFrameIndex = -1; } } @@ -10472,10 +10472,10 @@ var dragonBones; var framePosition = this._frameArray[frameOffset] / this._frameRate; if (this._position <= framePosition && framePosition <= this._position + this._duration // - ) { + ) { // Support interval play. this._onCrossFrame(crossedFrameIndex); } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event before first frame. this._armature._dragonBones.bufferEvent(loopCompleteEvent); loopCompleteEvent = null; } @@ -10493,13 +10493,13 @@ var dragonBones; this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; // Arrive at frame. var framePosition = this._frameArray[this._frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { + if (this.currentPlayTimes === prevPlayTimes) { // Start. if (prevTime <= framePosition) { this._onCrossFrame(this._frameIndex); } } - else if (this._position <= framePosition) { - if (!isReverse && loopCompleteEvent !== null) { + else if (this._position <= framePosition) { // Loop complete. + if (!isReverse && loopCompleteEvent !== null) { // Add loop complete event before first frame. this._armature._dragonBones.bufferEvent(loopCompleteEvent); loopCompleteEvent = null; } @@ -10525,7 +10525,7 @@ var dragonBones; /** * @internal */ - var ZOrderTimelineState = (function (_super) { + var ZOrderTimelineState = /** @class */ (function (_super) { __extends(ZOrderTimelineState, _super); function ZOrderTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10551,7 +10551,7 @@ var dragonBones; /** * @internal */ - var BoneAllTimelineState = (function (_super) { + var BoneAllTimelineState = /** @class */ (function (_super) { __extends(BoneAllTimelineState, _super); function BoneAllTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10565,7 +10565,7 @@ var dragonBones; this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); } - if (this._timelineData === null) { + if (this._timelineData === null) { // Pose. this._rd[4] = 1.0; this._rd[5] = 1.0; } @@ -10616,7 +10616,7 @@ var dragonBones; /** * @internal */ - var BoneTranslateTimelineState = (function (_super) { + var BoneTranslateTimelineState = /** @class */ (function (_super) { __extends(BoneTranslateTimelineState, _super); function BoneTranslateTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10658,7 +10658,7 @@ var dragonBones; /** * @internal */ - var BoneRotateTimelineState = (function (_super) { + var BoneRotateTimelineState = /** @class */ (function (_super) { __extends(BoneRotateTimelineState, _super); function BoneRotateTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10711,7 +10711,7 @@ var dragonBones; /** * @internal */ - var BoneScaleTimelineState = (function (_super) { + var BoneScaleTimelineState = /** @class */ (function (_super) { __extends(BoneScaleTimelineState, _super); function BoneScaleTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10721,7 +10721,7 @@ var dragonBones; }; BoneScaleTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { + if (this._timelineData === null) { // Pose. this._resultA = 1.0; this._resultB = 1.0; } @@ -10759,7 +10759,7 @@ var dragonBones; /** * @internal */ - var SurfaceTimelineState = (function (_super) { + var SurfaceTimelineState = /** @class */ (function (_super) { __extends(SurfaceTimelineState, _super); function SurfaceTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10838,7 +10838,7 @@ var dragonBones; /** * @internal */ - var AlphaTimelineState = (function (_super) { + var AlphaTimelineState = /** @class */ (function (_super) { __extends(AlphaTimelineState, _super); function AlphaTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10848,7 +10848,7 @@ var dragonBones; }; AlphaTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { + if (this._timelineData === null) { // Pose. this._result = 1.0; } }; @@ -10882,7 +10882,7 @@ var dragonBones; /** * @internal */ - var SlotDisplayTimelineState = (function (_super) { + var SlotDisplayTimelineState = /** @class */ (function (_super) { __extends(SlotDisplayTimelineState, _super); function SlotDisplayTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -10907,7 +10907,7 @@ var dragonBones; /** * @internal */ - var SlotColorTimelineState = (function (_super) { + var SlotColorTimelineState = /** @class */ (function (_super) { __extends(SlotColorTimelineState, _super); function SlotColorTimelineState() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -10968,7 +10968,7 @@ var dragonBones; this._result[7] = colorArray[colorOffset++]; } } - else { + else { // Pose. var slot = this.target; var color = slot.slotData.color; this._result[0] = color.alphaMultiplier; @@ -11053,7 +11053,7 @@ var dragonBones; /** * @internal */ - var SlotZIndexTimelineState = (function (_super) { + var SlotZIndexTimelineState = /** @class */ (function (_super) { __extends(SlotZIndexTimelineState, _super); function SlotZIndexTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -11063,7 +11063,7 @@ var dragonBones; }; SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { + if (this._timelineData === null) { // Pose. var blendState = this.target; var slot = blendState.target; this._result = slot.slotData.zIndex; @@ -11095,7 +11095,7 @@ var dragonBones; /** * @internal */ - var DeformTimelineState = (function (_super) { + var DeformTimelineState = /** @class */ (function (_super) { __extends(DeformTimelineState, _super); function DeformTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -11199,7 +11199,7 @@ var dragonBones; /** * @internal */ - var IKConstraintTimelineState = (function (_super) { + var IKConstraintTimelineState = /** @class */ (function (_super) { __extends(IKConstraintTimelineState, _super); function IKConstraintTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -11234,7 +11234,7 @@ var dragonBones; /** * @internal */ - var AnimationProgressTimelineState = (function (_super) { + var AnimationProgressTimelineState = /** @class */ (function (_super) { __extends(AnimationProgressTimelineState, _super); function AnimationProgressTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -11262,7 +11262,7 @@ var dragonBones; /** * @internal */ - var AnimationWeightTimelineState = (function (_super) { + var AnimationWeightTimelineState = /** @class */ (function (_super) { __extends(AnimationWeightTimelineState, _super); function AnimationWeightTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -11290,7 +11290,7 @@ var dragonBones; /** * @internal */ - var AnimationParametersTimelineState = (function (_super) { + var AnimationParametersTimelineState = /** @class */ (function (_super) { __extends(AnimationParametersTimelineState, _super); function AnimationParametersTimelineState() { return _super !== null && _super.apply(this, arguments) || this; @@ -11352,7 +11352,7 @@ var dragonBones; * @version DragonBones 4.5 * @language zh_CN */ - var EventObject = (function (_super) { + var EventObject = /** @class */ (function (_super) { __extends(EventObject, _super); function EventObject() { return _super !== null && _super.apply(this, arguments) || this; @@ -11523,7 +11523,7 @@ var dragonBones; /** * @private */ - var DataParser = (function () { + var DataParser = /** @class */ (function () { function DataParser() { } DataParser._getArmatureType = function (value) { @@ -11835,7 +11835,7 @@ var dragonBones; /** * @private */ - var ObjectDataParser = (function (_super) { + var ObjectDataParser = /** @class */ (function (_super) { __extends(ObjectDataParser, _super); function ObjectDataParser() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -11943,7 +11943,7 @@ var dragonBones; var stepIndex = -2; for (var i = 0, l = samples.length; i < l; ++i) { var t = (i + 1) / (l + 1); // float - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { + while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 stepIndex += 6; } var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; @@ -11975,7 +11975,7 @@ var dragonBones; var stepIndex = 0; for (var i = 0, l = samples.length; i < l; ++i) { var t = (i + 1) / (l + 1); // float - while (curve[stepIndex + 6] < t) { + while (curve[stepIndex + 6] < t) { // stepIndex + 3 * 2 stepIndex += 6; } var x1 = curve[stepIndex]; @@ -12029,13 +12029,13 @@ var dragonBones; var action = actions_2[_i]; this._armature.addAction(action, false); } - if (this._actionFrames.length === 0) { + if (this._actionFrames.length === 0) { // First frame. frame = new ActionFrame(); frame.frameStart = 0; this._actionFrames.push(frame); frame = null; } - for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { + for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { // Get same frame. var eachFrame = _b[_a]; if (eachFrame.frameStart === frameStart) { frame = eachFrame; @@ -12046,12 +12046,12 @@ var dragonBones; } frameIndex++; } - if (frame === null) { + if (frame === null) { // Create and cache frame. frame = new ActionFrame(); frame.frameStart = frameStart; this._actionFrames.splice(frameIndex, 0, frame); } - for (var i = 0; i < actions.length; ++i) { + for (var i = 0; i < actions.length; ++i) { // Cache action offsets. frame.actions.push(actionOffset + i); } }; @@ -12066,7 +12066,7 @@ var dragonBones; else { armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); } - if (armature.frameRate === 0) { + if (armature.frameRate === 0) { // Data error. armature.frameRate = 24; } this._armature = armature; @@ -12099,12 +12099,12 @@ var dragonBones; var rawBone = rawBones_1[_i]; var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); var bone = this._parseBone(rawBone); - if (parentName.length > 0) { + if (parentName.length > 0) { // Get bone parent. var parent_1 = armature.getBone(parentName); if (parent_1 !== null) { bone.parent = parent_1; } - else { + else { // Cache. if (!(parentName in this._cacheBones)) { this._cacheBones[parentName] = []; } @@ -12158,14 +12158,14 @@ var dragonBones; } } } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { + for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { // Link mesh. var rawData_1 = this._cacheRawMeshes[i]; var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); if (shareName.length === 0) { continue; } var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - if (skinName.length === 0) { + if (skinName.length === 0) { // skinName = dragonBones.DataParser.DEFAULT_NAME; } var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; @@ -12188,7 +12188,7 @@ var dragonBones; for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { var action = actions_3[_h]; armature.addAction(action, true); - if (action.type === 0 /* Play */) { + if (action.type === 0 /* Play */) { // Set default animation from default action. var animation = armature.getAnimation(action.name); if (animation !== null) { armature.defaultAnimation = animation; @@ -12489,7 +12489,7 @@ var dragonBones; }; ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { this._parseGeometry(rawData, mesh.geometry); - if (dragonBones.DataParser.WEIGHTS in rawData) { + if (dragonBones.DataParser.WEIGHTS in rawData) { // Cache pose data. var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; @@ -12619,7 +12619,7 @@ var dragonBones; var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - if (skinName.length === 0) { + if (skinName.length === 0) { // skinName = dragonBones.DataParser.DEFAULT_NAME; } this._slot = this._armature.getSlot(slotName); @@ -12857,7 +12857,7 @@ var dragonBones; this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; break; } - if (keyFrameCount === 1) { + if (keyFrameCount === 1) { // Only one frame. timeline.frameIndicesOffset = -1; this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; } @@ -13083,7 +13083,7 @@ var dragonBones; this._frameArray.length += 1 + 1 + actionCount; this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. - for (var i = 0; i < actionCount; ++i) { + for (var i = 0; i < actionCount; ++i) { // Action offsets. this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; } return frameOffset; @@ -13224,7 +13224,7 @@ var dragonBones; var colorOffset = -1; if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; - for (var k in rawColor) { + for (var k in rawColor) { // Detects the presence of color. // tslint:disable-next-line:no-unused-expression k; this._parseColorTransform(rawColor, this._helpColorTransform); @@ -13284,7 +13284,7 @@ var dragonBones; this._frameFloatArray.length += vertexCount * 2; } for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices === null) { + if (rawVertices === null) { // Fill 0. x = 0.0; y = 0.0; } @@ -13302,7 +13302,7 @@ var dragonBones; y = rawVertices[i + 1 - offset]; } } - if (weight !== null) { + if (weight !== null) { // If mesh is skinned, transform point by bone bind pose. var rawBonePoses = this._weightBonePoses[meshName]; var vertexBoneCount = this._intArray[iB++]; this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); @@ -13696,7 +13696,7 @@ var dragonBones; data.version = version; data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); - if (data.frameRate === 0) { + if (data.frameRate === 0) { // Data error. data.frameRate = 24; } if (dragonBones.DataParser.ARMATURE in rawData) { @@ -13707,7 +13707,7 @@ var dragonBones; var rawArmature = rawArmatures_1[_i]; data.addArmature(this._parseArmature(rawArmature, scale)); } - if (!this._data.binary) { + if (!this._data.binary) { // DragonBones.webAssembly ? 0 : null; this._modifyArray(); } if (dragonBones.DataParser.STAGE in rawData) { @@ -13799,7 +13799,7 @@ var dragonBones; /** * @private */ - var ActionFrame = (function () { + var ActionFrame = /** @class */ (function () { function ActionFrame() { this.frameStart = 0; this.actions = []; @@ -13835,7 +13835,7 @@ var dragonBones; /** * @private */ - var BinaryDataParser = (function (_super) { + var BinaryDataParser = /** @class */ (function (_super) { __extends(BinaryDataParser, _super); function BinaryDataParser() { return _super !== null && _super.apply(this, arguments) || this; @@ -14230,7 +14230,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var BaseFactory = (function () { + var BaseFactory = /** @class */ (function () { /** * - Create a factory instance. (typically only one global factory instance is required) * @version DragonBones 3.0 @@ -14272,7 +14272,7 @@ var dragonBones; } } } - if (this.autoSearch) { + if (this.autoSearch) { // Will be search all data, if the autoSearch is true. for (var k in this._textureAtlasDataMap) { for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { var textureAtlasData = _c[_b]; @@ -14296,7 +14296,7 @@ var dragonBones; armatureData = dragonBonesData.getArmature(armatureName); } } - if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { + if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { // Will be search all data, if do not give a data name or the autoSearch is true. for (var k in this._dragonBonesDataMap) { dragonBonesData = this._dragonBonesDataMap[k]; if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { @@ -15153,7 +15153,7 @@ var dragonBones; /** * @private */ - var BuildArmaturePackage = (function () { + var BuildArmaturePackage = /** @class */ (function () { function BuildArmaturePackage() { this.dataName = ""; this.textureAtlasName = ""; @@ -15191,7 +15191,7 @@ if (CC_EDITOR) { var dragonBones; (function (dragonBones) { var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; - var DragonBonesAsset = (function (_super) { + var DragonBonesAsset = /** @class */ (function (_super) { __extends(DragonBonesAsset, _super); function DragonBonesAsset() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -15250,7 +15250,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var CocosTextureAtlasData = (function (_super) { + var CocosTextureAtlasData = /** @class */ (function (_super) { __extends(CocosTextureAtlasData, _super); function CocosTextureAtlasData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -15320,7 +15320,7 @@ var dragonBones; /** * @internal */ - var CocosTextureData = (function (_super) { + var CocosTextureData = /** @class */ (function (_super) { __extends(CocosTextureData, _super); function CocosTextureData() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -15380,7 +15380,7 @@ var dragonBones; /** * @see dragonBones.IArmatureProxy */ - var CocosArmatureComponent = (function (_super) { + var CocosArmatureComponent = /** @class */ (function (_super) { __extends(CocosArmatureComponent, _super); function CocosArmatureComponent() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -15398,6 +15398,7 @@ var dragonBones; * @internal */ _this._armatureName = ""; + _this.dragonBonesName = ''; /** * @internal */ @@ -15425,6 +15426,7 @@ var dragonBones; _this._timeScale = 1.0; return _this; } + CocosArmatureComponent_1 = CocosArmatureComponent; CocosArmatureComponent.prototype.dbInit = function (armature) { this._armature = armature; }; @@ -15447,7 +15449,7 @@ var dragonBones; }; CocosArmatureComponent.prototype.destroy = function () { this.dispose(); - if (false) { + if (false) { // `super.destroy()` will be called in `dbClear()`. _super.prototype.destroy.call(this); } return true; @@ -15483,14 +15485,122 @@ var dragonBones; enumerable: true, configurable: true }); - CocosArmatureComponent.prototype.start = function () { + Object.defineProperty(CocosArmatureComponent.prototype, "dragonBonesAsset", { + get: function () { + return this._dragonBonesAsset || null; + }, + set: function (value) { + this._dragonBonesAsset = value; + this._loadAndDisplayDragonBones(); + }, + enumerable: true, + configurable: true + }); + CocosArmatureComponent.prototype._loadAndDisplayDragonBones = function () { + console.warn("\u5F00\u59CB\u521B\u5EFA DragonBones Armature"); + var notExistAsset = !this.dragonBonesAsset + || !this.dragonBonesAsset.dragonBonesData + || !this.dragonBonesAsset.textureAtlases + || !this.dragonBonesAsset.textures; + if (notExistAsset) { + console.error("dragonBonesAsset \u4E3A\u7A7A"); + return; + } + console.warn("\u521B\u5EFA DragonBones Armature"); + this._parseDragonAsset(); + this._parseDragonAtlasAsset(); + this.display(); }; + CocosArmatureComponent.prototype._parseDragonAsset = function () { + var dragonBonesData; + if (typeof this.dragonBonesAsset.dragonBonesData === 'string') { + console.log("JSON.parse(this.dragonBonesAsset.dragonBonesData)"); + dragonBonesData = JSON.parse(this.dragonBonesAsset.dragonBonesData); + } + else { + dragonBonesData = this.dragonBonesAsset.dragonBonesData; + } + var data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); + if (data === null) { + console.warn("DragonBones Armature not exist"); + return; + } + this._armatureName = data.armatureNames[0]; + console.log("parseDragonBonesData", data); + }; + CocosArmatureComponent.prototype._parseDragonAtlasAsset = function () { + var _this = this; + var textureAtlases = this.dragonBonesAsset.textureAtlases; + if (typeof textureAtlases[0] === 'string') { + console.log('JSON.parse(this.dragonBonesAsset.textureAtlases)'); + textureAtlases = JSON.parse(textureAtlases); + } + else { + textureAtlases = this.dragonBonesAsset.textureAtlases; + } + var texture = Array.isArray(this.dragonBonesAsset.textures) ? this.dragonBonesAsset.textures[0] : this.dragonBonesAsset.textures; + if (typeof texture === 'string') { + cc.textureCache.addImage(texture, function (tex, error) { + if (error) { + console.error("error:" + error.message, error); + return; + } + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); + console.log("parseTextureAtlasData", data); + console.log("dragonBonesAsset", _this.dragonBonesAsset); + console.log("textureAtlases", textureAtlases); + console.log("texture", tex); + }, this); + } + else { + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); + console.log("string parseTextureAtlasData", data); + console.log("string dragonBonesAsset", this.dragonBonesAsset); + } + }; + CocosArmatureComponent.prototype.display = function () { + console.warn("Armature name:" + this._armatureName + ",dragonBonesName:" + this.dragonBonesName); + var armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); + if (!armatureComponent) { + console.log("armatureComponent is null"); + return; + } + armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); + armatureComponent.node.x = 0.0; + armatureComponent.node.y = 0; + this.node.addChild(armatureComponent.node); + this._dragonBonesNode = armatureComponent.node; + console.log("play animation default animation"); + }; + CocosArmatureComponent.prototype.onLoad = function () { + // this.display(); + if (!!this._dragonBonesNode) { + var component = this._dragonBonesNode.getComponent(CocosArmatureComponent_1); + var state = component.animation.play(component.animation.animationNames[0], 0); + if (!state) { + return; + } + console.warn("\u64AD\u653E\u52A8\u753B\uFF1A" + state.name, state); + } + else { + this._loadAndDisplayDragonBones(); + // this.onLoad(); + // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); + // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); + } + }; + var CocosArmatureComponent_1; __decorate([ - property + property(cc.String) ], CocosArmatureComponent.prototype, "_armatureName", void 0); __decorate([ - property + property(cc.String) ], CocosArmatureComponent.prototype, "_animationName", void 0); + __decorate([ + property({ + type: dragonBones.DragonBonesAsset, + }) + ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); __decorate([ property({ type: dragonBones.DragonBonesAsset, @@ -15498,7 +15608,7 @@ var dragonBones; tooltip: "DragonBones Asset", visible: true, }) - ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); + ], CocosArmatureComponent.prototype, "dragonBonesAsset", null); __decorate([ property({ type: [cc.String], @@ -15539,7 +15649,7 @@ var dragonBones; range: [-2, 2, 0.01], }) ], CocosArmatureComponent.prototype, "_timeScale", void 0); - CocosArmatureComponent = __decorate([ + CocosArmatureComponent = CocosArmatureComponent_1 = __decorate([ ccclass("CocosArmatureComponent"), executeInEditMode, disallowMultiple, @@ -15586,7 +15696,7 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var CocosSlot = (function (_super) { + var CocosSlot = /** @class */ (function (_super) { __extends(CocosSlot, _super); function CocosSlot() { var _this = _super !== null && _super.apply(this, arguments) || this; @@ -15697,7 +15807,7 @@ var dragonBones; var sprite = this._renderDisplay.getComponent(cc.Sprite); if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { var currentTextureAtlasData = currentTextureData.parent; - if (this._armature.replacedTexture !== null) { + if (this._armature.replacedTexture !== null) { // Update replaced texture atlas. if (this._armature._replaceTextureAtlasData === null) { currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); currentTextureAtlasData.copyFrom(currentTextureData.parent); @@ -15711,7 +15821,7 @@ var dragonBones; } var renderTexture = currentTextureData.renderTexture; if (renderTexture !== null) { - if (this._geometryData !== null) { + if (this._geometryData !== null) { // Mesh. var data = this._geometryData.data; var intArray = data.intArray; var floatArray = data.floatArray; @@ -15781,7 +15891,7 @@ var dragonBones; // Delay to update cocos mesh. (some cocos bug.) this._ccMeshDirty = true; } - else { + else { // Normal texture. this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. sprite.spriteFrame = renderTexture; @@ -16000,7 +16110,7 @@ var dragonBones; var dragonBones; (function (dragonBones) { var ccclass = cc._decorator.ccclass; - var ClockHandler = (function (_super) { + var ClockHandler = /** @class */ (function (_super) { __extends(ClockHandler, _super); function ClockHandler() { return _super !== null && _super.apply(this, arguments) || this; @@ -16023,14 +16133,14 @@ var dragonBones; * @version DragonBones 3.0 * @language zh_CN */ - var CocosFactory = (function (_super) { + var CocosFactory = /** @class */ (function (_super) { __extends(CocosFactory, _super); function CocosFactory(dataParser) { if (dataParser === void 0) { dataParser = null; } var _this = _super.call(this, dataParser) || this; _this._node = null; _this._armatureNode = null; - if (!CC_EDITOR) { + if (!CC_EDITOR) { // Is playing. if (_this._node === null) { var nodeName = "DragonBones Node"; _this._node = cc.find(nodeName); @@ -16080,7 +16190,7 @@ var dragonBones; configurable: true }); CocosFactory.prototype._isSupportMesh = function () { - if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { + if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { // creator.d.ts error. console.warn("Only webgl mode can support mesh."); return false; } diff --git a/Cocos/README.md b/Cocos/README.md deleted file mode 100644 index 09b04ee4..00000000 --- a/Cocos/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# DragonBones Cocos Creator library - -## [Demos](./Demos/) -* [Hello DragonBones](./Demos/assets/Script/HelloDragonBones.ts) - -## [Cocos Creator website](http://www.cocos.com/) \ No newline at end of file From 2095e7bf1610d5e5b27b295002956d3581a7cf9b Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Mon, 30 Jul 2018 22:16:42 +0800 Subject: [PATCH 2/2] polish scripts --- Cocos/1.x/out/dragonBones.d.ts | 13108 +++---- Cocos/1.x/out/dragonBones.js | 32731 ++++++++-------- Cocos/1.x/out/dragonBones.min.js | 2 +- .../cocos/CocosArmatureComponent.ts | 25 +- .../dragonbones/assets/dragonBones.js | 32731 ++++++++-------- 5 files changed, 39291 insertions(+), 39306 deletions(-) diff --git a/Cocos/1.x/out/dragonBones.d.ts b/Cocos/1.x/out/dragonBones.d.ts index a4919c90..86a421c5 100755 --- a/Cocos/1.x/out/dragonBones.d.ts +++ b/Cocos/1.x/out/dragonBones.d.ts @@ -1,6554 +1,6554 @@ -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - const enum BinaryOffset { - WeigthBoneCount = 0, - WeigthFloatOffset = 1, - WeigthBoneIndices = 2, - GeometryVertexCount = 0, - GeometryTriangleCount = 1, - GeometryFloatOffset = 2, - GeometryWeightOffset = 3, - GeometryVertexIndices = 4, - TimelineScale = 0, - TimelineOffset = 1, - TimelineKeyFrameCount = 2, - TimelineFrameValueCount = 3, - TimelineFrameValueOffset = 4, - TimelineFrameOffset = 5, - FramePosition = 0, - FrameTweenType = 1, - FrameTweenEasingOrCurveSampleCount = 2, - FrameCurveSamples = 3, - DeformVertexOffset = 0, - DeformCount = 1, - DeformValueCount = 2, - DeformValueOffset = 3, - DeformFloatOffset = 4 - } - /** - * @private - */ - const enum ArmatureType { - Armature = 0, - MovieClip = 1, - Stage = 2 - } - /** - * @private - */ - const enum BoneType { - Bone = 0, - Surface = 1 - } - /** - * @private - */ - const enum DisplayType { - Image = 0, - Armature = 1, - Mesh = 2, - BoundingBox = 3, - Path = 4 - } - /** - * - Bounding box type. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框类型。 - * @version DragonBones 5.0 - * @language zh_CN - */ - const enum BoundingBoxType { - Rectangle = 0, - Ellipse = 1, - Polygon = 2 - } - /** - * @private - */ - const enum ActionType { - Play = 0, - Frame = 10, - Sound = 11 - } - /** - * @private - */ - const enum BlendMode { - Normal = 0, - Add = 1, - Alpha = 2, - Darken = 3, - Difference = 4, - Erase = 5, - HardLight = 6, - Invert = 7, - Layer = 8, - Lighten = 9, - Multiply = 10, - Overlay = 11, - Screen = 12, - Subtract = 13 - } - /** - * @private - */ - const enum TweenType { - None = 0, - Line = 1, - Curve = 2, - QuadIn = 3, - QuadOut = 4, - QuadInOut = 5 - } - /** - * @private - */ - const enum TimelineType { - Action = 0, - ZOrder = 1, - BoneAll = 10, - BoneTranslate = 11, - BoneRotate = 12, - BoneScale = 13, - Surface = 50, - BoneAlpha = 60, - SlotDisplay = 20, - SlotColor = 21, - SlotDeform = 22, - SlotZIndex = 23, - SlotAlpha = 24, - IKConstraint = 30, - AnimationProgress = 40, - AnimationWeight = 41, - AnimationParameter = 42 - } - /** - * - Offset mode. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 偏移模式。 - * @version DragonBones 5.5 - * @language zh_CN - */ - const enum OffsetMode { - None = 0, - Additive = 1, - Override = 2 - } - /** - * - Animation fade out mode. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出模式。 - * @version DragonBones 4.5 - * @language zh_CN - */ - const enum AnimationFadeOutMode { - /** - * - Fade out the animation states of the same layer. - * @language en_US - */ - /** - * - 淡出同层的动画状态。 - * @language zh_CN - */ - SameLayer = 1, - /** - * - Fade out the animation states of the same group. - * @language en_US - */ - /** - * - 淡出同组的动画状态。 - * @language zh_CN - */ - SameGroup = 2, - /** - * - Fade out the animation states of the same layer and group. - * @language en_US - */ - /** - * - 淡出同层并且同组的动画状态。 - * @language zh_CN - */ - SameLayerAndGroup = 3, - /** - * - Fade out of all animation states. - * @language en_US - */ - /** - * - 淡出所有的动画状态。 - * @language zh_CN - */ - All = 4, - /** - * - Does not replace the animation state with the same name. - * @language en_US - */ - /** - * - 不替换同名的动画状态。 - * @language zh_CN - */ - Single = 5 - } - /** - * @private - */ - const enum AnimationBlendType { - None = 0, - E1D = 1 - } - /** - * @private - */ - const enum AnimationBlendMode { - Additive = 0, - Override = 1 - } - /** - * @private - */ - const enum ConstraintType { - IK = 0, - Path = 1 - } - /** - * @private - */ - const enum PositionMode { - Fixed = 0, - Percent = 1 - } - /** - * @private - */ - const enum SpacingMode { - Length = 0, - Fixed = 1, - Percent = 2 - } - /** - * @private - */ - const enum RotateMode { - Tangent = 0, - Chain = 1, - ChainScale = 2 - } - /** - * @private - */ - interface Map { - [key: string]: T; - } - /** - * @private - */ - class DragonBones { - static readonly VERSION: string; - static yDown: boolean; - static debug: boolean; - static debugDraw: boolean; - private readonly _clock; - private readonly _events; - private readonly _objects; - private _eventManager; - constructor(eventManager: IEventDispatcher); - advanceTime(passedTime: number): void; - bufferEvent(value: EventObject): void; - bufferObject(object: BaseObject): void; - readonly clock: WorldClock; - readonly eventManager: IEventDispatcher; - } -} -declare var __extends: any; -declare var exports: any; -declare var module: any; -declare var define: any; -/** - * 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. - */ -declare namespace 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 - */ - abstract class BaseObject { - private static _hashCode; - private static _defaultMaxCount; - private static readonly _maxCountMap; - private static readonly _poolsMap; - private static _returnObject; - static toString(): string; - /** - * - 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 - */ - static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; - /** - * - 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 - */ - static clearPool(objectConstructor?: (typeof BaseObject) | null): void; - /** - * - 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 - */ - static borrowObject(objectConstructor: { - new (): T; - }): T; - /** - * - A unique identification number assigned to the object. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分配给此实例的唯一标识号。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly hashCode: number; - private _isInPool; - protected abstract _onClear(): void; - /** - * - Clear the object and return it back to object pool。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除该实例的所有数据并将其返还对象池。 - * @version DragonBones 4.5 - * @language zh_CN - */ - returnToPool(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - 2D Transform matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 转换矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Matrix { - /** - * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - a: number; - /** - * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - b: number; - /** - * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - c: number; - /** - * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - d: number; - /** - * - The distance by which to translate each point along the x axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 x 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - tx: number; - /** - * - The distance by which to translate each point along the y axis. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 沿 y 轴平移每个点的距离。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - ty: number; - /** - * @private - */ - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Matrix): Matrix; - /** - * @private - */ - copyFromArray(value: Array, offset?: number): Matrix; - /** - * - 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 - */ - identity(): Matrix; - /** - * - 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 - */ - concat(value: Matrix): Matrix; - /** - * - Convert to inverse matrix. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 转换为逆矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - invert(): Matrix; - /** - * - 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 - */ - transformPoint(x: number, y: number, result: { - x: number; - y: number; - }, delta?: boolean): void; - /** - * @private - */ - transformRectangle(rectangle: { - x: number; - y: number; - width: number; - height: number; - }, delta?: boolean): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - 2D Transform. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 2D 变换。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Transform { - /** - * @private - */ - static readonly PI: number; - /** - * @private - */ - static readonly PI_D: number; - /** - * @private - */ - static readonly PI_H: number; - /** - * @private - */ - static readonly PI_Q: number; - /** - * @private - */ - static readonly RAD_DEG: number; - /** - * @private - */ - static readonly DEG_RAD: number; - /** - * @private - */ - static normalizeRadian(value: number): number; - /** - * - Horizontal translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - Vertical translate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直位移。 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - Skew. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 倾斜。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - skew: number; - /** - * - rotation. (In radians) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 旋转。 (以弧度为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - rotation: number; - /** - * - Horizontal Scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 水平缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleX: number; - /** - * - Vertical scaling. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 垂直缩放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - scaleY: number; - /** - * @private - */ - constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); - toString(): string; - /** - * @private - */ - copyFrom(value: Transform): Transform; - /** - * @private - */ - identity(): Transform; - /** - * @private - */ - add(value: Transform): Transform; - /** - * @private - */ - minus(value: Transform): Transform; - /** - * @private - */ - fromMatrix(matrix: Matrix): Transform; - /** - * @private - */ - toMatrix(matrix: Matrix): Transform; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class ColorTransform { - alphaMultiplier: number; - redMultiplier: number; - greenMultiplier: number; - blueMultiplier: number; - alphaOffset: number; - redOffset: number; - greenOffset: number; - blueOffset: number; - constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); - copyFrom(value: ColorTransform): void; - identity(): void; - } -} -/** - * 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. - */ -declare namespace 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 - */ - class Point { - /** - * - The horizontal coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的水平坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The vertical coordinate. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 该点的垂直坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - 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 - */ - constructor(x?: number, y?: number); - /** - * @private - */ - copyFrom(value: Point): void; - /** - * @private - */ - clear(): void; - } -} -/** - * 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. - */ -declare namespace 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.
- * 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) 确定)以及宽度和高度定义的区域。
- * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 - * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width - * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class Rectangle { - /** - * - The x coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 x 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - x: number; - /** - * - The y coordinate of the top-left corner of the rectangle. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形左上角的 y 坐标。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - y: number; - /** - * - The width of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 矩形的宽度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - width: number; - /** - * - 矩形的高度(以像素为单位)。 - * @default 0.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - The height of the rectangle, in pixels. - * @default 0.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - height: number; - /** - * @private - */ - constructor(x?: number, y?: number, width?: number, height?: number); - /** - * @private - */ - copyFrom(value: Rectangle): void; - /** - * @private - */ - clear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The user custom data. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 用户自定义数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - class UserData extends BaseObject { - static toString(): string; - /** - * - The custom int numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly ints: Array; - /** - * - The custom float numbers. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly floats: Array; - /** - * - The custom strings. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly strings: Array; - protected _onClear(): void; - /** - * - Get the custom int number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义整数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getInt(index?: number): number; - /** - * - Get the custom float number. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义浮点数。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getFloat(index?: number): number; - /** - * - Get the custom string. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 获取自定义字符串。 - * @version DragonBones 5.0 - * @language zh_CN - */ - getString(index?: number): string; - } - /** - * @private - */ - class ActionData extends BaseObject { - static toString(): string; - type: ActionType; - name: string; - bone: BoneData | null; - slot: SlotData | null; - data: UserData | null; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace 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 - */ - class DragonBonesData extends BaseObject { - static toString(): string; - /** - * @private - */ - autoSearch: boolean; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧频。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * - The data version. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 数据版本。 - * @version DragonBones 3.0 - * @language zh_CN - */ - version: string; - /** - * - The DragonBones data name. - * The name is consistent with the DragonBones project name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 龙骨数据名称。 - * 该名称与龙骨项目名保持一致。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - stage: ArmatureData | null; - /** - * - All armature data names. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的骨架数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armatureNames: Array; - /** - * @private - */ - readonly armatures: Map; - /** - * @private - */ - userData: UserData | null; - protected _onClear(): void; - /** - * - 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 - */ - getArmature(armatureName: string): ArmatureData | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class ArmatureData extends BaseObject { - static toString(): string; - /** - * @private - */ - type: ArmatureType; - /** - * - The animation frame rate. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画帧率。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameRate: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * @private - */ - scale: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly aabb: Rectangle; - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationNames: Array; - /** - * @private - */ - readonly sortedBones: Array; - /** - * @private - */ - readonly sortedSlots: Array; - /** - * @private - */ - readonly defaultActions: Array; - /** - * @private - */ - readonly actions: Array; - /** - * @private - */ - readonly bones: Map; - /** - * @private - */ - readonly slots: Map; - /** - * @private - */ - readonly constraints: Map; - /** - * @private - */ - readonly skins: Map; - /** - * @private - */ - readonly animations: Map; - /** - * - The default skin data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认插槽数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultSkin: SkinData | null; - /** - * - The default animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 默认动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - defaultAnimation: AnimationData | null; - /** - * @private - */ - canvas: CanvasData | null; - /** - * @private - */ - userData: UserData | null; - /** - * @private - */ - parent: DragonBonesData; - protected _onClear(): void; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(boneName: string): BoneData | null; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(slotName: string): SlotData | null; - /** - * @private - */ - getConstraint(constraintName: string): ConstraintData | null; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getSkin(skinName: string): SkinData | null; - /** - * @private - */ - getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - getAnimation(animationName: string): AnimationData | null; - } - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class BoneData extends BaseObject { - static toString(): string; - /** - * @private - */ - inheritTranslation: boolean; - /** - * @private - */ - inheritRotation: boolean; - /** - * @private - */ - inheritScale: boolean; - /** - * @private - */ - inheritReflection: boolean; - /** - * @private - */ - type: BoneType; - /** - * - The bone length. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼长度。 - * @version DragonBones 3.0 - * @language zh_CN - */ - length: number; - /** - * @private - */ - alpha: number; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly transform: Transform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData | null; - protected _onClear(): void; - } - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SlotData extends BaseObject { - static toString(): string; - /** - * @private - */ - blendMode: BlendMode; - /** - * @private - */ - displayIndex: number; - /** - * @private - */ - zOrder: number; - /** - * @private - */ - zIndex: number; - /** - * @private - */ - alpha: number; - /** - * - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - color: ColorTransform; - /** - * @private - */ - userData: UserData | null; - /** - * - The parent bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 父骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - parent: BoneData; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class CanvasData extends BaseObject { - static toString(): string; - hasBackground: boolean; - color: number; - x: number; - y: number; - width: number; - height: number; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class SkinData extends BaseObject { - static toString(): string; - /** - * - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly displays: Map>; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @private - */ - getDisplay(slotName: string, displayName: string): DisplayData | null; - /** - * @private - */ - getDisplays(slotName: string): Array | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - abstract class ConstraintData extends BaseObject { - order: number; - name: string; - type: ConstraintType; - target: BoneData; - root: BoneData; - bone: BoneData | null; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class GeometryData { - isShared: boolean; - inheritDeform: boolean; - offset: number; - data: DragonBonesData; - weight: WeightData | null; - clear(): void; - shareFrom(value: GeometryData): void; - readonly vertexCount: number; - readonly triangleCount: number; - } - /** - * @private - */ - abstract class DisplayData extends BaseObject { - type: DisplayType; - name: string; - path: string; - readonly transform: Transform; - parent: SkinData; - protected _onClear(): void; - } - /** - * @private - */ - class ImageDisplayData extends DisplayData { - static toString(): string; - readonly pivot: Point; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @private - */ - class ArmatureDisplayData extends DisplayData { - static toString(): string; - inheritAnimation: boolean; - readonly actions: Array; - armature: ArmatureData | null; - protected _onClear(): void; - /** - * @private - */ - addAction(value: ActionData): void; - } - /** - * @private - */ - class MeshDisplayData extends DisplayData { - static toString(): string; - readonly geometry: GeometryData; - texture: TextureData | null; - protected _onClear(): void; - } - /** - * @private - */ - class BoundingBoxDisplayData extends DisplayData { - static toString(): string; - boundingBox: BoundingBoxData | null; - protected _onClear(): void; - } - /** - * @private - */ - class PathDisplayData extends DisplayData { - static toString(): string; - closed: boolean; - constantSpeed: boolean; - readonly geometry: GeometryData; - readonly curveLengths: Array; - protected _onClear(): void; - } - /** - * @private - */ - class WeightData extends BaseObject { - static toString(): string; - count: number; - offset: number; - readonly bones: Array; - protected _onClear(): void; - addBone(value: BoneData): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract class BoundingBoxData extends BaseObject { - /** - * - The bounding box type. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框类型。 - * @version DragonBones 5.0 - * @language zh_CN - */ - type: BoundingBoxType; - /** - * @private - */ - color: number; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - protected _onClear(): void; - /** - * - Check whether the bounding box contains a specific point. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否包含特定点。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract containsPoint(pX: number, pY: number): boolean; - /** - * - Check whether the bounding box intersects a specific segment. (Local coordinate system) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查边界框是否与特定线段相交。(本地坐标系) - * @version DragonBones 5.0 - * @language zh_CN - */ - abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { - x: number; - y: number; - } | null, intersectionPointB: { - x: number; - y: number; - } | null, normalRadians: { - x: number; - y: number; - } | null): number; - } - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class RectangleBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - private static _computeOutCode; - /** - * @private - */ - static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class EllipseBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - class PolygonBoundingBoxData extends BoundingBoxData { - static toString(): string; - /** - * @private - */ - static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * @private - */ - x: number; - /** - * @private - */ - y: number; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly vertices: Array; - protected _onClear(): void; - /** - * @inheritDoc - */ - containsPoint(pX: number, pY: number): boolean; - /** - * @inheritDoc - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationData extends BaseObject { - static toString(): string; - /** - * @private - */ - blendType: AnimationBlendType; - /** - * - The frame count of the animation. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的帧数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - frameCount: number; - /** - * - The play times of the animation. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The duration of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的持续时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - duration: number; - /** - * @private - */ - scale: number; - /** - * - The fade in time of the animation. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画的淡入时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * @private - */ - cacheFrameRate: number; - /** - * - The animation name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * @private - */ - readonly cachedFrames: Array; - /** - * @private - */ - readonly boneTimelines: Map>; - /** - * @private - */ - readonly slotTimelines: Map>; - /** - * @private - */ - readonly constraintTimelines: Map>; - /** - * @private - */ - readonly animationTimelines: Map>; - /** - * @private - */ - readonly boneCachedFrameIndices: Map>; - /** - * @private - */ - readonly slotCachedFrameIndices: Map>; - /** - * @private - */ - actionTimeline: TimelineData | null; - /** - * @private - */ - zOrderTimeline: TimelineData | null; - /** - * @private - */ - parent: ArmatureData; - protected _onClear(): void; - /** - * @private - */ - addBoneTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - addSlotTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - addConstraintTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - addAnimationTimeline(timelineName: string, timeline: TimelineData): void; - /** - * @private - */ - getBoneTimelines(timelineName: string): Array | null; - /** - * @private - */ - getSlotTimelines(timelineName: string): Array | null; - /** - * @private - */ - getConstraintTimelines(timelineName: string): Array | null; - /** - * @private - */ - getAnimationTimelines(timelineName: string): Array | null; - /** - * @private - */ - getBoneCachedFrameIndices(boneName: string): Array | null; - /** - * @private - */ - getSlotCachedFrameIndices(slotName: string): Array | null; - } - /** - * @private - */ - class TimelineData extends BaseObject { - static toString(): string; - type: TimelineType; - offset: number; - frameIndicesOffset: number; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - class AnimationConfig extends BaseObject { - static toString(): string; - /** - * @private - */ - pauseFadeOut: boolean; - /** - * - Fade out the pattern of other animation states when the animation state is fade in. - * This property is typically used to specify the substitution of multiple animation states blend. - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入动画状态时淡出其他动画状态的模式。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @default dragonBones.AnimationFadeOutMode.All - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeOutMode: AnimationFadeOutMode; - /** - * @private - */ - fadeOutTweenType: TweenType; - /** - * @private - */ - fadeOutTime: number; - /** - * @private - */ - pauseFadeIn: boolean; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additive: boolean; - /** - * - Whether the animation state has control over the display property of the slots. - * Sometimes blend a animation state does not want it to control the display properties of the slots, - * especially if other animation state are controlling the display properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * @private - */ - fadeInTweenType: TweenType; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The start time of play. (In seconds) - * @default 0.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的开始时间。 (以秒为单位) - * @default 0.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - position: number; - /** - * - The duration of play. - * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 播放的持续时间。 - * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - duration: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - weight: number; - /** - * - The fade in time. - * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 淡入时间。 - * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - fadeInTime: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The animation data name. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画数据名称。 - * @version DragonBones 5.0 - * @language zh_CN - */ - animation: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - /** - * @private - */ - readonly boneMask: Array; - protected _onClear(): void; - /** - * @private - */ - clear(): void; - /** - * @private - */ - copyFrom(value: AnimationConfig): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class TextureAtlasData extends BaseObject { - /** - * @private - */ - autoSearch: boolean; - /** - * @private - */ - width: number; - /** - * @private - */ - height: number; - /** - * @private - */ - scale: number; - /** - * - The texture atlas name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - name: string; - /** - * - The image path of the texture atlas. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集图片路径。 - * @version DragonBones 3.0 - * @language zh_CN - */ - imagePath: string; - /** - * @private - */ - readonly textures: Map; - protected _onClear(): void; - /** - * @private - */ - copyFrom(value: TextureAtlasData): void; - /** - * @private - */ - getTexture(textureName: string): TextureData | null; - } - /** - * @private - */ - abstract class TextureData extends BaseObject { - static createRectangle(): Rectangle; - rotated: boolean; - name: string; - readonly region: Rectangle; - parent: TextureAtlasData; - frame: Rectangle | null; - protected _onClear(): void; - copyFrom(value: TextureData): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The armature proxy interface, the docking engine needs to implement it concretely. - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 骨架代理接口,对接的引擎需要对其进行具体实现。 - * @see dragonBones.Armature - * @version DragonBones 5.0 - * @language zh_CN - */ - interface IArmatureProxy extends IEventDispatcher { - /** - * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) - * @example - *

-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 释放该实例和骨架。 (骨架会回收到对象池) - * @example - *
-         *     removeChild(armatureDisplay);
-         *     armatureDisplay.dispose();
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - dispose(disposeProxy: boolean): void; - /** - * - The armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armature: Armature; - /** - * - The animation player. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - class Armature extends BaseObject implements IAnimatable { - static toString(): string; - private static _onSortSlots; - /** - * - Whether to inherit the animation control of the parent armature. - * True to try to have the child armature play an animation with the same name when the parent armature play the animation. - * @default true - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 是否继承父骨架的动画控制。 - * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 - * @default true - * @version DragonBones 4.5 - * @language zh_CN - */ - inheritAnimation: boolean; - /** - * @private - */ - userData: any; - private _slotsDirty; - private _zOrderDirty; - private _flipX; - private _flipY; - private _alpha; - private readonly _bones; - private readonly _slots; - private readonly _actions; - private _animation; - private _proxy; - private _display; - private _replacedTexture; - private _clock; - protected _onClear(): void; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - dispose(): void; - /** - * @inheritDoc - */ - advanceTime(passedTime: number): void; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): Slot | null; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): Slot | null; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBone(name: string): Bone | null; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBoneByDisplay(display: any): Bone | null; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlot(name: string): Slot | null; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlotByDisplay(display: any): Slot | null; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - getBones(): Array; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - getSlots(): Array; - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipX: boolean; - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - flipY: boolean; - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-         *     armature.cacheFrameRate = 24;
-         * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - cacheFrameRate: number; - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly armatureData: ArmatureData; - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animation: Animation; - /** - * @pivate - */ - readonly proxy: IArmatureProxy; - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly eventDispatcher: IEventDispatcher; - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly display: any; - /** - * @private - */ - replacedTexture: any; - /** - * @inheritDoc - */ - clock: WorldClock | null; - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly parent: Slot | null; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - abstract class TransformObject extends BaseObject { - protected static readonly _helpMatrix: Matrix; - protected static readonly _helpTransform: Transform; - protected static readonly _helpPoint: Point; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly globalTransformMatrix: Matrix; - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly global: Transform; - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly offset: Transform; - /** - * @private - */ - origin: Transform | null; - /** - * @private - */ - userData: any; - protected _globalDirty: boolean; - /** - */ - protected _onClear(): void; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - updateGlobalTransform(): void; - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly armature: Armature; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - class Bone extends TransformObject { - static toString(): string; - /** - * - The offset mode. - * @see #offset - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 偏移模式。 - * @see #offset - * @version DragonBones 5.5 - * @language zh_CN - */ - offsetMode: OffsetMode; - protected _localDirty: boolean; - protected _visible: boolean; - protected _cachedFrameIndex: number; - /** - * @private - */ - protected _parent: Bone | null; - protected _onClear(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: Bone): boolean; - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly boneData: BoneData; - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - visible: boolean; - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone | null; - } -} -/** - * 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. - */ -declare namespace 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class DisplayFrame extends BaseObject { - static toString(): string; - rawDisplayData: DisplayData | null; - displayData: DisplayData | null; - textureData: TextureData | null; - display: any | Armature | null; - readonly deformVertices: Array; - protected _onClear(): void; - updateDeformVertices(): void; - getGeometryData(): GeometryData | null; - getBoundingBox(): BoundingBoxData | null; - getTextureData(): TextureData | null; - } - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class Slot extends TransformObject { - /** - * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - * @language zh_CN - */ - displayController: string | null; - protected _displayDataDirty: boolean; - protected _displayDirty: boolean; - protected _geometryDirty: boolean; - protected _textureDirty: boolean; - protected _visibleDirty: boolean; - protected _blendModeDirty: boolean; - protected _zOrderDirty: boolean; - protected _transformDirty: boolean; - protected _visible: boolean; - protected _blendMode: BlendMode; - protected _displayIndex: number; - protected _animationDisplayIndex: number; - protected _cachedFrameIndex: number; - protected readonly _localMatrix: Matrix; - protected _boundingBoxData: BoundingBoxData | null; - protected _textureData: TextureData | null; - protected _rawDisplay: any; - protected _meshDisplay: any; - protected _display: any | null; - protected _childArmature: Armature | null; - /** - * @private - */ - protected _parent: Bone; - protected _onClear(): void; - protected abstract _initDisplay(value: any, isRetain: boolean): void; - protected abstract _disposeDisplay(value: any, isRelease: boolean): void; - protected abstract _onUpdateDisplay(): void; - protected abstract _addDisplay(): void; - protected abstract _replaceDisplay(value: any): void; - protected abstract _removeDisplay(): void; - protected abstract _updateZOrder(): void; - protected abstract _updateBlendMode(): void; - protected abstract _updateColor(): void; - protected abstract _updateFrame(): void; - protected abstract _updateMesh(): void; - protected abstract _updateTransform(): void; - protected abstract _identityTransform(): void; - protected _hasDisplay(display: any): boolean; - protected _updateDisplayData(): void; - protected _updateDisplay(): void; - protected _updateGlobalTransformMatrix(isCache: boolean): void; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - invalidUpdate(): void; - /** - * @private - */ - updateTransformAndMatrix(): void; - /** - * @private - */ - replaceRawDisplayData(displayData: DisplayData | null, index?: number): void; - /** - * @private - */ - replaceDisplayData(displayData: DisplayData | null, index?: number): void; - /** - * @private - */ - replaceTextureData(textureData: TextureData | null, index?: number): void; - /** - * @private - */ - replaceDisplay(value: any | Armature | null, index?: number): void; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - containsPoint(x: number, y: number): boolean; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { - x: number; - y: number; - } | null, intersectionPointB?: { - x: number; - y: number; - } | null, normalRadians?: { - x: number; - y: number; - } | null): number; - /** - * @private - */ - getDisplayFrameAt(index: number): DisplayFrame; - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - visible: boolean; - /** - * @private - */ - displayFrameCount: number; - /** - * - The index of the display object displayed in the display list. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     slot.displayIndex = 3;
-         *     slot.displayController = "none";
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - displayIndex: number; - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly name: string; - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - displayList: Array; - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly slotData: SlotData; - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly boundingBoxData: BoundingBoxData | null; - /** - * @private - */ - readonly rawDisplay: any; - /** - * @private - */ - readonly meshDisplay: any; - /** - * - The display object that the slot displays at this time. - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-         *     let slot = armature.getSlot("text");
-         *     slot.display = new yourEngine.TextField();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - display: any; - /** - * - The child armature that the slot displayed at current time. - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     let prevChildArmature = slot.childArmature;
-         *     if (prevChildArmature) {
-         *         prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     let prevChildArmature = slot.childArmature;
-         *     if (prevChildArmature) {
-         *         prevChildArmature.dispose();
-         *     }
-         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - childArmature: Armature | null; - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly parent: Bone; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - getDisplay(): any; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - setDisplay(value: any): void; - } -} -/** - * 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. - */ -declare namespace 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. - */ -declare namespace dragonBones { - /** - * - Play animation interface. (Both Armature and Wordclock implement the interface) - * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) - * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - interface IAnimatable { - /** - * - Advance time. - * @param passedTime - Passed time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 更新时间。 - * @param passedTime - 前进的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - The Wordclock instance to which the current belongs. - * @example - *
-         *     armature.clock = factory.clock; // Add armature to clock.
-         *     armature.clock = null; // Remove armature from clock.
-         * 
- * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 当前所属的 WordClock 实例。 - * @example - *
-         *     armature.clock = factory.clock; // 将骨架添加到时钟。
-         *     armature.clock = null; // 将骨架从时钟移除。
-         * 
- * @version DragonBones 5.0 - * @language zh_CN - */ - clock: WorldClock | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - class WorldClock implements IAnimatable { - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - time: number; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - private _systemTime; - private readonly _animatebles; - private _clock; - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(time?: number); - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - advanceTime(passedTime: number): void; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - contains(value: IAnimatable): boolean; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - add(value: IAnimatable): void; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - remove(value: IAnimatable): void; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - clear(): void; - /** - * @inheritDoc - */ - clock: WorldClock | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - class Animation extends BaseObject { - static toString(): string; - /** - * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * Update bones and slots cachedFrameIndices. - */ - private _animationDirty; - private _inheritTimeScale; - private readonly _animationNames; - private readonly _animationStates; - private readonly _animations; - private readonly _blendStates; - private _armature; - private _animationConfig; - private _lastAnimationState; - protected _onClear(): void; - private _fadeOut; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - reset(): void; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(animationName?: string | null): void; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - playConfig(animationConfig: AnimationConfig): AnimationState | null; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - play(animationName?: string | null, playTimes?: number): AnimationState | null; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态。 - * @param animationName - 动画状态名称。 - * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - getState(animationName: string, layer?: number): AnimationState | null; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - hasAnimation(animationName: string): boolean; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - getStates(): ReadonlyArray; - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationName: string; - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly animationNames: ReadonlyArray; - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - animations: Map; - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - readonly animationConfig: AnimationConfig; - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly lastAnimationState: AnimationState | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - class AnimationState extends BaseObject { - static toString(): string; - /** - * @private - */ - actionEnabled: boolean; - /** - * @private - */ - additive: boolean; - /** - * - Whether the animation state has control over the display object properties of the slots. - * Sometimes blend a animation state does not want it to control the display object properties of the slots, - * especially if other animation state are controlling the display object properties of the slots. - * @default true - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态是否对插槽的显示对象属性有控制权。 - * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, - * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 - * @default true - * @version DragonBones 5.0 - * @language zh_CN - */ - displayControl: boolean; - /** - * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. - * This property should usually be set to false when blend multiple animation states. - * @default true - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 - * 通常在混合多个动画状态时应该将该属性设置为 false。 - * @default true - * @version DragonBones 5.1 - * @language zh_CN - */ - resetToPose: boolean; - /** - * @private - */ - blendType: AnimationBlendType; - /** - * - The play times. [0: Loop play, [1~N]: Play N times] - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 - * @language zh_CN - */ - playTimes: number; - /** - * - The blend layer. - * High layer animation state will get the blend weight first. - * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合图层。 - * 图层高的动画状态会优先获取混合权重。 - * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - layer: number; - /** - * - The play speed. - * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. - * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度。 - * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 - * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - timeScale: number; - /** - * @private - */ - parameterX: number; - /** - * @private - */ - parameterY: number; - /** - * @private - */ - positionX: number; - /** - * @private - */ - positionY: number; - /** - * - The auto fade out time when the animation state play completed. - * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) - * @default -1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态播放完成后的自动淡出时间。 - * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) - * @default -1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - autoFadeOutTime: number; - /** - * @private - */ - fadeTotalTime: number; - /** - * - The name of the animation state. (Can be different from the name of the animation data) - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画状态名称。 (可以不同于动画数据) - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - name: string; - /** - * - The blend group name of the animation state. - * This property is typically used to specify the substitution of multiple animation states blend. - * @readonly - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合组名称。 - * 该属性通常用来指定多个动画状态混合时的相互替换关系。 - * @readonly - * @version DragonBones 5.0 - * @language zh_CN - */ - group: string; - private _timelineDirty; - private _weight; - private _fadeTime; - private _time; - private readonly _boneMask; - private readonly _boneTimelines; - private readonly _boneBlendTimelines; - private readonly _slotTimelines; - private readonly _slotBlendTimelines; - private readonly _constraintTimelines; - private readonly _animationTimelines; - private readonly _poseTimelines; - private _animationData; - private _armature; - private _zOrderTimeline; - private _activeChildA; - private _activeChildB; - protected _onClear(): void; - private _updateTimelines; - private _updateBoneAndSlotTimelines; - private _advanceFadeTime; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - play(): void; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - stop(): void; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - containsBoneMask(boneName: string): boolean; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - addBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeBoneMask(boneName: string, recursive?: boolean): void; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - removeAllBoneMask(): void; - /** - * @private - */ - addState(animationState: AnimationState, timelineDatas?: TimelineData[] | null): void; - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeIn: boolean; - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeOut: boolean; - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - readonly isFadeComplete: boolean; - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isPlaying: boolean; - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly isCompleted: boolean; - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly currentPlayTimes: number; - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly totalTime: number; - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - currentTime: number; - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - weight: number; - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - readonly animationData: AnimationData; - } -} -/** - * 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. - */ -declare namespace 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. - */ -declare namespace 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. - */ -declare namespace dragonBones { - /** - * - The properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - class EventObject extends BaseObject { - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly START: string; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly LOOP_COMPLETE: string; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly COMPLETE: string; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN: string; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_IN_COMPLETE: string; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT: string; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FADE_OUT_COMPLETE: string; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly FRAME_EVENT: string; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - static readonly SOUND_EVENT: string; - static toString(): string; - /** - * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) - * @version DragonBones 4.5 - * @language zh_CN - */ - time: number; - /** - * - The event type。 - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - type: EventStringType; - /** - * - The event name. (The frame event name or the frame sound name) - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件名称。 (帧事件的名称或帧声音的名称) - * @version DragonBones 4.5 - * @language zh_CN - */ - name: string; - /** - * - The armature that dispatch the event. - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨架。 - * @see dragonBones.Armature - * @version DragonBones 4.5 - * @language zh_CN - */ - armature: Armature; - /** - * - The bone that dispatch the event. - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 4.5 - * @language zh_CN - */ - bone: Bone | null; - /** - * - The slot that dispatch the event. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - slot: Slot | null; - /** - * - The animation state that dispatch the event. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 发出该事件的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - animationState: AnimationState; - /** - * @private - */ - actionData: ActionData | null; - /** - * @private - */ - /** - * - The custom data. - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 自定义数据。 - * @see dragonBones.CustomData - * @version DragonBones 5.0 - * @language zh_CN - */ - data: UserData | null; - protected _onClear(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; - /** - * - The event dispatcher interface. - * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件派发接口。 - * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 - * @version DragonBones 4.5 - * @language zh_CN - */ - interface IEventDispatcher { - /** - * - Checks whether the object has any listeners registered for a specific type of event。 - * @param type - Event type. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 检查是否为特定的事件类型注册了任何侦听器。 - * @param type - 事件类型。 - * @version DragonBones 4.5 - * @language zh_CN - */ - hasDBEventListener(type: EventStringType): boolean; - /** - * - Dispatches an event into the event flow. - * @param type - Event type. - * @param eventObject - Event object. - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 分派特定的事件到事件流中。 - * @param type - 事件类型。 - * @param eventObject - 事件数据。 - * @see dragonBones.EventObject - * @version DragonBones 4.5 - * @language zh_CN - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - /** - * - Add an event listener object so that the listener receives notification of an event. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - /** - * - Removes a listener from the object. - * @param type - Event type. - * @param listener - Event listener. - * @param thisObject - The listener function's "this". - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 删除特定事件类型的侦听器。 - * @param type - 事件类型。 - * @param listener - 事件侦听器。 - * @param thisObject - 侦听函数绑定的 this 对象。 - * @version DragonBones 4.5 - * @language zh_CN - */ - removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - abstract class DataParser { - protected static readonly DATA_VERSION_2_3: string; - protected static readonly DATA_VERSION_3_0: string; - protected static readonly DATA_VERSION_4_0: string; - protected static readonly DATA_VERSION_4_5: string; - protected static readonly DATA_VERSION_5_0: string; - protected static readonly DATA_VERSION_5_5: string; - protected static readonly DATA_VERSION_5_6: string; - protected static readonly DATA_VERSION: string; - protected static readonly DATA_VERSIONS: Array; - protected static readonly TEXTURE_ATLAS: string; - protected static readonly SUB_TEXTURE: string; - protected static readonly FORMAT: string; - protected static readonly IMAGE_PATH: string; - protected static readonly WIDTH: string; - protected static readonly HEIGHT: string; - protected static readonly ROTATED: string; - protected static readonly FRAME_X: string; - protected static readonly FRAME_Y: string; - protected static readonly FRAME_WIDTH: string; - protected static readonly FRAME_HEIGHT: string; - protected static readonly DRADON_BONES: string; - protected static readonly USER_DATA: string; - protected static readonly ARMATURE: string; - protected static readonly CANVAS: string; - protected static readonly BONE: string; - protected static readonly SURFACE: string; - protected static readonly SLOT: string; - protected static readonly CONSTRAINT: string; - protected static readonly SKIN: string; - protected static readonly DISPLAY: string; - protected static readonly FRAME: string; - protected static readonly IK: string; - protected static readonly PATH_CONSTRAINT: string; - protected static readonly ANIMATION: string; - protected static readonly TIMELINE: string; - protected static readonly FFD: string; - protected static readonly TRANSLATE_FRAME: string; - protected static readonly ROTATE_FRAME: string; - protected static readonly SCALE_FRAME: string; - protected static readonly DISPLAY_FRAME: string; - protected static readonly COLOR_FRAME: string; - protected static readonly DEFAULT_ACTIONS: string; - protected static readonly ACTIONS: string; - protected static readonly EVENTS: string; - protected static readonly INTS: string; - protected static readonly FLOATS: string; - protected static readonly STRINGS: string; - protected static readonly TRANSFORM: string; - protected static readonly PIVOT: string; - protected static readonly AABB: string; - protected static readonly COLOR: string; - protected static readonly VERSION: string; - protected static readonly COMPATIBLE_VERSION: string; - protected static readonly FRAME_RATE: string; - protected static readonly TYPE: string; - protected static readonly SUB_TYPE: string; - protected static readonly NAME: string; - protected static readonly PARENT: string; - protected static readonly TARGET: string; - protected static readonly STAGE: string; - protected static readonly SHARE: string; - protected static readonly PATH: string; - protected static readonly LENGTH: string; - protected static readonly DISPLAY_INDEX: string; - protected static readonly Z_ORDER: string; - protected static readonly Z_INDEX: string; - protected static readonly BLEND_MODE: string; - protected static readonly INHERIT_TRANSLATION: string; - protected static readonly INHERIT_ROTATION: string; - protected static readonly INHERIT_SCALE: string; - protected static readonly INHERIT_REFLECTION: string; - protected static readonly INHERIT_ANIMATION: string; - protected static readonly INHERIT_DEFORM: string; - protected static readonly SEGMENT_X: string; - protected static readonly SEGMENT_Y: string; - protected static readonly BEND_POSITIVE: string; - protected static readonly CHAIN: string; - protected static readonly WEIGHT: string; - protected static readonly BLEND_TYPE: string; - protected static readonly FADE_IN_TIME: string; - protected static readonly PLAY_TIMES: string; - protected static readonly SCALE: string; - protected static readonly OFFSET: string; - protected static readonly POSITION: string; - protected static readonly DURATION: string; - protected static readonly TWEEN_EASING: string; - protected static readonly TWEEN_ROTATE: string; - protected static readonly TWEEN_SCALE: string; - protected static readonly CLOCK_WISE: string; - protected static readonly CURVE: string; - protected static readonly SOUND: string; - protected static readonly EVENT: string; - protected static readonly ACTION: string; - protected static readonly X: string; - protected static readonly Y: string; - protected static readonly SKEW_X: string; - protected static readonly SKEW_Y: string; - protected static readonly SCALE_X: string; - protected static readonly SCALE_Y: string; - protected static readonly VALUE: string; - protected static readonly ROTATE: string; - protected static readonly SKEW: string; - protected static readonly ALPHA: string; - protected static readonly ALPHA_OFFSET: string; - protected static readonly RED_OFFSET: string; - protected static readonly GREEN_OFFSET: string; - protected static readonly BLUE_OFFSET: string; - protected static readonly ALPHA_MULTIPLIER: string; - protected static readonly RED_MULTIPLIER: string; - protected static readonly GREEN_MULTIPLIER: string; - protected static readonly BLUE_MULTIPLIER: string; - protected static readonly UVS: string; - protected static readonly VERTICES: string; - protected static readonly TRIANGLES: string; - protected static readonly WEIGHTS: string; - protected static readonly SLOT_POSE: string; - protected static readonly BONE_POSE: string; - protected static readonly BONES: string; - protected static readonly POSITION_MODE: string; - protected static readonly SPACING_MODE: string; - protected static readonly ROTATE_MODE: string; - protected static readonly SPACING: string; - protected static readonly ROTATE_OFFSET: string; - protected static readonly ROTATE_MIX: string; - protected static readonly TRANSLATE_MIX: string; - protected static readonly TARGET_DISPLAY: string; - protected static readonly CLOSED: string; - protected static readonly CONSTANT_SPEED: string; - protected static readonly VERTEX_COUNT: string; - protected static readonly LENGTHS: string; - protected static readonly GOTO_AND_PLAY: string; - protected static readonly DEFAULT_NAME: string; - protected static _getArmatureType(value: string): ArmatureType; - protected static _getBoneType(value: string): BoneType; - protected static _getPositionMode(value: string): PositionMode; - protected static _getSpacingMode(value: string): SpacingMode; - protected static _getRotateMode(value: string): RotateMode; - protected static _getDisplayType(value: string): DisplayType; - protected static _getBoundingBoxType(value: string): BoundingBoxType; - protected static _getBlendMode(value: string): BlendMode; - protected static _getAnimationBlendType(value: string): AnimationBlendType; - protected static _getActionType(value: string): ActionType; - abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; - abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - const enum FrameValueType { - Step = 0, - Int = 1, - Float = 2 - } - /** - * @private - */ - class ObjectDataParser extends DataParser { - protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; - protected static _getNumber(rawData: any, key: string, defaultValue: number): number; - protected static _getString(rawData: any, key: string, defaultValue: string): string; - protected _rawTextureAtlasIndex: number; - protected readonly _rawBones: Array; - protected _data: DragonBonesData; - protected _armature: ArmatureData; - protected _bone: BoneData; - protected _geometry: GeometryData; - protected _slot: SlotData; - protected _skin: SkinData; - protected _mesh: MeshDisplayData; - protected _animation: AnimationData; - protected _timeline: TimelineData; - protected _rawTextureAtlases: Array | null; - private _frameValueType; - private _defaultColorOffset; - private _prevClockwise; - private _prevRotation; - private _frameDefaultValue; - private _frameValueScale; - private readonly _helpMatrixA; - private readonly _helpMatrixB; - private readonly _helpTransform; - private readonly _helpColorTransform; - private readonly _helpPoint; - private readonly _helpArray; - private readonly _intArray; - private readonly _floatArray; - private readonly _frameIntArray; - private readonly _frameFloatArray; - private readonly _frameArray; - private readonly _timelineArray; - private readonly _colorArray; - private readonly _cacheRawMeshes; - private readonly _cacheMeshes; - private readonly _actionFrames; - private readonly _weightSlotPose; - private readonly _weightBonePoses; - private readonly _cacheBones; - private readonly _slotChildActions; - private _getCurvePoint; - private _samplingEasingCurve; - private _parseActionDataInFrame; - private _mergeActionFrame; - protected _parseArmature(rawData: any, scale: number): ArmatureData; - protected _parseBone(rawData: any): BoneData; - protected _parseIKConstraint(rawData: any): ConstraintData | null; - protected _parsePathConstraint(rawData: any): ConstraintData | null; - protected _parseSlot(rawData: any, zOrder: number): SlotData; - protected _parseSkin(rawData: any): SkinData; - protected _parseDisplay(rawData: any): DisplayData | null; - protected _parsePath(rawData: any, display: PathDisplayData): void; - protected _parsePivot(rawData: any, display: ImageDisplayData): void; - protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; - protected _parseBoundingBox(rawData: any): BoundingBoxData | null; - protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, timelineType: TimelineType, frameValueType: FrameValueType, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number, timeline?: TimelineData | null): TimelineData | null; - protected _parseBoneTimeline(rawData: any): void; - protected _parseSlotTimeline(rawData: any): void; - protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSingleValueFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseDoubleValueFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; - protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseSlotDeformFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; - protected _parseDeformFrame(rawData: any, frameStart: number, frameCount: number): number; - protected _parseTransform(rawData: any, transform: Transform, scale: number): void; - protected _parseColorTransform(rawData: any, color: ColorTransform): void; - protected _parseGeometry(rawData: any, geometry: GeometryData): void; - protected _parseArray(rawData: any): void; - protected _modifyArray(): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; - private static _objectDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): ObjectDataParser; - } - /** - * @private - */ - class ActionFrame { - frameStart: number; - readonly actions: Array; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @private - */ - class BinaryDataParser extends ObjectDataParser { - private _binaryOffset; - private _binary; - private _intArrayBuffer; - private _frameArrayBuffer; - private _timelineArrayBuffer; - private _inRange; - private _decodeUTF8; - private _parseBinaryTimeline; - protected _parseAnimation(rawData: any): AnimationData; - protected _parseGeometry(rawData: any, geometry: GeometryData): void; - protected _parseArray(rawData: any): void; - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; - private static _binaryDataParserInstance; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - static getInstance(): BinaryDataParser; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - abstract class BaseFactory { - protected static _objectParser: ObjectDataParser; - protected static _binaryParser: BinaryDataParser; - /** - * @private - */ - autoSearch: boolean; - protected readonly _dragonBonesDataMap: Map; - protected readonly _textureAtlasDataMap: Map>; - protected _dragonBones: DragonBones; - protected _dataParser: DataParser; - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; - protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; - protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; - /** - * @private - */ - protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; - protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, _slot: Slot, displayData: ArmatureDisplayData): Armature | null; - protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, slot: Slot): any; - protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; - protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; - /** - * - Update texture atlases. - * @param textureAtlases - The texture atlas objects. - * @param name - The texture atlas name. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 更新贴图集对象。 - * @param textureAtlases - 多个贴图集对象。 - * @param name - 贴图集名称。 - * @version DragonBones 5.7 - * @language zh_CN - */ - updateTextureAtlases(textureAtlases: Array, name: string): void; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - getDragonBonesData(name: string): DragonBonesData | null; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - addDragonBonesData(data: DragonBonesData, name?: string | null): void; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeDragonBonesData(name: string, disposeData?: boolean): void; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureAtlasData(name: string): Array | null; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - removeTextureAtlasData(name: string, disposeData?: boolean): void; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - clear(disposeData?: boolean): void; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; - /** - * @private - */ - replaceDisplay(slot: Slot, displayData: DisplayData | null, displayIndex?: number): void; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; - /** - * @private - */ - replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; - /** - * @private - */ - getAllDragonBonesData(): Map; - /** - * @private - */ - getAllTextureAtlasData(): Map>; - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - readonly clock: WorldClock; - /** - * @private - */ - readonly dragonBones: DragonBones; - } - /** - * @private - */ - class BuildArmaturePackage { - dataName: string; - textureAtlasName: string; - data: DragonBonesData; - armature: ArmatureData; - skin: SkinData | null; - } -} -/** - * 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. - */ -declare var _Scene: any; -declare namespace dragonBones { - class DragonBonesAsset extends cc.Asset { - readonly dragonBonesData: string | ArrayBuffer; - readonly textureAtlases: string[]; - readonly textures: cc.Texture2D[]; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The Cocos texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class CocosTextureAtlasData extends TextureAtlasData { - static toString(): string; - private _renderTexture; - protected _onClear(): void; - createTexture(): TextureData; - /** - * - The Cocos texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - renderTexture: cc.Texture2D | null; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * @see dragonBones.IArmatureProxy - */ - class CocosArmatureComponent extends cc.Component implements IArmatureProxy { - /** - * @private - */ - debugDraw: boolean; - private _debugDraw; - dbInit(armature: Armature): void; - dbClear(): void; - dbUpdate(): void; - dispose(_isposeProxy?: boolean): void; - destroy(): true; - /** - * @private - */ - dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; - hasDBEventListener(type: EventStringType): boolean; - addDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; - removeDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; - readonly armature: Armature; - readonly animation: Animation; - dragonBonesName: string; - dragonBonesAsset: DragonBonesAsset | null; - _loadAndDisplayDragonBones(): void; - _parseDragonAsset(): void; - _parseDragonAtlasAsset(): void; - _dragonBonesNode: cc.Node; - display(): void; - onLoad(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The Cocos slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class CocosSlot extends Slot { - static toString(): string; - private _ccMeshDirty; - private _textureScale; - private _renderDisplay; - protected _onClear(): void; - protected _initDisplay(_value: any, _isRetain: boolean): void; - protected _disposeDisplay(value: any, isRelease: boolean): void; - protected _onUpdateDisplay(): void; - protected _addDisplay(): void; - protected _replaceDisplay(value: any): void; - protected _removeDisplay(): void; - protected _updateZOrder(): void; - protected _updateBlendMode(): void; - protected _updateColor(): void; - protected _updateFrame(): void; - protected _updateMesh(): void; - protected _updateTransform(): void; - protected _identityTransform(): void; - } -} -/** - * 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. - */ -declare namespace dragonBones { - /** - * - The Cocos factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - class CocosFactory extends BaseFactory { - private static _dragonBonesInstance; - private static _factory; - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - static readonly factory: CocosFactory; - protected _node: cc.Node | null; - protected _armatureNode: cc.Node | null; - constructor(dataParser?: DataParser | null); - protected _isSupportMesh(): boolean; - protected _buildTextureAtlasData(textureAtlasData: CocosTextureAtlasData | null, textureAtlas: cc.Texture2D | null): CocosTextureAtlasData; - protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; - protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: ArmatureDisplayData): Armature | null; - protected _buildSlot(_dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; - /** - * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature component. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 - * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架组件。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - buildArmatureComponent(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string, node?: cc.Node | null): CocosArmatureComponent | null; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - getTextureDisplay(textureName: string, textureAtlasName?: string | null): cc.Sprite | null; - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - readonly soundEventManager: cc.Node; - } -} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + GeometryVertexCount = 0, + GeometryTriangleCount = 1, + GeometryFloatOffset = 2, + GeometryWeightOffset = 3, + GeometryVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + DeformVertexOffset = 0, + DeformCount = 1, + DeformValueCount = 2, + DeformValueOffset = 3, + DeformFloatOffset = 4 + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2 + } + /** + * @private + */ + const enum BoneType { + Bone = 0, + Surface = 1 + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + Path = 4 + } + /** + * - Bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2 + } + /** + * @private + */ + const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11 + } + /** + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13 + } + /** + * @private + */ + const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5 + } + /** + * @private + */ + const enum TimelineType { + Action = 0, + ZOrder = 1, + BoneAll = 10, + BoneTranslate = 11, + BoneRotate = 12, + BoneScale = 13, + Surface = 50, + BoneAlpha = 60, + SlotDisplay = 20, + SlotColor = 21, + SlotDeform = 22, + SlotZIndex = 23, + SlotAlpha = 24, + IKConstraint = 30, + AnimationProgress = 40, + AnimationWeight = 41, + AnimationParameter = 42 + } + /** + * - Offset mode. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @version DragonBones 5.5 + * @language zh_CN + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2 + } + /** + * - Animation fade out mode. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出模式。 + * @version DragonBones 4.5 + * @language zh_CN + */ + const enum AnimationFadeOutMode { + /** + * - Fade out the animation states of the same layer. + * @language en_US + */ + /** + * - 淡出同层的动画状态。 + * @language zh_CN + */ + SameLayer = 1, + /** + * - Fade out the animation states of the same group. + * @language en_US + */ + /** + * - 淡出同组的动画状态。 + * @language zh_CN + */ + SameGroup = 2, + /** + * - Fade out the animation states of the same layer and group. + * @language en_US + */ + /** + * - 淡出同层并且同组的动画状态。 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * - Fade out of all animation states. + * @language en_US + */ + /** + * - 淡出所有的动画状态。 + * @language zh_CN + */ + All = 4, + /** + * - Does not replace the animation state with the same name. + * @language en_US + */ + /** + * - 不替换同名的动画状态。 + * @language zh_CN + */ + Single = 5 + } + /** + * @private + */ + const enum AnimationBlendType { + None = 0, + E1D = 1 + } + /** + * @private + */ + const enum AnimationBlendMode { + Additive = 0, + Override = 1 + } + /** + * @private + */ + const enum ConstraintType { + IK = 0, + Path = 1 + } + /** + * @private + */ + const enum PositionMode { + Fixed = 0, + Percent = 1 + } + /** + * @private + */ + const enum SpacingMode { + Length = 0, + Fixed = 1, + Percent = 2 + } + /** + * @private + */ + const enum RotateMode { + Tangent = 0, + Chain = 1, + ChainScale = 2 + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static readonly VERSION: string; + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + private readonly _clock; + private readonly _events; + private readonly _objects; + private _eventManager; + constructor(eventManager: IEventDispatcher); + advanceTime(passedTime: number): void; + bufferEvent(value: EventObject): void; + bufferObject(object: BaseObject): void; + readonly clock: WorldClock; + readonly eventManager: IEventDispatcher; + } +} +declare var __extends: any; +declare var exports: any; +declare var module: any; +declare var define: any; +/** + * 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. + */ +declare namespace 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 + */ + abstract class BaseObject { + private static _hashCode; + private static _defaultMaxCount; + private static readonly _maxCountMap; + private static readonly _poolsMap; + private static _returnObject; + static toString(): string; + /** + * - 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 + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * - 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 + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * - 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 + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * - A unique identification number assigned to the object. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分配给此实例的唯一标识号。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + protected abstract _onClear(): void; + /** + * - Clear the object and return it back to object pool。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除该实例的所有数据并将其返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - 2D Transform matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 转换矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + /** + * - The value that affects the positioning of pixels along the x axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 x 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + a: number; + /** + * - The value that affects the positioning of pixels along the y axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 y 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + b: number; + /** + * - The value that affects the positioning of pixels along the x axis when rotating or skewing an image. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转或倾斜图像时影响像素沿 x 轴定位的值。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + c: number; + /** + * - The value that affects the positioning of pixels along the y axis when scaling or rotating an image. + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 缩放或旋转图像时影响像素沿 y 轴定位的值。 + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + d: number; + /** + * - The distance by which to translate each point along the x axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 x 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + tx: number; + /** + * - The distance by which to translate each point along the y axis. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 沿 y 轴平移每个点的距离。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + ty: number; + /** + * @private + */ + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * - 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 + */ + identity(): Matrix; + /** + * - 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 + */ + concat(value: Matrix): Matrix; + /** + * - Convert to inverse matrix. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * - 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 + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + /** + * @private + */ + transformRectangle(rectangle: { + x: number; + y: number; + width: number; + height: number; + }, delta?: boolean): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - 2D Transform. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * @private + */ + static readonly PI: number; + /** + * @private + */ + static readonly PI_D: number; + /** + * @private + */ + static readonly PI_H: number; + /** + * @private + */ + static readonly PI_Q: number; + /** + * @private + */ + static readonly RAD_DEG: number; + /** + * @private + */ + static readonly DEG_RAD: number; + /** + * @private + */ + static normalizeRadian(value: number): number; + /** + * - Horizontal translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - Vertical translate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - Skew. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * - rotation. (In radians) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * - Horizontal Scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * - Vertical scaling. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: number; + /** + * @private + */ + constructor(x?: number, y?: number, skew?: number, rotation?: number, scaleX?: number, scaleY?: number); + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * @private + */ + fromMatrix(matrix: Matrix): Transform; + /** + * @private + */ + toMatrix(matrix: Matrix): Transform; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +/** + * 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. + */ +declare namespace 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 + */ + class Point { + /** + * - The horizontal coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的水平坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The vertical coordinate. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 该点的垂直坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - 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 + */ + constructor(x?: number, y?: number); + /** + * @private + */ + copyFrom(value: Point): void; + /** + * @private + */ + clear(): void; + } +} +/** + * 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. + */ +declare namespace 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.
+ * 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) 确定)以及宽度和高度定义的区域。
+ * Rectangle 类的 x、y、width 和 height 属性相互独立;更改一个属性的值不会影响其他属性。 + * 但是,right 和 bottom 属性与这四个属性是整体相关的。例如,如果更改 right 属性的值,则 width + * 属性的值将发生变化;如果更改 bottom 属性,则 height 属性的值将发生变化。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Rectangle { + /** + * - The x coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 x 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * - The y coordinate of the top-left corner of the rectangle. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形左上角的 y 坐标。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * - The width of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 矩形的宽度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + width: number; + /** + * - 矩形的高度(以像素为单位)。 + * @default 0.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - The height of the rectangle, in pixels. + * @default 0.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + constructor(x?: number, y?: number, width?: number, height?: number); + /** + * @private + */ + copyFrom(value: Rectangle): void; + /** + * @private + */ + clear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The user custom data. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 用户自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + static toString(): string; + /** + * - The custom int numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * - The custom float numbers. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * - The custom strings. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + protected _onClear(): void; + /** + * - Get the custom int number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * - Get the custom float number. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * - Get the custom string. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getString(index?: number): string; + } + /** + * @private + */ + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + name: string; + bone: BoneData | null; + slot: SlotData | null; + data: UserData | null; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace 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 + */ + class DragonBonesData extends BaseObject { + static toString(): string; + /** + * @private + */ + autoSearch: boolean; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * - The data version. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * - The DragonBones data name. + * The name is consistent with the DragonBones project name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 龙骨数据名称。 + * 该名称与龙骨项目名保持一致。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + stage: ArmatureData | null; + /** + * - All armature data names. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * @private + */ + readonly armatures: Map; + /** + * @private + */ + userData: UserData | null; + protected _onClear(): void; + /** + * - 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 + */ + getArmature(armatureName: string): ArmatureData | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * - The animation frame rate. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * @private + */ + readonly sortedBones: Array; + /** + * @private + */ + readonly sortedSlots: Array; + /** + * @private + */ + readonly defaultActions: Array; + /** + * @private + */ + readonly actions: Array; + /** + * @private + */ + readonly bones: Map; + /** + * @private + */ + readonly slots: Map; + /** + * @private + */ + readonly constraints: Map; + /** + * @private + */ + readonly skins: Map; + /** + * @private + */ + readonly animations: Map; + /** + * - The default skin data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认插槽数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * - The default animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 默认动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + parent: DragonBonesData; + protected _onClear(): void; + /** + * - Get a specific done data. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(boneName: string): BoneData | null; + /** + * - Get a specific slot data. + * @param slotName - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param slotName - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(slotName: string): SlotData | null; + /** + * @private + */ + getConstraint(constraintName: string): ConstraintData | null; + /** + * - Get a specific skin data. + * @param skinName - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param skinName - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getSkin(skinName: string): SkinData | null; + /** + * @private + */ + getMesh(skinName: string, slotName: string, meshName: string): MeshDisplayData | null; + /** + * - Get a specific animation data. + * @param animationName - The animation animationName. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param animationName - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getAnimation(animationName: string): AnimationData | null; + } + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + type: BoneType; + /** + * - The bone length. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼长度。 + * @version DragonBones 3.0 + * @language zh_CN + */ + length: number; + /** + * @private + */ + alpha: number; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + protected _onClear(): void; + } + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * @private + */ + zIndex: number; + /** + * @private + */ + alpha: number; + /** + * - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * - The parent bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + parent: ArmatureData; + protected _onClear(): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + name: string; + type: ConstraintType; + target: BoneData; + root: BoneData; + bone: BoneData | null; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class GeometryData { + isShared: boolean; + inheritDeform: boolean; + offset: number; + data: DragonBonesData; + weight: WeightData | null; + clear(): void; + shareFrom(value: GeometryData): void; + readonly vertexCount: number; + readonly triangleCount: number; + } + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: SkinData; + protected _onClear(): void; + } + /** + * @private + */ + class ImageDisplayData extends DisplayData { + static toString(): string; + readonly pivot: Point; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @private + */ + class ArmatureDisplayData extends DisplayData { + static toString(): string; + inheritAnimation: boolean; + readonly actions: Array; + armature: ArmatureData | null; + protected _onClear(): void; + /** + * @private + */ + addAction(value: ActionData): void; + } + /** + * @private + */ + class MeshDisplayData extends DisplayData { + static toString(): string; + readonly geometry: GeometryData; + texture: TextureData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class PathDisplayData extends DisplayData { + static toString(): string; + closed: boolean; + constantSpeed: boolean; + readonly geometry: GeometryData; + readonly curveLengths: Array; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + addBone(value: BoneData): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * - The bounding box type. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * @private + */ + color: number; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + protected _onClear(): void; + /** + * - Check whether the bounding box contains a specific point. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否包含特定点。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * - Check whether the bounding box intersects a specific segment. (Local coordinate system) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查边界框是否与特定线段相交。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA: { + x: number; + y: number; + } | null, intersectionPointB: { + x: number; + y: number; + } | null, normalRadians: { + x: number; + y: number; + } | null): number; + } + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode; + /** + * @private + */ + static rectangleIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xMin: number, yMin: number, xMax: number, yMax: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static ellipseIntersectsSegment(xA: number, yA: number, xB: number, yB: number, xC: number, yC: number, widthH: number, heightH: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly vertices: Array; + protected _onClear(): void; + /** + * @inheritDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inheritDoc + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + static toString(): string; + /** + * @private + */ + blendType: AnimationBlendType; + /** + * - The frame count of the animation. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的帧数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * - The play times of the animation. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The duration of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * - The fade in time of the animation. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画的淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * - The animation name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly constraintTimelines: Map>; + /** + * @private + */ + readonly animationTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + protected _onClear(): void; + /** + * @private + */ + addBoneTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + addConstraintTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + addAnimationTimeline(timelineName: string, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(timelineName: string): Array | null; + /** + * @private + */ + getSlotTimelines(timelineName: string): Array | null; + /** + * @private + */ + getConstraintTimelines(timelineName: string): Array | null; + /** + * @private + */ + getAnimationTimelines(timelineName: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(boneName: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(slotName: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * @private + */ + pauseFadeOut: boolean; + /** + * - Fade out the pattern of other animation states when the animation state is fade in. + * This property is typically used to specify the substitution of multiple animation states blend. + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入动画状态时淡出其他动画状态的模式。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * @private + */ + fadeOutTweenType: TweenType; + /** + * @private + */ + fadeOutTime: number; + /** + * @private + */ + pauseFadeIn: boolean; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additive: boolean; + /** + * - Whether the animation state has control over the display property of the slots. + * Sometimes blend a animation state does not want it to control the display properties of the slots, + * especially if other animation state are controlling the display properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + fadeInTweenType: TweenType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The start time of play. (In seconds) + * @default 0.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的开始时间。 (以秒为单位) + * @default 0.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * - The duration of play. + * [-1: Use the default value of the animation data, 0: Stop play, (0~N]: The duration] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 播放的持续时间。 + * [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * - The fade in time. + * [-1: Use the default value of the animation data, [0~N]: The fade in time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 淡入时间。 + * [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The animation data name. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画数据名称。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * @private + */ + readonly boneMask: Array; + protected _onClear(): void; + /** + * @private + */ + clear(): void; + /** + * @private + */ + copyFrom(value: AnimationConfig): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @private + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * @private + */ + scale: number; + /** + * - The texture atlas name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * - The image path of the texture atlas. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + getTexture(textureName: string): TextureData | null; + } + /** + * @private + */ + abstract class TextureData extends BaseObject { + static createRectangle(): Rectangle; + rotated: boolean; + name: string; + readonly region: Rectangle; + parent: TextureAtlasData; + frame: Rectangle | null; + protected _onClear(): void; + copyFrom(value: TextureData): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The armature proxy interface, the docking engine needs to implement it concretely. + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 骨架代理接口,对接的引擎需要对其进行具体实现。 + * @see dragonBones.Armature + * @version DragonBones 5.0 + * @language zh_CN + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * - Dispose the instance and the Armature instance. (The Armature instance will return to the object pool) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 释放该实例和骨架。 (骨架会回收到对象池) + * @example + *
+         *     removeChild(armatureDisplay);
+         *     armatureDisplay.dispose();
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + dispose(disposeProxy: boolean): void; + /** + * - The armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armature: Armature; + /** + * - The animation player. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + class Armature extends BaseObject implements IAnimatable { + static toString(): string; + private static _onSortSlots; + /** + * - Whether to inherit the animation control of the parent armature. + * True to try to have the child armature play an animation with the same name when the parent armature play the animation. + * @default true + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 是否继承父骨架的动画控制。 + * 如果该值为 true,当父骨架播放动画时,会尝试让子骨架播放同名动画。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + userData: any; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + private _alpha; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + private _replacedTexture; + private _clock; + protected _onClear(): void; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlot?: boolean): void; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): Slot | null; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipX: boolean; + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + flipY: boolean; + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+         *     armature.cacheFrameRate = 24;
+         * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly armatureData: ArmatureData; + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventDispatcher: IEventDispatcher; + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @private + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * @private + */ + origin: Transform | null; + /** + * @private + */ + userData: any; + protected _globalDirty: boolean; + /** + */ + protected _onClear(): void; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + updateGlobalTransform(): void; + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * - The offset mode. + * @see #offset + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 偏移模式。 + * @see #offset + * @version DragonBones 5.5 + * @language zh_CN + */ + offsetMode: OffsetMode; + protected _localDirty: boolean; + protected _visible: boolean; + protected _cachedFrameIndex: number; + /** + * @private + */ + protected _parent: Bone | null; + protected _onClear(): void; + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * - Check whether the bone contains a specific bone. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: Bone): boolean; + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly boneData: BoneData; + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone | null; + } +} +/** + * 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. + */ +declare namespace 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class DisplayFrame extends BaseObject { + static toString(): string; + rawDisplayData: DisplayData | null; + displayData: DisplayData | null; + textureData: TextureData | null; + display: any | Armature | null; + readonly deformVertices: Array; + protected _onClear(): void; + updateDeformVertices(): void; + getGeometryData(): GeometryData | null; + getBoundingBox(): BoundingBoxData | null; + getTextureData(): TextureData | null; + } + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * - Displays the animated state or mixed group name controlled by the object, set to null to be controlled by all animation states. + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + displayController: string | null; + protected _displayDataDirty: boolean; + protected _displayDirty: boolean; + protected _geometryDirty: boolean; + protected _textureDirty: boolean; + protected _visibleDirty: boolean; + protected _blendModeDirty: boolean; + protected _zOrderDirty: boolean; + protected _transformDirty: boolean; + protected _visible: boolean; + protected _blendMode: BlendMode; + protected _displayIndex: number; + protected _animationDisplayIndex: number; + protected _cachedFrameIndex: number; + protected readonly _localMatrix: Matrix; + protected _boundingBoxData: BoundingBoxData | null; + protected _textureData: TextureData | null; + protected _rawDisplay: any; + protected _meshDisplay: any; + protected _display: any | null; + protected _childArmature: Armature | null; + /** + * @private + */ + protected _parent: Bone; + protected _onClear(): void; + protected abstract _initDisplay(value: any, isRetain: boolean): void; + protected abstract _disposeDisplay(value: any, isRelease: boolean): void; + protected abstract _onUpdateDisplay(): void; + protected abstract _addDisplay(): void; + protected abstract _replaceDisplay(value: any): void; + protected abstract _removeDisplay(): void; + protected abstract _updateZOrder(): void; + protected abstract _updateBlendMode(): void; + protected abstract _updateColor(): void; + protected abstract _updateFrame(): void; + protected abstract _updateMesh(): void; + protected abstract _updateTransform(): void; + protected abstract _identityTransform(): void; + protected _hasDisplay(display: any): boolean; + protected _updateDisplayData(): void; + protected _updateDisplay(): void; + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * @private + */ + replaceRawDisplayData(displayData: DisplayData | null, index?: number): void; + /** + * @private + */ + replaceDisplayData(displayData: DisplayData | null, index?: number): void; + /** + * @private + */ + replaceTextureData(textureData: TextureData | null, index?: number): void; + /** + * @private + */ + replaceDisplay(value: any | Armature | null, index?: number): void; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + intersectsSegment(xA: number, yA: number, xB: number, yB: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + getDisplayFrameAt(index: number): DisplayFrame; + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + visible: boolean; + /** + * @private + */ + displayFrameCount: number; + /** + * - The index of the display object displayed in the display list. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     slot.displayIndex = 3;
+         *     slot.displayController = "none";
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly slotData: SlotData; + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * - The display object that the slot displays at this time. + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+         *     let slot = armature.getSlot("text");
+         *     slot.display = new yourEngine.TextField();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * - The child armature that the slot displayed at current time. + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     let prevChildArmature = slot.childArmature;
+         *     if (prevChildArmature) {
+         *         prevChildArmature.dispose();
+         *     }
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     let prevChildArmature = slot.childArmature;
+         *     if (prevChildArmature) {
+         *         prevChildArmature.dispose();
+         *     }
+         *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + getDisplay(): any; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + setDisplay(value: any): void; + } +} +/** + * 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. + */ +declare namespace 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. + */ +declare namespace dragonBones { + /** + * - Play animation interface. (Both Armature and Wordclock implement the interface) + * Any instance that implements the interface can be added to the Worldclock instance and advance time by Worldclock instance uniformly. + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以添加到 WorldClock 实例中,由 WorldClock 实例统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * - Advance time. + * @param passedTime - Passed time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 更新时间。 + * @param passedTime - 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - The Wordclock instance to which the current belongs. + * @example + *
+         *     armature.clock = factory.clock; // Add armature to clock.
+         *     armature.clock = null; // Remove armature from clock.
+         * 
+ * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 当前所属的 WordClock 实例。 + * @example + *
+         *     armature.clock = factory.clock; // 将骨架添加到时钟。
+         *     armature.clock = null; // 将骨架从时钟移除。
+         * 
+ * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _systemTime; + private readonly _animatebles; + private _clock; + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + static toString(): string; + /** + * - The play speed of all animations. [0: Stop, (0~1): Slow, 1: Normal, (1~N): Fast] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有动画的播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * Update bones and slots cachedFrameIndices. + */ + private _animationDirty; + private _inheritTimeScale; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private readonly _blendStates; + private _armature; + private _animationConfig; + private _lastAnimationState; + protected _onClear(): void; + private _fadeOut; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态。 + * @param animationName - 动画状态名称。 + * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string, layer?: number): AnimationState | null; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): ReadonlyArray; + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: ReadonlyArray; + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + static toString(): string; + /** + * @private + */ + actionEnabled: boolean; + /** + * @private + */ + additive: boolean; + /** + * - Whether the animation state has control over the display object properties of the slots. + * Sometimes blend a animation state does not want it to control the display object properties of the slots, + * especially if other animation state are controlling the display object properties of the slots. + * @default true + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态是否对插槽的显示对象属性有控制权。 + * 有时混合一个动画状态并不希望其控制插槽的显示对象属性, + * 尤其是其他动画状态正在控制这些插槽的显示对象属性时。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * - Whether to reset the objects without animation to the armature pose when the animation state is start to play. + * This property should usually be set to false when blend multiple animation states. + * @default true + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 开始播放动画状态时是否将没有动画的对象重置为骨架初始值。 + * 通常在混合多个动画状态时应该将该属性设置为 false。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * @private + */ + blendType: AnimationBlendType; + /** + * - The play times. [0: Loop play, [1~N]: Play N times] + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * - The blend layer. + * High layer animation state will get the blend weight first. + * When the blend weight is assigned more than 1, the remaining animation states will no longer get the weight assigned. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合图层。 + * 图层高的动画状态会优先获取混合权重。 + * 当混合权重分配超过 1 时,剩余的动画状态将不再获得权重分配。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * - The play speed. + * The value is an overlay relationship with {@link dragonBones.Animation#timeScale}. + * [(-N~0): Reverse play, 0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度。 + * 该值与 {@link dragonBones.Animation#timeScale} 是叠加关系。 + * [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * @private + */ + parameterX: number; + /** + * @private + */ + parameterY: number; + /** + * @private + */ + positionX: number; + /** + * @private + */ + positionY: number; + /** + * - The auto fade out time when the animation state play completed. + * [-1: Do not fade out automatically, [0~N]: The fade out time] (In seconds) + * @default -1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态播放完成后的自动淡出时间。 + * [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * - The name of the animation state. (Can be different from the name of the animation data) + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画状态名称。 (可以不同于动画数据) + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * - The blend group name of the animation state. + * This property is typically used to specify the substitution of multiple animation states blend. + * @readonly + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合组名称。 + * 该属性通常用来指定多个动画状态混合时的相互替换关系。 + * @readonly + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + private _timelineDirty; + private _weight; + private _fadeTime; + private _time; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _boneBlendTimelines; + private readonly _slotTimelines; + private readonly _slotBlendTimelines; + private readonly _constraintTimelines; + private readonly _animationTimelines; + private readonly _poseTimelines; + private _animationData; + private _armature; + private _zOrderTimeline; + private _activeChildA; + private _activeChildB; + protected _onClear(): void; + private _updateTimelines; + private _updateBoneAndSlotTimelines; + private _advanceFadeTime; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * - Check if a specific bone mask is included. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(boneName: string): boolean; + /** + * - Add a specific bone mask. + * @param boneName - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(boneName: string, recursive?: boolean): void; + /** + * - Remove the mask of a specific bone. + * @param boneName - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(boneName: string, recursive?: boolean): void; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * @private + */ + addState(animationState: AnimationState, timelineDatas?: TimelineData[] | null): void; + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + weight: number; + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animationData: AnimationData; + } +} +/** + * 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. + */ +declare namespace 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. + */ +declare namespace 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. + */ +declare namespace dragonBones { + /** + * - The properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + static toString(): string; + /** + * - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位) + * @version DragonBones 4.5 + * @language zh_CN + */ + time: number; + /** + * - The event type。 + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * - The event name. (The frame event name or the frame sound name) + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件名称。 (帧事件的名称或帧声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * - The armature that dispatch the event. + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * - The bone that dispatch the event. + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * - The slot that dispatch the event. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * - The animation state that dispatch the event. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 发出该事件的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * @private + */ + actionData: ActionData | null; + /** + * @private + */ + /** + * - The custom data. + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 自定义数据。 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + protected _onClear(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * - The event dispatcher interface. + * Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件派发接口。 + * DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * - Checks whether the object has any listeners registered for a specific type of event。 + * @param type - Event type. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 检查是否为特定的事件类型注册了任何侦听器。 + * @param type - 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasDBEventListener(type: EventStringType): boolean; + /** + * - Dispatches an event into the event flow. + * @param type - Event type. + * @param eventObject - Event object. + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 分派特定的事件到事件流中。 + * @param type - 事件类型。 + * @param eventObject - 事件数据。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + /** + * - Add an event listener object so that the listener receives notification of an event. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + /** + * - Removes a listener from the object. + * @param type - Event type. + * @param listener - Event listener. + * @param thisObject - The listener function's "this". + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 删除特定事件类型的侦听器。 + * @param type - 事件类型。 + * @param listener - 事件侦听器。 + * @param thisObject - 侦听函数绑定的 this 对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeDBEventListener(type: EventStringType, listener: Function, thisObject: any): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string; + protected static readonly DATA_VERSION_3_0: string; + protected static readonly DATA_VERSION_4_0: string; + protected static readonly DATA_VERSION_4_5: string; + protected static readonly DATA_VERSION_5_0: string; + protected static readonly DATA_VERSION_5_5: string; + protected static readonly DATA_VERSION_5_6: string; + protected static readonly DATA_VERSION: string; + protected static readonly DATA_VERSIONS: Array; + protected static readonly TEXTURE_ATLAS: string; + protected static readonly SUB_TEXTURE: string; + protected static readonly FORMAT: string; + protected static readonly IMAGE_PATH: string; + protected static readonly WIDTH: string; + protected static readonly HEIGHT: string; + protected static readonly ROTATED: string; + protected static readonly FRAME_X: string; + protected static readonly FRAME_Y: string; + protected static readonly FRAME_WIDTH: string; + protected static readonly FRAME_HEIGHT: string; + protected static readonly DRADON_BONES: string; + protected static readonly USER_DATA: string; + protected static readonly ARMATURE: string; + protected static readonly CANVAS: string; + protected static readonly BONE: string; + protected static readonly SURFACE: string; + protected static readonly SLOT: string; + protected static readonly CONSTRAINT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly FRAME: string; + protected static readonly IK: string; + protected static readonly PATH_CONSTRAINT: string; + protected static readonly ANIMATION: string; + protected static readonly TIMELINE: string; + protected static readonly FFD: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly DISPLAY_FRAME: string; + protected static readonly COLOR_FRAME: string; + protected static readonly DEFAULT_ACTIONS: string; + protected static readonly ACTIONS: string; + protected static readonly EVENTS: string; + protected static readonly INTS: string; + protected static readonly FLOATS: string; + protected static readonly STRINGS: string; + protected static readonly TRANSFORM: string; + protected static readonly PIVOT: string; + protected static readonly AABB: string; + protected static readonly COLOR: string; + protected static readonly VERSION: string; + protected static readonly COMPATIBLE_VERSION: string; + protected static readonly FRAME_RATE: string; + protected static readonly TYPE: string; + protected static readonly SUB_TYPE: string; + protected static readonly NAME: string; + protected static readonly PARENT: string; + protected static readonly TARGET: string; + protected static readonly STAGE: string; + protected static readonly SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_INDEX: string; + protected static readonly Z_ORDER: string; + protected static readonly Z_INDEX: string; + protected static readonly BLEND_MODE: string; + protected static readonly INHERIT_TRANSLATION: string; + protected static readonly INHERIT_ROTATION: string; + protected static readonly INHERIT_SCALE: string; + protected static readonly INHERIT_REFLECTION: string; + protected static readonly INHERIT_ANIMATION: string; + protected static readonly INHERIT_DEFORM: string; + protected static readonly SEGMENT_X: string; + protected static readonly SEGMENT_Y: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: string; + protected static readonly BLEND_TYPE: string; + protected static readonly FADE_IN_TIME: string; + protected static readonly PLAY_TIMES: string; + protected static readonly SCALE: string; + protected static readonly OFFSET: string; + protected static readonly POSITION: string; + protected static readonly DURATION: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: string; + protected static readonly CLOCK_WISE: string; + protected static readonly CURVE: string; + protected static readonly SOUND: string; + protected static readonly EVENT: string; + protected static readonly ACTION: string; + protected static readonly X: string; + protected static readonly Y: string; + protected static readonly SKEW_X: string; + protected static readonly SKEW_Y: string; + protected static readonly SCALE_X: string; + protected static readonly SCALE_Y: string; + protected static readonly VALUE: string; + protected static readonly ROTATE: string; + protected static readonly SKEW: string; + protected static readonly ALPHA: string; + protected static readonly ALPHA_OFFSET: string; + protected static readonly RED_OFFSET: string; + protected static readonly GREEN_OFFSET: string; + protected static readonly BLUE_OFFSET: string; + protected static readonly ALPHA_MULTIPLIER: string; + protected static readonly RED_MULTIPLIER: string; + protected static readonly GREEN_MULTIPLIER: string; + protected static readonly BLUE_MULTIPLIER: string; + protected static readonly UVS: string; + protected static readonly VERTICES: string; + protected static readonly TRIANGLES: string; + protected static readonly WEIGHTS: string; + protected static readonly SLOT_POSE: string; + protected static readonly BONE_POSE: string; + protected static readonly BONES: string; + protected static readonly POSITION_MODE: string; + protected static readonly SPACING_MODE: string; + protected static readonly ROTATE_MODE: string; + protected static readonly SPACING: string; + protected static readonly ROTATE_OFFSET: string; + protected static readonly ROTATE_MIX: string; + protected static readonly TRANSLATE_MIX: string; + protected static readonly TARGET_DISPLAY: string; + protected static readonly CLOSED: string; + protected static readonly CONSTANT_SPEED: string; + protected static readonly VERTEX_COUNT: string; + protected static readonly LENGTHS: string; + protected static readonly GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getBoneType(value: string): BoneType; + protected static _getPositionMode(value: string): PositionMode; + protected static _getSpacingMode(value: string): SpacingMode; + protected static _getRotateMode(value: string): RotateMode; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getBlendMode(value: string): BlendMode; + protected static _getAnimationBlendType(value: string): AnimationBlendType; + protected static _getActionType(value: string): ActionType; + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + const enum FrameValueType { + Step = 0, + Int = 1, + Float = 2 + } + /** + * @private + */ + class ObjectDataParser extends DataParser { + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _rawTextureAtlasIndex: number; + protected readonly _rawBones: Array; + protected _data: DragonBonesData; + protected _armature: ArmatureData; + protected _bone: BoneData; + protected _geometry: GeometryData; + protected _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _frameValueType; + private _defaultColorOffset; + private _prevClockwise; + private _prevRotation; + private _frameDefaultValue; + private _frameValueScale; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _intArray; + private readonly _floatArray; + private readonly _frameIntArray; + private readonly _frameFloatArray; + private readonly _frameArray; + private readonly _timelineArray; + private readonly _colorArray; + private readonly _cacheRawMeshes; + private readonly _cacheMeshes; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _cacheBones; + private readonly _slotChildActions; + private _getCurvePoint; + private _samplingEasingCurve; + private _parseActionDataInFrame; + private _mergeActionFrame; + protected _parseArmature(rawData: any, scale: number): ArmatureData; + protected _parseBone(rawData: any): BoneData; + protected _parseIKConstraint(rawData: any): ConstraintData | null; + protected _parsePathConstraint(rawData: any): ConstraintData | null; + protected _parseSlot(rawData: any, zOrder: number): SlotData; + protected _parseSkin(rawData: any): SkinData; + protected _parseDisplay(rawData: any): DisplayData | null; + protected _parsePath(rawData: any, display: PathDisplayData): void; + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseTimeline(rawData: any, rawFrames: Array | null, framesKey: string, timelineType: TimelineType, frameValueType: FrameValueType, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number, timeline?: TimelineData | null): TimelineData | null; + protected _parseBoneTimeline(rawData: any): void; + protected _parseSlotTimeline(rawData: any): void; + protected _parseFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSingleValueFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseDoubleValueFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionFrame(frame: ActionFrame, frameStart: number, frameCount: number): number; + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneAllFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneTranslateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneRotateFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseBoneScaleFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDisplayFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseSlotDeformFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseIKConstraintFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseActionData(rawData: any, type: ActionType, bone: BoneData | null, slot: SlotData | null): Array; + protected _parseDeformFrame(rawData: any, frameStart: number, frameCount: number): number; + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + protected _parseGeometry(rawData: any, geometry: GeometryData): void; + protected _parseArray(rawData: any): void; + protected _modifyArray(): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + private static _objectDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): ObjectDataParser; + } + /** + * @private + */ + class ActionFrame { + frameStart: number; + readonly actions: Array; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binaryOffset; + private _binary; + private _intArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + private _inRange; + private _decodeUTF8; + private _parseBinaryTimeline; + protected _parseAnimation(rawData: any): AnimationData; + protected _parseGeometry(rawData: any, geometry: GeometryData): void; + protected _parseArray(rawData: any): void; + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + private static _binaryDataParserInstance; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + static getInstance(): BinaryDataParser; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + protected static _objectParser: ObjectDataParser; + protected static _binaryParser: BinaryDataParser; + /** + * @private + */ + autoSearch: boolean; + protected readonly _dragonBonesDataMap: Map; + protected readonly _textureAtlasDataMap: Map>; + protected _dragonBones: DragonBones; + protected _dataParser: DataParser; + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + protected _isSupportMesh(): boolean; + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + protected _buildConstraints(dataPackage: BuildArmaturePackage, armature: Armature): void; + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, _slot: Slot, displayData: ArmatureDisplayData): Armature | null; + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, slot: Slot): any; + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseDragonBonesData(rawData: any, name?: string | null, scale?: number): DragonBonesData | null; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * - Update texture atlases. + * @param textureAtlases - The texture atlas objects. + * @param name - The texture atlas name. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 更新贴图集对象。 + * @param textureAtlases - 多个贴图集对象。 + * @param name - 贴图集名称。 + * @version DragonBones 5.7 + * @language zh_CN + */ + updateTextureAtlases(textureAtlases: Array, name: string): void; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + addDragonBonesData(data: DragonBonesData, name?: string | null): void; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + addTextureAtlasData(data: TextureAtlasData, name?: string | null): void; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string): Armature | null; + /** + * @private + */ + replaceDisplay(slot: Slot, displayData: DisplayData | null, displayIndex?: number): void; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): boolean; + /** + * @private + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): boolean; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceSkin(armature: Armature, skin: SkinData, isOverride?: boolean, exclude?: Array | null): boolean; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + replaceAnimation(armature: Armature, armatureData: ArmatureData, isOverride?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + readonly clock: WorldClock; + /** + * @private + */ + readonly dragonBones: DragonBones; + } + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } +} +/** + * 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. + */ +declare var _Scene: any; +declare namespace dragonBones { + class DragonBonesAsset extends cc.Asset { + readonly dragonBonesData: string | ArrayBuffer; + readonly textureAtlases: string[]; + readonly textures: cc.Texture2D[]; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The Cocos texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class CocosTextureAtlasData extends TextureAtlasData { + static toString(): string; + private _renderTexture; + protected _onClear(): void; + createTexture(): TextureData; + /** + * - The Cocos texture. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + renderTexture: cc.Texture2D | null; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * @see dragonBones.IArmatureProxy + */ + class CocosArmatureComponent extends cc.Component implements IArmatureProxy { + /** + * @private + */ + debugDraw: boolean; + private _debugDraw; + dbInit(armature: Armature): void; + dbClear(): void; + dbUpdate(): void; + dispose(_isposeProxy?: boolean): void; + destroy(): true; + /** + * @private + */ + dispatchDBEvent(type: EventStringType, eventObject: EventObject): void; + hasDBEventListener(type: EventStringType): boolean; + addDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; + removeDBEventListener(type: EventStringType, listener: (event: cc.Event.EventCustom) => void, target: any): void; + readonly armature: Armature; + readonly animation: Animation; + dragonBonesName: string; + dragonBonesAsset: DragonBonesAsset | null; + _dragonBonesNode: cc.Node; + _loadAndDisplayDragonBones(): void; + _parseDragonAsset(): void; + _parseDragonAtlasAsset(): void; + display(): void; + onLoad(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The Cocos slot. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class CocosSlot extends Slot { + static toString(): string; + private _ccMeshDirty; + private _textureScale; + private _renderDisplay; + protected _onClear(): void; + protected _initDisplay(_value: any, _isRetain: boolean): void; + protected _disposeDisplay(value: any, isRelease: boolean): void; + protected _onUpdateDisplay(): void; + protected _addDisplay(): void; + protected _replaceDisplay(value: any): void; + protected _removeDisplay(): void; + protected _updateZOrder(): void; + protected _updateBlendMode(): void; + protected _updateColor(): void; + protected _updateFrame(): void; + protected _updateMesh(): void; + protected _updateTransform(): void; + protected _identityTransform(): void; + } +} +/** + * 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. + */ +declare namespace dragonBones { + /** + * - The Cocos factory. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class CocosFactory extends BaseFactory { + private static _dragonBonesInstance; + private static _factory; + /** + * - A global factory instance that can be used directly. + * @version DragonBones 4.7 + * @language en_US + */ + /** + * - 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + static readonly factory: CocosFactory; + protected _node: cc.Node | null; + protected _armatureNode: cc.Node | null; + constructor(dataParser?: DataParser | null); + protected _isSupportMesh(): boolean; + protected _buildTextureAtlasData(textureAtlasData: CocosTextureAtlasData | null, textureAtlas: cc.Texture2D | null): CocosTextureAtlasData; + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; + protected _buildChildArmature(dataPackage: BuildArmaturePackage | null, slot: Slot, displayData: ArmatureDisplayData): Armature | null; + protected _buildSlot(_dataPackage: BuildArmaturePackage, slotData: SlotData, armature: Armature): Slot; + /** + * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. + * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. + * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature component. + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 + * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 + * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架组件。 + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language zh_CN + */ + buildArmatureComponent(armatureName: string, dragonBonesName?: string, skinName?: string, textureAtlasName?: string, node?: cc.Node | null): CocosArmatureComponent | null; + /** + * - Create the display object with the specified texture. + * @param textureName - The texture data name. + * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建带有指定贴图的显示对象。 + * @param textureName - 贴图数据名称。 + * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureDisplay(textureName: string, textureAtlasName?: string | null): cc.Sprite | null; + /** + * - A global sound event manager. + * Sound events can be listened to uniformly from the manager. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 全局声音事件管理器。 + * 声音事件可以从该管理器统一侦听。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly soundEventManager: cc.Node; + } +} diff --git a/Cocos/1.x/out/dragonBones.js b/Cocos/1.x/out/dragonBones.js index d95dfa76..41459d7c 100755 --- a/Cocos/1.x/out/dragonBones.js +++ b/Cocos/1.x/out/dragonBones.js @@ -1,16368 +1,16363 @@ -"use strict"; -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 __decorate = (this && this.__decorate) || function (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; -}; -/** - * 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("YuPeng 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.
- * 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) 确定)以及宽度和高度定义的区域。
- * 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, 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 armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var ArmatureData = /** @class */ (function (_super) { - __extends(ArmatureData, _super); - function ArmatureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.aabb = new dragonBones.Rectangle(); - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.animationNames = []; - /** - * @private - */ - _this.sortedBones = []; - /** - * @private - */ - _this.sortedSlots = []; - /** - * @private - */ - _this.defaultActions = []; - /** - * @private - */ - _this.actions = []; - /** - * @private - */ - _this.bones = {}; - /** - * @private - */ - _this.slots = {}; - /** - * @private - */ - _this.constraints = {}; - /** - * @private - */ - _this.skins = {}; - /** - * @private - */ - _this.animations = {}; - /** - * @private - */ - _this.canvas = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - ArmatureData.toString = function () { - return "[class dragonBones.ArmatureData]"; - }; - ArmatureData.prototype._onClear = function () { - for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { - var action = _c[_b]; - action.returnToPool(); - } - for (var k in this.bones) { - this.bones[k].returnToPool(); - delete this.bones[k]; - } - for (var k in this.slots) { - this.slots[k].returnToPool(); - delete this.slots[k]; - } - for (var k in this.constraints) { - this.constraints[k].returnToPool(); - delete this.constraints[k]; - } - for (var k in this.skins) { - this.skins[k].returnToPool(); - delete this.skins[k]; - } - for (var k in this.animations) { - this.animations[k].returnToPool(); - delete this.animations[k]; - } - if (this.canvas !== null) { - this.canvas.returnToPool(); - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.type = 0 /* Armature */; - this.frameRate = 0; - this.cacheFrameRate = 0; - this.scale = 1.0; - this.name = ""; - this.aabb.clear(); - this.animationNames.length = 0; - this.sortedBones.length = 0; - this.sortedSlots.length = 0; - this.defaultActions.length = 0; - this.actions.length = 0; - // this.bones.clear(); - // this.slots.clear(); - // this.constraints.clear(); - // this.skins.clear(); - // this.animations.clear(); - this.defaultSkin = null; - this.defaultAnimation = null; - this.canvas = null; - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - ArmatureData.prototype.sortBones = function () { - var total = this.sortedBones.length; - if (total <= 0) { - return; - } - var sortHelper = this.sortedBones.concat(); - var index = 0; - var count = 0; - this.sortedBones.length = 0; - while (count < total) { - var bone = sortHelper[index++]; - if (index >= total) { - index = 0; - } - if (this.sortedBones.indexOf(bone) >= 0) { - continue; - } - var flag = false; - for (var k in this.constraints) { // Wait constraint. - var constraint = this.constraints[k]; - if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { - flag = true; - break; - } - } - if (flag) { - continue; - } - if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. - continue; - } - this.sortedBones.push(bone); - count++; - } - }; - /** - * @internal - */ - ArmatureData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0) { // TODO clear cache. - return; - } - this.cacheFrameRate = frameRate; - for (var k in this.animations) { - this.animations[k].cacheFrames(this.cacheFrameRate); - } - }; - /** - * @internal - */ - ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { - var dataArray = this.parent.cachedFrames; - var arrayOffset = dataArray.length; - dataArray.length += 10; - dataArray[arrayOffset] = globalTransformMatrix.a; - dataArray[arrayOffset + 1] = globalTransformMatrix.b; - dataArray[arrayOffset + 2] = globalTransformMatrix.c; - dataArray[arrayOffset + 3] = globalTransformMatrix.d; - dataArray[arrayOffset + 4] = globalTransformMatrix.tx; - dataArray[arrayOffset + 5] = globalTransformMatrix.ty; - dataArray[arrayOffset + 6] = transform.rotation; - dataArray[arrayOffset + 7] = transform.skew; - dataArray[arrayOffset + 8] = transform.scaleX; - dataArray[arrayOffset + 9] = transform.scaleY; - return arrayOffset; - }; - /** - * @internal - */ - ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { - var dataArray = this.parent.cachedFrames; - globalTransformMatrix.a = dataArray[arrayOffset]; - globalTransformMatrix.b = dataArray[arrayOffset + 1]; - globalTransformMatrix.c = dataArray[arrayOffset + 2]; - globalTransformMatrix.d = dataArray[arrayOffset + 3]; - globalTransformMatrix.tx = dataArray[arrayOffset + 4]; - globalTransformMatrix.ty = dataArray[arrayOffset + 5]; - transform.rotation = dataArray[arrayOffset + 6]; - transform.skew = dataArray[arrayOffset + 7]; - transform.scaleX = dataArray[arrayOffset + 8]; - transform.scaleY = dataArray[arrayOffset + 9]; - transform.x = globalTransformMatrix.tx; - transform.y = globalTransformMatrix.ty; - }; - /** - * @internal - */ - ArmatureData.prototype.addBone = function (value) { - if (value.name in this.bones) { - console.warn("Same bone: " + value.name); - return; - } - this.bones[value.name] = value; - this.sortedBones.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addSlot = function (value) { - if (value.name in this.slots) { - console.warn("Same slot: " + value.name); - return; - } - this.slots[value.name] = value; - this.sortedSlots.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addConstraint = function (value) { - if (value.name in this.constraints) { - console.warn("Same constraint: " + value.name); - return; - } - this.constraints[value.name] = value; - }; - /** - * @internal - */ - ArmatureData.prototype.addSkin = function (value) { - if (value.name in this.skins) { - console.warn("Same skin: " + value.name); - return; - } - value.parent = this; - this.skins[value.name] = value; - if (this.defaultSkin === null) { - this.defaultSkin = value; - } - if (value.name === "default") { - this.defaultSkin = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAnimation = function (value) { - if (value.name in this.animations) { - console.warn("Same animation: " + value.name); - return; - } - value.parent = this; - this.animations[value.name] = value; - this.animationNames.push(value.name); - if (this.defaultAnimation === null) { - this.defaultAnimation = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAction = function (value, isDefault) { - if (isDefault) { - this.defaultActions.push(value); - } - else { - this.actions.push(value); - } - }; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getBone = function (boneName) { - return boneName in this.bones ? this.bones[boneName] : null; - }; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSlot = function (slotName) { - return slotName in this.slots ? this.slots[slotName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getConstraint = function (constraintName) { - return constraintName in this.constraints ? this.constraints[constraintName] : null; - }; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSkin = function (skinName) { - return skinName in this.skins ? this.skins[skinName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { - var skin = this.getSkin(skinName); - if (skin === null) { - return null; - } - return skin.getDisplay(slotName, meshName); - }; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getAnimation = function (animationName) { - return animationName in this.animations ? this.animations[animationName] : null; - }; - return ArmatureData; - }(dragonBones.BaseObject)); - dragonBones.ArmatureData = ArmatureData; - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var BoneData = /** @class */ (function (_super) { - __extends(BoneData, _super); - function BoneData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.transform = new dragonBones.Transform(); - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - BoneData.toString = function () { - return "[class dragonBones.BoneData]"; - }; - BoneData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.inheritTranslation = false; - this.inheritRotation = false; - this.inheritScale = false; - this.inheritReflection = false; - this.type = 0 /* Bone */; - this.length = 0.0; - this.alpha = 1.0; - this.name = ""; - this.transform.identity(); - this.userData = null; - this.parent = null; - }; - return BoneData; - }(dragonBones.BaseObject)); - dragonBones.BoneData = BoneData; - /** - * @internal - */ - var SurfaceData = /** @class */ (function (_super) { - __extends(SurfaceData, _super); - function SurfaceData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new dragonBones.GeometryData(); - return _this; - } - SurfaceData.toString = function () { - return "[class dragonBones.SurfaceData]"; - }; - SurfaceData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Surface */; - this.segmentX = 0; - this.segmentY = 0; - this.geometry.clear(); - }; - return SurfaceData; - }(BoneData)); - dragonBones.SurfaceData = SurfaceData; - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SlotData = /** @class */ (function (_super) { - __extends(SlotData, _super); - function SlotData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.color = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - /** - * @internal - */ - SlotData.createColor = function () { - return new dragonBones.ColorTransform(); - }; - SlotData.toString = function () { - return "[class dragonBones.SlotData]"; - }; - SlotData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.blendMode = 0 /* Normal */; - this.displayIndex = 0; - this.zOrder = 0; - this.zIndex = 0; - this.alpha = 1.0; - this.name = ""; - this.color = null; // - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotData; - }(dragonBones.BaseObject)); - dragonBones.SlotData = SlotData; -})(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 CanvasData = /** @class */ (function (_super) { - __extends(CanvasData, _super); - function CanvasData() { - return _super !== null && _super.apply(this, arguments) || this; - } - CanvasData.toString = function () { - return "[class dragonBones.CanvasData]"; - }; - CanvasData.prototype._onClear = function () { - this.hasBackground = false; - this.color = 0x000000; - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - return CanvasData; - }(dragonBones.BaseObject)); - dragonBones.CanvasData = CanvasData; -})(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 skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SkinData = /** @class */ (function (_super) { - __extends(SkinData, _super); - function SkinData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.displays = {}; - return _this; - } - SkinData.toString = function () { - return "[class dragonBones.SkinData]"; - }; - SkinData.prototype._onClear = function () { - for (var k in this.displays) { - var slotDisplays = this.displays[k]; - for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { - var display = slotDisplays_1[_i]; - if (display !== null) { - display.returnToPool(); - } - } - delete this.displays[k]; - } - this.name = ""; - // this.displays.clear(); - this.parent = null; // - }; - /** - * @internal - */ - SkinData.prototype.addDisplay = function (slotName, value) { - if (!(slotName in this.displays)) { - this.displays[slotName] = []; - } - if (value !== null) { - value.parent = this; - } - var slotDisplays = this.displays[slotName]; // TODO clear prev - slotDisplays.push(value); - }; - /** - * @private - */ - SkinData.prototype.getDisplay = function (slotName, displayName) { - var slotDisplays = this.getDisplays(slotName); - if (slotDisplays !== null) { - for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { - var display = slotDisplays_2[_i]; - if (display !== null && display.name === displayName) { - return display; - } - } - } - return null; - }; - /** - * @private - */ - SkinData.prototype.getDisplays = function (slotName) { - if (!(slotName in this.displays)) { - return null; - } - return this.displays[slotName]; - }; - return SkinData; - }(dragonBones.BaseObject)); - dragonBones.SkinData = SkinData; -})(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 ConstraintData = /** @class */ (function (_super) { - __extends(ConstraintData, _super); - function ConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintData.prototype._onClear = function () { - this.order = 0; - this.name = ""; - this.type = 0 /* IK */; - this.target = null; // - this.root = null; // - this.bone = null; - }; - return ConstraintData; - }(dragonBones.BaseObject)); - dragonBones.ConstraintData = ConstraintData; - /** - * @internal - */ - var IKConstraintData = /** @class */ (function (_super) { - __extends(IKConstraintData, _super); - function IKConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintData.toString = function () { - return "[class dragonBones.IKConstraintData]"; - }; - IKConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.scaleEnabled = false; - this.bendPositive = false; - this.weight = 1.0; - }; - return IKConstraintData; - }(ConstraintData)); - dragonBones.IKConstraintData = IKConstraintData; - /** - * @internal - */ - var PathConstraintData = /** @class */ (function (_super) { - __extends(PathConstraintData, _super); - function PathConstraintData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - PathConstraintData.toString = function () { - return "[class dragonBones.PathConstraintData]"; - }; - PathConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.pathSlot = null; - this.pathDisplayData = null; - this.bones.length = 0; - this.positionMode = 0 /* Fixed */; - this.spacingMode = 1 /* Fixed */; - this.rotateMode = 1 /* Chain */; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 0.0; - this.translateMix = 0.0; - }; - PathConstraintData.prototype.AddBone = function (value) { - this.bones.push(value); - }; - return PathConstraintData; - }(ConstraintData)); - dragonBones.PathConstraintData = PathConstraintData; -})(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 GeometryData = /** @class */ (function () { - function GeometryData() { - this.weight = null; // Initial value. - } - GeometryData.prototype.clear = function () { - if (!this.isShared && this.weight !== null) { - this.weight.returnToPool(); - } - this.isShared = false; - this.inheritDeform = false; - this.offset = 0; - this.data = null; - this.weight = null; - }; - GeometryData.prototype.shareFrom = function (value) { - this.isShared = true; - this.offset = value.offset; - this.weight = value.weight; - }; - Object.defineProperty(GeometryData.prototype, "vertexCount", { - get: function () { - var intArray = this.data.intArray; - return intArray[this.offset + 0 /* GeometryVertexCount */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GeometryData.prototype, "triangleCount", { - get: function () { - var intArray = this.data.intArray; - return intArray[this.offset + 1 /* GeometryTriangleCount */]; - }, - enumerable: true, - configurable: true - }); - return GeometryData; - }()); - dragonBones.GeometryData = GeometryData; - /** - * @private - */ - var DisplayData = /** @class */ (function (_super) { - __extends(DisplayData, _super); - function DisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.transform = new dragonBones.Transform(); - return _this; - } - DisplayData.prototype._onClear = function () { - this.name = ""; - this.path = ""; - this.transform.identity(); - this.parent = null; // - }; - return DisplayData; - }(dragonBones.BaseObject)); - dragonBones.DisplayData = DisplayData; - /** - * @private - */ - var ImageDisplayData = /** @class */ (function (_super) { - __extends(ImageDisplayData, _super); - function ImageDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.pivot = new dragonBones.Point(); - return _this; - } - ImageDisplayData.toString = function () { - return "[class dragonBones.ImageDisplayData]"; - }; - ImageDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Image */; - this.pivot.clear(); - this.texture = null; - }; - return ImageDisplayData; - }(DisplayData)); - dragonBones.ImageDisplayData = ImageDisplayData; - /** - * @private - */ - var ArmatureDisplayData = /** @class */ (function (_super) { - __extends(ArmatureDisplayData, _super); - function ArmatureDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.actions = []; - return _this; - } - ArmatureDisplayData.toString = function () { - return "[class dragonBones.ArmatureDisplayData]"; - }; - ArmatureDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - this.type = 1 /* Armature */; - this.inheritAnimation = false; - this.actions.length = 0; - this.armature = null; - }; - /** - * @private - */ - ArmatureDisplayData.prototype.addAction = function (value) { - this.actions.push(value); - }; - return ArmatureDisplayData; - }(DisplayData)); - dragonBones.ArmatureDisplayData = ArmatureDisplayData; - /** - * @private - */ - var MeshDisplayData = /** @class */ (function (_super) { - __extends(MeshDisplayData, _super); - function MeshDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new GeometryData(); - return _this; - } - MeshDisplayData.toString = function () { - return "[class dragonBones.MeshDisplayData]"; - }; - MeshDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Mesh */; - this.geometry.clear(); - this.texture = null; - }; - return MeshDisplayData; - }(DisplayData)); - dragonBones.MeshDisplayData = MeshDisplayData; - /** - * @private - */ - var BoundingBoxDisplayData = /** @class */ (function (_super) { - __extends(BoundingBoxDisplayData, _super); - function BoundingBoxDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.boundingBox = null; // Initial value. - return _this; - } - BoundingBoxDisplayData.toString = function () { - return "[class dragonBones.BoundingBoxDisplayData]"; - }; - BoundingBoxDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.boundingBox !== null) { - this.boundingBox.returnToPool(); - } - this.type = 3 /* BoundingBox */; - this.boundingBox = null; - }; - return BoundingBoxDisplayData; - }(DisplayData)); - dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; - /** - * @private - */ - var PathDisplayData = /** @class */ (function (_super) { - __extends(PathDisplayData, _super); - function PathDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new GeometryData(); - _this.curveLengths = []; - return _this; - } - PathDisplayData.toString = function () { - return "[class dragonBones.PathDisplayData]"; - }; - PathDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 4 /* Path */; - this.closed = false; - this.constantSpeed = false; - this.geometry.clear(); - this.curveLengths.length = 0; - }; - return PathDisplayData; - }(DisplayData)); - dragonBones.PathDisplayData = PathDisplayData; - /** - * @private - */ - var WeightData = /** @class */ (function (_super) { - __extends(WeightData, _super); - function WeightData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - WeightData.toString = function () { - return "[class dragonBones.WeightData]"; - }; - WeightData.prototype._onClear = function () { - this.count = 0; - this.offset = 0; - this.bones.length = 0; - }; - WeightData.prototype.addBone = function (value) { - this.bones.push(value); - }; - return WeightData; - }(dragonBones.BaseObject)); - dragonBones.WeightData = WeightData; -})(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 base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - var BoundingBoxData = /** @class */ (function (_super) { - __extends(BoundingBoxData, _super); - function BoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoundingBoxData.prototype._onClear = function () { - this.color = 0x000000; - this.width = 0.0; - this.height = 0.0; - }; - return BoundingBoxData; - }(dragonBones.BaseObject)); - dragonBones.BoundingBoxData = BoundingBoxData; - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var RectangleBoundingBoxData = /** @class */ (function (_super) { - __extends(RectangleBoundingBoxData, _super); - function RectangleBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - RectangleBoundingBoxData.toString = function () { - return "[class dragonBones.RectangleBoundingBoxData]"; - }; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { - var code = 0 /* InSide */; // initialised as being inside of [[clip window]] - if (x < xMin) { // to the left of clip window - code |= 1 /* Left */; - } - else if (x > xMax) { // to the right of clip window - code |= 2 /* Right */; - } - if (y < yMin) { // below the clip window - code |= 4 /* Top */; - } - else if (y > yMax) { // above the clip window - code |= 8 /* Bottom */; - } - return code; - }; - /** - * @private - */ - RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; - var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; - if (inSideA && inSideB) { - return -1; - } - var intersectionCount = 0; - var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - while (true) { - if ((outcode0 | outcode1) === 0) { // Bitwise OR is 0. Trivially accept and get out of loop - intersectionCount = 2; - break; - } - else if ((outcode0 & outcode1) !== 0) { // Bitwise AND is not 0. Trivially reject and get out of loop - break; - } - // failed both tests, so calculate the line segment to clip - // from an outside point to an intersection with clip edge - var x = 0.0; - var y = 0.0; - var normalRadian = 0.0; - // At least one endpoint is outside the clip rectangle; pick it. - var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; - // Now find the intersection point; - if ((outcodeOut & 4 /* Top */) !== 0) { // point is above the clip rectangle - x = xA + (xB - xA) * (yMin - yA) / (yB - yA); - y = yMin; - if (normalRadians !== null) { - normalRadian = -Math.PI * 0.5; - } - } - else if ((outcodeOut & 8 /* Bottom */) !== 0) { // point is below the clip rectangle - x = xA + (xB - xA) * (yMax - yA) / (yB - yA); - y = yMax; - if (normalRadians !== null) { - normalRadian = Math.PI * 0.5; - } - } - else if ((outcodeOut & 2 /* Right */) !== 0) { // point is to the right of clip rectangle - y = yA + (yB - yA) * (xMax - xA) / (xB - xA); - x = xMax; - if (normalRadians !== null) { - normalRadian = 0; - } - } - else if ((outcodeOut & 1 /* Left */) !== 0) { // point is to the left of clip rectangle - y = yA + (yB - yA) * (xMin - xA) / (xB - xA); - x = xMin; - if (normalRadians !== null) { - normalRadian = Math.PI; - } - } - // Now we move outside point to intersection point to clip - // and get ready for next pass. - if (outcodeOut === outcode0) { - xA = x; - yA = y; - outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.x = normalRadian; - } - } - else { - xB = x; - yB = y; - outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.y = normalRadian; - } - } - } - if (intersectionCount) { - if (inSideA) { - intersectionCount = 2; // 10 - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = xB; - } - if (normalRadians !== null) { - normalRadians.x = normalRadians.y + Math.PI; - } - } - else if (inSideB) { - intersectionCount = 1; // 01 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - } - } - return intersectionCount; - }; - RectangleBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Rectangle */; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - return true; - } - } - return false; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var widthH = this.width * 0.5; - var heightH = this.height * 0.5; - var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return RectangleBoundingBoxData; - }(BoundingBoxData)); - dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var EllipseBoundingBoxData = /** @class */ (function (_super) { - __extends(EllipseBoundingBoxData, _super); - function EllipseBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - EllipseBoundingBoxData.toString = function () { - return "[class dragonBones.EllipseData]"; - }; - /** - * @private - */ - EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var d = widthH / heightH; - var dd = d * d; - yA *= d; - yB *= d; - var dX = xB - xA; - var dY = yB - yA; - var lAB = Math.sqrt(dX * dX + dY * dY); - var xD = dX / lAB; - var yD = dY / lAB; - var a = (xC - xA) * xD + (yC - yA) * yD; - var aa = a * a; - var ee = xA * xA + yA * yA; - var rr = widthH * widthH; - var dR = rr - ee + aa; - var intersectionCount = 0; - if (dR >= 0.0) { - var dT = Math.sqrt(dR); - var sA = a - dT; - var sB = a + dT; - var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); - var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); - var sideAB = inSideA * inSideB; - if (sideAB < 0) { - return -1; - } - else if (sideAB === 0) { - if (inSideA === -1) { - intersectionCount = 2; // 10 - xB = xA + sB * xD; - yB = (yA + sB * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (inSideB === 1) { - intersectionCount = 1; // 01 - xA = xA + sA * xD; - yA = (yA + sA * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA + sA * xD; - intersectionPointA.y = (yA + sA * yD) / d; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); - } - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA + sB * xD; - intersectionPointB.y = (yA + sB * yD) / d; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); - } - } - } - } - } - return intersectionCount; - }; - EllipseBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Ellipse */; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - pY *= widthH / heightH; - return Math.sqrt(pX * pX + pY * pY) <= widthH; - } - } - return false; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return EllipseBoundingBoxData; - }(BoundingBoxData)); - dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var PolygonBoundingBoxData = /** @class */ (function (_super) { - __extends(PolygonBoundingBoxData, _super); - function PolygonBoundingBoxData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - _this.vertices = []; - return _this; - } - PolygonBoundingBoxData.toString = function () { - return "[class dragonBones.PolygonBoundingBoxData]"; - }; - /** - * @private - */ - PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (xA === xB) { - xA = xB + 0.000001; - } - if (yA === yB) { - yA = yB + 0.000001; - } - var count = vertices.length; - var dXAB = xA - xB; - var dYAB = yA - yB; - var llAB = xA * yB - yA * xB; - var intersectionCount = 0; - var xC = vertices[count - 2]; - var yC = vertices[count - 1]; - var dMin = 0.0; - var dMax = 0.0; - var xMin = 0.0; - var yMin = 0.0; - var xMax = 0.0; - var yMax = 0.0; - for (var i = 0; i < count; i += 2) { - var xD = vertices[i]; - var yD = vertices[i + 1]; - if (xC === xD) { - xC = xD + 0.0001; - } - if (yC === yD) { - yC = yD + 0.0001; - } - var dXCD = xC - xD; - var dYCD = yC - yD; - var llCD = xC * yD - yC * xD; - var ll = dXAB * dYCD - dYAB * dXCD; - var x = (llAB * dXCD - dXAB * llCD) / ll; - if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { - var y = (llAB * dYCD - dYAB * llCD) / ll; - if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { - if (intersectionPointB !== null) { - var d = x - xA; - if (d < 0.0) { - d = -d; - } - if (intersectionCount === 0) { - dMin = d; - dMax = d; - xMin = x; - yMin = y; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - } - else { - if (d < dMin) { - dMin = d; - xMin = x; - yMin = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - if (d > dMax) { - dMax = d; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - } - intersectionCount++; - } - else { - xMin = x; - yMin = y; - xMax = x; - yMax = y; - intersectionCount++; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - break; - } - } - } - xC = xD; - yC = yD; - } - if (intersectionCount === 1) { - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMin; - intersectionPointB.y = yMin; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (intersectionCount > 1) { - intersectionCount++; - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMax; - intersectionPointB.y = yMax; - } - } - return intersectionCount; - }; - PolygonBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Polygon */; - this.x = 0.0; - this.y = 0.0; - this.vertices.length = 0; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var isInSide = false; - if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { - for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { - var yA = this.vertices[iP + 1]; - var yB = this.vertices[i + 1]; - if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { - var xA = this.vertices[iP]; - var xB = this.vertices[i]; - if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { - isInSide = !isInSide; - } - } - iP = i; - } - } - return isInSide; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = 0; - if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { - intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); - } - return intersectionCount; - }; - return PolygonBoundingBoxData; - }(BoundingBoxData)); - dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; -})(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 animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationData = /** @class */ (function (_super) { - __extends(AnimationData, _super); - function AnimationData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.cachedFrames = []; - /** - * @private - */ - _this.boneTimelines = {}; - /** - * @private - */ - _this.slotTimelines = {}; - /** - * @private - */ - _this.constraintTimelines = {}; - /** - * @private - */ - _this.animationTimelines = {}; - /** - * @private - */ - _this.boneCachedFrameIndices = {}; - /** - * @private - */ - _this.slotCachedFrameIndices = {}; - /** - * @private - */ - _this.actionTimeline = null; // Initial value. - /** - * @private - */ - _this.zOrderTimeline = null; // Initial value. - return _this; - } - AnimationData.toString = function () { - return "[class dragonBones.AnimationData]"; - }; - AnimationData.prototype._onClear = function () { - for (var k in this.boneTimelines) { - for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - delete this.boneTimelines[k]; - } - for (var k in this.slotTimelines) { - for (var _b = 0, _c = this.slotTimelines[k]; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - delete this.slotTimelines[k]; - } - for (var k in this.constraintTimelines) { - for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - delete this.constraintTimelines[k]; - } - for (var k in this.animationTimelines) { - for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - delete this.animationTimelines[k]; - } - for (var k in this.boneCachedFrameIndices) { - delete this.boneCachedFrameIndices[k]; - } - for (var k in this.slotCachedFrameIndices) { - delete this.slotCachedFrameIndices[k]; - } - if (this.actionTimeline !== null) { - this.actionTimeline.returnToPool(); - } - if (this.zOrderTimeline !== null) { - this.zOrderTimeline.returnToPool(); - } - this.frameIntOffset = 0; - this.frameFloatOffset = 0; - this.frameOffset = 0; - this.blendType = 0 /* None */; - this.frameCount = 0; - this.playTimes = 0; - this.duration = 0.0; - this.scale = 1.0; - this.fadeInTime = 0.0; - this.cacheFrameRate = 0.0; - this.name = ""; - this.cachedFrames.length = 0; - // this.boneTimelines.clear(); - // this.slotTimelines.clear(); - // this.constraintTimelines.clear(); - // this.animationTimelines.clear(); - // this.boneCachedFrameIndices.clear(); - // this.slotCachedFrameIndices.clear(); - this.actionTimeline = null; - this.zOrderTimeline = null; - this.parent = null; // - }; - /** - * @internal - */ - AnimationData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0.0) { // TODO clear cache. - return; - } - this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); - var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. - this.cachedFrames.length = cacheFrameCount; - for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { - this.cachedFrames[i] = false; - } - for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { - var bone = _a[_i]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.boneCachedFrameIndices[bone.name] = indices; - } - for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { - var slot = _c[_b]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.slotCachedFrameIndices[slot.name] = indices; - } - }; - /** - * @private - */ - AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : (this.constraintTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.getBoneTimelines = function (timelineName) { - return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotTimelines = function (timelineName) { - return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getConstraintTimelines = function (timelineName) { - return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getAnimationTimelines = function (timelineName) { - return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { - return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { - return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; - }; - return AnimationData; - }(dragonBones.BaseObject)); - dragonBones.AnimationData = AnimationData; - /** - * @private - */ - var TimelineData = /** @class */ (function (_super) { - __extends(TimelineData, _super); - function TimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineData.toString = function () { - return "[class dragonBones.TimelineData]"; - }; - TimelineData.prototype._onClear = function () { - this.type = 10 /* BoneAll */; - this.offset = 0; - this.frameIndicesOffset = -1; - }; - return TimelineData; - }(dragonBones.BaseObject)); - dragonBones.TimelineData = TimelineData; - /** - * @internal - */ - var AnimationTimelineData = /** @class */ (function (_super) { - __extends(AnimationTimelineData, _super); - function AnimationTimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationTimelineData.toString = function () { - return "[class dragonBones.AnimationTimelineData]"; - }; - AnimationTimelineData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.x = 0.0; - this.y = 0.0; - }; - return AnimationTimelineData; - }(TimelineData)); - dragonBones.AnimationTimelineData = AnimationTimelineData; -})(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 animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - var AnimationConfig = /** @class */ (function (_super) { - __extends(AnimationConfig, _super); - function AnimationConfig() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.boneMask = []; - return _this; - } - AnimationConfig.toString = function () { - return "[class dragonBones.AnimationConfig]"; - }; - AnimationConfig.prototype._onClear = function () { - this.pauseFadeOut = true; - this.fadeOutMode = 4 /* All */; - this.fadeOutTweenType = 1 /* Line */; - this.fadeOutTime = -1.0; - this.actionEnabled = true; - this.additive = false; - this.displayControl = true; - this.pauseFadeIn = true; - this.resetToPose = true; - this.fadeInTweenType = 1 /* Line */; - this.playTimes = -1; - this.layer = 0; - this.position = 0.0; - this.duration = -1.0; - this.timeScale = -100.0; - this.weight = 1.0; - this.fadeInTime = -1.0; - this.autoFadeOutTime = -1.0; - this.name = ""; - this.animation = ""; - this.group = ""; - this.boneMask.length = 0; - }; - /** - * @private - */ - AnimationConfig.prototype.clear = function () { - this._onClear(); - }; - /** - * @private - */ - AnimationConfig.prototype.copyFrom = function (value) { - this.pauseFadeOut = value.pauseFadeOut; - this.fadeOutMode = value.fadeOutMode; - this.autoFadeOutTime = value.autoFadeOutTime; - this.fadeOutTweenType = value.fadeOutTweenType; - this.actionEnabled = value.actionEnabled; - this.additive = value.additive; - this.displayControl = value.displayControl; - this.pauseFadeIn = value.pauseFadeIn; - this.resetToPose = value.resetToPose; - this.playTimes = value.playTimes; - this.layer = value.layer; - this.position = value.position; - this.duration = value.duration; - this.timeScale = value.timeScale; - this.fadeInTime = value.fadeInTime; - this.fadeOutTime = value.fadeOutTime; - this.fadeInTweenType = value.fadeInTweenType; - this.weight = value.weight; - this.name = value.name; - this.animation = value.animation; - this.group = value.group; - this.boneMask.length = value.boneMask.length; - for (var i = 0, l = this.boneMask.length; i < l; ++i) { - this.boneMask[i] = value.boneMask[i]; - } - }; - return AnimationConfig; - }(dragonBones.BaseObject)); - dragonBones.AnimationConfig = AnimationConfig; -})(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 texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var TextureAtlasData = /** @class */ (function (_super) { - __extends(TextureAtlasData, _super); - function TextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.textures = {}; - return _this; - } - TextureAtlasData.prototype._onClear = function () { - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - this.autoSearch = false; - this.width = 0; - this.height = 0; - this.scale = 1.0; - // this.textures.clear(); - this.name = ""; - this.imagePath = ""; - }; - /** - * @private - */ - TextureAtlasData.prototype.copyFrom = function (value) { - this.autoSearch = value.autoSearch; - this.scale = value.scale; - this.width = value.width; - this.height = value.height; - this.name = value.name; - this.imagePath = value.imagePath; - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - // this.textures.clear(); - for (var k in value.textures) { - var texture = this.createTexture(); - texture.copyFrom(value.textures[k]); - this.textures[k] = texture; - } - }; - /** - * @internal - */ - TextureAtlasData.prototype.addTexture = function (value) { - if (value.name in this.textures) { - console.warn("Same texture: " + value.name); - return; - } - value.parent = this; - this.textures[value.name] = value; - }; - /** - * @private - */ - TextureAtlasData.prototype.getTexture = function (textureName) { - return textureName in this.textures ? this.textures[textureName] : null; - }; - return TextureAtlasData; - }(dragonBones.BaseObject)); - dragonBones.TextureAtlasData = TextureAtlasData; - /** - * @private - */ - var TextureData = /** @class */ (function (_super) { - __extends(TextureData, _super); - function TextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.region = new dragonBones.Rectangle(); - _this.frame = null; // Initial value. - return _this; - } - TextureData.createRectangle = function () { - return new dragonBones.Rectangle(); - }; - TextureData.prototype._onClear = function () { - this.rotated = false; - this.name = ""; - this.region.clear(); - this.parent = null; // - this.frame = null; - }; - TextureData.prototype.copyFrom = function (value) { - this.rotated = value.rotated; - this.name = value.name; - this.region.copyFrom(value.region); - this.parent = value.parent; - if (this.frame === null && value.frame !== null) { - this.frame = TextureData.createRectangle(); - } - else if (this.frame !== null && value.frame === null) { - this.frame = null; - } - if (this.frame !== null && value.frame !== null) { - this.frame.copyFrom(value.frame); - } - }; - return TextureData; - }(dragonBones.BaseObject)); - dragonBones.TextureData = TextureData; -})(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_1) { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - var Armature = /** @class */ (function (_super) { - __extends(Armature, _super); - function Armature() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._slots = []; - /** - * @internal - */ - _this._constraints = []; - _this._actions = []; - _this._animation = null; // Initial value. - _this._proxy = null; // Initial value. - /** - * @internal - */ - _this._replaceTextureAtlasData = null; // Initial value. - _this._clock = null; // Initial value. - return _this; - } - Armature.toString = function () { - return "[class dragonBones.Armature]"; - }; - Armature._onSortSlots = function (a, b) { - return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; - }; - Armature.prototype._onClear = function () { - if (this._clock !== null) { // Remove clock first. - this._clock.remove(this); - } - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone.returnToPool(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot.returnToPool(); - } - for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { - var constraint = _e[_d]; - constraint.returnToPool(); - } - for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { - var action = _g[_f]; - action.returnToPool(); - } - if (this._animation !== null) { - this._animation.returnToPool(); - } - if (this._proxy !== null) { - this._proxy.dbClear(); - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - } - this.inheritAnimation = true; - this.userData = null; - this._lockUpdate = false; - this._slotsDirty = true; - this._zOrderDirty = false; - this._zIndexDirty = false; - this._alphaDirty = true; - this._flipX = false; - this._flipY = false; - this._cacheFrameIndex = -1; - this._alpha = 1.0; - this._globalAlpha = 1.0; - this._bones.length = 0; - this._slots.length = 0; - this._constraints.length = 0; - this._actions.length = 0; - this._armatureData = null; // - this._animation = null; // - this._proxy = null; // - this._display = null; - this._replaceTextureAtlasData = null; - this._replacedTexture = null; - this._dragonBones = null; // - this._clock = null; - this._parent = null; - }; - /** - * @internal - */ - Armature.prototype._sortZOrder = function (slotIndices, offset) { - var slotDatas = this._armatureData.sortedSlots; - var isOriginal = slotIndices === null; - if (this._zOrderDirty || !isOriginal) { - for (var i = 0, l = slotDatas.length; i < l; ++i) { - var slotIndex = isOriginal ? i : slotIndices[offset + i]; - if (slotIndex < 0 || slotIndex >= l) { - continue; - } - var slotData = slotDatas[slotIndex]; - var slot = this.getSlot(slotData.name); - if (slot !== null) { - slot._setZOrder(i); - } - } - this._slotsDirty = true; - this._zOrderDirty = !isOriginal; - } - }; - /** - * @internal - */ - Armature.prototype._addBone = function (value) { - if (this._bones.indexOf(value) < 0) { - this._bones.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addSlot = function (value) { - if (this._slots.indexOf(value) < 0) { - this._slots.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addConstraint = function (value) { - if (this._constraints.indexOf(value) < 0) { - this._constraints.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._bufferAction = function (action, append) { - if (this._actions.indexOf(action) < 0) { - if (append) { - this._actions.push(action); - } - else { - this._actions.unshift(action); - } - } - }; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.dispose = function () { - if (this._armatureData !== null) { - this._lockUpdate = true; - this._dragonBones.bufferObject(this); - } - }; - /** - * @internal - */ - Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { - if (this._armatureData !== null) { - return; - } - this._armatureData = armatureData; - this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); - this._proxy = proxy; - this._display = display; - this._dragonBones = dragonBones; - this._proxy.dbInit(this); - this._animation.init(this); - this._animation.animations = this._armatureData.animations; - }; - /** - * @inheritDoc - */ - Armature.prototype.advanceTime = function (passedTime) { - if (this._lockUpdate) { - return; - } - this._lockUpdate = true; - if (this._armatureData === null) { - console.warn("The armature has been disposed."); - return; - } - else if (this._armatureData.parent === null) { - console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); - return; - } - var prevCacheFrameIndex = this._cacheFrameIndex; - // Update animation. - this._animation.advanceTime(passedTime); - // Sort slots. - if (this._slotsDirty || this._zIndexDirty) { - this._slots.sort(Armature._onSortSlots); - if (this._zIndexDirty) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i]._setZOrder(i); // - } - } - this._slotsDirty = false; - this._zIndexDirty = false; - } - // Update alpha. - if (this._alphaDirty) { - this._alphaDirty = false; - this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone._updateAlpha(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot._updateAlpha(); - } - } - // Update bones and slots. - if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { - var i = 0, l = 0; - for (i = 0, l = this._bones.length; i < l; ++i) { - this._bones[i].update(this._cacheFrameIndex); - } - for (i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].update(this._cacheFrameIndex); - } - } - // Do actions. - if (this._actions.length > 0) { - for (var _d = 0, _e = this._actions; _d < _e.length; _d++) { - var action = _e[_d]; - var actionData = action.actionData; - if (actionData !== null) { - if (actionData.type === 0 /* Play */) { - if (action.slot !== null) { - var childArmature = action.slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - else if (action.bone !== null) { - for (var _f = 0, _g = this.getSlots(); _f < _g.length; _f++) { - var slot = _g[_f]; - if (slot.parent === action.bone) { - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - } - } - else { - this._animation.fadeIn(actionData.name); - } - } - } - action.returnToPool(); - } - this._actions.length = 0; - } - this._lockUpdate = false; - this._proxy.dbUpdate(); - }; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.invalidUpdate = function (boneName, updateSlot) { - if (boneName === void 0) { boneName = null; } - if (updateSlot === void 0) { updateSlot = false; } - if (boneName !== null && boneName.length > 0) { - var bone = this.getBone(boneName); - if (bone !== null) { - bone.invalidUpdate(); - if (updateSlot) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === bone) { - slot.invalidUpdate(); - } - } - } - } - } - else { - for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { - var bone = _c[_b]; - bone.invalidUpdate(); - } - if (updateSlot) { - for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { - var slot = _e[_d]; - slot.invalidUpdate(); - } - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.containsPoint = function (x, y) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.containsPoint(x, y)) { - return slot; - } - } - return null; - }; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var isV = xA === xB; - var dMin = 0.0; - var dMax = 0.0; - var intXA = 0.0; - var intYA = 0.0; - var intXB = 0.0; - var intYB = 0.0; - var intAN = 0.0; - var intBN = 0.0; - var intSlotA = null; - var intSlotB = null; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionPointA !== null || intersectionPointB !== null) { - if (intersectionPointA !== null) { - var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotA === null || d < dMin) { - dMin = d; - intXA = intersectionPointA.x; - intYA = intersectionPointA.y; - intSlotA = slot; - if (normalRadians) { - intAN = normalRadians.x; - } - } - } - if (intersectionPointB !== null) { - var d = intersectionPointB.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotB === null || d > dMax) { - dMax = d; - intXB = intersectionPointB.x; - intYB = intersectionPointB.y; - intSlotB = slot; - if (normalRadians !== null) { - intBN = normalRadians.y; - } - } - } - } - else { - intSlotA = slot; - break; - } - } - } - if (intSlotA !== null && intersectionPointA !== null) { - intersectionPointA.x = intXA; - intersectionPointA.y = intYA; - if (normalRadians !== null) { - normalRadians.x = intAN; - } - } - if (intSlotB !== null && intersectionPointB !== null) { - intersectionPointB.x = intXB; - intersectionPointB.y = intYB; - if (normalRadians !== null) { - normalRadians.y = intBN; - } - } - return intSlotA; - }; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBone = function (name) { - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.name === name) { - return bone; - } - } - return null; - }; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBoneByDisplay = function (display) { - var slot = this.getSlotByDisplay(display); - return slot !== null ? slot.parent : null; - }; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlot = function (name) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.name === name) { - return slot; - } - } - return null; - }; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlotByDisplay = function (display) { - if (display !== null) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.display === display) { - return slot; - } - } - } - return null; - }; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBones = function () { - return this._bones; - }; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlots = function () { - return this._slots; - }; - Object.defineProperty(Armature.prototype, "flipX", { - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipX; - }, - set: function (value) { - if (this._flipX === value) { - return; - } - this._flipX = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "flipY", { - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipY; - }, - set: function (value) { - if (this._flipY === value) { - return; - } - this._flipY = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "cacheFrameRate", { - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData.cacheFrameRate; - }, - set: function (value) { - if (this._armatureData.cacheFrameRate !== value) { - this._armatureData.cacheFrames(value); - // Set child armature frameRate. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.cacheFrameRate = value; - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "name", { - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armatureData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "armatureData", { - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "animation", { - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "proxy", { - /** - * @pivate - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "eventDispatcher", { - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "display", { - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "replacedTexture", { - /** - * @private - */ - get: function () { - return this._replacedTexture; - }, - set: function (value) { - if (this._replacedTexture === value) { - return; - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - this._replaceTextureAtlasData = null; - } - this._replacedTexture = value; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - slot.invalidUpdate(); - slot.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - // Update childArmature clock. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.clock = this._clock; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "parent", { - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.getDisplay = function () { - return this._display; - }; - return Armature; - }(dragonBones_1.BaseObject)); - dragonBones_1.Armature = Armature; -})(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 base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - var TransformObject = /** @class */ (function (_super) { - __extends(TransformObject, _super); - function TransformObject() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.globalTransformMatrix = new dragonBones.Matrix(); - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.global = new dragonBones.Transform(); - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.offset = new dragonBones.Transform(); - return _this; - } - /** - */ - TransformObject.prototype._onClear = function () { - this.globalTransformMatrix.identity(); - this.global.identity(); - this.offset.identity(); - this.origin = null; - this.userData = null; - this._globalDirty = false; - this._alpha = 1.0; - this._globalAlpha = 1.0; - this._armature = null; // - }; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - TransformObject.prototype.updateGlobalTransform = function () { - if (this._globalDirty) { - this._globalDirty = false; - this.global.fromMatrix(this.globalTransformMatrix); - } - }; - Object.defineProperty(TransformObject.prototype, "armature", { - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - TransformObject._helpMatrix = new dragonBones.Matrix(); - TransformObject._helpTransform = new dragonBones.Transform(); - TransformObject._helpPoint = new dragonBones.Point(); - return TransformObject; - }(dragonBones.BaseObject)); - dragonBones.TransformObject = TransformObject; -})(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) { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - var Bone = /** @class */ (function (_super) { - __extends(Bone, _super); - function Bone() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.animationPose = new dragonBones.Transform(); - return _this; - } - Bone.toString = function () { - return "[class dragonBones.Bone]"; - }; - Bone.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.offsetMode = 1 /* Additive */; - this.animationPose.identity(); - this._transformDirty = false; - this._childrenTransformDirty = false; - this._localDirty = true; - this._hasConstraint = false; - this._visible = true; - this._cachedFrameIndex = -1; - this._boneData = null; // - this._parent = null; // - this._cachedFrameIndices = null; - }; - Bone.prototype._updateGlobalTransformMatrix = function (isCache) { - // For typescript. - var boneData = this._boneData; - var global = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - var origin = this.origin; - var offset = this.offset; - var animationPose = this.animationPose; - var parent = this._parent; // - var flipX = this._armature.flipX; - var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; - var inherit = parent !== null; - var rotation = 0.0; - if (this.offsetMode === 1 /* Additive */) { - if (origin !== null) { - // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); - global.x = origin.x + offset.x + animationPose.x; - global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; - global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; - if (dragonBones.DragonBones.yDown) { - global.y = origin.y + offset.y + animationPose.y; - global.skew = origin.skew + offset.skew + animationPose.skew; - global.rotation = origin.rotation + offset.rotation + animationPose.rotation; - } - else { - global.y = origin.y - offset.y + animationPose.y; - global.skew = origin.skew - offset.skew + animationPose.skew; - global.rotation = origin.rotation - offset.rotation + animationPose.rotation; - } - } - else { - global.copyFrom(offset); - if (!dragonBones.DragonBones.yDown) { - global.y = -global.y; - global.skew = -global.skew; - global.rotation = -global.rotation; - } - global.add(animationPose); - } - } - else if (this.offsetMode === 0 /* None */) { - if (origin !== null) { - global.copyFrom(origin).add(animationPose); - } - else { - global.copyFrom(animationPose); - } - } - else { - inherit = false; - global.copyFrom(offset); - if (!dragonBones.DragonBones.yDown) { - global.y = -global.y; - global.skew = -global.skew; - global.rotation = -global.rotation; - } - } - if (inherit) { - var isSurface = parent._boneData.type === 1 /* Surface */; - var surfaceBone = isSurface ? parent._bone : null; - var parentMatrix = isSurface ? parent._getGlobalTransformMatrix(global.x, global.y) : parent.globalTransformMatrix; - if (boneData.inheritScale && (!isSurface || surfaceBone !== null)) { - if (isSurface) { - if (boneData.inheritRotation) { - global.rotation += parent.global.rotation; - } - surfaceBone.updateGlobalTransform(); - global.scaleX *= surfaceBone.global.scaleX; - global.scaleY *= surfaceBone.global.scaleY; - parentMatrix.transformPoint(global.x, global.y, global); - global.toMatrix(globalTransformMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - } - else { - if (!boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (flipX && flipY) { - rotation = global.rotation - (parent.global.rotation + Math.PI); - } - else if (flipX) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else if (flipY) { - rotation = global.rotation + parent.global.rotation; - } - else { - rotation = global.rotation - parent.global.rotation; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - globalTransformMatrix.concat(parentMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - if (isCache) { - global.fromMatrix(globalTransformMatrix); - } - else { - this._globalDirty = true; - } - } - } - else { - if (boneData.inheritTranslation) { - var x = global.x; - var y = global.y; - global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - else { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - } - if (boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (parent.global.scaleX < 0.0) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else { - rotation = global.rotation + parent.global.rotation; - } - if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { - rotation -= global.rotation * 2.0; - if (flipX !== flipY || boneData.inheritReflection) { - global.skew += Math.PI; - } - if (!dragonBones.DragonBones.yDown) { - global.skew = -global.skew; - } - } - global.rotation = rotation; - } - else if (flipX || flipY) { - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - } - else { - if (flipX || flipY) { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - }; - /** - * @internal - */ - Bone.prototype._updateAlpha = function () { - if (this._parent !== null) { - this._globalAlpha = this._alpha * this._parent._globalAlpha; - } - else { - this._globalAlpha = this._alpha * this._armature._globalAlpha; - } - }; - /** - * @internal - */ - Bone.prototype.init = function (boneData, armatureValue) { - if (this._boneData !== null) { - return; - } - this._boneData = boneData; - this._armature = armatureValue; - this._alpha = this._boneData.alpha; - if (this._boneData.parent !== null) { - this._parent = this._armature.getBone(this._boneData.parent.name); - } - this._armature._addBone(this); - // - this.origin = this._boneData.transform; - }; - /** - * @internal - */ - Bone.prototype.update = function (cacheFrameIndex) { - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { // Has been Cached. - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - /** - * @internal - */ - Bone.prototype.updateByConstraint = function () { - if (this._localDirty) { - this._localDirty = false; - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - this._updateGlobalTransformMatrix(true); - } - this._transformDirty = true; - } - }; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.invalidUpdate = function () { - this._transformDirty = true; - }; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.parent; - } - return ancestor === this; - }; - Object.defineProperty(Bone.prototype, "boneData", { - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._boneData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "visible", { - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slot._updateVisible(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "name", { - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._boneData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - return Bone; - }(dragonBones.TransformObject)); - dragonBones.Bone = Bone; -})(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) { - /** - * @internal - */ - var Surface = /** @class */ (function (_super) { - __extends(Surface, _super); - function Surface() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._vertices = []; - _this._deformVertices = []; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - _this._hullCache = []; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - _this._matrixCahce = []; - return _this; - } - Surface.toString = function () { - return "[class dragonBones.Surface]"; - }; - Surface.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dX = 0.0; - this._dY = 0.0; - this._k = 0.0; - this._kX = 0.0; - this._kY = 0.0; - this._vertices.length = 0; - this._deformVertices.length = 0; - this._matrixCahce.length = 0; - this._hullCache.length = 0; - this._bone = null; - }; - Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { - var dabX = bX - aX; - var dabY = bY - aY; - var dacX = cX - aX; - var dacY = cY - aY; - transform.rotation = Math.atan2(dabY, dabX); - transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; - if (isDown) { - transform.rotation += Math.PI; - } - transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; - transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; - transform.toMatrix(matrix); - transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); - transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); - }; - Surface.prototype._updateVertices = function () { - var data = this._armature.armatureData.parent; - var geometry = this._boneData.geometry; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; - var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; - var vertices = this._vertices; - var animationVertices = this._deformVertices; - if (this._parent !== null) { - if (this._parent._boneData.type === 1 /* Surface */) { - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - var matrix = this._parent._getGlobalTransformMatrix(x, y); - // - vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; - vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - } - else { - var parentMatrix = this._parent.globalTransformMatrix; - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - // - vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - } - } - else { - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; - vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - } - } - }; - Surface.prototype._updateGlobalTransformMatrix = function (isCache) { - // tslint:disable-next-line:no-unused-expression - isCache; - var segmentXD = this._boneData.segmentX * 2; - var lastIndex = this._vertices.length - 2; - var lA = 200.0; - // - var raX = this._vertices[0]; - var raY = this._vertices[1]; - var rbX = this._vertices[segmentXD]; - var rbY = this._vertices[segmentXD + 1]; - var rcX = this._vertices[lastIndex]; - var rcY = this._vertices[lastIndex + 1]; - var rdX = this._vertices[lastIndex - segmentXD]; - var rdY = this._vertices[lastIndex - segmentXD + 1]; - // - var dacX = raX + (rcX - raX) * 0.5; - var dacY = raY + (rcY - raY) * 0.5; - var dbdX = rbX + (rdX - rbX) * 0.5; - var dbdY = rbY + (rdY - rbY) * 0.5; - var aX = dacX + (dbdX - dacX) * 0.5; - var aY = dacY + (dbdY - dacY) * 0.5; - var bX = rbX + (rcX - rbX) * 0.5; - var bY = rbY + (rcY - rbY) * 0.5; - var cX = rdX + (rcX - rdX) * 0.5; - var cY = rdY + (rcY - rdY) * 0.5; - // TODO interpolation - this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); - this._globalDirty = false; - }; - Surface.prototype._getGlobalTransformMatrix = function (x, y) { - var lA = 200.0; - var lB = 1000.0; - if (x < -lB || lB < x || y < -lB || lB < y) { - return this.globalTransformMatrix; - } - var isDown = false; - var surfaceData = this._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var segmentXD = surfaceData.segmentX * 2; - var dX = this._dX; - var dY = this._dY; - var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 - var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 - var matrixIndex = 0; - var pX = indexX * dX - lA; - var pY = indexY * dY - lA; - // - var matrices = this._matrixCahce; - var helpMatrix = Surface._helpMatrix; - if (x < -lA) { - if (y < -lA || y >= lA) { // Out. - return this.globalTransformMatrix; - } - // Left. - isDown = y > this._kX * (x + lA) + pY; - matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexY * (segmentXD + 2); - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[2] - (segmentY - indexY) * ddX; - var sY = this._hullCache[3] - (segmentY - indexY) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (x >= lA) { - if (y < -lA || y >= lA) { // Out. - return this.globalTransformMatrix; - } - // Right. - isDown = y > this._kX * (x - lB) + pY; - matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[0] + indexY * ddX; - var sY = this._hullCache[1] + indexY * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y < -lA) { - if (x < -lA || x >= lA) { // Out. - return this.globalTransformMatrix; - } - // Up. - isDown = y > this._kY * (x - pX - dX) - lB; - matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[8] + indexX * ddX; - var sY = this._hullCache[9] + indexX * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y >= lA) { - if (x < -lA || x >= lA) { // Out. - return this.globalTransformMatrix; - } - // Down - isDown = y > this._kY * (x - pX - dX) + lA; - matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[6] - (segmentX - indexX) * ddX; - var sY = this._hullCache[7] - (segmentX - indexX) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else { // Center. - isDown = y > this._k * (x - pX - dX) + pY; - matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - return helpMatrix; - }; - /** - * @internal - * @private - */ - Surface.prototype.init = function (surfaceData, armatureValue) { - if (this._boneData !== null) { - return; - } - _super.prototype.init.call(this, surfaceData, armatureValue); - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; - var lB = 1000.0; - var lA = 200.0; - // - this._dX = lA * 2.0 / segmentX; - this._dY = lA * 2.0 / segmentY; - this._k = -this._dY / this._dX; - this._kX = -this._dY / (lB - lA); - this._kY = -(lB - lA) / this._dX; - this._vertices.length = vertexCount * 2; - this._deformVertices.length = vertexCount * 2; - this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; - this._hullCache.length = 10; - for (var i = 0; i < vertexCount * 2; ++i) { - this._deformVertices[i] = 0.0; - } - if (this._parent !== null) { - if (this._parent.boneData.type === 0 /* Bone */) { - this._bone = this._parent; - } - else { - this._bone = this._parent._bone; - } - } - }; - /** - * @internal - */ - Surface.prototype.update = function (cacheFrameIndex) { - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { // Has been Cached. - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { - this._matrixCahce[i] = -1.0; - } - // - this._updateVertices(); - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // Update hull vertices. - var lB = 1000.0; - var lA = 200.0; - var ddX = 2 * this.global.x; - var ddY = 2 * this.global.y; - // - var helpPoint = Surface._helpPoint; - this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); - this._hullCache[0] = helpPoint.x; - this._hullCache[1] = helpPoint.y; - this._hullCache[2] = ddX - helpPoint.x; - this._hullCache[3] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); - this._hullCache[4] = helpPoint.x; - this._hullCache[5] = helpPoint.y; - // - this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); - this._hullCache[6] = helpPoint.x; - this._hullCache[7] = helpPoint.y; - this._hullCache[8] = ddX - helpPoint.x; - this._hullCache[9] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); - this._hullCache[10] = helpPoint.x; - this._hullCache[11] = helpPoint.y; - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - return Surface; - }(dragonBones.Bone)); - dragonBones.Surface = Surface; -})(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 DisplayFrame = /** @class */ (function (_super) { - __extends(DisplayFrame, _super); - function DisplayFrame() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.deformVertices = []; - return _this; - } - DisplayFrame.toString = function () { - return "[class dragonBones.DisplayFrame]"; - }; - DisplayFrame.prototype._onClear = function () { - this.rawDisplayData = null; - this.displayData = null; - this.textureData = null; - this.display = null; - this.deformVertices.length = 0; - }; - DisplayFrame.prototype.updateDeformVertices = function () { - if (this.rawDisplayData === null || this.deformVertices.length !== 0) { - return; - } - var rawGeometryData; - if (this.rawDisplayData.type === 2 /* Mesh */) { - rawGeometryData = this.rawDisplayData.geometry; - } - else if (this.rawDisplayData.type === 4 /* Path */) { - rawGeometryData = this.rawDisplayData.geometry; - } - else { - return; - } - var vertexCount = 0; - if (rawGeometryData.weight !== null) { - vertexCount = rawGeometryData.weight.count * 2; - } - else { - vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; - } - this.deformVertices.length = vertexCount; - for (var i = 0, l = this.deformVertices.length; i < l; ++i) { - this.deformVertices[i] = 0.0; - } - }; - DisplayFrame.prototype.getGeometryData = function () { - if (this.displayData !== null) { - if (this.displayData.type === 2 /* Mesh */) { - return this.displayData.geometry; - } - if (this.displayData.type === 4 /* Path */) { - return this.displayData.geometry; - } - } - if (this.rawDisplayData !== null) { - if (this.rawDisplayData.type === 2 /* Mesh */) { - return this.rawDisplayData.geometry; - } - if (this.rawDisplayData.type === 4 /* Path */) { - return this.rawDisplayData.geometry; - } - } - return null; - }; - DisplayFrame.prototype.getBoundingBox = function () { - if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { - return this.displayData.boundingBox; - } - if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { - return this.rawDisplayData.boundingBox; - } - return null; - }; - DisplayFrame.prototype.getTextureData = function () { - if (this.displayData !== null) { - if (this.displayData.type === 0 /* Image */) { - return this.displayData.texture; - } - if (this.displayData.type === 2 /* Mesh */) { - return this.displayData.texture; - } - } - if (this.textureData !== null) { - return this.textureData; - } - if (this.rawDisplayData !== null) { - if (this.rawDisplayData.type === 0 /* Image */) { - return this.rawDisplayData.texture; - } - if (this.rawDisplayData.type === 2 /* Mesh */) { - return this.rawDisplayData.texture; - } - } - return null; - }; - return DisplayFrame; - }(dragonBones.BaseObject)); - dragonBones.DisplayFrame = DisplayFrame; - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - var Slot = /** @class */ (function (_super) { - __extends(Slot, _super); - function Slot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._localMatrix = new dragonBones.Matrix(); - /** - * @internal - */ - _this._colorTransform = new dragonBones.ColorTransform(); - /** - * @internal - */ - _this._displayFrames = []; - /** - * @internal - */ - _this._geometryBones = []; - _this._rawDisplay = null; // Initial value. - _this._meshDisplay = null; // Initial value. - _this._display = null; - return _this; - } - Slot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - var disposeDisplayList = []; - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var dispayFrame = _a[_i]; - var display = dispayFrame.display; - if (display !== this._rawDisplay && display !== this._meshDisplay && - disposeDisplayList.indexOf(display) < 0) { - disposeDisplayList.push(display); - } - dispayFrame.returnToPool(); - } - for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { - var eachDisplay = disposeDisplayList_1[_b]; - if (eachDisplay instanceof dragonBones.Armature) { - eachDisplay.dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. - this._disposeDisplay(this._meshDisplay, false); - } - if (this._rawDisplay !== null) { - this._disposeDisplay(this._rawDisplay, false); - } - this.displayController = null; - this._displayDataDirty = false; - this._displayDirty = false; - this._geometryDirty = false; - this._textureDirty = false; - this._visibleDirty = false; - this._blendModeDirty = false; - this._zOrderDirty = false; - this._colorDirty = false; - this._verticesDirty = false; - this._transformDirty = false; - this._visible = true; - this._blendMode = 0 /* Normal */; - this._displayIndex = -1; - this._animationDisplayIndex = -1; - this._zOrder = 0; - this._zIndex = 0; - this._cachedFrameIndex = -1; - this._pivotX = 0.0; - this._pivotY = 0.0; - this._localMatrix.identity(); - this._colorTransform.identity(); - this._displayFrames.length = 0; - this._geometryBones.length = 0; - this._slotData = null; // - this._displayFrame = null; - this._geometryData = null; - this._boundingBoxData = null; - this._textureData = null; - this._rawDisplay = null; - this._meshDisplay = null; - this._display = null; - this._childArmature = null; - this._parent = null; // - this._cachedFrameIndices = null; - }; - Slot.prototype._hasDisplay = function (display) { - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var displayFrame = _a[_i]; - if (displayFrame.display === display) { - return true; - } - } - return false; - }; - /** - * @internal - */ - Slot.prototype._isBonesUpdate = function () { - for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone !== null && bone._childrenTransformDirty) { - return true; - } - } - return false; - }; - /** - * @internal - */ - Slot.prototype._updateAlpha = function () { - var globalAlpha = this._alpha * this._parent._globalAlpha; - if (this._globalAlpha !== globalAlpha) { - this._globalAlpha = globalAlpha; - this._colorDirty = true; - } - }; - Slot.prototype._updateDisplayData = function () { - var prevDisplayFrame = this._displayFrame; - var prevGeometryData = this._geometryData; - var prevTextureData = this._textureData; - var rawDisplayData = null; - var displayData = null; - this._displayFrame = null; - this._geometryData = null; - this._boundingBoxData = null; - this._textureData = null; - if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { - this._displayFrame = this._displayFrames[this._displayIndex]; - rawDisplayData = this._displayFrame.rawDisplayData; - displayData = this._displayFrame.displayData; - this._geometryData = this._displayFrame.getGeometryData(); - this._boundingBoxData = this._displayFrame.getBoundingBox(); - this._textureData = this._displayFrame.getTextureData(); - } - if (this._displayFrame !== prevDisplayFrame || - this._geometryData !== prevGeometryData || this._textureData !== prevTextureData) { - // Update pivot offset. - if (this._geometryData === null && this._textureData !== null) { - var imageDisplayData = ((displayData !== null && displayData.type === 0 /* Image */) ? displayData : rawDisplayData); // - var scale = this._textureData.parent.scale * this._armature._armatureData.scale; - var frame = this._textureData.frame; - this._pivotX = imageDisplayData.pivot.x; - this._pivotY = imageDisplayData.pivot.y; - var rect = frame !== null ? frame : this._textureData.region; - var width = rect.width; - var height = rect.height; - if (this._textureData.rotated && frame === null) { - width = rect.height; - height = rect.width; - } - this._pivotX *= width * scale; - this._pivotY *= height * scale; - if (frame !== null) { - this._pivotX += frame.x * scale; - this._pivotY += frame.y * scale; - } - // Update replace pivot. TODO - if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) { - rawDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX -= Slot._helpPoint.x; - this._pivotY -= Slot._helpPoint.y; - imageDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX += Slot._helpPoint.x; - this._pivotY += Slot._helpPoint.y; - } - if (!dragonBones.DragonBones.yDown) { - this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; - } - } - else { - this._pivotX = 0.0; - this._pivotY = 0.0; - } - // Update original transform. - if (rawDisplayData !== null) { // Compatible. - this.origin = rawDisplayData.transform; - } - else if (displayData !== null) { // Compatible. - this.origin = displayData.transform; - } - else { - this.origin = null; - } - // TODO remove slot offset. - if (this.origin !== null) { - this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); - } - else { - this.global.copyFrom(this.offset).toMatrix(this._localMatrix); - } - // Update geometry. - if (this._geometryData !== prevGeometryData) { - this._geometryDirty = true; - this._verticesDirty = true; - if (this._geometryData !== null) { - this._geometryBones.length = 0; - if (this._geometryData.weight !== null) { - for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { - var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); - this._geometryBones.push(bone); - } - } - } - else { - this._geometryBones.length = 0; - this._geometryData = null; - } - } - this._textureDirty = this._textureData !== prevTextureData; - this._transformDirty = true; - } - }; - Slot.prototype._updateDisplay = function () { - var prevDisplay = this._display !== null ? this._display : this._rawDisplay; - var prevChildArmature = this._childArmature; - // Update display and child armature. - if (this._displayFrame !== null) { - this._display = this._displayFrame.display; - if (this._display !== null && this._display instanceof dragonBones.Armature) { - this._childArmature = this._display; - this._display = this._childArmature.display; - } - else { - this._childArmature = null; - } - } - else { - this._display = null; - this._childArmature = null; - } - // Update display. - var currentDisplay = this._display !== null ? this._display : this._rawDisplay; - if (currentDisplay !== prevDisplay) { - this._textureDirty = true; - this._visibleDirty = true; - this._blendModeDirty = true; - // this._zOrderDirty = true; - this._colorDirty = true; - this._transformDirty = true; - this._onUpdateDisplay(); - this._replaceDisplay(prevDisplay); - } - // Update child armature. - if (this._childArmature !== prevChildArmature) { - if (prevChildArmature !== null) { - prevChildArmature._parent = null; // Update child armature parent. - prevChildArmature.clock = null; - if (prevChildArmature.inheritAnimation) { - prevChildArmature.animation.reset(); - } - } - if (this._childArmature !== null) { - this._childArmature._parent = this; // Update child armature parent. - this._childArmature.clock = this._armature.clock; - if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. - if (this._childArmature.cacheFrameRate === 0) { - var cacheFrameRate = this._armature.cacheFrameRate; - if (cacheFrameRate !== 0) { - this._childArmature.cacheFrameRate = cacheFrameRate; - } - } - // Child armature action. - if (this._displayFrame !== null) { - var actions = null; - var displayData = this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; - if (displayData !== null && displayData.type === 1 /* Armature */) { - actions = displayData.actions; - } - if (actions !== null && actions.length > 0) { - for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { - var action = actions_1[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - eventObject.slot = this; - this._armature._bufferAction(eventObject, false); - } - } - else { - this._childArmature.animation.play(); - } - } - } - } - } - }; - Slot.prototype._updateGlobalTransformMatrix = function (isCache) { - var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); - this.globalTransformMatrix.copyFrom(this._localMatrix); - this.globalTransformMatrix.concat(parentMatrix); - if (isCache) { - this.global.fromMatrix(this.globalTransformMatrix); - } - else { - this._globalDirty = true; - } - }; - /** - * @internal - */ - Slot.prototype._setDisplayIndex = function (value, isAnimation) { - if (isAnimation === void 0) { isAnimation = false; } - if (isAnimation) { - if (this._animationDisplayIndex === value) { - return; - } - this._animationDisplayIndex = value; - } - if (this._displayIndex === value) { - return; - } - this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; - this._displayDataDirty = true; - this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; - }; - /** - * @internal - */ - Slot.prototype._setZOrder = function (value) { - if (this._zOrder === value) { - // return false; - } - this._zOrder = value; - this._zOrderDirty = true; - return this._zOrderDirty; - }; - /** - * @internal - */ - Slot.prototype._setColor = function (value) { - this._colorTransform.copyFrom(value); - return this._colorDirty = true; - }; - /** - * @internal - */ - Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - if (this._slotData !== null) { - return; - } - this._slotData = slotData; - this._colorDirty = true; // - this._blendModeDirty = true; // - this._blendMode = this._slotData.blendMode; - this._zOrder = this._slotData.zOrder; - this._zIndex = this._slotData.zIndex; - this._alpha = this._slotData.alpha; - this._colorTransform.copyFrom(this._slotData.color); - this._rawDisplay = rawDisplay; - this._meshDisplay = meshDisplay; - // - this._armature = armatureValue; - var slotParent = this._armature.getBone(this._slotData.parent.name); - if (slotParent !== null) { - this._parent = slotParent; - } - else { - // Never; - } - this._armature._addSlot(this); - // - this._initDisplay(this._rawDisplay, false); - if (this._rawDisplay !== this._meshDisplay) { - this._initDisplay(this._meshDisplay, false); - } - this._onUpdateDisplay(); - this._addDisplay(); - }; - /** - * @internal - */ - Slot.prototype.update = function (cacheFrameIndex) { - if (this._displayDataDirty) { - this._updateDisplayData(); - this._displayDataDirty = false; - } - if (this._displayDirty) { - this._updateDisplay(); - this._displayDirty = false; - } - if (this._geometryDirty || this._textureDirty) { - if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { - this._updateFrame(); - } - this._geometryDirty = false; - this._textureDirty = false; - } - if (this._display === null) { - return; - } - if (this._visibleDirty) { - this._updateVisible(); - this._visibleDirty = false; - } - if (this._blendModeDirty) { - this._updateBlendMode(); - this._blendModeDirty = false; - } - if (this._colorDirty) { - this._updateColor(); - this._colorDirty = false; - } - if (this._zOrderDirty) { - this._updateZOrder(); - this._zOrderDirty = false; - } - if (this._geometryData !== null && this._display === this._meshDisplay) { - var isSkinned = this._geometryData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (this._verticesDirty || - (isSkinned && this._isBonesUpdate()) || - (isSurface && this._parent._childrenTransformDirty)) { - this._verticesDirty = false; // Allow update mesh to reset the dirty value. - this._updateMesh(); - } - if (isSkinned || isSurface) { // Compatible. - return; - } - } - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { // Has been Cached. - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - if (this._transformDirty) { - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - this._updateGlobalTransformMatrix(isCache); - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - this._updateTransform(); - this._transformDirty = false; - } - }; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Slot.prototype.invalidUpdate = function () { - this._displayDataDirty = true; - this._displayDirty = true; - // - this._transformDirty = true; - }; - /** - * @private - */ - Slot.prototype.updateTransformAndMatrix = function () { - if (this._transformDirty) { - this._updateGlobalTransformMatrix(false); - this._transformDirty = false; - } - }; - /** - * @private - */ - Slot.prototype.replaceRawDisplayData = function (displayData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.rawDisplayData !== displayData) { - displayFrame.deformVertices.length = 0; - displayFrame.rawDisplayData = displayData; - if (displayFrame.rawDisplayData === null) { - var defaultSkin = this._armature._armatureData.defaultSkin; - if (defaultSkin !== null) { - var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); - if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { - displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; - } - } - } - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplayData = function (displayData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { - displayFrame.displayData = displayData; - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceTextureData = function (textureData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.textureData !== textureData) { - displayFrame.textureData = textureData; - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplay = function (value, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.display !== value) { - var prevDisplay = displayFrame.display; - displayFrame.display = value; - if (prevDisplay !== null && - prevDisplay !== this._rawDisplay && prevDisplay !== this._meshDisplay && - !this._hasDisplay(prevDisplay)) { - if (prevDisplay instanceof dragonBones.Armature) { - // (eachDisplay as Armature).dispose(); - } - else { - this._disposeDisplay(prevDisplay, true); - } - } - if (value !== null && - value !== this._rawDisplay && value !== this._meshDisplay && - !this._hasDisplay(prevDisplay) && - !(value instanceof dragonBones.Armature)) { - this._initDisplay(value, true); - } - if (index === this._displayIndex) { - this._displayDirty = true; - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.containsPoint = function (x, y) { - if (this._boundingBoxData === null) { - return false; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); - return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); - }; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (this._boundingBoxData === null) { - return 0; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); - xA = Slot._helpPoint.x; - yA = Slot._helpPoint.y; - Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); - xB = Slot._helpPoint.x; - yB = Slot._helpPoint.y; - var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionCount === 1 || intersectionCount === 2) { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - if (intersectionPointB !== null) { - intersectionPointB.x = intersectionPointA.x; - intersectionPointB.y = intersectionPointA.y; - } - } - else if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - else { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - } - if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - if (normalRadians !== null) { - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); - normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); - normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - } - } - return intersectionCount; - }; - /** - * @private - */ - Slot.prototype.getDisplayFrameAt = function (index) { - return this._displayFrames[index]; - }; - Object.defineProperty(Slot.prototype, "visible", { - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - this._updateVisible(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayFrameCount", { - /** - * @private - */ - get: function () { - return this._displayFrames.length; - }, - set: function (value) { - var prevCount = this._displayFrames.length; - if (prevCount < value) { - this._displayFrames.length = value; - for (var i = prevCount; i < value; ++i) { - this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); - } - } - else if (prevCount > value) { - for (var i = prevCount - 1; i < value; --i) { - this.replaceDisplay(null, i); - this._displayFrames[i].returnToPool(); - } - this._displayFrames.length = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayIndex", { - /** - * - The index of the display object displayed in the display list. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._displayIndex; - }, - set: function (value) { - this._setDisplayIndex(value); - this.update(-1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "name", { - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._slotData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayList", { - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - var displays = new Array(); - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var displayFrame = _a[_i]; - displays.push(displayFrame.display); - } - return displays; - }, - set: function (value) { - this.displayFrameCount = value.length; - var index = 0; - for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { - var eachDisplay = value_1[_i]; - this.replaceDisplay(eachDisplay, index++); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "slotData", { - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._slotData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "boundingBoxData", { - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - return this._boundingBoxData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplay", { - /** - * @private - */ - get: function () { - return this._rawDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "meshDisplay", { - /** - * @private - */ - get: function () { - return this._meshDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "display", { - /** - * - The display object that the slot displays at this time. - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - set: function (value) { - if (this._display === value) { - return; - } - if (this._displayFrames.length === 0) { - this.displayFrameCount = 1; - this._displayIndex = 0; - } - this.replaceDisplay(value, this._displayIndex); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "childArmature", { - /** - * - The child armature that the slot displayed at current time. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     let prevChildArmature = slot.childArmature;
-             *     if (prevChildArmature) {
-             *         prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     let prevChildArmature = slot.childArmature;
-             *     if (prevChildArmature) {
-             *         prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._childArmature; - }, - set: function (value) { - if (this._childArmature === value) { - return; - } - this.display = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.getDisplay = function () { - return this._display; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.setDisplay = function (value) { - this.display = value; - }; - return Slot; - }(dragonBones.TransformObject)); - dragonBones.Slot = Slot; -})(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) { - /** - * @internal - */ - var Constraint = /** @class */ (function (_super) { - __extends(Constraint, _super); - function Constraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - Constraint.prototype._onClear = function () { - this._armature = null; // - this._target = null; // - this._root = null; // - this._bone = null; - }; - Object.defineProperty(Constraint.prototype, "name", { - get: function () { - return this._constraintData.name; - }, - enumerable: true, - configurable: true - }); - Constraint._helpMatrix = new dragonBones.Matrix(); - Constraint._helpTransform = new dragonBones.Transform(); - Constraint._helpPoint = new dragonBones.Point(); - return Constraint; - }(dragonBones.BaseObject)); - dragonBones.Constraint = Constraint; - /** - * @internal - */ - var IKConstraint = /** @class */ (function (_super) { - __extends(IKConstraint, _super); - function IKConstraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraint.toString = function () { - return "[class dragonBones.IKConstraint]"; - }; - IKConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._scaleEnabled = false; - this._bendPositive = false; - this._weight = 1.0; - this._constraintData = null; - }; - IKConstraint.prototype._computeA = function () { - var ikGlobal = this._target.global; - var global = this._root.global; - var globalTransformMatrix = this._root.globalTransformMatrix; - var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radian += Math.PI; - } - global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype._computeB = function () { - var boneLength = this._bone._boneData.length; - var parent = this._root; - var ikGlobal = this._target.global; - var parentGlobal = parent.global; - var global = this._bone.global; - var globalTransformMatrix = this._bone.globalTransformMatrix; - var x = globalTransformMatrix.a * boneLength; - var y = globalTransformMatrix.b * boneLength; - var lLL = x * x + y * y; - var lL = Math.sqrt(lLL); - var dX = global.x - parentGlobal.x; - var dY = global.y - parentGlobal.y; - var lPP = dX * dX + dY * dY; - var lP = Math.sqrt(lPP); - var rawRadian = global.rotation; - var rawParentRadian = parentGlobal.rotation; - var rawRadianA = Math.atan2(dY, dX); - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - var lTT = dX * dX + dY * dY; - var lT = Math.sqrt(lTT); - var radianA = 0.0; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); - if (lL + lP <= lT) { - } - else if (lP < lL) { - radianA += Math.PI; - } - } - else { - var h = (lPP - lLL + lTT) / (2.0 * lTT); - var r = Math.sqrt(lPP - h * h * lTT) / lT; - var hX = parentGlobal.x + (dX * h); - var hY = parentGlobal.y + (dY * h); - var rX = -dY * r; - var rY = dX * r; - var isPPR = false; - var parentParent = parent.parent; - if (parentParent !== null) { - var parentParentMatrix = parentParent.globalTransformMatrix; - isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; - } - if (isPPR !== this._bendPositive) { - global.x = hX - rX; - global.y = hY - rY; - } - else { - global.x = hX + rX; - global.y = hY + rY; - } - radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); - } - var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); - parentGlobal.rotation = rawParentRadian + dR * this._weight; - parentGlobal.toMatrix(parent.globalTransformMatrix); - // - var currentRadianA = rawRadianA + dR * this._weight; - global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; - global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; - // - var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radianB += Math.PI; - } - global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype.init = function (constraintData, armature) { - if (this._constraintData !== null) { - return; - } - this._constraintData = constraintData; - this._armature = armature; - this._target = this._armature.getBone(this._constraintData.target.name); - this._root = this._armature.getBone(this._constraintData.root.name); - this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; - { - var ikConstraintData = this._constraintData; - this._scaleEnabled = ikConstraintData.scaleEnabled; - this._bendPositive = ikConstraintData.bendPositive; - this._weight = ikConstraintData.weight; - } - this._root._hasConstraint = true; - }; - IKConstraint.prototype.update = function () { - this._root.updateByConstraint(); - if (this._bone !== null) { - this._bone.updateByConstraint(); - this._computeB(); - } - else { - this._computeA(); - } - }; - IKConstraint.prototype.invalidUpdate = function () { - this._root.invalidUpdate(); - if (this._bone !== null) { - this._bone.invalidUpdate(); - } - }; - return IKConstraint; - }(Constraint)); - dragonBones.IKConstraint = IKConstraint; - /** - * @internal - */ - var PathConstraint = /** @class */ (function (_super) { - __extends(PathConstraint, _super); - function PathConstraint() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._spaces = []; - _this._positions = []; - _this._curves = []; - _this._boneLengths = []; - _this._pathGlobalVertices = []; - _this._segments = [10]; - return _this; - } - PathConstraint.toString = function () { - return "[class dragonBones.PathConstraint]"; - }; - PathConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.dirty = false; - this.pathOffset = 0; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 1.0; - this.translateMix = 1.0; - this._pathSlot = null; - this._bones.length = 0; - this._spaces.length = 0; - this._positions.length = 0; - this._curves.length = 0; - this._boneLengths.length = 0; - this._pathGlobalVertices.length = 0; - }; - PathConstraint.prototype._updatePathVertices = function (verticesData) { - //计算曲线的节点数据 - var armature = this._armature; - var dragonBonesData = armature.armatureData.parent; - var scale = armature.armatureData.scale; - var intArray = dragonBonesData.intArray; - var floatArray = dragonBonesData.floatArray; - var pathOffset = verticesData.offset; - var pathVertexCount = intArray[pathOffset + 0 /* GeometryVertexCount */]; - var pathVertexOffset = intArray[pathOffset + 2 /* GeometryFloatOffset */]; - this._pathGlobalVertices.length = pathVertexCount * 2; - var weightData = verticesData.weight; - //没有骨骼约束我,那节点只受自己的Bone控制 - if (weightData === null) { - var parentBone = this._pathSlot.parent; - parentBone.updateByConstraint(); - var matrix = parentBone.globalTransformMatrix; - for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { - var vx = floatArray[iV_1++] * scale; - var vy = floatArray[iV_1++] * scale; - var x = matrix.a * vx + matrix.c * vy + matrix.tx; - var y = matrix.b * vx + matrix.d * vy + matrix.ty; - // - this._pathGlobalVertices[i] = x; - this._pathGlobalVertices[i + 1] = y; - } - return; - } - //有骨骼约束我,那我的节点受骨骼权重控制 - var bones = this._pathSlot._geometryBones; - var weightBoneCount = weightData.bones.length; - var weightOffset = weightData.offset; - var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; - var iV = floatOffset; - var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; - for (var i = 0, iW = 0; i < pathVertexCount; i++) { - var vertexBoneCount = intArray[iB++]; // - var xG = 0.0, yG = 0.0; - for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone === null) { - continue; - } - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var vx = floatArray[iV++] * scale; - var vy = floatArray[iV++] * scale; - xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; - yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; - } - this._pathGlobalVertices[iW++] = xG; - this._pathGlobalVertices[iW++] = yG; - } - }; - PathConstraint.prototype._computeVertices = function (start, count, offset, out) { - //TODO优化 - for (var i = offset, iW = start; i < count; i += 2) { - out[i] = this._pathGlobalVertices[iW++]; - out[i + 1] = this._pathGlobalVertices[iW++]; - } - }; - PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { - //计算当前的骨骼在曲线上的位置 - var armature = this._armature; - var intArray = armature.armatureData.parent.intArray; - var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; - var positions = this._positions; - var spaces = this._spaces; - var isClosed = pathDisplayDta.closed; - var curveVertices = Array(); - var verticesLength = vertexCount * 2; - var curveCount = verticesLength / 6; - var preCurve = -1; - var position = this.position; - positions.length = spaceCount * 3 + 2; - var pathLength = 0.0; - //不需要匀速运动,效率高些 - if (!pathDisplayDta.constantSpeed) { - var lenghts = pathDisplayDta.curveLengths; - curveCount -= isClosed ? 1 : 2; - pathLength = lenghts[curveCount]; - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - curveVertices.length = 8; - for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - if (isClosed) { - position %= pathLength; - if (position < 0) { - position += pathLength; - } - curve = 0; - } - else if (position < 0) { - //TODO - continue; - } - else if (position > pathLength) { - //TODO - continue; - } - var percent = 0.0; - for (;; curve++) { - var len = lenghts[curve]; - if (position > len) { - continue; - } - if (curve === 0) { - percent = position / len; - } - else { - var preLen = lenghts[curve - 1]; - percent = (position - preLen) / (len - preLen); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - if (isClosed && curve === curveCount) { - //计算曲线 - this._computeVertices(verticesLength - 4, 4, 0, curveVertices); - this._computeVertices(0, 4, 4, curveVertices); - } - else { - this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); - } - } - // - this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); - } - return; - } - //匀速的 - if (isClosed) { - verticesLength += 2; - curveVertices.length = vertexCount; - this._computeVertices(2, verticesLength - 4, 0, curveVertices); - this._computeVertices(0, 2, verticesLength - 4, curveVertices); - curveVertices[verticesLength - 2] = curveVertices[0]; - curveVertices[verticesLength - 1] = curveVertices[1]; - } - else { - curveCount--; - verticesLength -= 4; - curveVertices.length = verticesLength; - this._computeVertices(2, verticesLength, 0, curveVertices); - } - // - var curves = new Array(curveCount); - pathLength = 0; - var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = curveVertices[w]; - cy1 = curveVertices[w + 1]; - cx2 = curveVertices[w + 2]; - cy2 = curveVertices[w + 3]; - x2 = curveVertices[w + 4]; - y2 = curveVertices[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - var segments = this._segments; - var curveLength = 0; - for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (isClosed) { - p %= pathLength; - if (p < 0) - p += pathLength; - curve = 0; - } - else if (p < 0) { - continue; - } - else if (p > pathLength) { - continue; - } - // Determine curve containing position. - for (;; curve++) { - var length_1 = curves[curve]; - if (p > length_1) - continue; - if (curve === 0) - p /= length_1; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_1 - prev); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - var ii = curve * 6; - x1 = curveVertices[ii]; - y1 = curveVertices[ii + 1]; - cx1 = curveVertices[ii + 2]; - cy1 = curveVertices[ii + 3]; - cx2 = curveVertices[ii + 4]; - cy2 = curveVertices[ii + 5]; - x2 = curveVertices[ii + 6]; - y2 = curveVertices[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - // Weight by segment length. - p *= curveLength; - for (;; segment++) { - var length_2 = segments[segment]; - if (p > length_2) - continue; - if (segment === 0) - p /= length_2; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_2 - prev); - } - break; - } - this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); - } - }; - //Calculates a point on the curve, for a given t value between 0 and 1. - PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { - if (t === 0) { - out[offset] = x1; - out[offset + 1] = y1; - out[offset + 2] = 0; - return; - } - if (t === 1) { - out[offset] = x2; - out[offset + 1] = y2; - out[offset + 2] = 0; - return; - } - var mt = 1 - t; - var mt2 = mt * mt; - var t2 = t * t; - var a = mt2 * mt; - var b = mt2 * t * 3; - var c = mt * t2 * 3; - var d = t * t2; - var x = a * x1 + b * cx1 + c * cx2 + d * x2; - var y = a * y1 + b * cy1 + c * cy2 + d * y2; - out[offset] = x; - out[offset + 1] = y; - if (tangents) { - //Calculates the curve tangent at the specified t value - out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); - } - else { - out[offset + 2] = 0; - } - }; - PathConstraint.prototype.init = function (constraintData, armature) { - this._constraintData = constraintData; - this._armature = armature; - var data = constraintData; - this.pathOffset = data.pathDisplayData.geometry.offset; - // - this.position = data.position; - this.spacing = data.spacing; - this.rotateOffset = data.rotateOffset; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - // - this._root = this._armature.getBone(data.root.name); - this._target = this._armature.getBone(data.target.name); - this._pathSlot = this._armature.getSlot(data.pathSlot.name); - for (var i = 0, l = data.bones.length; i < l; i++) { - var bone = this._armature.getBone(data.bones[i].name); - if (bone !== null) { - this._bones.push(bone); - } - } - if (data.rotateMode === 2 /* ChainScale */) { - this._boneLengths.length = this._bones.length; - } - this._root._hasConstraint = true; - }; - PathConstraint.prototype.update = function () { - var pathSlot = this._pathSlot; - if (pathSlot._geometryData === null || - pathSlot._geometryData.offset !== this.pathOffset) { - return; - } - var constraintData = this._constraintData; - // - //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 - var isPathVerticeDirty = false; - if (this._root._childrenTransformDirty) { - this._updatePathVertices(pathSlot._geometryData); - isPathVerticeDirty = true; - } - else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) { - this._updatePathVertices(pathSlot._geometryData); - pathSlot._verticesDirty = false; - isPathVerticeDirty = true; - } - if (!isPathVerticeDirty && !this.dirty) { - return; - } - // - var positionMode = constraintData.positionMode; - var spacingMode = constraintData.spacingMode; - var rotateMode = constraintData.rotateMode; - var bones = this._bones; - var isLengthMode = spacingMode === 0 /* Length */; - var isChainScaleMode = rotateMode === 2 /* ChainScale */; - var isTangentMode = rotateMode === 0 /* Tangent */; - var boneCount = bones.length; - var spacesCount = isTangentMode ? boneCount : boneCount + 1; - var spacing = this.spacing; - var spaces = this._spaces; - spaces.length = spacesCount; - //计曲线间隔和长度 - if (isChainScaleMode || isLengthMode) { - //Bone改变和spacing改变触发 - spaces[0] = 0; - for (var i = 0, l = spacesCount - 1; i < l; i++) { - var bone = bones[i]; - bone.updateByConstraint(); - var boneLength = bone._boneData.length; - var matrix = bone.globalTransformMatrix; - var x = boneLength * matrix.a; - var y = boneLength * matrix.b; - var len = Math.sqrt(x * x + y * y); - if (isChainScaleMode) { - this._boneLengths[i] = len; - } - spaces[i + 1] = (boneLength + spacing) * len / boneLength; - } - } - else { - for (var i = 0; i < spacesCount; i++) { - spaces[i] = spacing; - } - } - // - this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); - //根据新的节点数据重新采样 - var positions = this._positions; - var rotateOffset = this.rotateOffset; - var boneX = positions[0], boneY = positions[1]; - var tip; - if (rotateOffset === 0) { - tip = rotateMode === 1 /* Chain */; - } - else { - tip = false; - var bone = pathSlot.parent; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; - } - } - // - var rotateMix = this.rotateMix; - var translateMix = this.translateMix; - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - matrix.tx += (boneX - matrix.tx) * translateMix; - matrix.ty += (boneY - matrix.ty) * translateMix; - var x = positions[p], y = positions[p + 1]; - var dx = x - boneX, dy = y - boneY; - if (isChainScaleMode) { - var lenght = this._boneLengths[i]; - var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; - matrix.a *= s; - matrix.b *= s; - } - boneX = x; - boneY = y; - if (rotateMix > 0) { - var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; - if (isTangentMode) { - r = positions[p - 1]; - } - else { - r = Math.atan2(dy, dx); - } - r -= Math.atan2(b, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone._boneData.length; - boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; - } - else { - r += rotateOffset; - } - if (r > dragonBones.Transform.PI) { - r -= dragonBones.Transform.PI_D; - } - else if (r < -dragonBones.Transform.PI) { - r += dragonBones.Transform.PI_D; - } - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - matrix.a = cos * a - sin * b; - matrix.b = sin * a + cos * b; - matrix.c = cos * c - sin * d; - matrix.d = sin * c + cos * d; - } - bone.global.fromMatrix(matrix); - } - this.dirty = false; - }; - PathConstraint.prototype.invalidUpdate = function () { - }; - return PathConstraint; - }(Constraint)); - dragonBones.PathConstraint = PathConstraint; -})(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) { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var WorldClock = /** @class */ (function () { - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function WorldClock(time) { - if (time === void 0) { time = 0.0; } - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - this.time = 0.0; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - this.timeScale = 1.0; - this._systemTime = 0.0; - this._animatebles = []; - this._clock = null; - this.time = time; - this._systemTime = new Date().getTime() * 0.001; - } - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.advanceTime = function (passedTime) { - if (passedTime !== passedTime) { - passedTime = 0.0; - } - var currentTime = Date.now() * 0.001; - if (passedTime < 0.0) { - passedTime = currentTime - this._systemTime; - } - this._systemTime = currentTime; - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - if (passedTime === 0.0) { - return; - } - if (passedTime < 0.0) { - this.time -= passedTime; - } - else { - this.time += passedTime; - } - var i = 0, r = 0, l = this._animatebles.length; - for (; i < l; ++i) { - var animatable = this._animatebles[i]; - if (animatable !== null) { - if (r > 0) { - this._animatebles[i - r] = animatable; - this._animatebles[i] = null; - } - animatable.advanceTime(passedTime); - } - else { - r++; - } - } - if (r > 0) { - l = this._animatebles.length; - for (; i < l; ++i) { - var animateble = this._animatebles[i]; - if (animateble !== null) { - this._animatebles[i - r] = animateble; - } - else { - r++; - } - } - this._animatebles.length -= r; - } - }; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.clock; - } - return ancestor === this; - }; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.add = function (value) { - if (this._animatebles.indexOf(value) < 0) { - this._animatebles.push(value); - value.clock = this; - } - }; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.remove = function (value) { - var index = this._animatebles.indexOf(value); - if (index >= 0) { - this._animatebles[index] = null; - value.clock = null; - } - }; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.clear = function () { - for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { - var animatable = _a[_i]; - if (animatable !== null) { - animatable.clock = null; - } - } - }; - Object.defineProperty(WorldClock.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock !== null) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - return WorldClock; - }()); - dragonBones.WorldClock = WorldClock; -})(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 animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - var Animation = /** @class */ (function (_super) { - __extends(Animation, _super); - function Animation() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._animationNames = []; - _this._animationStates = []; - _this._animations = {}; - _this._blendStates = {}; - _this._animationConfig = null; // Initial value. - return _this; - } - Animation.toString = function () { - return "[class dragonBones.Animation]"; - }; - Animation.prototype._onClear = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in this._blendStates) { - var blendStates = this._blendStates[k]; - for (var kB in blendStates) { - blendStates[kB].returnToPool(); - } - delete this._blendStates[k]; - } - if (this._animationConfig !== null) { - this._animationConfig.returnToPool(); - } - this.timeScale = 1.0; - this._animationDirty = false; - this._inheritTimeScale = 1.0; - this._animationNames.length = 0; - this._animationStates.length = 0; - //this._animations.clear(); - this._armature = null; // - this._animationConfig = null; // - this._lastAnimationState = null; - }; - Animation.prototype._fadeOut = function (animationConfig) { - switch (animationConfig.fadeOutMode) { - case 1 /* SameLayer */: - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 2 /* SameGroup */: - for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { - var animationState = _c[_b]; - if (animationState._parent !== null) { - continue; - } - if (animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 3 /* SameLayerAndGroup */: - for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { - var animationState = _e[_d]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer && - animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 4 /* All */: - for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { - var animationState = _g[_f]; - if (animationState._parent !== null) { - continue; - } - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - break; - case 5 /* Single */: // TODO - default: - break; - } - }; - /** - * @internal - */ - Animation.prototype.init = function (armature) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); - }; - /** - * @internal - */ - Animation.prototype.advanceTime = function (passedTime) { - if (passedTime < 0.0) { // Only animationState can reverse play. - passedTime = -passedTime; - } - if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. - this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; - } - else { - this._inheritTimeScale = this.timeScale; - } - if (this._inheritTimeScale !== 1.0) { - passedTime *= this._inheritTimeScale; - } - for (var k in this._blendStates) { - var blendStates = this._blendStates[k]; - for (var kB in blendStates) { - blendStates[kB].reset(); - } - } - var animationStateCount = this._animationStates.length; - if (animationStateCount === 1) { - var animationState = this._animationStates[0]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - this._armature._dragonBones.bufferObject(animationState); - this._animationStates.length = 0; - this._lastAnimationState = null; - } - else { - var animationData = animationState.animationData; - var cacheFrameRate = animationData.cacheFrameRate; - if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. - this._animationDirty = false; - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - if (slot.displayFrameCount > 0) { - var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; - if (rawDisplayData !== null && - rawDisplayData.parent === this._armature.armatureData.defaultSkin) { - slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); - continue; - } - } - slot._cachedFrameIndices = null; - } - } - animationState.advanceTime(passedTime, cacheFrameRate); - } - } - else if (animationStateCount > 1) { - for (var i = 0, r = 0; i < animationStateCount; ++i) { - var animationState = this._animationStates[i]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - r++; - this._armature._dragonBones.bufferObject(animationState); - this._animationDirty = true; - if (this._lastAnimationState === animationState) { // Update last animation state. - this._lastAnimationState = null; - } - } - else { - if (r > 0) { - this._animationStates[i - r] = animationState; - } - animationState.advanceTime(passedTime, 0.0); - } - if (i === animationStateCount - 1 && r > 0) { // Modify animation states size. - this._animationStates.length -= r; - if (this._lastAnimationState === null && this._animationStates.length > 0) { - this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; - } - } - } - this._armature._cacheFrameIndex = -1; - } - else { - this._armature._cacheFrameIndex = -1; - } - }; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.reset = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - this._animationDirty = false; - this._animationConfig.clear(); - this._animationStates.length = 0; - this._lastAnimationState = null; - }; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.stop = function (animationName) { - if (animationName === void 0) { animationName = null; } - if (animationName !== null) { - var animationState = this.getState(animationName); - if (animationState !== null) { - animationState.stop(); - } - } - else { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.stop(); - } - } - }; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - Animation.prototype.playConfig = function (animationConfig) { - var animationName = animationConfig.animation; - if (!(animationName in this._animations)) { - console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); - return null; - } - var animationData = this._animations[animationName]; - if (animationConfig.fadeOutMode === 5 /* Single */) { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState_1 = _a[_i]; - if (animationState_1._fadeState < 1 && - animationState_1.layer === animationConfig.layer && - animationState_1.animationData === animationData) { - return animationState_1; - } - } - } - if (this._animationStates.length === 0) { - animationConfig.fadeInTime = 0.0; - } - else if (animationConfig.fadeInTime < 0.0) { - animationConfig.fadeInTime = animationData.fadeInTime; - } - if (animationConfig.fadeOutTime < 0.0) { - animationConfig.fadeOutTime = animationConfig.fadeInTime; - } - if (animationConfig.timeScale <= -100.0) { - animationConfig.timeScale = 1.0 / animationData.scale; - } - if (animationData.frameCount > 0) { - if (animationConfig.position < 0.0) { - animationConfig.position %= animationData.duration; - animationConfig.position = animationData.duration - animationConfig.position; - } - else if (animationConfig.position === animationData.duration) { - animationConfig.position -= 0.000001; // Play a little time before end. - } - else if (animationConfig.position > animationData.duration) { - animationConfig.position %= animationData.duration; - } - if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { - animationConfig.duration = animationData.duration - animationConfig.position; - } - if (animationConfig.playTimes < 0) { - animationConfig.playTimes = animationData.playTimes; - } - } - else { - animationConfig.playTimes = 1; - animationConfig.position = 0.0; - if (animationConfig.duration > 0.0) { - animationConfig.duration = 0.0; - } - } - if (animationConfig.duration === 0.0) { - animationConfig.duration = -1.0; - } - this._fadeOut(animationConfig); - // - var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); - animationState.init(this._armature, animationData, animationConfig); - this._animationDirty = true; - this._armature._cacheFrameIndex = -1; - if (this._animationStates.length > 0) { // Sort animation state. - var added = false; - for (var i = 0, l = this._animationStates.length; i < l; ++i) { - if (animationState.layer > this._animationStates[i].layer) { - added = true; - this._animationStates.splice(i, 0, animationState); - break; - } - else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { - added = true; - this._animationStates.splice(i + 1, 0, animationState); - break; - } - } - if (!added) { - this._animationStates.push(animationState); - } - } - else { - this._animationStates.push(animationState); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { // Child armature play same name animation. - var slot = _c[_b]; - var childArmature = slot.childArmature; - if (childArmature !== null && childArmature.inheritAnimation && - childArmature.animation.hasAnimation(animationName) && - childArmature.animation.getState(animationName) === null) { - childArmature.animation.fadeIn(animationName); // - } - } - for (var k in animationData.animationTimelines) { // Blend animation node. - var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); - if (childAnimationState === null) { - continue; - } - var timelines = animationData.animationTimelines[k]; - childAnimationState.actionEnabled = false; - childAnimationState.resetToPose = false; - childAnimationState.stop(); - animationState.addState(childAnimationState, timelines); - // - var index = this._animationStates.indexOf(animationState); - var childIndex = this._animationStates.indexOf(childAnimationState); - if (childIndex < index) { - this._animationStates.splice(index, 1); - this._animationStates.splice(childIndex, 0, animationState); - } - } - // if (!this._armature._lockUpdate && animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. - // this._armature.advanceTime(0.0); - // } - this._lastAnimationState = animationState; - return animationState; - }; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.play = function (animationName, playTimes) { - if (animationName === void 0) { animationName = null; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName !== null ? animationName : ""; - if (animationName !== null && animationName.length > 0) { - this.playConfig(this._animationConfig); - } - else if (this._lastAnimationState === null) { - var defaultAnimation = this._armature.armatureData.defaultAnimation; - if (defaultAnimation !== null) { - this._animationConfig.animation = defaultAnimation.name; - this.playConfig(this._animationConfig); - } - } - else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { - this._lastAnimationState.play(); - } - else { - this._animationConfig.animation = this._lastAnimationState.name; - this.playConfig(this._animationConfig); - } - return this._lastAnimationState; - }; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { - if (fadeInTime === void 0) { fadeInTime = -1.0; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - this._animationConfig.clear(); - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { - if (time === void 0) { time = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.position = time; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { - if (frame === void 0) { frame = 0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.frameCount > 0 ? animationData.duration * frame / animationData.frameCount : 0.0; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { - if (progress === void 0) { progress = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); - } - return this.playConfig(this._animationConfig); - }; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByTime = function (animationName, time) { - if (time === void 0) { time = 0.0; } - var animationState = this.gotoAndPlayByTime(animationName, time, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { - if (frame === void 0) { frame = 0; } - var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { - if (progress === void 0) { progress = 0.0; } - var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * @internal - */ - Animation.prototype.getBlendState = function (type, name, target) { - if (!(type in this._blendStates)) { - this._blendStates[type] = {}; - } - var blendStates = this._blendStates[type]; - if (!(name in blendStates)) { - var blendState = blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState); - blendState.target = target; - } - return blendStates[name]; - }; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态。 - * @param animationName - 动画状态名称。 - * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.getState = function (animationName, layer) { - if (layer === void 0) { layer = -1; } - var i = this._animationStates.length; - while (i--) { - var animationState = this._animationStates[i]; - if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { - return animationState; - } - } - return null; - }; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.hasAnimation = function (animationName) { - return animationName in this._animations; - }; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - Animation.prototype.getStates = function () { - return this._animationStates; - }; - Object.defineProperty(Animation.prototype, "isPlaying", { - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState.isPlaying) { - return true; - } - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "isCompleted", { - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (!animationState.isCompleted) { - return false; - } - } - return this._animationStates.length > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationName", { - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationNames", { - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animations", { - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animations; - }, - set: function (value) { - if (this._animations === value) { - return; - } - this._animationNames.length = 0; - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in value) { - this._animationNames.push(k); - this._animations[k] = value[k]; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationConfig", { - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - this._animationConfig.clear(); - return this._animationConfig; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationState", { - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState; - }, - enumerable: true, - configurable: true - }); - return Animation; - }(dragonBones.BaseObject)); - dragonBones.Animation = Animation; -})(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 animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationState = /** @class */ (function (_super) { - __extends(AnimationState, _super); - function AnimationState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._boneMask = []; - _this._boneTimelines = []; - _this._boneBlendTimelines = []; - _this._slotTimelines = []; - _this._slotBlendTimelines = []; - _this._constraintTimelines = []; - _this._animationTimelines = []; - _this._poseTimelines = []; - /** - * @internal - */ - _this._actionTimeline = null; // Initial value. - _this._zOrderTimeline = null; // Initial value. - return _this; - } - AnimationState.toString = function () { - return "[class dragonBones.AnimationState]"; - }; - AnimationState.prototype._onClear = function () { - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { - var timeline = _l[_k]; - var animationState = timeline.target; - if (animationState._parent === this) { - animationState._fadeState = 1; - animationState._subFadeState = 1; - animationState._parent = null; - } - timeline.returnToPool(); - } - if (this._actionTimeline !== null) { - this._actionTimeline.returnToPool(); - } - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.returnToPool(); - } - this.actionEnabled = false; - this.additive = false; - this.displayControl = false; - this.resetToPose = false; - this.blendType = 0 /* None */; - this.playTimes = 1; - this.layer = 0; - this.timeScale = 1.0; - this._weight = 1.0; - this.parameterX = 0.0; - this.parameterY = 0.0; - this.positionX = 0.0; - this.positionY = 0.0; - this.autoFadeOutTime = 0.0; - this.fadeTotalTime = 0.0; - this.name = ""; - this.group = ""; - this._timelineDirty = 2; - this._playheadState = 0; - this._fadeState = -1; - this._subFadeState = -1; - this._position = 0.0; - this._duration = 0.0; - this._fadeTime = 0.0; - this._time = 0.0; - this._fadeProgress = 0.0; - this._weightResult = 0.0; - this._boneMask.length = 0; - this._boneTimelines.length = 0; - this._boneBlendTimelines.length = 0; - this._slotTimelines.length = 0; - this._slotBlendTimelines.length = 0; - this._constraintTimelines.length = 0; - this._animationTimelines.length = 0; - this._poseTimelines.length = 0; - // this._bonePoses.clear(); - this._animationData = null; // - this._armature = null; // - this._actionTimeline = null; // - this._zOrderTimeline = null; - this._activeChildA = null; - this._activeChildB = null; - this._parent = null; - }; - AnimationState.prototype._updateTimelines = function () { - { // Update constraint timelines. - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); - if (timelineDatas !== null) { - for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { - var timelineData = timelineDatas_1[_b]; - switch (timelineData.type) { - case 30 /* IKConstraint */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.target = constraint; - timeline.init(this._armature, this, timelineData); - this._constraintTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { // Pose timeline. - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.target = constraint; - timeline.init(this._armature, this, null); - this._constraintTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - }; - AnimationState.prototype._updateBoneAndSlotTimelines = function () { - { // Update bone and surface timelines. - var boneTimelines = {}; - // Create bone timelines map. - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var timelineName = timeline.target.target.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - var timelineName = timeline.target.target.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - // - for (var _d = 0, _e = this._armature.getBones(); _d < _e.length; _d++) { - var bone = _e[_d]; - var timelineName = bone.name; - if (!this.containsBoneMask(timelineName)) { - continue; - } - if (timelineName in boneTimelines) { // Remove bone timeline from map. - delete boneTimelines[timelineName]; - } - else { // Create new bone timeline. - var timelineDatas = this._animationData.getBoneTimelines(timelineName); - var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); - if (timelineDatas !== null) { - for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { - var timelineData = timelineDatas_2[_f]; - switch (timelineData.type) { - case 10 /* BoneAll */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 11 /* BoneTranslate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 12 /* BoneRotate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 13 /* BoneScale */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 60 /* BoneAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); - timeline.init(this._armature, this, timelineData); - this._boneBlendTimelines.push(timeline); - break; - } - case 50 /* Surface */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); - timeline.init(this._armature, this, timelineData); - this._boneBlendTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { // Pose timeline. - if (bone._boneData.type === 0 /* Bone */) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, null); - this._boneTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - else { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); - timeline.init(this._armature, this, null); - this._boneBlendTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - for (var k in boneTimelines) { // Remove bone timelines. - for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { - var timeline = _h[_g]; - var index = this._boneTimelines.indexOf(timeline); - if (index >= 0) { - this._boneTimelines.splice(index, 1); - timeline.returnToPool(); - } - index = this._boneBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._boneBlendTimelines.splice(index, 1); - timeline.returnToPool(); - } - } - } - } - { // Update slot timelines. - var slotTimelines = {}; - var ffdFlags = []; - // Create slot timelines map. - for (var _j = 0, _k = this._slotTimelines; _j < _k.length; _j++) { - var timeline = _k[_j]; - var timelineName = timeline.target.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - for (var _l = 0, _m = this._slotBlendTimelines; _l < _m.length; _l++) { - var timeline = _m[_l]; - var timelineName = timeline.target.target.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - // - for (var _o = 0, _p = this._armature.getSlots(); _o < _p.length; _o++) { - var slot = _p[_o]; - var boneName = slot.parent.name; - if (!this.containsBoneMask(boneName)) { - continue; - } - var timelineName = slot.name; - if (timelineName in slotTimelines) { // Remove slot timeline from map. - delete slotTimelines[timelineName]; - } - else { // Create new slot timeline. - var displayIndexFlag = false; - var colorFlag = false; - ffdFlags.length = 0; - var timelineDatas = this._animationData.getSlotTimelines(timelineName); - if (timelineDatas !== null) { - for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { - var timelineData = timelineDatas_3[_q]; - switch (timelineData.type) { - case 20 /* SlotDisplay */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - displayIndexFlag = true; - break; - } - case 23 /* SlotZIndex */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); - timeline.init(this._armature, this, timelineData); - this._slotBlendTimelines.push(timeline); - break; - } - case 21 /* SlotColor */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - colorFlag = true; - break; - } - case 22 /* SlotDeform */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); - timeline.init(this._armature, this, timelineData); - if (timeline.target !== null) { - this._slotBlendTimelines.push(timeline); - ffdFlags.push(timeline.geometryOffset); - } - else { - timeline.returnToPool(); - } - break; - } - case 24 /* SlotAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); - timeline.init(this._armature, this, timelineData); - this._slotBlendTimelines.push(timeline); - break; - } - default: - break; - } - } - } - if (this.resetToPose) { // Pose timeline. - if (!displayIndexFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (!colorFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayFrame = slot.getDisplayFrameAt(i); - if (displayFrame.deformVertices.length === 0) { - continue; - } - var geometryData = displayFrame.getGeometryData(); - if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.geometryOffset = geometryData.offset; // - timeline.displayFrame = displayFrame; // - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); - timeline.init(this._armature, this, null); - this._slotBlendTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - } - for (var k in slotTimelines) { // Remove slot timelines. - for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { - var timeline = _s[_r]; - var index = this._slotTimelines.indexOf(timeline); - if (index >= 0) { - this._slotTimelines.splice(index, 1); - timeline.returnToPool(); - } - index = this._slotBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._slotBlendTimelines.splice(index, 1); - timeline.returnToPool(); - } - } - } - } - }; - AnimationState.prototype._advanceFadeTime = function (passedTime) { - var isFadeOut = this._fadeState > 0; - if (this._subFadeState < 0) { // Fade start event. - this._subFadeState = 0; - var eventActive = this._parent === null && this.actionEnabled; - if (eventActive) { - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - if (passedTime < 0.0) { - passedTime = -passedTime; - } - this._fadeTime += passedTime; - if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. - this._subFadeState = 1; - this._fadeProgress = isFadeOut ? 0.0 : 1.0; - } - else if (this._fadeTime > 0.0) { // Fading. - this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); - } - else { // Before fade. - this._fadeProgress = isFadeOut ? 1.0 : 0.0; - } - if (this._subFadeState > 0) { // Fade complete event. - if (!isFadeOut) { - this._playheadState |= 1; // x1 - this._fadeState = 0; - } - var eventActive = this._parent === null && this.actionEnabled; - if (eventActive) { - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - }; - /** - * @internal - */ - AnimationState.prototype.init = function (armature, animationData, animationConfig) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationData = animationData; - // - this.resetToPose = animationConfig.resetToPose; - this.additive = animationConfig.additive; - this.displayControl = animationConfig.displayControl; - this.actionEnabled = animationConfig.actionEnabled; - this.blendType = animationData.blendType; - this.layer = animationConfig.layer; - this.playTimes = animationConfig.playTimes; - this.timeScale = animationConfig.timeScale; - this.fadeTotalTime = animationConfig.fadeInTime; - this.autoFadeOutTime = animationConfig.autoFadeOutTime; - this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; - this.group = animationConfig.group; - // - this._weight = animationConfig.weight; - if (animationConfig.pauseFadeIn) { - this._playheadState = 2; // 10 - } - else { - this._playheadState = 3; // 11 - } - if (animationConfig.duration < 0.0) { - this._position = 0.0; - this._duration = this._animationData.duration; - if (animationConfig.position !== 0.0) { - if (this.timeScale >= 0.0) { - this._time = animationConfig.position; - } - else { - this._time = animationConfig.position - this._duration; - } - } - else { - this._time = 0.0; - } - } - else { - this._position = animationConfig.position; - this._duration = animationConfig.duration; - this._time = 0.0; - } - if (this.timeScale < 0.0 && this._time === 0.0) { - this._time = -0.000001; // Turn to end. - } - if (this.fadeTotalTime <= 0.0) { - this._fadeProgress = 0.999999; // Make different. - } - if (animationConfig.boneMask.length > 0) { - this._boneMask.length = animationConfig.boneMask.length; - for (var i = 0, l = this._boneMask.length; i < l; ++i) { - this._boneMask[i] = animationConfig.boneMask[i]; - } - } - this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); - this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); - this._actionTimeline.currentTime = this._time; - if (this._actionTimeline.currentTime < 0.0) { - this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; - } - if (this._animationData.zOrderTimeline !== null) { - this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); - this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); - } - }; - /** - * @internal - */ - AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { - // Update fade time. - if (this._fadeState !== 0 || this._subFadeState !== 0) { - this._advanceFadeTime(passedTime); - } - // Update time. - if (this._playheadState === 3) { // 11 - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - this._time += passedTime; - } - // Update timeline. - if (this._timelineDirty !== 0) { - if (this._timelineDirty === 2) { - this._updateTimelines(); - } - this._timelineDirty = 0; - this._updateBoneAndSlotTimelines(); - } - var isBlendDirty = this._fadeState !== 0 || this._subFadeState === 0; - var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; - var isUpdateTimeline = true; - var isUpdateBoneTimeline = true; - var time = this._time; - this._weightResult = this._weight * this._fadeProgress; - if (this._parent !== null) { - this._weightResult *= this._parent._weightResult; - } - if (this._actionTimeline.playState <= 0) { // Update main timeline. - this._actionTimeline.update(time); - } - if (this._weight === 0.0) { - return; - } - if (isCacheEnabled) { // Cache time internval. - var internval = cacheFrameRate * 2.0; - this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; - } - if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { // Update zOrder timeline. - this._zOrderTimeline.update(time); - } - if (isCacheEnabled) { // Update cache. - var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint - if (this._armature._cacheFrameIndex === cacheFrameIndex) { // Same cache. - isUpdateTimeline = false; - isUpdateBoneTimeline = false; - } - else { - this._armature._cacheFrameIndex = cacheFrameIndex; - if (this._animationData.cachedFrames[cacheFrameIndex]) { // Cached. - isUpdateBoneTimeline = false; - } - else { // Cache. - this._animationData.cachedFrames[cacheFrameIndex] = true; - } - } - } - if (isUpdateTimeline) { - var isBlend = false; - var prevTarget = null; // - if (isUpdateBoneTimeline) { - for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { - var timeline = this._boneTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (timeline.target !== prevTarget) { - var blendState = timeline.target; - isBlend = blendState.update(this); - prevTarget = blendState; - if (blendState.dirty === 1) { - var pose = blendState.target.animationPose; - pose.x = 0.0; - pose.y = 0.0; - pose.rotation = 0.0; - pose.skew = 0.0; - pose.scaleX = 1.0; - pose.scaleY = 1.0; - } - } - if (isBlend) { - timeline.blend(isBlendDirty); - } - } - } - for (var i = 0, l = this._boneBlendTimelines.length; i < l; ++i) { - var timeline = this._boneBlendTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (timeline.target.update(this)) { - timeline.blend(isBlendDirty); - } - } - if (this.displayControl) { - for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { - var timeline = this._slotTimelines[i]; - if (timeline.playState <= 0) { - var slot = timeline.target; - var displayController = slot.displayController; - if (displayController === null || - displayController === this.name || - displayController === this.group) { - timeline.update(time); - } - } - } - } - for (var i = 0, l = this._slotBlendTimelines.length; i < l; ++i) { - var timeline = this._slotBlendTimelines[i]; - if (timeline.playState <= 0) { - var blendState = timeline.target; - timeline.update(time); - if (blendState.update(this)) { - timeline.blend(isBlendDirty); - } - } - } - for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { - var timeline = this._constraintTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - } - if (this._animationTimelines.length > 0) { - var dL = 100.0; - var dR = 100.0; - var leftState = null; - var rightState = null; - for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { - var timeline = this._animationTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (this.blendType === 1 /* E1D */) { // TODO - var animationState = timeline.target; - var d = this.parameterX - animationState.positionX; - if (d >= 0.0) { - if (d < dL) { - dL = d; - leftState = animationState; - } - } - else { - if (-d < dR) { - dR = -d; - rightState = animationState; - } - } - } - } - if (leftState !== null) { - if (this._activeChildA !== leftState) { - if (this._activeChildA !== null) { - this._activeChildA.weight = 0.0; - } - this._activeChildA = leftState; - this._activeChildA.activeTimeline(); - } - if (this._activeChildB !== rightState) { - if (this._activeChildB !== null) { - this._activeChildB.weight = 0.0; - } - this._activeChildB = rightState; - } - leftState.weight = dR / (dL + dR); - if (rightState) { - rightState.weight = 1.0 - leftState.weight; - } - } - } - } - if (this._fadeState === 0) { - if (this._subFadeState > 0) { - this._subFadeState = 0; - if (this._poseTimelines.length > 0) { // Remove pose timelines. - for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var index = this._boneTimelines.indexOf(timeline); - if (index >= 0) { - this._boneTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._boneBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._boneBlendTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._slotTimelines.indexOf(timeline); - if (index >= 0) { - this._slotTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._slotBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._slotBlendTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._constraintTimelines.indexOf(timeline); - if (index >= 0) { - this._constraintTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - } - this._poseTimelines.length = 0; - } - } - if (this._actionTimeline.playState > 0) { - if (this.autoFadeOutTime >= 0.0) { // Auto fade out. - this.fadeOut(this.autoFadeOutTime); - } - } - } - }; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.play = function () { - this._playheadState = 3; // 11 - }; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.stop = function () { - this._playheadState &= 1; // 0x - }; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { - if (pausePlayhead === void 0) { pausePlayhead = true; } - if (fadeOutTime < 0.0) { - fadeOutTime = 0.0; - } - if (pausePlayhead) { - this._playheadState &= 2; // x0 - } - if (this._fadeState > 0) { - if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { // If the animation is already in fade out, the new fade out will be ignored. - return; - } - } - else { - this._fadeState = 1; - this._subFadeState = -1; - if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { - this._fadeProgress = 0.000001; // Modify fade progress to different value. - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.fadeOut(); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.fadeOut(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.fadeOut(); - } - for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.fadeOut(); - } - for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.fadeOut(); - } - for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { - var timeline = _l[_k]; - timeline.fadeOut(); - // - var animaitonState = timeline.target; - animaitonState.fadeOut(999999.0, true); - } - } - this.displayControl = false; // - this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; - this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); - }; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.containsBoneMask = function (boneName) { - return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; - }; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.addBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = this._armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this._boneMask.indexOf(boneName) < 0) { // Add mixing - this._boneMask.push(boneName); - } - if (recursive) { // Add recursive mixing. - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this._boneMask.indexOf(boneName); - if (index >= 0) { // Remove mixing. - this._boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = this._armature.getBone(boneName); - if (currentBone !== null) { - var bones = this._armature.getBones(); - if (this._boneMask.length > 0) { // Remove recursive mixing. - for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { - var bone = bones_1[_i]; - var index_1 = this._boneMask.indexOf(bone.name); - if (index_1 >= 0 && currentBone.contains(bone)) { - this._boneMask.splice(index_1, 1); - } - } - } - else { // Add unrecursive mixing. - for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { - var bone = bones_2[_a]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeAllBoneMask = function () { - this._boneMask.length = 0; - this._timelineDirty = 1; - }; - /** - * @private - */ - AnimationState.prototype.addState = function (animationState, timelineDatas) { - if (timelineDatas === void 0) { timelineDatas = null; } - if (timelineDatas !== null) { - for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { - var timelineData = timelineDatas_4[_i]; - switch (timelineData.type) { - case 40 /* AnimationProgress */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - if (this.blendType !== 0 /* None */) { - var animaitonTimelineData = timelineData; - animationState.positionX = animaitonTimelineData.x; - animationState.positionY = animaitonTimelineData.y; - animationState.weight = 0.0; - } - animationState._parent = this; - this.resetToPose = false; - break; - } - case 41 /* AnimationWeight */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - case 42 /* AnimationParameter */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - default: - break; - } - } - } - if (animationState._parent === null) { - animationState._parent = this; - } - }; - /** - * @internal - */ - AnimationState.prototype.activeTimeline = function () { - for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.dirty = true; - timeline.currentTime = -1.0; - } - }; - Object.defineProperty(AnimationState.prototype, "isFadeIn", { - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState < 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeOut", { - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeComplete", { - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState === 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isPlaying", { - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isCompleted", { - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.playState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "totalTime", { - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentTime", { - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentTime; - }, - set: function (value) { - var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); - if (value < 0 || this._duration < value) { - value = (value % this._duration) + currentPlayTimes * this._duration; - if (value < 0) { - value += this._duration; - } - } - if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && - value === this._duration && this._parent === null) { - value = this._duration - 0.000001; // - } - if (this._time === value) { - return; - } - this._time = value; - this._actionTimeline.setCurrentTime(this._time); - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.playState = -1; - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.playState = -1; - } - for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.playState = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "weight", { - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - get: function () { - return this._weight; - }, - set: function (value) { - if (this._weight === value) { - return; - } - this._weight = value; - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.dirty = true; - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.dirty = true; - } - for (var _d = 0, _e = this._slotBlendTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.dirty = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "animationData", { - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animationData; - }, - enumerable: true, - configurable: true - }); - return AnimationState; - }(dragonBones.BaseObject)); - dragonBones.AnimationState = AnimationState; - /** - * @internal - */ - var BlendState = /** @class */ (function (_super) { - __extends(BlendState, _super); - function BlendState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BlendState.toString = function () { - return "[class dragonBones.BlendState]"; - }; - BlendState.prototype._onClear = function () { - this.reset(); - this.target = null; - }; - BlendState.prototype.update = function (animationState) { - var animationLayer = animationState.layer; - var animationWeight = animationState._weightResult; - if (this.dirty > 0) { - if (this.leftWeight > 0.0) { - if (this.layer !== animationLayer) { - if (this.layerWeight >= this.leftWeight) { - this.dirty++; - this.layer = animationLayer; - this.leftWeight = 0.0; - this.blendWeight = 0.0; - return false; - } - this.layer = animationLayer; - this.leftWeight -= this.layerWeight; - this.layerWeight = 0.0; - } - animationWeight *= this.leftWeight; - this.dirty++; - this.blendWeight = animationWeight; - this.layerWeight += this.blendWeight; - return true; - } - return false; - } - this.dirty++; - this.layer = animationLayer; - this.leftWeight = 1.0; - this.blendWeight = animationWeight; - this.layerWeight = animationWeight; - return true; - }; - BlendState.prototype.reset = function () { - this.dirty = 0; - this.layer = 0; - this.leftWeight = 0.0; - this.layerWeight = 0.0; - this.blendWeight = 0.0; - }; - BlendState.BONE_TRANSFORM = "boneTransform"; - BlendState.BONE_ALPHA = "boneAlpha"; - BlendState.SURFACE = "surface"; - BlendState.SLOT_DEFORM = "slotDeform"; - BlendState.SLOT_ALPHA = "slotAlpha"; - BlendState.SLOT_Z_INDEX = "slotZIndex"; - return BlendState; - }(dragonBones.BaseObject)); - dragonBones.BlendState = BlendState; -})(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) { - /** - * @internal - */ - var TimelineState = /** @class */ (function (_super) { - __extends(TimelineState, _super); - function TimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineState.prototype._onClear = function () { - this.dirty = false; - this.playState = -1; - this.currentPlayTimes = -1; - this.currentTime = -1.0; - this.target = null; - this._isTween = false; - this._valueOffset = 0; - this._frameValueOffset = 0; - this._frameOffset = 0; - this._frameRate = 0; - this._frameCount = 0; - this._frameIndex = -1; - this._frameRateR = 0.0; - this._position = 0.0; - this._duration = 0.0; - this._timeScale = 1.0; - this._timeOffset = 0.0; - this._animationData = null; // - this._timelineData = null; // - this._armature = null; // - this._animationState = null; // - this._actionTimeline = null; // - this._frameArray = null; // - this._valueArray = null; // - this._timelineArray = null; // - this._frameIndices = null; // - }; - TimelineState.prototype._setCurrentTime = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._actionTimeline !== null && this._frameCount <= 1) { // No frame or only one frame. - this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; - this.currentPlayTimes = 1; - this.currentTime = this._actionTimeline.currentTime; - } - else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { // Action timeline or has scale and offset. - var playTimes = this._animationState.playTimes; - var totalTime = playTimes * this._duration; - passedTime *= this._timeScale; - if (this._timeOffset !== 0.0) { - passedTime += this._timeOffset * this._animationData.duration; - } - if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { - if (this.playState <= 0 && this._animationState._playheadState === 3) { - this.playState = 1; - } - this.currentPlayTimes = playTimes; - if (passedTime < 0.0) { - this.currentTime = 0.0; - } - else { - this.currentTime = this.playState === 1 ? this._duration + 0.000001 : this._duration; // Precision problem - } - } - else { - if (this.playState !== 0 && this._animationState._playheadState === 3) { - this.playState = 0; - } - if (passedTime < 0.0) { - passedTime = -passedTime; - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = this._duration - (passedTime % this._duration); - } - else { - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = passedTime % this._duration; - } - } - this.currentTime += this._position; - } - else { // Multi frames. - this.playState = this._actionTimeline.playState; - this.currentPlayTimes = this._actionTimeline.currentPlayTimes; - this.currentTime = this._actionTimeline.currentTime; - } - if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { - return false; - } - // Clear frame flag when timeline start or loopComplete. - if ((prevState < 0 && this.playState !== prevState) || - (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { - this._frameIndex = -1; - } - return true; - }; - TimelineState.prototype.init = function (armature, animationState, timelineData) { - this._armature = armature; - this._animationState = animationState; - this._timelineData = timelineData; - this._actionTimeline = this._animationState._actionTimeline; - if (this === this._actionTimeline) { - this._actionTimeline = null; // - } - this._animationData = this._animationState.animationData; - // - this._frameRate = this._animationData.parent.frameRate; - this._frameRateR = 1.0 / this._frameRate; - this._position = this._animationState._position; - this._duration = this._animationState._duration; - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. - this._frameArray = dragonBonesData.frameArray; - this._timelineArray = dragonBonesData.timelineArray; - this._frameIndices = dragonBonesData.frameIndices; - // - this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; - this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; - this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; - this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; - } - }; - TimelineState.prototype.fadeOut = function () { - this.dirty = false; - }; - TimelineState.prototype.update = function (passedTime) { - if (this._setCurrentTime(passedTime)) { - if (this._frameCount > 1) { - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - this._frameIndex = frameIndex; - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - this._onArriveAtFrame(); - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { // May be pose timeline. - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - } - this._onArriveAtFrame(); - } - if (this._isTween || this.dirty) { - this._onUpdateFrame(); - } - } - }; - TimelineState.prototype.blend = function (_isDirty) { - }; - return TimelineState; - }(dragonBones.BaseObject)); - dragonBones.TimelineState = TimelineState; - /** - * @internal - */ - var TweenTimelineState = /** @class */ (function (_super) { - __extends(TweenTimelineState, _super); - function TweenTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { - var value = progress; - switch (tweenType) { - case 3 /* QuadIn */: - value = Math.pow(progress, 2.0); - break; - case 4 /* QuadOut */: - value = 1.0 - Math.pow(1.0 - progress, 2.0); - break; - case 5 /* QuadInOut */: - value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); - break; - } - return (value - progress) * easing + progress; - }; - TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { - if (progress <= 0.0) { - return 0.0; - } - else if (progress >= 1.0) { - return 1.0; - } - var isOmited = count > 0; - var segmentCount = count + 1; // + 2 - 1 - var valueIndex = Math.floor(progress * segmentCount); - var fromValue = 0.0; - var toValue = 0.0; - if (isOmited) { - fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; - toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; - } - else { - fromValue = samples[offset + valueIndex - 1]; - toValue = samples[offset + valueIndex]; - } - return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; - }; - TweenTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._tweenType = 0 /* None */; - this._curveCount = 0; - this._framePosition = 0.0; - this._frameDurationR = 0.0; - this._tweenEasing = 0.0; - this._tweenProgress = 0.0; - this._valueScale = 1.0; - }; - TweenTimelineState.prototype._onArriveAtFrame = function () { - if (this._frameCount > 1 && - (this._frameIndex !== this._frameCount - 1 || - this._animationState.playTimes === 0 || - this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { - this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; - this._isTween = this._tweenType !== 0 /* None */; - if (this._isTween) { - if (this._tweenType === 2 /* Curve */) { - this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; - } - else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { - this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; - } - } - else { - this.dirty = true; - } - this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; - if (this._frameIndex === this._frameCount - 1) { - this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); - } - else { - var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; - var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; - if (frameDuration > 0) { - this._frameDurationR = 1.0 / frameDuration; - } - else { - this._frameDurationR = 0.0; - } - } - } - else { - this.dirty = true; - this._isTween = false; - } - }; - TweenTimelineState.prototype._onUpdateFrame = function () { - if (this._isTween) { - this.dirty = true; - this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; - if (this._tweenType === 2 /* Curve */) { - this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); - } - else if (this._tweenType !== 1 /* Line */) { - this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); - } - } - }; - return TweenTimelineState; - }(TimelineState)); - dragonBones.TweenTimelineState = TweenTimelineState; - /** - * @internal - */ - var SingleValueTimelineState = /** @class */ (function (_super) { - __extends(SingleValueTimelineState, _super); - function SingleValueTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SingleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._current = 0.0; - this._difference = 0.0; - this._result = 0.0; - }; - SingleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + 1; - if (valueScale === 1.0) { - this._current = valueArray[valueOffset]; - this._difference = valueArray[nextValueOffset] - this._current; - } - else { - this._current = valueArray[valueOffset] * valueScale; - this._difference = valueArray[nextValueOffset] * valueScale - this._current; - } - } - else { - this._result = valueArray[valueOffset] * valueScale; - } - } - else { - this._result = 0.0; - } - }; - SingleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._result = this._current + this._difference * this._tweenProgress; - } - }; - return SingleValueTimelineState; - }(TweenTimelineState)); - dragonBones.SingleValueTimelineState = SingleValueTimelineState; - /** - * @internal - */ - var DoubleValueTimelineState = /** @class */ (function (_super) { - __extends(DoubleValueTimelineState, _super); - function DoubleValueTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - DoubleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._currentA = 0.0; - this._currentB = 0.0; - this._differenceA = 0.0; - this._differenceB = 0.0; - this._resultA = 0.0; - this._resultB = 0.0; - }; - DoubleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + 2; - if (valueScale === 1.0) { - this._currentA = valueArray[valueOffset]; - this._currentB = valueArray[valueOffset + 1]; - this._differenceA = valueArray[nextValueOffset] - this._currentA; - this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; - } - else { - this._currentA = valueArray[valueOffset] * valueScale; - this._currentB = valueArray[valueOffset + 1] * valueScale; - this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; - this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; - } - } - else { - this._resultA = valueArray[valueOffset] * valueScale; - this._resultB = valueArray[valueOffset + 1] * valueScale; - } - } - else { - this._resultA = 0.0; - this._resultB = 0.0; - } - }; - DoubleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._resultA = this._currentA + this._differenceA * this._tweenProgress; - this._resultB = this._currentB + this._differenceB * this._tweenProgress; - } - }; - return DoubleValueTimelineState; - }(TweenTimelineState)); - dragonBones.DoubleValueTimelineState = DoubleValueTimelineState; - /** - * @internal - */ - var MutilpleValueTimelineState = /** @class */ (function (_super) { - __extends(MutilpleValueTimelineState, _super); - function MutilpleValueTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rd = []; - return _this; - } - MutilpleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._valueCount = 0; - this._rd.length = 0; - }; - MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - var valueCount = this._valueCount; - var rd = this._rd; - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + valueCount; - if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; - } - } - } - else if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i]; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] * valueScale; - } - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = 0.0; - } - } - }; - MutilpleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - var valueCount = this._valueCount; - var valueScale = this._valueScale; - var tweenProgress = this._tweenProgress; - var valueArray = this._valueArray; - var rd = this._rd; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; - if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; - } - } - } - }; - return MutilpleValueTimelineState; - }(TweenTimelineState)); - dragonBones.MutilpleValueTimelineState = MutilpleValueTimelineState; -})(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) { - /** - * @internal - */ - var ActionTimelineState = /** @class */ (function (_super) { - __extends(ActionTimelineState, _super); - function ActionTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ActionTimelineState.toString = function () { - return "[class dragonBones.ActionTimelineState]"; - }; - ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { - var eventDispatcher = this._armature.eventDispatcher; - if (this._animationState.actionEnabled) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; - var actionCount = this._frameArray[frameOffset + 1]; - var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. - for (var i = 0; i < actionCount; ++i) { - var actionIndex = this._frameArray[frameOffset + 2 + i]; - var action = actions[actionIndex]; - if (action.type === 0 /* Play */) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._bufferAction(eventObject, true); - } - else { - var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; - if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - } - }; - ActionTimelineState.prototype._onArriveAtFrame = function () { }; - ActionTimelineState.prototype._onUpdateFrame = function () { }; - ActionTimelineState.prototype.update = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._setCurrentTime(passedTime)) { - var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; - var eventDispatcher = this._armature.eventDispatcher; - if (prevState < 0) { - if (this.playState !== prevState) { - if (this._animationState.displayControl && this._animationState.resetToPose) { // Reset zorder to pose. - this._armature._sortZOrder(null, 0); - } - prevPlayTimes = this.currentPlayTimes; - if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = dragonBones.EventObject.START; - eventObject.armature = this._armature; - eventObject.animationState = this._animationState; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - else { - return; - } - } - var isReverse = this._animationState.timeScale < 0.0; - var loopCompleteEvent = null; - var completeEvent = null; - if (eventActive && this.currentPlayTimes !== prevPlayTimes) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { - loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; - loopCompleteEvent.armature = this._armature; - loopCompleteEvent.animationState = this._animationState; - } - if (this.playState > 0) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { - completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - completeEvent.type = dragonBones.EventObject.COMPLETE; - completeEvent.armature = this._armature; - completeEvent.animationState = this._animationState; - } - } - } - if (this._frameCount > 1) { - var timelineData = this._timelineData; - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { // Arrive at frame. - var crossedFrameIndex = this._frameIndex; - this._frameIndex = frameIndex; - if (this._timelineArray !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - if (isReverse) { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - if (this.currentPlayTimes === prevPlayTimes) { // Start. - if (crossedFrameIndex === frameIndex) { // Uncrossed. - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { // Support interval play. - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event after first frame. - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - else { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { // Start. - if (prevTime <= framePosition) { // Crossed. - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - } - else if (crossedFrameIndex === frameIndex) { // Uncrossed. - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - if (crossedFrameIndex < this._frameCount - 1) { - crossedFrameIndex++; - } - else { - crossedFrameIndex = 0; - } - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration // - ) { // Support interval play. - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event before first frame. - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - } - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - // Arrive at frame. - var framePosition = this._frameArray[this._frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { // Start. - if (prevTime <= framePosition) { - this._onCrossFrame(this._frameIndex); - } - } - else if (this._position <= framePosition) { // Loop complete. - if (!isReverse && loopCompleteEvent !== null) { // Add loop complete event before first frame. - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - this._onCrossFrame(this._frameIndex); - } - } - } - if (loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - } - if (completeEvent !== null) { - this._armature._dragonBones.bufferEvent(completeEvent); - } - } - }; - ActionTimelineState.prototype.setCurrentTime = function (value) { - this._setCurrentTime(value); - this._frameIndex = -1; - }; - return ActionTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ActionTimelineState = ActionTimelineState; - /** - * @internal - */ - var ZOrderTimelineState = /** @class */ (function (_super) { - __extends(ZOrderTimelineState, _super); - function ZOrderTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ZOrderTimelineState.toString = function () { - return "[class dragonBones.ZOrderTimelineState]"; - }; - ZOrderTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var count = this._frameArray[this._frameOffset + 1]; - if (count > 0) { - this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); - } - else { - this._armature._sortZOrder(null, 0); - } - } - }; - ZOrderTimelineState.prototype._onUpdateFrame = function () { }; - return ZOrderTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ZOrderTimelineState = ZOrderTimelineState; - /** - * @internal - */ - var BoneAllTimelineState = /** @class */ (function (_super) { - __extends(BoneAllTimelineState, _super); - function BoneAllTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneAllTimelineState.toString = function () { - return "[class dragonBones.BoneAllTimelineState]"; - }; - BoneAllTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); - this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); - } - if (this._timelineData === null) { // Pose. - this._rd[4] = 1.0; - this._rd[5] = 1.0; - } - }; - BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = 6; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneAllTimelineState.prototype.fadeOut = function () { - this.dirty = false; - this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); - this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); - }; - BoneAllTimelineState.prototype.blend = function (isDirty) { - var valueScale = this._armature.armatureData.scale; - var rd = this._rd; - // - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.x += rd[0] * blendWeight * valueScale; - result.y += rd[1] * blendWeight * valueScale; - result.rotation += rd[2] * blendWeight; - result.skew += rd[3] * blendWeight; - result.scaleX += (rd[4] - 1.0) * blendWeight; - result.scaleY += (rd[5] - 1.0) * blendWeight; - } - else { - result.x = rd[0] * blendWeight * valueScale; - result.y = rd[1] * blendWeight * valueScale; - result.rotation = rd[2] * blendWeight; - result.skew = rd[3] * blendWeight; - result.scaleX = (rd[4] - 1.0) * blendWeight + 1.0; // - result.scaleY = (rd[5] - 1.0) * blendWeight + 1.0; // - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneAllTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.BoneAllTimelineState = BoneAllTimelineState; - /** - * @internal - */ - var BoneTranslateTimelineState = /** @class */ (function (_super) { - __extends(BoneTranslateTimelineState, _super); - function BoneTranslateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTranslateTimelineState.toString = function () { - return "[class dragonBones.BoneTranslateTimelineState]"; - }; - BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneTranslateTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.x += this._resultA * blendWeight; - result.y += this._resultB * blendWeight; - } - else if (blendWeight !== 1.0) { - result.x = this._resultA * blendWeight; - result.y = this._resultB * blendWeight; - } - else { - result.x = this._resultA; - result.y = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneTranslateTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; - /** - * @internal - */ - var BoneRotateTimelineState = /** @class */ (function (_super) { - __extends(BoneRotateTimelineState, _super); - function BoneRotateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneRotateTimelineState.toString = function () { - return "[class dragonBones.BoneRotateTimelineState]"; - }; - BoneRotateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); - this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); - } - }; - BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneRotateTimelineState.prototype.fadeOut = function () { - this.dirty = false; - this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); - this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); - }; - BoneRotateTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.rotation += this._resultA * blendWeight; - result.skew += this._resultB * blendWeight; - } - else if (blendWeight !== 1.0) { - result.rotation = this._resultA * blendWeight; - result.skew = this._resultB * blendWeight; - } - else { - result.rotation = this._resultA; - result.skew = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneRotateTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; - /** - * @internal - */ - var BoneScaleTimelineState = /** @class */ (function (_super) { - __extends(BoneScaleTimelineState, _super); - function BoneScaleTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneScaleTimelineState.toString = function () { - return "[class dragonBones.BoneScaleTimelineState]"; - }; - BoneScaleTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { // Pose. - this._resultA = 1.0; - this._resultB = 1.0; - } - }; - BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneScaleTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.scaleX += (this._resultA - 1.0) * blendWeight; - result.scaleY += (this._resultB - 1.0) * blendWeight; - } - else if (blendWeight !== 1.0) { - result.scaleX = (this._resultA - 1.0) * blendWeight + 1.0; - result.scaleY = (this._resultB - 1.0) * blendWeight + 1.0; - } - else { - result.scaleX = this._resultA; - result.scaleY = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneScaleTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; - /** - * @internal - */ - var SurfaceTimelineState = /** @class */ (function (_super) { - __extends(SurfaceTimelineState, _super); - function SurfaceTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SurfaceTimelineState.toString = function () { - return "[class dragonBones.SurfaceTimelineState]"; - }; - SurfaceTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._deformCount = 0; - this._deformOffset = 0; - this._sameValueOffset = 0; - }; - SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; - var frameIntArray = dragonBonesData.frameIntArray; - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = dragonBonesData.frameFloatArray; - this._rd.length = this._valueCount * 2; - } - else { - this._deformCount = this.target.target._deformVertices.length; - } - }; - SurfaceTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var surface = blendState.target; - var blendWeight = blendState.blendWeight; - var result = surface._deformVertices; - var valueArray = this._valueArray; - if (valueArray !== null) { - var valueCount = this._valueCount; - var deformOffset = this._deformOffset; - var sameValueOffset = this._sameValueOffset; - var rd = this._rd; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < deformOffset) { - value = valueArray[sameValueOffset + i]; - } - else if (i < deformOffset + valueCount) { - value = rd[i - deformOffset]; - } - else { - value = valueArray[sameValueOffset + i - valueCount]; - } - if (blendState.dirty > 1) { - result[i] += value * blendWeight; - } - else { - result[i] = value * blendWeight; - } - } - } - else if (blendState.dirty === 1) { - for (var i = 0; i < this._deformCount; ++i) { - result[i] = 0.0; - } - } - if (isDirty || this.dirty) { - this.dirty = false; - surface._transformDirty = true; - } - }; - return SurfaceTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.SurfaceTimelineState = SurfaceTimelineState; - /** - * @internal - */ - var AlphaTimelineState = /** @class */ (function (_super) { - __extends(AlphaTimelineState, _super); - function AlphaTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AlphaTimelineState.toString = function () { - return "[class dragonBones.AlphaTimelineState]"; - }; - AlphaTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { // Pose. - this._result = 1.0; - } - }; - AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.01; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - AlphaTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var alphaTarget = blendState.target; - var blendWeight = blendState.blendWeight; - if (blendState.dirty > 1) { - alphaTarget._alpha += this._result * blendWeight; - if (alphaTarget._alpha > 1.0) { - alphaTarget._alpha = 1.0; - } - } - else { - alphaTarget._alpha = this._result * blendWeight; - } - if (isDirty || this.dirty) { - this.dirty = false; - this._armature._alphaDirty = true; - } - }; - return AlphaTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AlphaTimelineState = AlphaTimelineState; - /** - * @internal - */ - var SlotDisplayTimelineState = /** @class */ (function (_super) { - __extends(SlotDisplayTimelineState, _super); - function SlotDisplayTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotDisplayTimelineState.toString = function () { - return "[class dragonBones.SlotDisplayTimelineState]"; - }; - SlotDisplayTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var slot = this.target; - var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; - if (slot.displayIndex !== displayIndex) { - slot._setDisplayIndex(displayIndex, true); - } - } - }; - SlotDisplayTimelineState.prototype._onUpdateFrame = function () { - }; - return SlotDisplayTimelineState; - }(dragonBones.TimelineState)); - dragonBones.SlotDisplayTimelineState = SlotDisplayTimelineState; - /** - * @internal - */ - var SlotColorTimelineState = /** @class */ (function (_super) { - __extends(SlotColorTimelineState, _super); - function SlotColorTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._difference = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - SlotColorTimelineState.toString = function () { - return "[class dragonBones.SlotColorTimelineState]"; - }; - SlotColorTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; - var colorArray = dragonBonesData.colorArray; - var frameIntArray = dragonBonesData.frameIntArray; - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; - var colorOffset = frameIntArray[valueOffset]; - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bounds bug. - } - if (this._isTween) { - this._current[0] = colorArray[colorOffset++]; - this._current[1] = colorArray[colorOffset++]; - this._current[2] = colorArray[colorOffset++]; - this._current[3] = colorArray[colorOffset++]; - this._current[4] = colorArray[colorOffset++]; - this._current[5] = colorArray[colorOffset++]; - this._current[6] = colorArray[colorOffset++]; - this._current[7] = colorArray[colorOffset++]; - if (this._frameIndex === this._frameCount - 1) { - colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; - } - else { - colorOffset = frameIntArray[valueOffset + 1]; - } - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bounds bug. - } - this._difference[0] = colorArray[colorOffset++] - this._current[0]; - this._difference[1] = colorArray[colorOffset++] - this._current[1]; - this._difference[2] = colorArray[colorOffset++] - this._current[2]; - this._difference[3] = colorArray[colorOffset++] - this._current[3]; - this._difference[4] = colorArray[colorOffset++] - this._current[4]; - this._difference[5] = colorArray[colorOffset++] - this._current[5]; - this._difference[6] = colorArray[colorOffset++] - this._current[6]; - this._difference[7] = colorArray[colorOffset++] - this._current[7]; - } - else { - this._result[0] = colorArray[colorOffset++] * 0.01; - this._result[1] = colorArray[colorOffset++] * 0.01; - this._result[2] = colorArray[colorOffset++] * 0.01; - this._result[3] = colorArray[colorOffset++] * 0.01; - this._result[4] = colorArray[colorOffset++]; - this._result[5] = colorArray[colorOffset++]; - this._result[6] = colorArray[colorOffset++]; - this._result[7] = colorArray[colorOffset++]; - } - } - else { // Pose. - var slot = this.target; - var color = slot.slotData.color; - this._result[0] = color.alphaMultiplier; - this._result[1] = color.redMultiplier; - this._result[2] = color.greenMultiplier; - this._result[3] = color.blueMultiplier; - this._result[4] = color.alphaOffset; - this._result[5] = color.redOffset; - this._result[6] = color.greenOffset; - this._result[7] = color.blueOffset; - } - }; - SlotColorTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; - this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; - this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; - this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; - this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; - this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; - this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; - this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; - } - }; - SlotColorTimelineState.prototype.fadeOut = function () { - this._isTween = false; - }; - SlotColorTimelineState.prototype.update = function (passedTime) { - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._isTween || this.dirty) { - var slot = this.target; - var result = slot._colorTransform; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); - result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; - result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; - result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; - result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; - result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; - result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; - result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; - result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; - slot._colorDirty = true; - } - } - else if (this.dirty) { - this.dirty = false; - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - result.alphaMultiplier = this._result[0]; - result.redMultiplier = this._result[1]; - result.greenMultiplier = this._result[2]; - result.blueMultiplier = this._result[3]; - result.alphaOffset = this._result[4]; - result.redOffset = this._result[5]; - result.greenOffset = this._result[6]; - result.blueOffset = this._result[7]; - slot._colorDirty = true; - } - } - } - }; - return SlotColorTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.SlotColorTimelineState = SlotColorTimelineState; - /** - * @internal - */ - var SlotZIndexTimelineState = /** @class */ (function (_super) { - __extends(SlotZIndexTimelineState, _super); - function SlotZIndexTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotZIndexTimelineState.toString = function () { - return "[class dragonBones.SlotZIndexTimelineState]"; - }; - SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { // Pose. - var blendState = this.target; - var slot = blendState.target; - this._result = slot.slotData.zIndex; - } - }; - SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - SlotZIndexTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var slot = blendState.target; - var blendWeight = blendState.blendWeight; - if (blendState.dirty > 1) { - slot._zIndex += this._result * blendWeight; - } - else { - slot._zIndex = this._result * blendWeight; - } - if (isDirty || this.dirty) { - this.dirty = false; - this._armature._zIndexDirty = true; - } - }; - return SlotZIndexTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.SlotZIndexTimelineState = SlotZIndexTimelineState; - /** - * @internal - */ - var DeformTimelineState = /** @class */ (function (_super) { - __extends(DeformTimelineState, _super); - function DeformTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - DeformTimelineState.toString = function () { - return "[class dragonBones.DeformTimelineState]"; - }; - DeformTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.geometryOffset = 0; - this.displayFrame = null; - this._deformCount = 0; - this._deformOffset = 0; - this._sameValueOffset = 0; - }; - DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - var dragonBonesData = this._animationData.parent.parent; - var frameIntArray = dragonBonesData.frameIntArray; - var slot = this.target.target; - this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; - if (this.geometryOffset < 0) { - this.geometryOffset += 65536; // Fixed out of bounds bug. - } - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayFrame = slot.getDisplayFrameAt(i); - var geometryData = displayFrame.getGeometryData(); - if (geometryData === null) { - continue; - } - if (geometryData.offset === this.geometryOffset) { - this.displayFrame = displayFrame; - this.displayFrame.updateDeformVertices(); - break; - } - } - if (this.displayFrame === null) { - this.returnToPool(); // - return; - } - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = dragonBonesData.frameFloatArray; - this._rd.length = this._valueCount * 2; - } - else { - this._deformCount = this.displayFrame.deformVertices.length; - } - }; - DeformTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var slot = blendState.target; - var blendWeight = blendState.blendWeight; - var result = this.displayFrame.deformVertices; - var valueArray = this._valueArray; - if (valueArray !== null) { - var valueCount = this._valueCount; - var deformOffset = this._deformOffset; - var sameValueOffset = this._sameValueOffset; - var rd = this._rd; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < deformOffset) { - value = valueArray[sameValueOffset + i]; - } - else if (i < deformOffset + valueCount) { - value = rd[i - deformOffset]; - } - else { - value = valueArray[sameValueOffset + i - valueCount]; - } - if (blendState.dirty > 1) { - result[i] += value * blendWeight; - } - else { - result[i] = value * blendWeight; - } - } - } - else if (blendState.dirty === 1) { - for (var i = 0; i < this._deformCount; ++i) { - result[i] = 0.0; - } - } - if (isDirty || this.dirty) { - this.dirty = false; - if (slot._geometryData === this.displayFrame.getGeometryData()) { - slot._verticesDirty = true; - } - } - }; - return DeformTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.DeformTimelineState = DeformTimelineState; - /** - * @internal - */ - var IKConstraintTimelineState = /** @class */ (function (_super) { - __extends(IKConstraintTimelineState, _super); - function IKConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintTimelineState.toString = function () { - return "[class dragonBones.IKConstraintTimelineState]"; - }; - IKConstraintTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var ikConstraint = this.target; - if (this._timelineData !== null) { - ikConstraint._bendPositive = this._currentA > 0.0; - ikConstraint._weight = this._currentB; - } - else { - var ikConstraintData = ikConstraint._constraintData; - ikConstraint._bendPositive = ikConstraintData.bendPositive; - ikConstraint._weight = ikConstraintData.weight; - } - ikConstraint.invalidUpdate(); - this.dirty = false; - }; - IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.01; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return IKConstraintTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; - /** - * @internal - */ - var AnimationProgressTimelineState = /** @class */ (function (_super) { - __extends(AnimationProgressTimelineState, _super); - function AnimationProgressTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationProgressTimelineState.toString = function () { - return "[class dragonBones.AnimationProgressTimelineState]"; - }; - AnimationProgressTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.currentTime = this._result * animationState.totalTime; - } - this.dirty = false; - }; - AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationProgressTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AnimationProgressTimelineState = AnimationProgressTimelineState; - /** - * @internal - */ - var AnimationWeightTimelineState = /** @class */ (function (_super) { - __extends(AnimationWeightTimelineState, _super); - function AnimationWeightTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationWeightTimelineState.toString = function () { - return "[class dragonBones.AnimationWeightTimelineState]"; - }; - AnimationWeightTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.weight = this._result; - } - this.dirty = false; - }; - AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationWeightTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AnimationWeightTimelineState = AnimationWeightTimelineState; - /** - * @internal - */ - var AnimationParametersTimelineState = /** @class */ (function (_super) { - __extends(AnimationParametersTimelineState, _super); - function AnimationParametersTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationParametersTimelineState.toString = function () { - return "[class dragonBones.AnimationParametersTimelineState]"; - }; - AnimationParametersTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.parameterX = this._resultA; - animationState.parameterY = this._resultB; - } - this.dirty = false; - }; - AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationParametersTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.AnimationParametersTimelineState = AnimationParametersTimelineState; -})(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 properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EventObject = /** @class */ (function (_super) { - __extends(EventObject, _super); - function EventObject() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @internal - * @private - */ - EventObject.actionDataToInstance = function (data, instance, armature) { - if (data.type === 0 /* Play */) { - instance.type = EventObject.FRAME_EVENT; - } - else { - instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; - } - instance.name = data.name; - instance.armature = armature; - instance.actionData = data; - instance.data = data.data; - if (data.bone !== null) { - instance.bone = armature.getBone(data.bone.name); - } - if (data.slot !== null) { - instance.slot = armature.getSlot(data.slot.name); - } - }; - EventObject.toString = function () { - return "[class dragonBones.EventObject]"; - }; - EventObject.prototype._onClear = function () { - this.time = 0.0; - this.type = ""; - this.name = ""; - this.armature = null; - this.bone = null; - this.slot = null; - this.animationState = null; - this.actionData = null; - this.data = null; - }; - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.START = "start"; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.LOOP_COMPLETE = "loopComplete"; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.COMPLETE = "complete"; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN = "fadeIn"; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN_COMPLETE = "fadeInComplete"; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT = "fadeOut"; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FRAME_EVENT = "frameEvent"; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.SOUND_EVENT = "soundEvent"; - return EventObject; - }(dragonBones.BaseObject)); - dragonBones.EventObject = EventObject; -})(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 DataParser = /** @class */ (function () { - function DataParser() { - } - DataParser._getArmatureType = function (value) { - switch (value.toLowerCase()) { - case "stage": - return 2 /* Stage */; - case "armature": - return 0 /* Armature */; - case "movieclip": - return 1 /* MovieClip */; - default: - return 0 /* Armature */; - } - }; - DataParser._getBoneType = function (value) { - switch (value.toLowerCase()) { - case "bone": - return 0 /* Bone */; - case "surface": - return 1 /* Surface */; - default: - return 0 /* Bone */; - } - }; - DataParser._getPositionMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "percent": - return 1 /* Percent */; - case "fixed": - return 0 /* Fixed */; - default: - return 1 /* Percent */; - } - }; - DataParser._getSpacingMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "length": - return 0 /* Length */; - case "percent": - return 2 /* Percent */; - case "fixed": - return 1 /* Fixed */; - default: - return 0 /* Length */; - } - }; - DataParser._getRotateMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "tangent": - return 0 /* Tangent */; - case "chain": - return 1 /* Chain */; - case "chainscale": - return 2 /* ChainScale */; - default: - return 0 /* Tangent */; - } - }; - DataParser._getDisplayType = function (value) { - switch (value.toLowerCase()) { - case "image": - return 0 /* Image */; - case "mesh": - return 2 /* Mesh */; - case "armature": - return 1 /* Armature */; - case "boundingbox": - return 3 /* BoundingBox */; - case "path": - return 4 /* Path */; - default: - return 0 /* Image */; - } - }; - DataParser._getBoundingBoxType = function (value) { - switch (value.toLowerCase()) { - case "rectangle": - return 0 /* Rectangle */; - case "ellipse": - return 1 /* Ellipse */; - case "polygon": - return 2 /* Polygon */; - default: - return 0 /* Rectangle */; - } - }; - DataParser._getBlendMode = function (value) { - switch (value.toLowerCase()) { - case "normal": - return 0 /* Normal */; - case "add": - return 1 /* Add */; - case "alpha": - return 2 /* Alpha */; - case "darken": - return 3 /* Darken */; - case "difference": - return 4 /* Difference */; - case "erase": - return 5 /* Erase */; - case "hardlight": - return 6 /* HardLight */; - case "invert": - return 7 /* Invert */; - case "layer": - return 8 /* Layer */; - case "lighten": - return 9 /* Lighten */; - case "multiply": - return 10 /* Multiply */; - case "overlay": - return 11 /* Overlay */; - case "screen": - return 12 /* Screen */; - case "subtract": - return 13 /* Subtract */; - default: - return 0 /* Normal */; - } - }; - DataParser._getAnimationBlendType = function (value) { - switch (value.toLowerCase()) { - case "none": - return 0 /* None */; - case "1d": - return 1 /* E1D */; - default: - return 0 /* None */; - } - }; - DataParser._getActionType = function (value) { - switch (value.toLowerCase()) { - case "play": - return 0 /* Play */; - case "frame": - return 10 /* Frame */; - case "sound": - return 11 /* Sound */; - default: - return 0 /* Play */; - } - }; - DataParser.DATA_VERSION_2_3 = "2.3"; - DataParser.DATA_VERSION_3_0 = "3.0"; - DataParser.DATA_VERSION_4_0 = "4.0"; - DataParser.DATA_VERSION_4_5 = "4.5"; - DataParser.DATA_VERSION_5_0 = "5.0"; - DataParser.DATA_VERSION_5_5 = "5.5"; - DataParser.DATA_VERSION_5_6 = "5.6"; - DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_6; - DataParser.DATA_VERSIONS = [ - DataParser.DATA_VERSION_4_0, - DataParser.DATA_VERSION_4_5, - DataParser.DATA_VERSION_5_0, - DataParser.DATA_VERSION_5_5, - DataParser.DATA_VERSION_5_6 - ]; - DataParser.TEXTURE_ATLAS = "textureAtlas"; - DataParser.SUB_TEXTURE = "SubTexture"; - DataParser.FORMAT = "format"; - DataParser.IMAGE_PATH = "imagePath"; - DataParser.WIDTH = "width"; - DataParser.HEIGHT = "height"; - DataParser.ROTATED = "rotated"; - DataParser.FRAME_X = "frameX"; - DataParser.FRAME_Y = "frameY"; - DataParser.FRAME_WIDTH = "frameWidth"; - DataParser.FRAME_HEIGHT = "frameHeight"; - DataParser.DRADON_BONES = "dragonBones"; - DataParser.USER_DATA = "userData"; - DataParser.ARMATURE = "armature"; - DataParser.CANVAS = "canvas"; - DataParser.BONE = "bone"; - DataParser.SURFACE = "surface"; - DataParser.SLOT = "slot"; - DataParser.CONSTRAINT = "constraint"; - DataParser.SKIN = "skin"; - DataParser.DISPLAY = "display"; - DataParser.FRAME = "frame"; - DataParser.IK = "ik"; - DataParser.PATH_CONSTRAINT = "path"; - DataParser.ANIMATION = "animation"; - DataParser.TIMELINE = "timeline"; - DataParser.FFD = "ffd"; - DataParser.TRANSLATE_FRAME = "translateFrame"; - DataParser.ROTATE_FRAME = "rotateFrame"; - DataParser.SCALE_FRAME = "scaleFrame"; - DataParser.DISPLAY_FRAME = "displayFrame"; - DataParser.COLOR_FRAME = "colorFrame"; - DataParser.DEFAULT_ACTIONS = "defaultActions"; - DataParser.ACTIONS = "actions"; - DataParser.EVENTS = "events"; - DataParser.INTS = "ints"; - DataParser.FLOATS = "floats"; - DataParser.STRINGS = "strings"; - DataParser.TRANSFORM = "transform"; - DataParser.PIVOT = "pivot"; - DataParser.AABB = "aabb"; - DataParser.COLOR = "color"; - DataParser.VERSION = "version"; - DataParser.COMPATIBLE_VERSION = "compatibleVersion"; - DataParser.FRAME_RATE = "frameRate"; - DataParser.TYPE = "type"; - DataParser.SUB_TYPE = "subType"; - DataParser.NAME = "name"; - DataParser.PARENT = "parent"; - DataParser.TARGET = "target"; - DataParser.STAGE = "stage"; - DataParser.SHARE = "share"; - DataParser.PATH = "path"; - DataParser.LENGTH = "length"; - DataParser.DISPLAY_INDEX = "displayIndex"; - DataParser.Z_ORDER = "zOrder"; - DataParser.Z_INDEX = "zIndex"; - DataParser.BLEND_MODE = "blendMode"; - DataParser.INHERIT_TRANSLATION = "inheritTranslation"; - DataParser.INHERIT_ROTATION = "inheritRotation"; - DataParser.INHERIT_SCALE = "inheritScale"; - DataParser.INHERIT_REFLECTION = "inheritReflection"; - DataParser.INHERIT_ANIMATION = "inheritAnimation"; - DataParser.INHERIT_DEFORM = "inheritDeform"; - DataParser.SEGMENT_X = "segmentX"; - DataParser.SEGMENT_Y = "segmentY"; - DataParser.BEND_POSITIVE = "bendPositive"; - DataParser.CHAIN = "chain"; - DataParser.WEIGHT = "weight"; - DataParser.BLEND_TYPE = "blendType"; - DataParser.FADE_IN_TIME = "fadeInTime"; - DataParser.PLAY_TIMES = "playTimes"; - DataParser.SCALE = "scale"; - DataParser.OFFSET = "offset"; - DataParser.POSITION = "position"; - DataParser.DURATION = "duration"; - DataParser.TWEEN_EASING = "tweenEasing"; - DataParser.TWEEN_ROTATE = "tweenRotate"; - DataParser.TWEEN_SCALE = "tweenScale"; - DataParser.CLOCK_WISE = "clockwise"; - DataParser.CURVE = "curve"; - DataParser.SOUND = "sound"; - DataParser.EVENT = "event"; - DataParser.ACTION = "action"; - DataParser.X = "x"; - DataParser.Y = "y"; - DataParser.SKEW_X = "skX"; - DataParser.SKEW_Y = "skY"; - DataParser.SCALE_X = "scX"; - DataParser.SCALE_Y = "scY"; - DataParser.VALUE = "value"; - DataParser.ROTATE = "rotate"; - DataParser.SKEW = "skew"; - DataParser.ALPHA = "alpha"; - DataParser.ALPHA_OFFSET = "aO"; - DataParser.RED_OFFSET = "rO"; - DataParser.GREEN_OFFSET = "gO"; - DataParser.BLUE_OFFSET = "bO"; - DataParser.ALPHA_MULTIPLIER = "aM"; - DataParser.RED_MULTIPLIER = "rM"; - DataParser.GREEN_MULTIPLIER = "gM"; - DataParser.BLUE_MULTIPLIER = "bM"; - DataParser.UVS = "uvs"; - DataParser.VERTICES = "vertices"; - DataParser.TRIANGLES = "triangles"; - DataParser.WEIGHTS = "weights"; - DataParser.SLOT_POSE = "slotPose"; - DataParser.BONE_POSE = "bonePose"; - DataParser.BONES = "bones"; - DataParser.POSITION_MODE = "positionMode"; - DataParser.SPACING_MODE = "spacingMode"; - DataParser.ROTATE_MODE = "rotateMode"; - DataParser.SPACING = "spacing"; - DataParser.ROTATE_OFFSET = "rotateOffset"; - DataParser.ROTATE_MIX = "rotateMix"; - DataParser.TRANSLATE_MIX = "translateMix"; - DataParser.TARGET_DISPLAY = "targetDisplay"; - DataParser.CLOSED = "closed"; - DataParser.CONSTANT_SPEED = "constantSpeed"; - DataParser.VERTEX_COUNT = "vertexCount"; - DataParser.LENGTHS = "lengths"; - DataParser.GOTO_AND_PLAY = "gotoAndPlay"; - DataParser.DEFAULT_NAME = "default"; - return DataParser; - }()); - dragonBones.DataParser = DataParser; -})(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 ObjectDataParser = /** @class */ (function (_super) { - __extends(ObjectDataParser, _super); - function ObjectDataParser() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rawTextureAtlasIndex = 0; - _this._rawBones = []; - _this._data = null; // - _this._armature = null; // - _this._bone = null; // - _this._geometry = null; // - _this._slot = null; // - _this._skin = null; // - _this._mesh = null; // - _this._animation = null; // - _this._timeline = null; // - _this._rawTextureAtlases = null; - _this._frameValueType = 0 /* Step */; - _this._defaultColorOffset = -1; - _this._prevClockwise = 0; - _this._prevRotation = 0.0; - _this._frameDefaultValue = 0.0; - _this._frameValueScale = 1.0; - _this._helpMatrixA = new dragonBones.Matrix(); - _this._helpMatrixB = new dragonBones.Matrix(); - _this._helpTransform = new dragonBones.Transform(); - _this._helpColorTransform = new dragonBones.ColorTransform(); - _this._helpPoint = new dragonBones.Point(); - _this._helpArray = []; - _this._intArray = []; - _this._floatArray = []; - _this._frameIntArray = []; - _this._frameFloatArray = []; - _this._frameArray = []; - _this._timelineArray = []; - _this._colorArray = []; - _this._cacheRawMeshes = []; - _this._cacheMeshes = []; - _this._actionFrames = []; - _this._weightSlotPose = {}; - _this._weightBonePoses = {}; - _this._cacheBones = {}; - _this._slotChildActions = {}; - return _this; - } - ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "boolean") { - return value; - } - else if (type === "string") { - switch (value) { - case "0": - case "NaN": - case "": - case "false": - case "null": - case "undefined": - return false; - default: - return true; - } - } - else { - return !!value; - } - } - return defaultValue; - }; - ObjectDataParser._getNumber = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - if (value === null || value === "NaN") { - return defaultValue; - } - return +value || 0; - } - return defaultValue; - }; - ObjectDataParser._getString = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "string") { - return value; - } - return String(value); - } - return defaultValue; - }; - ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { - var l_t = 1.0 - t; - var powA = l_t * l_t; - var powB = t * t; - var kA = l_t * powA; - var kB = 3.0 * t * powA; - var kC = 3.0 * l_t * powB; - var kD = t * powB; - result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; - result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; - }; - ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { - var curveCount = curve.length; - if (curveCount % 3 === 1) { - var stepIndex = -2; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 - stepIndex += 6; - } - var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; - var x1 = isInCurve ? curve[stepIndex] : 0.0; - var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; - var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - return true; - } - else { - var stepIndex = 0; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while (curve[stepIndex + 6] < t) { // stepIndex + 3 * 2 - stepIndex += 6; - } - var x1 = curve[stepIndex]; - var y1 = curve[stepIndex + 1]; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = curve[stepIndex + 6]; - var y4 = curve[stepIndex + 7]; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - return false; - } - }; - ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { - if (dragonBones.DataParser.EVENT in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.SOUND in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); - } - if (dragonBones.DataParser.ACTION in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); - } - if (dragonBones.DataParser.EVENTS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); - } - }; - ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { - var actionOffset = this._armature.actions.length; - var actions = this._parseActionData(rawData, type, bone, slot); - var frameIndex = 0; - var frame = null; - for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { - var action = actions_2[_i]; - this._armature.addAction(action, false); - } - if (this._actionFrames.length === 0) { // First frame. - frame = new ActionFrame(); - frame.frameStart = 0; - this._actionFrames.push(frame); - frame = null; - } - for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { // Get same frame. - var eachFrame = _b[_a]; - if (eachFrame.frameStart === frameStart) { - frame = eachFrame; - break; - } - else if (eachFrame.frameStart > frameStart) { - break; - } - frameIndex++; - } - if (frame === null) { // Create and cache frame. - frame = new ActionFrame(); - frame.frameStart = frameStart; - this._actionFrames.splice(frameIndex, 0, frame); - } - for (var i = 0; i < actions.length; ++i) { // Cache action offsets. - frame.actions.push(actionOffset + i); - } - }; - ObjectDataParser.prototype._parseArmature = function (rawData, scale) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); - armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); - armature.scale = scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); - } - else { - armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); - } - if (armature.frameRate === 0) { // Data error. - armature.frameRate = 24; - } - this._armature = armature; - if (dragonBones.DataParser.CANVAS in rawData) { - var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; - var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); - if (dragonBones.DataParser.COLOR in rawCanvas) { - canvas.hasBackground = true; - } - else { - canvas.hasBackground = false; - } - canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); - canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; - canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; - canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; - canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; - armature.canvas = canvas; - } - if (dragonBones.DataParser.AABB in rawData) { - var rawAABB = rawData[dragonBones.DataParser.AABB]; - armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; - armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; - armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; - armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; - } - if (dragonBones.DataParser.BONE in rawData) { - var rawBones = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { - var rawBone = rawBones_1[_i]; - var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); - var bone = this._parseBone(rawBone); - if (parentName.length > 0) { // Get bone parent. - var parent_1 = armature.getBone(parentName); - if (parent_1 !== null) { - bone.parent = parent_1; - } - else { // Cache. - if (!(parentName in this._cacheBones)) { - this._cacheBones[parentName] = []; - } - this._cacheBones[parentName].push(bone); - } - } - if (bone.name in this._cacheBones) { - for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { - var child = _b[_a]; - child.parent = bone; - } - delete this._cacheBones[bone.name]; - } - armature.addBone(bone); - this._rawBones.push(bone); // Cache raw bones sort. - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawIKS = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { - var rawIK = rawIKS_1[_c]; - var constraint = this._parseIKConstraint(rawIK); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - armature.sortBones(); - if (dragonBones.DataParser.SLOT in rawData) { - var zOrder = 0; - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { - var rawSlot = rawSlots_1[_d]; - armature.addSlot(this._parseSlot(rawSlot, zOrder++)); - } - } - if (dragonBones.DataParser.SKIN in rawData) { - var rawSkins = rawData[dragonBones.DataParser.SKIN]; - for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { - var rawSkin = rawSkins_1[_e]; - armature.addSkin(this._parseSkin(rawSkin)); - } - } - if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { - var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; - for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { - var rawPath = rawPaths_1[_f]; - var constraint = this._parsePathConstraint(rawPath); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { // Link mesh. - var rawData_1 = this._cacheRawMeshes[i]; - var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); - if (shareName.length === 0) { - continue; - } - var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - if (skinName.length === 0) { // - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; - if (shareMesh === null) { - continue; // Error. - } - var mesh = this._cacheMeshes[i]; - mesh.geometry.shareFrom(shareMesh.geometry); - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; - for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { - var rawAnimation = rawAnimations_1[_g]; - var animation = this._parseAnimation(rawAnimation); - armature.addAnimation(animation); - } - } - if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); - for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { - var action = actions_3[_h]; - armature.addAction(action, true); - if (action.type === 0 /* Play */) { // Set default animation from default action. - var animation = armature.getAnimation(action.name); - if (animation !== null) { - armature.defaultAnimation = animation; - } - } - } - } - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { - var action = actions_4[_j]; - armature.addAction(action, false); - } - } - // Clear helper. - this._rawBones.length = 0; - this._cacheRawMeshes.length = 0; - this._cacheMeshes.length = 0; - this._armature = null; - for (var k in this._weightSlotPose) { - delete this._weightSlotPose[k]; - } - for (var k in this._weightBonePoses) { - delete this._weightBonePoses[k]; - } - for (var k in this._cacheBones) { - delete this._cacheBones[k]; - } - for (var k in this._slotChildActions) { - delete this._slotChildActions[k]; - } - return armature; - }; - ObjectDataParser.prototype._parseBone = function (rawData) { - var type = 0 /* Bone */; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); - } - if (type === 0 /* Bone */) { - var scale = this._armature.scale; - var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); - bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); - bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); - bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); - bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); - bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; - bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); - } - return bone; - } - var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); - surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); - surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); - this._parseGeometry(rawData, surface.geometry); - return surface; - }; - ObjectDataParser.prototype._parseIKConstraint = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); - if (bone === null) { - return null; - } - var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); - constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); - constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); - constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 0 /* IK */; - constraint.target = target; - if (chain > 0 && bone.parent !== null) { - constraint.root = bone.parent; - constraint.bone = bone; - } - else { - constraint.root = bone; - constraint.bone = null; - } - return constraint; - }; - ObjectDataParser.prototype._parsePathConstraint = function (rawData) { - var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var defaultSkin = this._armature.defaultSkin; - if (defaultSkin === null) { - return null; - } - //TODO - var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); - if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { - return null; - } - var bones = rawData[dragonBones.DataParser.BONES]; - if (bones === null || bones.length === 0) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 1 /* Path */; - constraint.pathSlot = target; - constraint.pathDisplayData = targetDisplay; - constraint.target = target.parent; - constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); - constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); - constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); - constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); - constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); - constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); - constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); - constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); - // - for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { - var boneName = bones_3[_i]; - var bone = this._armature.getBone(boneName); - if (bone !== null) { - constraint.AddBone(bone); - if (constraint.root === null) { - constraint.root = bone; - } - } - } - return constraint; - }; - ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - slot.zOrder = zOrder; - slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); - slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // - if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { - slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); - } - else { - slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); - } - if (dragonBones.DataParser.COLOR in rawData) { - slot.color = dragonBones.SlotData.createColor(); - this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - } - return slot; - }; - ObjectDataParser.prototype._parseSkin = function (rawData) { - var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); - skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (skin.name.length === 0) { - skin.name = dragonBones.DataParser.DEFAULT_NAME; - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - this._skin = skin; - for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { - var rawSlot = rawSlots_2[_i]; - var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); - var slot = this._armature.getSlot(slotName); - if (slot !== null) { - this._slot = slot; - if (dragonBones.DataParser.DISPLAY in rawSlot) { - var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; - for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { - var rawDisplay = rawDisplays_1[_a]; - if (rawDisplay) { - skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); - } - else { - skin.addDisplay(slotName, null); - } - } - } - this._slot = null; // - } - } - this._skin = null; // - } - return skin; - }; - ObjectDataParser.prototype._parseDisplay = function (rawData) { - var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); - var type = 0 /* Image */; - var display = null; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); - } - switch (type) { - case 0 /* Image */: { - var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); - imageDisplay.name = name; - imageDisplay.path = path.length > 0 ? path : name; - this._parsePivot(rawData, imageDisplay); - break; - } - case 1 /* Armature */: { - var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); - armatureDisplay.name = name; - armatureDisplay.path = path.length > 0 ? path : name; - armatureDisplay.inheritAnimation = true; - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { - var action = actions_5[_i]; - armatureDisplay.addAction(action); - } - } - else if (this._slot.name in this._slotChildActions) { - var displays = this._skin.getDisplays(this._slot.name); - if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { - for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { - var action = _b[_a]; - armatureDisplay.addAction(action); - } - delete this._slotChildActions[this._slot.name]; - } - } - break; - } - case 2 /* Mesh */: { - var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); - meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); - meshDisplay.name = name; - meshDisplay.path = path.length > 0 ? path : name; - if (dragonBones.DataParser.SHARE in rawData) { - meshDisplay.geometry.data = this._data; - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - else { - this._parseMesh(rawData, meshDisplay); - } - break; - } - case 3 /* BoundingBox */: { - var boundingBox = this._parseBoundingBox(rawData); - if (boundingBox !== null) { - var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); - boundingBoxDisplay.name = name; - boundingBoxDisplay.path = path.length > 0 ? path : name; - boundingBoxDisplay.boundingBox = boundingBox; - } - break; - } - case 4 /* Path */: { - var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; - var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); - pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); - pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); - pathDisplay.name = name; - pathDisplay.path = path.length > 0 ? path : name; - pathDisplay.curveLengths.length = rawCurveLengths.length; - for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { - pathDisplay.curveLengths[i] = rawCurveLengths[i]; - } - this._parsePath(rawData, pathDisplay); - break; - } - } - if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); - } - return display; - }; - ObjectDataParser.prototype._parsePath = function (rawData, display) { - this._parseGeometry(rawData, display.geometry); - }; - ObjectDataParser.prototype._parsePivot = function (rawData, display) { - if (dragonBones.DataParser.PIVOT in rawData) { - var rawPivot = rawData[dragonBones.DataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); - display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); - } - else { - display.pivot.x = 0.5; - display.pivot.y = 0.5; - } - }; - ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { - this._parseGeometry(rawData, mesh.geometry); - if (dragonBones.DataParser.WEIGHTS in rawData) { // Cache pose data. - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; - this._weightSlotPose[meshName] = rawSlotPose; - this._weightBonePoses[meshName] = rawBonePoses; - } - }; - ObjectDataParser.prototype._parseBoundingBox = function (rawData) { - var boundingBox = null; - var type = 0 /* Rectangle */; - if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { - type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); - } - switch (type) { - case 0 /* Rectangle */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); - break; - case 1 /* Ellipse */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); - break; - case 2 /* Polygon */: - boundingBox = this._parsePolygonBoundingBox(rawData); - break; - } - if (boundingBox !== null) { - boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); - if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { - boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); - boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); - } - } - return boundingBox; - }; - ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { - var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); - if (dragonBones.DataParser.VERTICES in rawData) { - var scale = this._armature.scale; - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertices = polygonBoundingBox.vertices; - vertices.length = rawVertices.length; - for (var i = 0, l = rawVertices.length; i < l; i += 2) { - var x = rawVertices[i] * scale; - var y = rawVertices[i + 1] * scale; - vertices[i] = x; - vertices[i + 1] = y; - // AABB. - if (i === 0) { - polygonBoundingBox.x = x; - polygonBoundingBox.y = y; - polygonBoundingBox.width = x; - polygonBoundingBox.height = y; - } - else { - if (x < polygonBoundingBox.x) { - polygonBoundingBox.x = x; - } - else if (x > polygonBoundingBox.width) { - polygonBoundingBox.width = x; - } - if (y < polygonBoundingBox.y) { - polygonBoundingBox.y = y; - } - else if (y > polygonBoundingBox.height) { - polygonBoundingBox.height = y; - } - } - } - polygonBoundingBox.width -= polygonBoundingBox.x; - polygonBoundingBox.height -= polygonBoundingBox.y; - } - else { - console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); - } - return polygonBoundingBox; - }; - ObjectDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.blendType = dragonBones.DataParser._getAnimationBlendType(ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); - animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); - animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - animation.frameIntOffset = this._frameIntArray.length; - animation.frameFloatOffset = this._frameFloatArray.length; - animation.frameOffset = this._frameArray.length; - this._animation = animation; - if (dragonBones.DataParser.FRAME in rawData) { - var rawFrames = rawData[dragonBones.DataParser.FRAME]; - var keyFrameCount = rawFrames.length; - if (keyFrameCount > 0) { - for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { - var rawFrame = rawFrames[i]; - this._parseActionDataInFrame(rawFrame, frameStart, null, null); - frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, 0 /* Step */, 0, this._parseZOrderFrame); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { - var rawTimeline = rawTimelines_1[_i]; - this._parseBoneTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SLOT]; - for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { - var rawTimeline = rawTimelines_2[_a]; - this._parseSlotTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.FFD in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.FFD]; - for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { - var rawTimeline = rawTimelines_3[_b]; - var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); - var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - if (skinName.length === 0) { // - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - this._slot = this._armature.getSlot(slotName); - this._mesh = this._armature.getMesh(skinName, slotName, displayName); - if (this._slot === null || this._mesh === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, 2 /* Float */, 0, this._parseSlotDeformFrame); - if (timeline !== null) { - this._animation.addSlotTimeline(slotName, timeline); - } - this._slot = null; // - this._mesh = null; // - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { - var rawTimeline = rawTimelines_4[_c]; - var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var constraint = this._armature.getConstraint(constraintName); - if (constraint === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, 1 /* Int */, 2, this._parseIKConstraintFrame); - if (timeline !== null) { - this._animation.addConstraintTimeline(constraintName, timeline); - } - } - } - if (this._actionFrames.length > 0) { - this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, 0 /* Step */, 0, this._parseActionFrame); - this._actionFrames.length = 0; - } - if (dragonBones.DataParser.TIMELINE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { - var rawTimeline = rawTimelines_5[_d]; - var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); - var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = null; - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 20 /* SlotDisplay */: // TODO - case 23 /* SlotZIndex */: - case 60 /* BoneAlpha */: - case 24 /* SlotAlpha */: - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - if (timelineType === 20 /* SlotDisplay */) { - this._frameValueType = 0 /* Step */; - this._frameValueScale = 1.0; - } - else { - this._frameValueType = 1 /* Int */; - if (timelineType === 23 /* SlotZIndex */) { - this._frameValueScale = 1.0; - } - else if (timelineType === 40 /* AnimationProgress */ || - timelineType === 41 /* AnimationWeight */) { - this._frameValueScale = 10000.0; - } - else { - this._frameValueScale = 100.0; - } - } - if (timelineType === 60 /* BoneAlpha */ || - timelineType === 24 /* SlotAlpha */ || - timelineType === 41 /* AnimationWeight */) { - this._frameDefaultValue = 1.0; - } - else { - this._frameDefaultValue = 0.0; - } - if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); - var animaitonTimeline = timeline; - animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); - animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 1, this._parseSingleValueFrame, timeline); - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 30 /* IKConstraint */: - case 42 /* AnimationParameter */: - if (timelineType === 30 /* IKConstraint */ || - timelineType === 42 /* AnimationParameter */) { - this._frameValueType = 1 /* Int */; - if (timelineType === 42 /* AnimationParameter */) { - this._frameValueScale = 10000.0; - } - else { - this._frameValueScale = 100.0; - } - } - else { - if (timelineType === 12 /* BoneRotate */) { - this._frameValueScale = dragonBones.Transform.DEG_RAD; - } - else { - this._frameValueScale = 1.0; - } - this._frameValueType = 2 /* Float */; - } - if (timelineType === 13 /* BoneScale */ || - timelineType === 30 /* IKConstraint */) { - this._frameDefaultValue = 1.0; - } - else { - this._frameDefaultValue = 0.0; - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 2, this._parseDoubleValueFrame); - break; - case 1 /* ZOrder */: - // TODO - break; - case 50 /* Surface */: { - var surface = this._armature.getBone(timelineName); - if (surface === null) { - continue; - } - this._geometry = surface.geometry; - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); - this._geometry = null; // - break; - } - case 22 /* SlotDeform */: { - this._geometry = null; // - for (var skinName in this._armature.skins) { - var skin = this._armature.skins[skinName]; - for (var slontName in skin.displays) { - var displays = skin.displays[slontName]; - for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { - var display = displays_1[_e]; - if (display !== null && display.name === timelineName) { - this._geometry = display.geometry; - break; - } - } - } - } - if (this._geometry === null) { - continue; - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); - this._geometry = null; // - break; - } - case 21 /* SlotColor */: - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 1 /* Int */, 1, this._parseSlotColorFrame); - break; - } - if (timeline !== null) { - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 1 /* ZOrder */: - // TODO - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 50 /* Surface */: - case 60 /* BoneAlpha */: - this._animation.addBoneTimeline(timelineName, timeline); - break; - case 20 /* SlotDisplay */: - case 21 /* SlotColor */: - case 22 /* SlotDeform */: - case 23 /* SlotZIndex */: - case 24 /* SlotAlpha */: - this._animation.addSlotTimeline(timelineName, timeline); - break; - case 30 /* IKConstraint */: - this._animation.addConstraintTimeline(timelineName, timeline); - break; - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - case 42 /* AnimationParameter */: - this._animation.addAnimationTimeline(timelineName, timeline); - break; - } - } - } - } - this._animation = null; // - return animation; - }; - ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, timelineType, frameValueType, frameValueCount, frameParser, timeline) { - if (timeline === void 0) { timeline = null; } - if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { - rawFrames = rawData[framesKey]; - } - if (rawFrames === null) { - return null; - } - var keyFrameCount = rawFrames.length; - if (keyFrameCount === 0) { - return null; - } - var frameIntArrayLength = this._frameIntArray.length; - var frameFloatArrayLength = this._frameFloatArray.length; - var timelineOffset = this._timelineArray.length; - if (timeline === null) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - } - timeline.type = timelineType; - timeline.offset = timelineOffset; - this._frameValueType = frameValueType; - this._timeline = timeline; - this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; - if (rawData !== null) { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); - } - else { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; - } - this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; - this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; - switch (this._frameValueType) { - case 0 /* Step */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; - break; - case 1 /* Int */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; - break; - case 2 /* Float */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; - break; - } - if (keyFrameCount === 1) { // Only one frame. - timeline.frameIndicesOffset = -1; - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; - } - else { - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - var frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - var rawFrame = rawFrames[iK]; - frameStart = i; // frame.frameStart; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - if (rawFrame instanceof ActionFrame) { - frameCount = this._actionFrames[iK + 1].frameStart - frameStart; - } - else { - frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; - iK++; - } - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - this._timeline = null; // - return timeline; - }; - ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (bone === null) { - return; - } - this._bone = bone; - this._slot = this._armature.getSlot(this._bone.name); - if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { - this._frameDefaultValue = 0.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, 2 /* Float */, 2, this._parseDoubleValueFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.ROTATE_FRAME in rawData) { - this._frameDefaultValue = 0.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, 2 /* Float */, 2, this._parseBoneRotateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.SCALE_FRAME in rawData) { - this._frameDefaultValue = 1.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, 2 /* Float */, 2, this._parseBoneScaleFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, 2 /* Float */, 6, this._parseBoneAllFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - this._bone = null; // - this._slot = null; // - }; - ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { - var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (slot === null) { - return; - } - var displayTimeline = null; - var colorTimeline = null; - this._slot = slot; - if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); - } - else { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); - } - if (dragonBones.DataParser.COLOR_FRAME in rawData) { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); - } - else { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); - } - if (displayTimeline !== null) { - this._animation.addSlotTimeline(slot.name, displayTimeline); - } - if (colorTimeline !== null) { - this._animation.addSlotTimeline(slot.name, colorTimeline); - } - this._slot = null; // - }; - ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - rawData; - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - this._frameArray.length += 1; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - return frameOffset; - }; - ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (frameCount > 0) { - if (dragonBones.DataParser.CURVE in rawData) { - var sampleCount = frameCount + 1; - this._helpArray.length = sampleCount; - var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); - this._frameArray.length += 1 + 1 + this._helpArray.length; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited ? sampleCount : -sampleCount; - for (var i = 0; i < sampleCount; ++i) { - this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); - } - } - else { - var noTween = -2.0; - var tweenEasing = noTween; - if (dragonBones.DataParser.TWEEN_EASING in rawData) { - tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); - } - if (tweenEasing === noTween) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - else if (tweenEasing === 0.0) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; - } - else if (tweenEasing < 0.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); - } - else if (tweenEasing <= 1.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); - } - else { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); - } - } - } - else { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { - var frameOffset = 0; - switch (this._frameValueType) { - case 0: { - frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue); - break; - } - case 1: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale); - break; - } - case 2: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 1; - this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale; - break; - } - } - return frameOffset; - }; - ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { - var frameOffset = 0; - switch (this._frameValueType) { - case 0: { - frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 2; - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue); - this._frameArray[frameOffset + 2] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue); - break; - } - case 1: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale); - this._frameIntArray[frameValueOffset + 1] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale); - break; - } - case 2: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale; - this._frameFloatArray[frameValueOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale; - break; - } - } - return frameOffset; - }; - ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - var actionCount = frame.actions.length; - this._frameArray.length += 1 + 1 + actionCount; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. - for (var i = 0; i < actionCount; ++i) { // Action offsets. - this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (dragonBones.DataParser.Z_ORDER in rawData) { - var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; - if (rawZOrder.length > 0) { - var slotCount = this._armature.sortedSlots.length; - var unchanged = new Array(slotCount - rawZOrder.length / 2); - var zOrders = new Array(slotCount); - for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { - unchanged[i_1] = 0; - } - for (var i_2 = 0; i_2 < slotCount; ++i_2) { - zOrders[i_2] = -1; - } - var originalIndex = 0; - var unchangedIndex = 0; - for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { - var slotIndex = rawZOrder[i_3]; - var zOrderOffset = rawZOrder[i_3 + 1]; - while (originalIndex !== slotIndex) { - unchanged[unchangedIndex++] = originalIndex++; - } - var index = originalIndex + zOrderOffset; - zOrders[index] = originalIndex++; - } - while (originalIndex < slotCount) { - unchanged[unchangedIndex++] = originalIndex++; - } - this._frameArray.length += 1 + slotCount; - this._frameArray[frameOffset + 1] = slotCount; - var i = slotCount; - while (i--) { - if (zOrders[i] === -1) { - this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; - } - else { - this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; - } - } - return frameOffset; - } - } - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = 0; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { - this._helpTransform.identity(); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); - } - // Modify rotation. - var rotation = this._helpTransform.rotation; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 6; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; - this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { - // Modify rotation. - var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - if (dragonBones.DataParser.VALUE in rawData) { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - } - else { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - } - this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var colorOffset = -1; - if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { - var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; - for (var k in rawColor) { // Detects the presence of color. - // tslint:disable-next-line:no-unused-expression - k; - this._parseColorTransform(rawColor, this._helpColorTransform); - colorOffset = this._colorArray.length; - this._colorArray.length += 8; - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); - colorOffset -= 8; - break; - } - } - if (colorOffset < 0) { - if (this._defaultColorOffset < 0) { - this._defaultColorOffset = colorOffset = this._colorArray.length; - this._colorArray.length += 8; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - } - colorOffset = this._defaultColorOffset; - } - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameIntOffset] = colorOffset; - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; - var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; - var weight = this._mesh.geometry.weight; - var x = 0.0; - var y = 0.0; - var iB = 0; - var iV = 0; - if (weight !== null) { - var rawSlotPose = this._weightSlotPose[meshName]; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - this._frameFloatArray.length += weight.count * 2; - iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; - } - else { - this._frameFloatArray.length += vertexCount * 2; - } - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices === null) { // Fill 0. - x = 0.0; - y = 0.0; - } - else { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - if (weight !== null) { // If mesh is skinned, transform point by bone bind pose. - var rawBonePoses = this._weightBonePoses[meshName]; - var vertexBoneCount = this._intArray[iB++]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var boneIndex = this._intArray[iB++]; - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; - } - } - else { - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { - var actions = new Array(); - if (typeof rawData === "string") { - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - action.type = type; - action.name = rawData; - action.bone = bone; - action.slot = slot; - actions.push(action); - } - else if (rawData instanceof Array) { - for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { - var rawAction = rawData_2[_i]; - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { - action.type = 0 /* Play */; - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); - } - else { - if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { - action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); - } - else { - action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); - } - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); - } - if (dragonBones.DataParser.BONE in rawAction) { - var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); - action.bone = this._armature.getBone(boneName); - } - else { - action.bone = bone; - } - if (dragonBones.DataParser.SLOT in rawAction) { - var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); - action.slot = this._armature.getSlot(slotName); - } - else { - action.slot = slot; - } - var userData = null; - if (dragonBones.DataParser.INTS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawInts = rawAction[dragonBones.DataParser.INTS]; - for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { - var rawValue = rawInts_1[_a]; - userData.addInt(rawValue); - } - } - if (dragonBones.DataParser.FLOATS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; - for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { - var rawValue = rawFloats_1[_b]; - userData.addFloat(rawValue); - } - } - if (dragonBones.DataParser.STRINGS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; - for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { - var rawValue = rawStrings_1[_c]; - userData.addString(rawValue); - } - } - action.data = userData; - actions.push(action); - } - } - return actions; - }; - ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? - rawData[dragonBones.DataParser.VERTICES] : - (dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null); - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; - var weight = this._geometry.weight; - var x = 0.0; - var y = 0.0; - if (weight !== null) { - // TODO - } - else { - this._frameFloatArray.length += vertexCount * 2; - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices !== null) { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - else { - x = 0.0; - y = 0.0; - } - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { - transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; - transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; - if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); - } - else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; - } - transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); - transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); - }; - ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { - color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; - color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; - color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; - color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); - color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); - color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); - color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); - }; - ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertexCount = Math.floor(rawVertices.length / 2); // uint - var triangleCount = 0; - var geometryOffset = this._intArray.length; - var verticesOffset = this._floatArray.length; - // - geometry.offset = geometryOffset; - geometry.data = this._data; - // - this._intArray.length += 1 + 1 + 1 + 1; - this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; - this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; - this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // - // - this._floatArray.length += vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[verticesOffset + i] = rawVertices[i]; - } - if (dragonBones.DataParser.TRIANGLES in rawData) { - var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; - triangleCount = Math.floor(rawTriangles.length / 3); // uint - // - this._intArray.length += triangleCount * 3; - for (var i = 0, l = triangleCount * 3; i < l; ++i) { - this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; - } - } - // Fill triangle count. - this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; - if (dragonBones.DataParser.UVS in rawData) { - var rawUVs = rawData[dragonBones.DataParser.UVS]; - var uvOffset = verticesOffset + vertexCount * 2; - this._floatArray.length += vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[uvOffset + i] = rawUVs[i]; - } - } - if (dragonBones.DataParser.WEIGHTS in rawData) { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var floatOffset = this._floatArray.length; - var weightBoneCount = 0; - var sortedBones = this._armature.sortedBones; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - if (dragonBones.DataParser.BONE_POSE in rawData) { - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var weightBoneIndices = new Array(); - weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint - weightBoneIndices.length = weightBoneCount; - for (var i = 0; i < weightBoneCount; ++i) { - var rawBoneIndex = rawBonePoses[i * 7]; // uint - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - weightBoneIndices[i] = rawBoneIndex; - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { - var iD = i * 2; - var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint - var x = this._floatArray[verticesOffset + iD]; - var y = this._floatArray[verticesOffset + iD + 1]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var rawBoneIndex = rawWeights[iW++]; // uint - var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint); - this._intArray[iB++] = boneIndex; - this._floatArray[iV++] = rawWeights[iW++]; - this._floatArray[iV++] = this._helpPoint.x; - this._floatArray[iV++] = this._helpPoint.y; - } - } - } - else { - var rawBones = rawData[dragonBones.DataParser.BONES]; - weightBoneCount = rawBones.length; - for (var i = 0; i < weightBoneCount; i++) { - var rawBoneIndex = rawBones[i]; - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { - var vertexBoneCount = rawWeights[iW++]; - this._intArray[iB++] = vertexBoneCount; - for (var j = 0; j < vertexBoneCount; j++) { - var boneIndex = rawWeights[iW++]; - var boneWeight = rawWeights[iW++]; - var x = rawVertices[iV++]; - var y = rawVertices[iV++]; - this._intArray[iB++] = rawBones.indexOf(boneIndex); - this._floatArray[iF++] = boneWeight; - this._floatArray[iF++] = x; - this._floatArray[iF++] = y; - } - } - } - geometry.weight = weight; - } - }; - ObjectDataParser.prototype._parseArray = function (rawData) { - // tslint:disable-next-line:no-unused-expression - rawData; - this._intArray.length = 0; - this._floatArray.length = 0; - this._frameIntArray.length = 0; - this._frameFloatArray.length = 0; - this._frameArray.length = 0; - this._timelineArray.length = 0; - this._colorArray.length = 0; - }; - ObjectDataParser.prototype._modifyArray = function () { - // Align. - if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._intArray.push(0); - } - if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameIntArray.push(0); - } - if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameArray.push(0); - } - if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { - this._timelineArray.push(0); - } - if ((this._timelineArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._colorArray.push(0); - } - var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; - var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; - var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; - var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; - var l7 = this._colorArray.length * Int16Array.BYTES_PER_ELEMENT; - var lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7; - // - var binary = new ArrayBuffer(lTotal); - var intArray = new Int16Array(binary, 0, this._intArray.length); - var floatArray = new Float32Array(binary, l1, this._floatArray.length); - var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - for (var i = 0, l = this._colorArray.length; i < l; ++i) { - colorArray[i] = this._colorArray[i]; - } - this._data.binary = binary; - this._data.intArray = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = frameArray; - this._data.timelineArray = timelineArray; - this._data.colorArray = colorArray; - this._defaultColorOffset = -1; - }; - ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined, "Data error."); - var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); - var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); - if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || - dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { - var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); - data.version = version; - data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); - if (data.frameRate === 0) { // Data error. - data.frameRate = 24; - } - if (dragonBones.DataParser.ARMATURE in rawData) { - this._data = data; - this._parseArray(rawData); - var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; - for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { - var rawArmature = rawArmatures_1[_i]; - data.addArmature(this._parseArmature(rawArmature, scale)); - } - if (!this._data.binary) { // DragonBones.webAssembly ? 0 : null; - this._modifyArray(); - } - if (dragonBones.DataParser.STAGE in rawData) { - data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); - } - else if (data.armatureNames.length > 0) { - data.stage = data.getArmature(data.armatureNames[0]); - } - this._data = null; - } - if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { - this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; - } - return data; - } - else { - console.assert(false, "Nonsupport data version: " + version + "\n" + - "Please convert DragonBones data to support version.\n" + - "Read more: https://github.com/DragonBones/Tools/"); - } - return null; - }; - ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { - if (scale === void 0) { scale = 1.0; } - console.assert(rawData !== undefined); - if (rawData === null) { - if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { - return false; - } - var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; - this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); - if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { - this._rawTextureAtlasIndex = 0; - this._rawTextureAtlases = null; - } - return true; - } - // Texture format. - textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); - textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); - textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; - textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); - if (dragonBones.DataParser.SUB_TEXTURE in rawData) { - var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; - for (var i = 0, l = rawTextures.length; i < l; ++i) { - var rawTexture = rawTextures[i]; - var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); - var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); - var textureData = textureAtlasData.createTexture(); - textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); - textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); - textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); - textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); - textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); - textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); - if (frameWidth > 0.0 && frameHeight > 0.0) { - textureData.frame = dragonBones.TextureData.createRectangle(); - textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); - textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); - textureData.frame.width = frameWidth; - textureData.frame.height = frameHeight; - } - textureAtlasData.addTexture(textureData); - } - } - return true; - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - ObjectDataParser.getInstance = function () { - if (ObjectDataParser._objectDataParserInstance === null) { - ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); - } - return ObjectDataParser._objectDataParserInstance; - }; - ObjectDataParser._objectDataParserInstance = null; - return ObjectDataParser; - }(dragonBones.DataParser)); - dragonBones.ObjectDataParser = ObjectDataParser; - /** - * @private - */ - var ActionFrame = /** @class */ (function () { - function ActionFrame() { - this.frameStart = 0; - this.actions = []; - } - return ActionFrame; - }()); - dragonBones.ActionFrame = ActionFrame; -})(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 BinaryDataParser = /** @class */ (function (_super) { - __extends(BinaryDataParser, _super); - function BinaryDataParser() { - return _super !== null && _super.apply(this, arguments) || this; - } - BinaryDataParser.prototype._inRange = function (a, min, max) { - return min <= a && a <= max; - }; - BinaryDataParser.prototype._decodeUTF8 = function (data) { - var EOF_byte = -1; - var EOF_code_point = -1; - var FATAL_POINT = 0xFFFD; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte === EOF_byte) { - if (utf8_bytes_needed !== 0) { - code_point = FATAL_POINT; - } - else { - code_point = EOF_code_point; - } - } - else { - if (utf8_bytes_needed === 0) { - if (this._inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this._inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this._inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this._inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this._inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = _byte; - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = _byte; - } - } - } - } - //Decode string - if (code_point !== null && code_point !== EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { - if (timelineData === void 0) { timelineData = null; } - var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - timeline.type = type; - timeline.offset = offset; - this._timeline = timeline; - var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - } - else { - var frameIndicesOffset = 0; - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; - } - iK++; - } - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - this._timeline = null; // - return timeline; - }; - BinaryDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.blendType = dragonBones.DataParser._getAnimationBlendType(dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); - animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); - animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - // Offsets. - var offsets = rawData[dragonBones.DataParser.OFFSET]; - animation.frameIntOffset = offsets[0]; - animation.frameFloatOffset = offsets[1]; - animation.frameOffset = offsets[2]; - this._animation = animation; - if (dragonBones.DataParser.ACTION in rawData) { - animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.BONE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var bone = this._armature.getBone(k); - if (bone === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addBoneTimeline(bone.name, timeline); - } - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var slot = this._armature.getSlot(k); - if (slot === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSlotTimeline(slot.name, timeline); - } - } - } - if (dragonBones.DataParser.CONSTRAINT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var constraint = this._armature.getConstraint(k); - if (constraint === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addConstraintTimeline(constraint.name, timeline); - } - } - } - if (dragonBones.DataParser.TIMELINE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { - var rawTimeline = rawTimelines_6[_i]; - var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); - if (timelineOffset >= 0) { - var timelineType = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); - var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = null; - if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); - var animaitonTimeline = timeline; - animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); - animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); - } - timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 1 /* ZOrder */: - // TODO - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 50 /* Surface */: - case 60 /* BoneAlpha */: - this._animation.addBoneTimeline(timelineName, timeline); - break; - case 20 /* SlotDisplay */: - case 21 /* SlotColor */: - case 22 /* SlotDeform */: - case 23 /* SlotZIndex */: - case 24 /* SlotAlpha */: - this._animation.addSlotTimeline(timelineName, timeline); - break; - case 30 /* IKConstraint */: - this._animation.addConstraintTimeline(timelineName, timeline); - break; - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - case 42 /* AnimationParameter */: - this._animation.addAnimationTimeline(timelineName, timeline); - break; - } - } - } - } - this._animation = null; - return animation; - }; - BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { - geometry.offset = rawData[dragonBones.DataParser.OFFSET]; - geometry.data = this._data; - var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; - if (weightOffset >= 0) { - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; - var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; - weight.offset = weightOffset; - for (var i = 0; i < boneCount; ++i) { - var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; - weight.addBone(this._rawBones[boneIndex]); - } - var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; - var weightCount = 0; - for (var i = 0, l = vertexCount; i < l; ++i) { - var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; - weightCount += vertexBoneCount; - boneIndicesOffset += vertexBoneCount; - } - weight.count = weightCount; - geometry.weight = weight; - } - }; - BinaryDataParser.prototype._parseArray = function (rawData) { - var offsets = rawData[dragonBones.DataParser.OFFSET]; - var l1 = offsets[1]; - var l2 = offsets[3]; - var l3 = offsets[5]; - var l4 = offsets[7]; - var l5 = offsets[9]; - var l6 = offsets[11]; - var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. - var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); - var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); - var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); - var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); - var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); - var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); - var colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. - this._data.binary = this._binary; - this._data.intArray = this._intArrayBuffer = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = this._frameArrayBuffer = frameArray; - this._data.timelineArray = this._timelineArrayBuffer = timelineArray; - this._data.colorArray = colorArray; - }; - BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); - var tag = new Uint8Array(rawData, 0, 8); - if (tag[0] !== "D".charCodeAt(0) || - tag[1] !== "B".charCodeAt(0) || - tag[2] !== "D".charCodeAt(0) || - tag[3] !== "T".charCodeAt(0)) { - console.assert(false, "Nonsupport data."); - return null; - } - var headerLength = new Uint32Array(rawData, 8, 1)[0]; - var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); - var headerString = this._decodeUTF8(headerBytes); - var header = JSON.parse(headerString); - // - this._binaryOffset = 8 + 4 + headerLength; - this._binary = rawData; - return _super.prototype.parseDragonBonesData.call(this, header, scale); - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - BinaryDataParser.getInstance = function () { - if (BinaryDataParser._binaryDataParserInstance === null) { - BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); - } - return BinaryDataParser._binaryDataParserInstance; - }; - BinaryDataParser._binaryDataParserInstance = null; - return BinaryDataParser; - }(dragonBones.ObjectDataParser)); - dragonBones.BinaryDataParser = BinaryDataParser; -})(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) { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var BaseFactory = /** @class */ (function () { - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - function BaseFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - /** - * @private - */ - this.autoSearch = false; - this._dragonBonesDataMap = {}; - this._textureAtlasDataMap = {}; - this._dragonBones = null; - this._dataParser = null; - if (BaseFactory._objectParser === null) { - BaseFactory._objectParser = new dragonBones.ObjectDataParser(); - } - if (BaseFactory._binaryParser === null) { - BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); - } - this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; - } - BaseFactory.prototype._isSupportMesh = function () { - return true; - }; - BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { - if (textureAtlasName in this._textureAtlasDataMap) { - for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { - var textureAtlasData = _a[_i]; - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - if (this.autoSearch) { // Will be search all data, if the autoSearch is true. - for (var k in this._textureAtlasDataMap) { - for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { - var textureAtlasData = _c[_b]; - if (textureAtlasData.autoSearch) { - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - } - } - return null; - }; - BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { - var dragonBonesData = null; - var armatureData = null; - if (dragonBonesName.length > 0) { - if (dragonBonesName in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - armatureData = dragonBonesData.getArmature(armatureName); - } - } - if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { // Will be search all data, if do not give a data name or the autoSearch is true. - for (var k in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[k]; - if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { - armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData !== null) { - dragonBonesName = k; - break; - } - } - } - } - if (armatureData !== null) { - dataPackage.dataName = dragonBonesName; - dataPackage.textureAtlasName = textureAtlasName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = null; - if (skinName.length > 0) { - dataPackage.skin = armatureData.getSkin(skinName); - if (dataPackage.skin === null && this.autoSearch) { - for (var k in this._dragonBonesDataMap) { - var skinDragonBonesData = this._dragonBonesDataMap[k]; - var skinArmatureData = skinDragonBonesData.getArmature(skinName); - if (skinArmatureData !== null) { - dataPackage.skin = skinArmatureData.defaultSkin; - break; - } - } - } - } - if (dataPackage.skin === null) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - return false; - }; - BaseFactory.prototype._buildBones = function (dataPackage, armature) { - for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { - var boneData = _a[_i]; - var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); - bone.init(boneData, armature); - } - }; - /** - * @private - */ - BaseFactory.prototype._buildSlots = function (dataPackage, armature) { - var currentSkin = dataPackage.skin; - var defaultSkin = dataPackage.armature.defaultSkin; - if (currentSkin === null || defaultSkin === null) { - return; - } - var skinSlots = {}; - for (var k in defaultSkin.displays) { - var displays = defaultSkin.getDisplays(k); - skinSlots[k] = displays; - } - if (currentSkin !== defaultSkin) { - for (var k in currentSkin.displays) { - var displays = currentSkin.getDisplays(k); - skinSlots[k] = displays; - } - } - for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { - var slotData = _a[_i]; - var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; - var slot = this._buildSlot(dataPackage, slotData, armature); - if (displayDatas !== null) { - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - slot.replaceRawDisplayData(displayData, i); - if (displayData !== null) { - if (dataPackage.textureAtlasName.length > 0) { - var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); - slot.replaceTextureData(textureData, i); - } - var display = this._getSlotDisplay(dataPackage, displayData, slot); - slot.replaceDisplay(display, i); - } - else { - slot.replaceDisplay(null); - } - } - } - slot._setDisplayIndex(slotData.displayIndex, true); - } - }; - BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { - var constraints = dataPackage.armature.constraints; - for (var k in constraints) { - var constraintData = constraints[k]; - // TODO more constraint type. - switch (constraintData.type) { - case 0 /* IK */: - var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - ikConstraint.init(constraintData, armature); - armature._addConstraint(ikConstraint); - break; - case 1 /* Path */: - var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); - pathConstraint.init(constraintData, armature); - armature._addConstraint(pathConstraint); - break; - default: - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - constraint.init(constraintData, armature); - armature._addConstraint(constraint); - break; - } - } - }; - BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { - return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); - }; - BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { - var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; - var display = null; - switch (displayData.type) { - case 0 /* Image */: { - var imageDisplayData = displayData; - if (imageDisplayData.texture === null) { - imageDisplayData.texture = this._getTextureData(dataName, displayData.path); - } - display = slot.rawDisplay; - break; - } - case 2 /* Mesh */: { - var meshDisplayData = displayData; - if (meshDisplayData.texture === null) { - meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); - } - if (this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 1 /* Armature */: { - var armatureDisplayData = displayData; - var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); - if (childArmature !== null) { - childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; - if (!childArmature.inheritAnimation) { - var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; - if (actions.length > 0) { - for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { - var action = actions_6[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); - eventObject.slot = slot; - slot.armature._bufferAction(eventObject, false); - } - } - else { - childArmature.animation.play(); - } - } - armatureDisplayData.armature = childArmature.armatureData; // - } - display = childArmature; - break; - } - case 3 /* BoundingBox */: - break; - default: - break; - } - return display; - }; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; - var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); - while (true) { - var textureAtlasData = this._buildTextureAtlasData(null, null); - if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { - this.addTextureAtlasData(textureAtlasData, name); - } - else { - textureAtlasData.returnToPool(); - break; - } - } - if (dragonBonesData !== null) { - this.addDragonBonesData(dragonBonesData, name); - } - return dragonBonesData; - }; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var textureAtlasData = this._buildTextureAtlasData(null, null); - this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); - this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); - this.addTextureAtlasData(textureAtlasData, name); - return textureAtlasData; - }; - /** - * - Update texture atlases. - * @param textureAtlases - The texture atlas objects. - * @param name - The texture atlas name. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 更新贴图集对象。 - * @param textureAtlases - 多个贴图集对象。 - * @param name - 贴图集名称。 - * @version DragonBones 5.7 - * @language zh_CN - */ - BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { - var textureAtlasDatas = this.getTextureAtlasData(name); - if (textureAtlasDatas !== null) { - for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { - if (i < textureAtlases.length) { - this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); - } - } - } - }; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getDragonBonesData = function (name) { - return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; - }; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addDragonBonesData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - if (name in this._dragonBonesDataMap) { - if (this._dragonBonesDataMap[name] === data) { - return; - } - console.warn("Can not add same name data: " + name); - return; - } - this._dragonBonesDataMap[name] = data; - }; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); - } - delete this._dragonBonesDataMap[name]; - } - }; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getTextureAtlasData = function (name) { - return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; - }; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addTextureAtlasData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); - if (textureAtlasList.indexOf(data) < 0) { - textureAtlasList.push(data); - } - }; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._textureAtlasDataMap) { - var textureAtlasDataList = this._textureAtlasDataMap[name]; - if (disposeData) { - for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { - var textureAtlasData = textureAtlasDataList_1[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[name]; - } - }; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { - return null; - } - return dataPackage.armature; - }; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.clear = function (disposeData) { - if (disposeData === void 0) { disposeData = true; } - for (var k in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); - } - delete this._dragonBonesDataMap[k]; - } - for (var k in this._textureAtlasDataMap) { - if (disposeData) { - var textureAtlasDataList = this._textureAtlasDataMap[k]; - for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { - var textureAtlasData = textureAtlasDataList_2[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[k]; - } - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { - console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); - return null; - } - var armature = this._buildArmature(dataPackage); - this._buildBones(dataPackage, armature); - this._buildSlots(dataPackage, armature); - this._buildConstraints(dataPackage, armature); - armature.invalidUpdate(null, true); - armature.advanceTime(0.0); // Update armature pose. - return armature; - }; - /** - * @private - */ - BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - displayIndex = slot.displayIndex; - } - if (displayIndex < 0) { - displayIndex = 0; - } - slot.replaceDisplayData(displayData, displayIndex); - if (displayData !== null) { - var display = this._getSlotDisplay(null, displayData, slot); - if (displayData.type === 0 /* Image */) { - var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; - if (rawDisplayData !== null && - rawDisplayData.type === 2 /* Mesh */) { - display = slot.meshDisplay; - } - } - slot.replaceDisplay(display, displayIndex); - } - else { - slot.replaceDisplay(null, displayIndex); - } - }; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (armatureData === null || armatureData.defaultSkin === null) { - return false; - } - var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); - this.replaceDisplay(slot, displayData, displayIndex); - return true; - }; - /** - * @private - */ - BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displayDatas = armatureData.defaultSkin.getDisplays(slotName); - if (!displayDatas) { - return false; - } - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - this.replaceDisplay(slot, displayData, i); - } - return true; - }; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { - if (isOverride === void 0) { isOverride = false; } - if (exclude === void 0) { exclude = null; } - var success = false; - var defaultSkin = skin.parent.defaultSkin; - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (exclude !== null && exclude.indexOf(slot.name) >= 0) { - continue; - } - var displayDatas = skin.getDisplays(slot.name); - if (displayDatas === null) { - if (defaultSkin !== null && skin !== defaultSkin) { - displayDatas = defaultSkin.getDisplays(slot.name); - } - if (displayDatas === null) { - if (isOverride) { - slot.displayFrameCount = 0; - } - continue; - } - } - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - slot.replaceRawDisplayData(displayData, i); - if (displayData !== null) { - slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); - } - else { - slot.replaceDisplay(null, i); - } - } - success = true; - } - return success; - }; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { - if (isOverride === void 0) { isOverride = true; } - var skinData = armatureData.defaultSkin; - if (skinData === null) { - return false; - } - if (isOverride) { - armature.animation.animations = armatureData.animations; - } - else { - var rawAnimations = armature.animation.animations; - var animations = {}; - for (var k in rawAnimations) { - animations[k] = rawAnimations[k]; - } - for (var k in armatureData.animations) { - animations[k] = armatureData.animations[k]; - } - armature.animation.animations = animations; - } - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var index = 0; - for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { - var display = _c[_b]; - if (display instanceof dragonBones.Armature) { - var displayDatas = skinData.getDisplays(slot.name); - if (displayDatas !== null && index < displayDatas.length) { - var displayData = displayDatas[index]; - if (displayData !== null && displayData.type === 1 /* Armature */) { - var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); - if (childArmatureData) { - this.replaceAnimation(display, childArmatureData, isOverride); - } - } - } - } - index++; - } - } - return true; - }; - /** - * @private - */ - BaseFactory.prototype.getAllDragonBonesData = function () { - return this._dragonBonesDataMap; - }; - /** - * @private - */ - BaseFactory.prototype.getAllTextureAtlasData = function () { - return this._textureAtlasDataMap; - }; - Object.defineProperty(BaseFactory.prototype, "clock", { - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - get: function () { - return this._dragonBones.clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseFactory.prototype, "dragonBones", { - /** - * @private - */ - get: function () { - return this._dragonBones; - }, - enumerable: true, - configurable: true - }); - BaseFactory._objectParser = null; - BaseFactory._binaryParser = null; - return BaseFactory; - }()); - dragonBones.BaseFactory = BaseFactory; - /** - * @private - */ - var BuildArmaturePackage = /** @class */ (function () { - function BuildArmaturePackage() { - this.dataName = ""; - this.textureAtlasName = ""; - this.skin = null; - } - return BuildArmaturePackage; - }()); - dragonBones.BuildArmaturePackage = BuildArmaturePackage; -})(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. - */ -if (CC_EDITOR) { - _Scene.Sandbox._globalsVerifier_loadPluginScript.ignoreNames['dragonBones'] = true; -} -var dragonBones; -(function (dragonBones) { - var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; - var DragonBonesAsset = /** @class */ (function (_super) { - __extends(DragonBonesAsset, _super); - function DragonBonesAsset() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.dragonBonesData = ""; - _this.textureAtlases = []; - _this.textures = []; - return _this; - } - __decorate([ - property - ], DragonBonesAsset.prototype, "dragonBonesData", void 0); - __decorate([ - property([cc.String]) - ], DragonBonesAsset.prototype, "textureAtlases", void 0); - __decorate([ - property([cc.Texture2D]) - ], DragonBonesAsset.prototype, "textures", void 0); - DragonBonesAsset = __decorate([ - ccclass("DragonBones.DragonBonesAsset") - ], DragonBonesAsset); - return DragonBonesAsset; - }(cc.Asset)); - dragonBones.DragonBonesAsset = DragonBonesAsset; -})(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 Cocos texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosTextureAtlasData = /** @class */ (function (_super) { - __extends(CocosTextureAtlasData, _super); - function CocosTextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._renderTexture = null; // Initial value. - return _this; - } - CocosTextureAtlasData.toString = function () { - return "[class dragonBones.CocosTextureAtlasData]"; - }; - CocosTextureAtlasData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this._renderTexture !== null) { - // this._renderTexture.dispose(); - } - this._renderTexture = null; - }; - CocosTextureAtlasData.prototype.createTexture = function () { - return dragonBones.BaseObject.borrowObject(CocosTextureData); - }; - Object.defineProperty(CocosTextureAtlasData.prototype, "renderTexture", { - /** - * - The Cocos texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._renderTexture; - }, - set: function (value) { - if (this._renderTexture === value) { - return; - } - this._renderTexture = value; - if (this._renderTexture !== null) { - for (var k in this.textures) { - var textureData = this.textures[k]; - if (textureData.renderTexture !== null) { - textureData.renderTexture.destroy(); - } - var reat = cc.rect(textureData.region.x, textureData.region.y, textureData.rotated ? textureData.region.height : textureData.region.width, textureData.rotated ? textureData.region.width : textureData.region.height); - var offset = cc.v2(); - var originSize = cc.size(reat.size.width, reat.size.height); - textureData.renderTexture = new cc.SpriteFrame(this._renderTexture, reat, textureData.rotated, offset, originSize); - } - } - else { - for (var k in this.textures) { - var textureData = this.textures[k]; - if (textureData.renderTexture !== null) { - textureData.renderTexture.destroy(); - } - textureData.renderTexture = null; - } - } - }, - enumerable: true, - configurable: true - }); - return CocosTextureAtlasData; - }(dragonBones.TextureAtlasData)); - dragonBones.CocosTextureAtlasData = CocosTextureAtlasData; - /** - * @internal - */ - var CocosTextureData = /** @class */ (function (_super) { - __extends(CocosTextureData, _super); - function CocosTextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.renderTexture = null; // Initial value. - return _this; - } - CocosTextureData.toString = function () { - return "[class dragonBones.CocosTextureData]"; - }; - CocosTextureData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.renderTexture !== null) { - this.renderTexture.destroy(); - } - this.renderTexture = null; - }; - return CocosTextureData; - }(dragonBones.TextureData)); - dragonBones.CocosTextureData = CocosTextureData; -})(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) { - // const _defaultItems = cc.Enum({ "None": -1 }); - // function _setItems(object: any, key: string, items: any) { - // (cc.Class as any).attr( // creator.d.ts error. - // object, - // key, - // { - // type: "Enum", - // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. - // } - // ); - // } - var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, executeInEditMode = _a.executeInEditMode, disallowMultiple = _a.disallowMultiple, playOnFocus = _a.playOnFocus, menu = _a.menu, help = _a.help; - /** - * @see dragonBones.IArmatureProxy - */ - var CocosArmatureComponent = /** @class */ (function (_super) { - __extends(CocosArmatureComponent, _super); - function CocosArmatureComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.debugDraw = false; - _this._debugDraw = false; - /** - * @internal - */ - _this._armature = null; - // Editor. - /** - * @internal - */ - _this._armatureName = ""; - _this.dragonBonesName = ''; - /** - * @internal - */ - _this._animationName = ""; - // Visibie. - /** - * @internal - */ - _this._dragonBonesAsset = null; - /** - * @internal - */ - _this._armatureNames = []; - /** - * @internal - */ - _this._animationNames = []; - /** - * @internal - */ - _this._playTimes = -1; - /** - * @internal - */ - _this._timeScale = 1.0; - return _this; - } - CocosArmatureComponent_1 = CocosArmatureComponent; - CocosArmatureComponent.prototype.dbInit = function (armature) { - this._armature = armature; - }; - CocosArmatureComponent.prototype.dbClear = function () { - this._armature = null; - _super.prototype.destroy.call(this); - }; - CocosArmatureComponent.prototype.dbUpdate = function () { - var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; - if (drawed || this._debugDraw) { - this._debugDraw = drawed; - } - }; - CocosArmatureComponent.prototype.dispose = function (_isposeProxy) { - if (_isposeProxy === void 0) { _isposeProxy = true; } - if (this._armature !== null) { - this._armature.dispose(); - this._armature = null; - } - }; - CocosArmatureComponent.prototype.destroy = function () { - this.dispose(); - if (false) { // `super.destroy()` will be called in `dbClear()`. - _super.prototype.destroy.call(this); - } - return true; - }; - /** - * @private - */ - CocosArmatureComponent.prototype.dispatchDBEvent = function (type, eventObject) { - var event = new cc.Event.EventCustom(type, false); - event.setUserData(eventObject); - this.node.dispatchEvent(event); - }; - CocosArmatureComponent.prototype.hasDBEventListener = function (type) { - return this.node.hasEventListener(type, false); // creator.d.ts error. - }; - CocosArmatureComponent.prototype.addDBEventListener = function (type, listener, target) { - this.node.on(type, listener, target); - }; - CocosArmatureComponent.prototype.removeDBEventListener = function (type, listener, target) { - this.node.off(type, listener, target); - }; - Object.defineProperty(CocosArmatureComponent.prototype, "armature", { - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CocosArmatureComponent.prototype, "animation", { - get: function () { - return this._armature.animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CocosArmatureComponent.prototype, "dragonBonesAsset", { - get: function () { - return this._dragonBonesAsset || null; - }, - set: function (value) { - this._dragonBonesAsset = value; - this._loadAndDisplayDragonBones(); - }, - enumerable: true, - configurable: true - }); - CocosArmatureComponent.prototype._loadAndDisplayDragonBones = function () { - console.warn("\u5F00\u59CB\u521B\u5EFA DragonBones Armature"); - var notExistAsset = !this.dragonBonesAsset - || !this.dragonBonesAsset.dragonBonesData - || !this.dragonBonesAsset.textureAtlases - || !this.dragonBonesAsset.textures; - if (notExistAsset) { - console.error("dragonBonesAsset \u4E3A\u7A7A"); - return; - } - console.warn("\u521B\u5EFA DragonBones Armature"); - this._parseDragonAsset(); - this._parseDragonAtlasAsset(); - this.display(); - }; - CocosArmatureComponent.prototype._parseDragonAsset = function () { - var dragonBonesData; - if (typeof this.dragonBonesAsset.dragonBonesData === 'string') { - console.log("JSON.parse(this.dragonBonesAsset.dragonBonesData)"); - dragonBonesData = JSON.parse(this.dragonBonesAsset.dragonBonesData); - } - else { - dragonBonesData = this.dragonBonesAsset.dragonBonesData; - } - var data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); - if (data === null) { - console.warn("DragonBones Armature not exist"); - return; - } - this._armatureName = data.armatureNames[0]; - console.log("parseDragonBonesData", data); - }; - CocosArmatureComponent.prototype._parseDragonAtlasAsset = function () { - var _this = this; - var textureAtlases = this.dragonBonesAsset.textureAtlases; - if (typeof textureAtlases[0] === 'string') { - console.log('JSON.parse(this.dragonBonesAsset.textureAtlases)'); - textureAtlases = JSON.parse(textureAtlases); - } - else { - textureAtlases = this.dragonBonesAsset.textureAtlases; - } - var texture = Array.isArray(this.dragonBonesAsset.textures) ? this.dragonBonesAsset.textures[0] : this.dragonBonesAsset.textures; - if (typeof texture === 'string') { - cc.textureCache.addImage(texture, function (tex, error) { - if (error) { - console.error("error:" + error.message, error); - return; - } - var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); - console.log("parseTextureAtlasData", data); - console.log("dragonBonesAsset", _this.dragonBonesAsset); - console.log("textureAtlases", textureAtlases); - console.log("texture", tex); - }, this); - } - else { - var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); - console.log("string parseTextureAtlasData", data); - console.log("string dragonBonesAsset", this.dragonBonesAsset); - } - }; - CocosArmatureComponent.prototype.display = function () { - console.warn("Armature name:" + this._armatureName + ",dragonBonesName:" + this.dragonBonesName); - var armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); - if (!armatureComponent) { - console.log("armatureComponent is null"); - return; - } - armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); - armatureComponent.node.x = 0.0; - armatureComponent.node.y = 0; - this.node.addChild(armatureComponent.node); - this._dragonBonesNode = armatureComponent.node; - console.log("play animation default animation"); - }; - CocosArmatureComponent.prototype.onLoad = function () { - // this.display(); - if (!!this._dragonBonesNode) { - var component = this._dragonBonesNode.getComponent(CocosArmatureComponent_1); - var state = component.animation.play(component.animation.animationNames[0], 0); - if (!state) { - return; - } - console.warn("\u64AD\u653E\u52A8\u753B\uFF1A" + state.name, state); - } - else { - this._loadAndDisplayDragonBones(); - // this.onLoad(); - // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); - // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); - } - }; - var CocosArmatureComponent_1; - __decorate([ - property(cc.String) - ], CocosArmatureComponent.prototype, "_armatureName", void 0); - __decorate([ - property(cc.String) - ], CocosArmatureComponent.prototype, "_animationName", void 0); - __decorate([ - property({ - type: dragonBones.DragonBonesAsset, - }) - ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); - __decorate([ - property({ - type: dragonBones.DragonBonesAsset, - displayName: "DragonBones", - tooltip: "DragonBones Asset", - visible: true, - }) - ], CocosArmatureComponent.prototype, "dragonBonesAsset", null); - __decorate([ - property({ - type: [cc.String], - displayName: "Armature", - tooltip: "The armature name.", - visible: true, - editorOnly: true, - serializable: false, - }) - ], CocosArmatureComponent.prototype, "_armatureNames", void 0); - __decorate([ - property({ - type: [cc.String], - displayName: "Animation", - tooltip: "The animation name.", - visible: true, - editorOnly: true, - serializable: false, - }) - ], CocosArmatureComponent.prototype, "_animationNames", void 0); - __decorate([ - property({ - type: cc.Integer, - displayName: "Play times", - tooltip: "The animation play times.", - visible: true, - slide: true, - range: [-1, 99, 1], - }) - ], CocosArmatureComponent.prototype, "_playTimes", void 0); - __decorate([ - property({ - type: cc.Float, - displayName: "TimeScale", - tooltip: "The animation play speed.", - visible: true, - slide: true, - range: [-2, 2, 0.01], - }) - ], CocosArmatureComponent.prototype, "_timeScale", void 0); - CocosArmatureComponent = CocosArmatureComponent_1 = __decorate([ - ccclass("CocosArmatureComponent"), - executeInEditMode, - disallowMultiple, - playOnFocus, - menu("DragonBones/Armature"), - executeInEditMode, - help("https://github.com/DragonBones/") - ], CocosArmatureComponent); - return CocosArmatureComponent; - }(cc.Component)); - dragonBones.CocosArmatureComponent = CocosArmatureComponent; -})(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 Cocos slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosSlot = /** @class */ (function (_super) { - __extends(CocosSlot, _super); - function CocosSlot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._ccMeshDirty = false; - return _this; - } - CocosSlot.toString = function () { - return "[class dragonBones.CocosSlot]"; - }; - CocosSlot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._textureScale = 1.0; - this._renderDisplay = null; - }; - CocosSlot.prototype._initDisplay = function (_value, _isRetain) { - }; - CocosSlot.prototype._disposeDisplay = function (value, isRelease) { - if (!isRelease) { - value.destroy(); - } - }; - CocosSlot.prototype._onUpdateDisplay = function () { - this._renderDisplay = (this._display ? this._display : this._rawDisplay); - }; - CocosSlot.prototype._addDisplay = function () { - var container = this._armature.display; - container.addChild(this._renderDisplay, this._zOrder); - }; - CocosSlot.prototype._replaceDisplay = function (value) { - var container = this._armature.display; - var prevDisplay = value; - if (this._renderDisplay.parent !== container) { - container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder()); - } - // container.removeChild(prevDisplay, false); - this._renderDisplay.active = true; - prevDisplay.active = false; - this._textureScale = 1.0; - }; - CocosSlot.prototype._removeDisplay = function () { - this._renderDisplay.parent.removeChild(this._renderDisplay, false); - }; - CocosSlot.prototype._updateZOrder = function () { - if (this._renderDisplay.getLocalZOrder() === this._zOrder) { - return; - } - this._renderDisplay.setLocalZOrder(this._zOrder); - }; - /** - * @internal - */ - CocosSlot.prototype._updateVisible = function () { - this._renderDisplay.active = this._parent.visible && this._visible; - }; - CocosSlot.prototype._updateBlendMode = function () { - var sprite = this._renderDisplay.getComponent(cc.Sprite); - if (sprite) { - switch (this._blendMode) { - case 0 /* Normal */: - break; - case 1 /* Add */: - var texture = sprite.spriteFrame.getTexture(); - var BlendFunc = cc.BlendFunc; // creator.d.ts error. - if (texture && texture.hasPremultipliedAlpha()) { - sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.ONE, BlendFunc.BlendFactor.ONE); // creator.d.ts error. - } - else { - sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.SRC_ALPHA, BlendFunc.BlendFactor.ONE); // creator.d.ts error. - } - break; - case 3 /* Darken */: - break; - case 4 /* Difference */: - break; - case 6 /* HardLight */: - break; - case 9 /* Lighten */: - break; - case 10 /* Multiply */: - break; - case 11 /* Overlay */: - break; - case 12 /* Screen */: - break; - default: - break; - } - } - else if (this._childArmature !== null) { - for (var _i = 0, _a = this._childArmature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - slot._blendMode = this._blendMode; - slot._updateBlendMode(); - } - } - }; - CocosSlot.prototype._updateColor = function () { - var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha * 255; - var color = this._renderDisplay.color; - this._renderDisplay.opacity = alpha; - color.setR(this._colorTransform.redMultiplier * 0xFF); - color.setG(this._colorTransform.greenMultiplier * 0xFF); - color.setB(this._colorTransform.blueMultiplier * 0xFF); - this._renderDisplay.setColor(color); // creator.d.ts error. - }; - CocosSlot.prototype._updateFrame = function () { - var currentTextureData = this._textureData; - var sprite = this._renderDisplay.getComponent(cc.Sprite); - if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { - var currentTextureAtlasData = currentTextureData.parent; - if (this._armature.replacedTexture !== null) { // Update replaced texture atlas. - if (this._armature._replaceTextureAtlasData === null) { - currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); - currentTextureAtlasData.copyFrom(currentTextureData.parent); - currentTextureAtlasData.renderTexture = this._armature.replacedTexture; - this._armature._replaceTextureAtlasData = currentTextureAtlasData; - } - else { - currentTextureAtlasData = this._armature._replaceTextureAtlasData; - } - currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); - } - var renderTexture = currentTextureData.renderTexture; - if (renderTexture !== null) { - if (this._geometryData !== null) { // Mesh. - var data = this._geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; - var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; - var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - var uvOffset = vertexOffset + vertexCount * 2; - var scale = this._armature._armatureData.scale; - var textureAtlasSize = renderTexture.getTexture().getContentSizeInPixels(); - var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : textureAtlasSize.width; - var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : textureAtlasSize.height; - var region = currentTextureData.region; - var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); - var polygonInfo = { - triangles: { - verts: [], - indices: [] - }, - rect: boundsRect - }; - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var vertex = { - x: floatArray[vertexOffset + i] * scale, - y: -floatArray[vertexOffset + i + 1] * scale, - u: floatArray[uvOffset + i], - v: floatArray[uvOffset + i + 1] - }; - if (currentTextureData.rotated) { - var backU = vertex.u; - vertex.u = (region.x + (1.0 - vertex.v) * region.width) / textureAtlasWidth; - vertex.v = (region.y + backU * region.height) / textureAtlasHeight; - } - else { - vertex.u = (region.x + vertex.u * region.width) / textureAtlasWidth; - vertex.v = (region.y + vertex.v * region.height) / textureAtlasHeight; - } - polygonInfo.triangles.verts[i / 2] = vertex; - if (boundsRect.x > vertex.x) { - boundsRect.x = vertex.x; - } - if (boundsRect.width < vertex.x) { - boundsRect.width = vertex.x; - } - if (boundsRect.y > vertex.y) { - boundsRect.y = vertex.y; - } - if (boundsRect.height < vertex.y) { - boundsRect.height = vertex.y; - } - } - for (var i = 0; i < triangleCount * 3; ++i) { - polygonInfo.triangles.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; - } - this._textureScale = 1.0; - sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.MESH); // creator.d.ts error. - sprite.spriteFrame = renderTexture; - sprite._sgNode.setMeshPolygonInfo(polygonInfo); // creator.d.ts error. - sprite._sgNode.setContentSize(cc.size(boundsRect.width, boundsRect.height)); // creator.d.ts error. - var isSkinned = this._geometryData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (isSkinned || isSurface) { - this._identityTransform(); - } - // Delay to update cocos mesh. (some cocos bug.) - this._ccMeshDirty = true; - } - else { // Normal texture. - this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; - sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. - sprite.spriteFrame = renderTexture; - sprite._sgNode.setContentSize(renderTexture.getOriginalSize()); // creator.d.ts error. - } - this._visibleDirty = true; - // this._blendModeDirty = true; - // this._colorDirty = true; - return; - } - } - this._renderDisplay.active = false; - this._renderDisplay.setPosition(0.0, 0.0); - }; - CocosSlot.prototype._updateMesh = function () { - var scale = this._armature._armatureData.scale; - var deformVertices = this._displayFrame.deformVertices; - var bones = this._geometryBones; - var geometryData = this._geometryData; - var weightData = geometryData.weight; - var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform; - var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite; - var polygonInfo = meshDisplay.getMeshPolygonInfo(); - if (!polygonInfo) { - return; - } - var verticesAndUVs = polygonInfo.triangles.verts; - var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); - if (weightData !== null) { - var data = geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; - if (weightFloatOffset < 0) { - weightFloatOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { - var boneCount = intArray[iB++]; - var xG = 0.0, yG = 0.0; - for (var j = 0; j < boneCount; ++j) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var xL = floatArray[iV++] * scale; - var yL = floatArray[iV++] * scale; - if (hasDeform) { - xL += deformVertices[iF++]; - yL += deformVertices[iF++]; - } - xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; - yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; - } - } - var vertex = verticesAndUVs[i]; - vertex.x = xG; - vertex.y = yG; - if (boundsRect.x > xG) { - boundsRect.x = xG; - } - if (boundsRect.width < xG) { - boundsRect.width = xG; - } - if (boundsRect.y > yG) { - boundsRect.y = yG; - } - if (boundsRect.height < yG) { - boundsRect.height = yG; - } - } - } - else { - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - var data = geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var iH = i / 2; // int. - var x = floatArray[vertexOffset + i] * scale; - var y = floatArray[vertexOffset + i + 1] * scale; - if (hasDeform) { - x += deformVertices[i]; - y += deformVertices[i + 1]; - } - var vertex = verticesAndUVs[iH]; - if (isSurface) { - var matrix = this._parent._getGlobalTransformMatrix(x, y); - vertex.x = matrix.a * x + matrix.c * y + matrix.tx; - vertex.y = matrix.b * x + matrix.d * y + matrix.ty; - // - x = vertex.x; - y = vertex.y; - } - else { - vertex.x = x; - y = vertex.y = -y; - } - if (boundsRect.x > x) { - boundsRect.x = x; - } - if (boundsRect.width < x) { - boundsRect.width = x; - } - if (boundsRect.y > y) { - boundsRect.y = y; - } - if (boundsRect.height < y) { - boundsRect.height = y; - } - } - } - boundsRect.width -= boundsRect.x; - boundsRect.height -= boundsRect.y; - polygonInfo.rect = boundsRect; - meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height)); - meshDisplay.setMeshPolygonInfo(polygonInfo); - if (weightData !== null) { - this._identityTransform(); - } - else { - var transform = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); - this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); - this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; - this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; - this._renderDisplay.scaleX = transform.scaleX * this._textureScale; - this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; - } - if (this._ccMeshDirty) { - this._ccMeshDirty = false; - this._verticesDirty = true; - } - }; - CocosSlot.prototype._updateTransform = function () { - // const globalTransformMatrix = this.globalTransformMatrix; - // const helpMatrix = TransformObject._helpMatrix; - // helpMatrix.a = globalTransformMatrix.a; - // helpMatrix.b = globalTransformMatrix.b; - // helpMatrix.c = -globalTransformMatrix.c; - // helpMatrix.d = -globalTransformMatrix.d; - // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { - // helpMatrix.tx = globalTransformMatrix.tx - (globalTransformMatrix.a * this._pivotX + globalTransformMatrix.c * this._pivotY); - // helpMatrix.ty = (globalTransformMatrix.ty - (globalTransformMatrix.b * this._pivotX + globalTransformMatrix.d * this._pivotY)); - // } - // else { - // helpMatrix.tx = globalTransformMatrix.tx; - // helpMatrix.ty = globalTransformMatrix.ty; - // } - // (this._renderDisplay as any)._sgNode._renderCmd.setNodeToParentTransform(helpMatrix); // creator.d.ts error. - this.updateGlobalTransform(); - var transform = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { - this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); - this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); - } - else { - this._renderDisplay.x = transform.x; - this._renderDisplay.y = transform.y; - } - this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; - this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; - this._renderDisplay.scaleX = transform.scaleX * this._textureScale; - this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; - }; - CocosSlot.prototype._identityTransform = function () { - // const helpMatrix = TransformObject._helpMatrix; - // helpMatrix.a = 1.0; - // helpMatrix.b = 0.0; - // helpMatrix.c = -0.0; - // helpMatrix.d = -1.0; - // helpMatrix.tx = 0.0; - // helpMatrix.ty = 0.0; - // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix); - this._renderDisplay.x = 0.0; - this._renderDisplay.y = 0.0; - this._renderDisplay.rotationX = 0.0; - this._renderDisplay.rotationY = 0.0; - this._renderDisplay.scaleX = 1.0; - this._renderDisplay.scaleY = 1.0; - }; - return CocosSlot; - }(dragonBones.Slot)); - dragonBones.CocosSlot = CocosSlot; -})(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) { - var ccclass = cc._decorator.ccclass; - var ClockHandler = /** @class */ (function (_super) { - __extends(ClockHandler, _super); - function ClockHandler() { - return _super !== null && _super.apply(this, arguments) || this; - } - ClockHandler.prototype.update = function (passedTime) { - CocosFactory.factory.dragonBones.advanceTime(passedTime); - }; - ClockHandler = __decorate([ - ccclass - ], ClockHandler); - return ClockHandler; - }(cc.Component)); - /** - * - The Cocos factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosFactory = /** @class */ (function (_super) { - __extends(CocosFactory, _super); - function CocosFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - var _this = _super.call(this, dataParser) || this; - _this._node = null; - _this._armatureNode = null; - if (!CC_EDITOR) { // Is playing. - if (_this._node === null) { - var nodeName = "DragonBones Node"; - _this._node = cc.find(nodeName); - if (_this._node === null) { - _this._node = new cc.Node(nodeName); - cc.game.addPersistRootNode(_this._node); - } - } - if (!_this._node.getComponent(ClockHandler)) { - _this._node.addComponent(ClockHandler); - } - var eventManager = _this._node.getComponent(dragonBones.CocosArmatureComponent) || _this._node.addComponent(dragonBones.CocosArmatureComponent); - if (CocosFactory._dragonBonesInstance === null) { - CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); - // - dragonBones.DragonBones.yDown = false; - } - } - else { - if (CocosFactory._dragonBonesInstance === null) { - CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(null); - // - dragonBones.DragonBones.yDown = false; - } - } - _this._dragonBones = CocosFactory._dragonBonesInstance; - return _this; - } - Object.defineProperty(CocosFactory, "factory", { - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - if (this._factory === null) { - this._factory = new CocosFactory(); - } - return this._factory; - }, - enumerable: true, - configurable: true - }); - CocosFactory.prototype._isSupportMesh = function () { - if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { // creator.d.ts error. - console.warn("Only webgl mode can support mesh."); - return false; - } - return true; - }; - CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { - if (textureAtlasData !== null) { - textureAtlasData.renderTexture = textureAtlas; - } - else { - textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); - } - return textureAtlasData; - }; - CocosFactory.prototype._buildArmature = function (dataPackage) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); - var armatureDisplay = this._armatureNode === null ? new cc.Node(dataPackage.armature.name) : this._armatureNode; - var armatureComponent = armatureDisplay.getComponent(dragonBones.CocosArmatureComponent) || armatureDisplay.addComponent(dragonBones.CocosArmatureComponent); - armatureDisplay.setOpacityModifyRGB(false); - armatureDisplay.setCascadeOpacityEnabled(true); - armatureDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. - this._armatureNode = null; - armatureComponent._armature = armature; - armature.init(dataPackage.armature, armatureComponent, armatureDisplay, this._dragonBones); - return armature; - }; - CocosFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { - var childDisplayName = slot.slotData.name + " (" + displayData.path.replace("/", "_") + ")"; // - var proxy = slot.armature.proxy; - var childNode = cc.find(childDisplayName, proxy.node); - var childArmature = null; - if (!childNode) { - if (dataPackage !== null) { - childArmature = this.buildArmature(displayData.path, dataPackage.dataName); - } - else { - childArmature = this.buildArmature(displayData.path, displayData.parent.parent.parent.name); - } - } - else { - var childArmatureComponent = childNode.getComponent(dragonBones.CocosArmatureComponent) || null; - if (childArmatureComponent === null) { - if (dataPackage !== null) { - childArmatureComponent = this.buildArmatureComponent(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage.textureAtlasName, childNode); - } - else { - childArmatureComponent = this.buildArmatureComponent(displayData.path, "", "", "", childNode); - } - } - if (childArmatureComponent !== null) { - childArmature = childArmatureComponent.armature; - } - } - if (childArmature === null) { - return null; - } - var childArmatureDisplay = childArmature.display; - childArmatureDisplay.name = childDisplayName; - if (childArmatureDisplay.parent !== proxy.node) { - proxy.node.addChild(childArmatureDisplay, slot._zOrder); - } - childArmatureDisplay.active = false; - return childArmature; - }; - CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.CocosSlot); - var armatureDisplay = armature.display; - var rawSlotDisplay = cc.find(slotData.name, armatureDisplay) || new cc.Node(slotData.name); - rawSlotDisplay.addComponent(cc.Sprite); - rawSlotDisplay.setAnchorPoint(0.0, 0.0); - rawSlotDisplay.setOpacityModifyRGB(false); - rawSlotDisplay.setCascadeOpacityEnabled(true); - rawSlotDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. - slot.init(slotData, armature, rawSlotDisplay, rawSlotDisplay); - return slot; - }; - /** - * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature component. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 - * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架组件。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - CocosFactory.prototype.buildArmatureComponent = function (armatureName, dragonBonesName, skinName, textureAtlasName, node) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - if (node === void 0) { node = null; } - this._armatureNode = node; - var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); - if (armature !== null) { - this._dragonBones.clock.add(armature); - return armature.proxy; - } - return null; - }; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { - if (textureAtlasName === void 0) { textureAtlasName = null; } - var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); - if (textureData !== null && textureData.renderTexture !== null) { - var texture = textureData.renderTexture; - var sprite = new cc.Sprite(); - sprite.spriteFrame = texture; - return sprite; - } - return null; - }; - Object.defineProperty(CocosFactory.prototype, "soundEventManager", { - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._dragonBones.eventManager.node; - }, - enumerable: true, - configurable: true - }); - CocosFactory._dragonBonesInstance = null; - CocosFactory._factory = null; - return CocosFactory; - }(dragonBones.BaseFactory)); - dragonBones.CocosFactory = CocosFactory; -})(dragonBones || (dragonBones = {})); +"use strict"; +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 __decorate = (this && this.__decorate) || function (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; +}; +/** + * 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.
+ * 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) 确定)以及宽度和高度定义的区域。
+ * 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, 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 armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var ArmatureData = /** @class */ (function (_super) { + __extends(ArmatureData, _super); + function ArmatureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.aabb = new dragonBones.Rectangle(); + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * @private + */ + _this.bones = {}; + /** + * @private + */ + _this.slots = {}; + /** + * @private + */ + _this.constraints = {}; + /** + * @private + */ + _this.skins = {}; + /** + * @private + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + ArmatureData.prototype._onClear = function () { + for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { + var action = _c[_b]; + action.returnToPool(); + } + for (var k in this.bones) { + this.bones[k].returnToPool(); + delete this.bones[k]; + } + for (var k in this.slots) { + this.slots[k].returnToPool(); + delete this.slots[k]; + } + for (var k in this.constraints) { + this.constraints[k].returnToPool(); + delete this.constraints[k]; + } + for (var k in this.skins) { + this.skins[k].returnToPool(); + delete this.skins[k]; + } + for (var k in this.animations) { + this.animations[k].returnToPool(); + delete this.animations[k]; + } + if (this.canvas !== null) { + this.canvas.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.type = 0 /* Armature */; + this.frameRate = 0; + this.cacheFrameRate = 0; + this.scale = 1.0; + this.name = ""; + this.aabb.clear(); + this.animationNames.length = 0; + this.sortedBones.length = 0; + this.sortedSlots.length = 0; + this.defaultActions.length = 0; + this.actions.length = 0; + // this.bones.clear(); + // this.slots.clear(); + // this.constraints.clear(); + // this.skins.clear(); + // this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @internal + */ + ArmatureData.prototype.sortBones = function () { + var total = this.sortedBones.length; + if (total <= 0) { + return; + } + var sortHelper = this.sortedBones.concat(); + var index = 0; + var count = 0; + this.sortedBones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this.sortedBones.indexOf(bone) >= 0) { + continue; + } + var flag = false; + for (var k in this.constraints) { // Wait constraint. + var constraint = this.constraints[k]; + if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @internal + */ + ArmatureData.prototype.cacheFrames = function (frameRate) { + if (this.cacheFrameRate > 0) { // TODO clear cache. + return; + } + this.cacheFrameRate = frameRate; + for (var k in this.animations) { + this.animations[k].cacheFrames(this.cacheFrameRate); + } + }; + /** + * @internal + */ + ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { + var dataArray = this.parent.cachedFrames; + var arrayOffset = dataArray.length; + dataArray.length += 10; + dataArray[arrayOffset] = globalTransformMatrix.a; + dataArray[arrayOffset + 1] = globalTransformMatrix.b; + dataArray[arrayOffset + 2] = globalTransformMatrix.c; + dataArray[arrayOffset + 3] = globalTransformMatrix.d; + dataArray[arrayOffset + 4] = globalTransformMatrix.tx; + dataArray[arrayOffset + 5] = globalTransformMatrix.ty; + dataArray[arrayOffset + 6] = transform.rotation; + dataArray[arrayOffset + 7] = transform.skew; + dataArray[arrayOffset + 8] = transform.scaleX; + dataArray[arrayOffset + 9] = transform.scaleY; + return arrayOffset; + }; + /** + * @internal + */ + ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { + var dataArray = this.parent.cachedFrames; + globalTransformMatrix.a = dataArray[arrayOffset]; + globalTransformMatrix.b = dataArray[arrayOffset + 1]; + globalTransformMatrix.c = dataArray[arrayOffset + 2]; + globalTransformMatrix.d = dataArray[arrayOffset + 3]; + globalTransformMatrix.tx = dataArray[arrayOffset + 4]; + globalTransformMatrix.ty = dataArray[arrayOffset + 5]; + transform.rotation = dataArray[arrayOffset + 6]; + transform.skew = dataArray[arrayOffset + 7]; + transform.scaleX = dataArray[arrayOffset + 8]; + transform.scaleY = dataArray[arrayOffset + 9]; + transform.x = globalTransformMatrix.tx; + transform.y = globalTransformMatrix.ty; + }; + /** + * @internal + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Same bone: " + value.name); + return; + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @internal + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Same slot: " + value.name); + return; + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @internal + */ + ArmatureData.prototype.addConstraint = function (value) { + if (value.name in this.constraints) { + console.warn("Same constraint: " + value.name); + return; + } + this.constraints[value.name] = value; + }; + /** + * @internal + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Same skin: " + value.name); + return; + } + value.parent = this; + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + if (value.name === "default") { + this.defaultSkin = value; + } + }; + /** + * @internal + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Same animation: " + value.name); + return; + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * @internal + */ + ArmatureData.prototype.addAction = function (value, isDefault) { + if (isDefault) { + this.defaultActions.push(value); + } + else { + this.actions.push(value); + } + }; + /** + * - Get a specific done data. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (boneName) { + return boneName in this.bones ? this.bones[boneName] : null; + }; + /** + * - Get a specific slot data. + * @param slotName - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param slotName - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (slotName) { + return slotName in this.slots ? this.slots[slotName] : null; + }; + /** + * @private + */ + ArmatureData.prototype.getConstraint = function (constraintName) { + return constraintName in this.constraints ? this.constraints[constraintName] : null; + }; + /** + * - Get a specific skin data. + * @param skinName - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param skinName - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (skinName) { + return skinName in this.skins ? this.skins[skinName] : null; + }; + /** + * @private + */ + ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { + var skin = this.getSkin(skinName); + if (skin === null) { + return null; + } + return skin.getDisplay(slotName, meshName); + }; + /** + * - Get a specific animation data. + * @param animationName - The animation animationName. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param animationName - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (animationName) { + return animationName in this.animations ? this.animations[animationName] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var BoneData = /** @class */ (function (_super) { + __extends(BoneData, _super); + function BoneData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.transform = new dragonBones.Transform(); + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + BoneData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.type = 0 /* Bone */; + this.length = 0.0; + this.alpha = 1.0; + this.name = ""; + this.transform.identity(); + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * @internal + */ + var SurfaceData = /** @class */ (function (_super) { + __extends(SurfaceData, _super); + function SurfaceData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new dragonBones.GeometryData(); + return _this; + } + SurfaceData.toString = function () { + return "[class dragonBones.SurfaceData]"; + }; + SurfaceData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Surface */; + this.segmentX = 0; + this.segmentY = 0; + this.geometry.clear(); + }; + return SurfaceData; + }(BoneData)); + dragonBones.SurfaceData = SurfaceData; + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var SlotData = /** @class */ (function (_super) { + __extends(SlotData, _super); + function SlotData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.color = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @internal + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.zIndex = 0; + this.alpha = 1.0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @internal + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; +})(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 CanvasData = /** @class */ (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + CanvasData.prototype._onClear = function () { + this.hasBackground = false; + this.color = 0x000000; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + }; + return CanvasData; + }(dragonBones.BaseObject)); + dragonBones.CanvasData = CanvasData; +})(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 skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var SkinData = /** @class */ (function (_super) { + __extends(SkinData, _super); + function SkinData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.displays = {}; + return _this; + } + SkinData.toString = function () { + return "[class dragonBones.SkinData]"; + }; + SkinData.prototype._onClear = function () { + for (var k in this.displays) { + var slotDisplays = this.displays[k]; + for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { + var display = slotDisplays_1[_i]; + if (display !== null) { + display.returnToPool(); + } + } + delete this.displays[k]; + } + this.name = ""; + // this.displays.clear(); + this.parent = null; // + }; + /** + * @internal + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + if (value !== null) { + value.parent = this; + } + var slotDisplays = this.displays[slotName]; // TODO clear prev + slotDisplays.push(value); + }; + /** + * @private + */ + SkinData.prototype.getDisplay = function (slotName, displayName) { + var slotDisplays = this.getDisplays(slotName); + if (slotDisplays !== null) { + for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { + var display = slotDisplays_2[_i]; + if (display !== null && display.name === displayName) { + return display; + } + } + } + return null; + }; + /** + * @private + */ + SkinData.prototype.getDisplays = function (slotName) { + if (!(slotName in this.displays)) { + return null; + } + return this.displays[slotName]; + }; + return SkinData; + }(dragonBones.BaseObject)); + dragonBones.SkinData = SkinData; +})(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 ConstraintData = /** @class */ (function (_super) { + __extends(ConstraintData, _super); + function ConstraintData() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConstraintData.prototype._onClear = function () { + this.order = 0; + this.name = ""; + this.type = 0 /* IK */; + this.target = null; // + this.root = null; // + this.bone = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @internal + */ + var IKConstraintData = /** @class */ (function (_super) { + __extends(IKConstraintData, _super); + function IKConstraintData() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraintData.toString = function () { + return "[class dragonBones.IKConstraintData]"; + }; + IKConstraintData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.scaleEnabled = false; + this.bendPositive = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; + /** + * @internal + */ + var PathConstraintData = /** @class */ (function (_super) { + __extends(PathConstraintData, _super); + function PathConstraintData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + PathConstraintData.toString = function () { + return "[class dragonBones.PathConstraintData]"; + }; + PathConstraintData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.pathSlot = null; + this.pathDisplayData = null; + this.bones.length = 0; + this.positionMode = 0 /* Fixed */; + this.spacingMode = 1 /* Fixed */; + this.rotateMode = 1 /* Chain */; + this.position = 0.0; + this.spacing = 0.0; + this.rotateOffset = 0.0; + this.rotateMix = 0.0; + this.translateMix = 0.0; + }; + PathConstraintData.prototype.AddBone = function (value) { + this.bones.push(value); + }; + return PathConstraintData; + }(ConstraintData)); + dragonBones.PathConstraintData = PathConstraintData; +})(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 GeometryData = /** @class */ (function () { + function GeometryData() { + this.weight = null; // Initial value. + } + GeometryData.prototype.clear = function () { + if (!this.isShared && this.weight !== null) { + this.weight.returnToPool(); + } + this.isShared = false; + this.inheritDeform = false; + this.offset = 0; + this.data = null; + this.weight = null; + }; + GeometryData.prototype.shareFrom = function (value) { + this.isShared = true; + this.offset = value.offset; + this.weight = value.weight; + }; + Object.defineProperty(GeometryData.prototype, "vertexCount", { + get: function () { + var intArray = this.data.intArray; + return intArray[this.offset + 0 /* GeometryVertexCount */]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GeometryData.prototype, "triangleCount", { + get: function () { + var intArray = this.data.intArray; + return intArray[this.offset + 1 /* GeometryTriangleCount */]; + }, + enumerable: true, + configurable: true + }); + return GeometryData; + }()); + dragonBones.GeometryData = GeometryData; + /** + * @private + */ + var DisplayData = /** @class */ (function (_super) { + __extends(DisplayData, _super); + function DisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.transform = new dragonBones.Transform(); + return _this; + } + DisplayData.prototype._onClear = function () { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null; // + }; + return DisplayData; + }(dragonBones.BaseObject)); + dragonBones.DisplayData = DisplayData; + /** + * @private + */ + var ImageDisplayData = /** @class */ (function (_super) { + __extends(ImageDisplayData, _super); + function ImageDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.pivot = new dragonBones.Point(); + return _this; + } + ImageDisplayData.toString = function () { + return "[class dragonBones.ImageDisplayData]"; + }; + ImageDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Image */; + this.pivot.clear(); + this.texture = null; + }; + return ImageDisplayData; + }(DisplayData)); + dragonBones.ImageDisplayData = ImageDisplayData; + /** + * @private + */ + var ArmatureDisplayData = /** @class */ (function (_super) { + __extends(ArmatureDisplayData, _super); + function ArmatureDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.actions = []; + return _this; + } + ArmatureDisplayData.toString = function () { + return "[class dragonBones.ArmatureDisplayData]"; + }; + ArmatureDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + this.type = 1 /* Armature */; + this.inheritAnimation = false; + this.actions.length = 0; + this.armature = null; + }; + /** + * @private + */ + ArmatureDisplayData.prototype.addAction = function (value) { + this.actions.push(value); + }; + return ArmatureDisplayData; + }(DisplayData)); + dragonBones.ArmatureDisplayData = ArmatureDisplayData; + /** + * @private + */ + var MeshDisplayData = /** @class */ (function (_super) { + __extends(MeshDisplayData, _super); + function MeshDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new GeometryData(); + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 2 /* Mesh */; + this.geometry.clear(); + this.texture = null; + }; + return MeshDisplayData; + }(DisplayData)); + dragonBones.MeshDisplayData = MeshDisplayData; + /** + * @private + */ + var BoundingBoxDisplayData = /** @class */ (function (_super) { + __extends(BoundingBoxDisplayData, _super); + function BoundingBoxDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.boundingBox = null; // Initial value. + return _this; + } + BoundingBoxDisplayData.toString = function () { + return "[class dragonBones.BoundingBoxDisplayData]"; + }; + BoundingBoxDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.boundingBox !== null) { + this.boundingBox.returnToPool(); + } + this.type = 3 /* BoundingBox */; + this.boundingBox = null; + }; + return BoundingBoxDisplayData; + }(DisplayData)); + dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; + /** + * @private + */ + var PathDisplayData = /** @class */ (function (_super) { + __extends(PathDisplayData, _super); + function PathDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new GeometryData(); + _this.curveLengths = []; + return _this; + } + PathDisplayData.toString = function () { + return "[class dragonBones.PathDisplayData]"; + }; + PathDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 4 /* Path */; + this.closed = false; + this.constantSpeed = false; + this.geometry.clear(); + this.curveLengths.length = 0; + }; + return PathDisplayData; + }(DisplayData)); + dragonBones.PathDisplayData = PathDisplayData; + /** + * @private + */ + var WeightData = /** @class */ (function (_super) { + __extends(WeightData, _super); + function WeightData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + WeightData.toString = function () { + return "[class dragonBones.WeightData]"; + }; + WeightData.prototype._onClear = function () { + this.count = 0; + this.offset = 0; + this.bones.length = 0; + }; + WeightData.prototype.addBone = function (value) { + this.bones.push(value); + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(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 base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + var BoundingBoxData = /** @class */ (function (_super) { + __extends(BoundingBoxData, _super); + function BoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = /** @class */ (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + RectangleBoundingBoxData.toString = function () { + return "[class dragonBones.RectangleBoundingBoxData]"; + }; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { + var code = 0 /* InSide */; // initialised as being inside of [[clip window]] + if (x < xMin) { // to the left of clip window + code |= 1 /* Left */; + } + else if (x > xMax) { // to the right of clip window + code |= 2 /* Right */; + } + if (y < yMin) { // below the clip window + code |= 4 /* Top */; + } + else if (y > yMax) { // above the clip window + code |= 8 /* Bottom */; + } + return code; + }; + /** + * @private + */ + RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; + var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; + if (inSideA && inSideB) { + return -1; + } + var intersectionCount = 0; + var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + while (true) { + if ((outcode0 | outcode1) === 0) { // Bitwise OR is 0. Trivially accept and get out of loop + intersectionCount = 2; + break; + } + else if ((outcode0 & outcode1) !== 0) { // Bitwise AND is not 0. Trivially reject and get out of loop + break; + } + // failed both tests, so calculate the line segment to clip + // from an outside point to an intersection with clip edge + var x = 0.0; + var y = 0.0; + var normalRadian = 0.0; + // At least one endpoint is outside the clip rectangle; pick it. + var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; + // Now find the intersection point; + if ((outcodeOut & 4 /* Top */) !== 0) { // point is above the clip rectangle + x = xA + (xB - xA) * (yMin - yA) / (yB - yA); + y = yMin; + if (normalRadians !== null) { + normalRadian = -Math.PI * 0.5; + } + } + else if ((outcodeOut & 8 /* Bottom */) !== 0) { // point is below the clip rectangle + x = xA + (xB - xA) * (yMax - yA) / (yB - yA); + y = yMax; + if (normalRadians !== null) { + normalRadian = Math.PI * 0.5; + } + } + else if ((outcodeOut & 2 /* Right */) !== 0) { // point is to the right of clip rectangle + y = yA + (yB - yA) * (xMax - xA) / (xB - xA); + x = xMax; + if (normalRadians !== null) { + normalRadian = 0; + } + } + else if ((outcodeOut & 1 /* Left */) !== 0) { // point is to the left of clip rectangle + y = yA + (yB - yA) * (xMin - xA) / (xB - xA); + x = xMin; + if (normalRadians !== null) { + normalRadian = Math.PI; + } + } + // Now we move outside point to intersection point to clip + // and get ready for next pass. + if (outcodeOut === outcode0) { + xA = x; + yA = y; + outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + if (normalRadians !== null) { + normalRadians.x = normalRadian; + } + } + else { + xB = x; + yB = y; + outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + if (normalRadians !== null) { + normalRadians.y = normalRadian; + } + } + } + if (intersectionCount) { + if (inSideA) { + intersectionCount = 2; // 10 + if (intersectionPointA !== null) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = xB; + } + if (normalRadians !== null) { + normalRadians.x = normalRadians.y + Math.PI; + } + } + else if (inSideB) { + intersectionCount = 1; // 01 + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (normalRadians !== null) { + normalRadians.y = normalRadians.x + Math.PI; + } + } + else { + intersectionCount = 3; // 11 + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + } + } + return intersectionCount; + }; + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inheritDoc + */ + RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + var heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + return true; + } + } + return false; + }; + /** + * @inheritDoc + */ + RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var widthH = this.width * 0.5; + var heightH = this.height * 0.5; + var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return RectangleBoundingBoxData; + }(BoundingBoxData)); + dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = /** @class */ (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + EllipseBoundingBoxData.toString = function () { + return "[class dragonBones.EllipseData]"; + }; + /** + * @private + */ + EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var d = widthH / heightH; + var dd = d * d; + yA *= d; + yB *= d; + var dX = xB - xA; + var dY = yB - yA; + var lAB = Math.sqrt(dX * dX + dY * dY); + var xD = dX / lAB; + var yD = dY / lAB; + var a = (xC - xA) * xD + (yC - yA) * yD; + var aa = a * a; + var ee = xA * xA + yA * yA; + var rr = widthH * widthH; + var dR = rr - ee + aa; + var intersectionCount = 0; + if (dR >= 0.0) { + var dT = Math.sqrt(dR); + var sA = a - dT; + var sB = a + dT; + var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); + var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); + var sideAB = inSideA * inSideB; + if (sideAB < 0) { + return -1; + } + else if (sideAB === 0) { + if (inSideA === -1) { + intersectionCount = 2; // 10 + xB = xA + sB * xD; + yB = (yA + sB * yD) / d; + if (intersectionPointA !== null) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } + else if (inSideB === 1) { + intersectionCount = 1; // 01 + xA = xA + sA * xD; + yA = (yA + sA * yD) / d; + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } + else { + intersectionCount = 3; // 11 + if (intersectionPointA !== null) { + intersectionPointA.x = xA + sA * xD; + intersectionPointA.y = (yA + sA * yD) / d; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); + } + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA + sB * xD; + intersectionPointB.y = (yA + sB * yD) / d; + if (normalRadians !== null) { + normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); + } + } + } + } + } + return intersectionCount; + }; + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inheritDoc + */ + EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + var heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + pY *= widthH / heightH; + return Math.sqrt(pX * pX + pY * pY) <= widthH; + } + } + return false; + }; + /** + * @inheritDoc + */ + EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return EllipseBoundingBoxData; + }(BoundingBoxData)); + dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var PolygonBoundingBoxData = /** @class */ (function (_super) { + __extends(PolygonBoundingBoxData, _super); + function PolygonBoundingBoxData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + _this.vertices = []; + return _this; + } + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + if (xA === xB) { + xA = xB + 0.000001; + } + if (yA === yB) { + yA = yB + 0.000001; + } + var count = vertices.length; + var dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[count - 2]; + var yC = vertices[count - 1]; + var dMin = 0.0; + var dMax = 0.0; + var xMin = 0.0; + var yMin = 0.0; + var xMax = 0.0; + var yMax = 0.0; + for (var i = 0; i < count; i += 2) { + var xD = vertices[i]; + var yD = vertices[i + 1]; + if (xC === xD) { + xC = xD + 0.0001; + } + if (yC === yD) { + yC = yD + 0.0001; + } + var dXCD = xC - xD; + var dYCD = yC - yD; + var llCD = xC * yD - yC * xD; + var ll = dXAB * dYCD - dYAB * dXCD; + var x = (llAB * dXCD - dXAB * llCD) / ll; + if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { + var y = (llAB * dYCD - dYAB * llCD) / ll; + if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { + if (intersectionPointB !== null) { + var d = x - xA; + if (d < 0.0) { + d = -d; + } + if (intersectionCount === 0) { + dMin = d; + dMax = d; + xMin = x; + yMin = y; + xMax = x; + yMax = y; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = normalRadians.x; + } + } + else { + if (d < dMin) { + dMin = d; + xMin = x; + yMin = y; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + } + } + if (d > dMax) { + dMax = d; + xMax = x; + yMax = y; + if (normalRadians !== null) { + normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + } + } + } + intersectionCount++; + } + else { + xMin = x; + yMin = y; + xMax = x; + yMax = y; + intersectionCount++; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = normalRadians.x; + } + break; + } + } + } + xC = xD; + yC = yD; + } + if (intersectionCount === 1) { + if (intersectionPointA !== null) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xMin; + intersectionPointB.y = yMin; + } + if (normalRadians !== null) { + normalRadians.y = normalRadians.x + Math.PI; + } + } + else if (intersectionCount > 1) { + intersectionCount++; + if (intersectionPointA !== null) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xMax; + intersectionPointB.y = yMax; + } + } + return intersectionCount; + }; + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 2 /* Polygon */; + this.x = 0.0; + this.y = 0.0; + this.vertices.length = 0; + }; + /** + * @inheritDoc + */ + PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var isInSide = false; + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { + for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[iP + 1]; + var yB = this.vertices[i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[iP]; + var xB = this.vertices[i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inheritDoc + */ + PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var intersectionCount = 0; + if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(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 animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var AnimationData = /** @class */ (function (_super) { + __extends(AnimationData, _super); + function AnimationData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.cachedFrames = []; + /** + * @private + */ + _this.boneTimelines = {}; + /** + * @private + */ + _this.slotTimelines = {}; + /** + * @private + */ + _this.constraintTimelines = {}; + /** + * @private + */ + _this.animationTimelines = {}; + /** + * @private + */ + _this.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var _b = 0, _c = this.slotTimelines[k]; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + delete this.slotTimelines[k]; + } + for (var k in this.constraintTimelines) { + for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + delete this.constraintTimelines[k]; + } + for (var k in this.animationTimelines) { + for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + delete this.animationTimelines[k]; + } + for (var k in this.boneCachedFrameIndices) { + delete this.boneCachedFrameIndices[k]; + } + for (var k in this.slotCachedFrameIndices) { + delete this.slotCachedFrameIndices[k]; + } + if (this.actionTimeline !== null) { + this.actionTimeline.returnToPool(); + } + if (this.zOrderTimeline !== null) { + this.zOrderTimeline.returnToPool(); + } + this.frameIntOffset = 0; + this.frameFloatOffset = 0; + this.frameOffset = 0; + this.blendType = 0 /* None */; + this.frameCount = 0; + this.playTimes = 0; + this.duration = 0.0; + this.scale = 1.0; + this.fadeInTime = 0.0; + this.cacheFrameRate = 0.0; + this.name = ""; + this.cachedFrames.length = 0; + // this.boneTimelines.clear(); + // this.slotTimelines.clear(); + // this.constraintTimelines.clear(); + // this.animationTimelines.clear(); + // this.boneCachedFrameIndices.clear(); + // this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @internal + */ + AnimationData.prototype.cacheFrames = function (frameRate) { + if (this.cacheFrameRate > 0.0) { // TODO clear cache. + return; + } + this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); + var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. + this.cachedFrames.length = cacheFrameCount; + for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { + this.cachedFrames[i] = false; + } + for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { + var bone = _a[_i]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + this.boneCachedFrameIndices[bone.name] = indices; + } + for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { + var slot = _c[_b]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + this.slotCachedFrameIndices[slot.name] = indices; + } + }; + /** + * @private + */ + AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : (this.constraintTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (timelineName) { + return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimelines = function (timelineName) { + return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getConstraintTimelines = function (timelineName) { + return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getAnimationTimelines = function (timelineName) { + return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { + return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { + return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; + }; + return AnimationData; + }(dragonBones.BaseObject)); + dragonBones.AnimationData = AnimationData; + /** + * @private + */ + var TimelineData = /** @class */ (function (_super) { + __extends(TimelineData, _super); + function TimelineData() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineData.toString = function () { + return "[class dragonBones.TimelineData]"; + }; + TimelineData.prototype._onClear = function () { + this.type = 10 /* BoneAll */; + this.offset = 0; + this.frameIndicesOffset = -1; + }; + return TimelineData; + }(dragonBones.BaseObject)); + dragonBones.TimelineData = TimelineData; + /** + * @internal + */ + var AnimationTimelineData = /** @class */ (function (_super) { + __extends(AnimationTimelineData, _super); + function AnimationTimelineData() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationTimelineData.toString = function () { + return "[class dragonBones.AnimationTimelineData]"; + }; + AnimationTimelineData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.x = 0.0; + this.y = 0.0; + }; + return AnimationTimelineData; + }(TimelineData)); + dragonBones.AnimationTimelineData = AnimationTimelineData; +})(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 animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + var AnimationConfig = /** @class */ (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additive = false; + this.displayControl = true; + this.pauseFadeIn = true; + this.resetToPose = true; + this.fadeInTweenType = 1 /* Line */; + this.playTimes = -1; + this.layer = 0; + this.position = 0.0; + this.duration = -1.0; + this.timeScale = -100.0; + this.weight = 1.0; + this.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + /** + * @private + */ + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + /** + * @private + */ + AnimationConfig.prototype.copyFrom = function (value) { + this.pauseFadeOut = value.pauseFadeOut; + this.fadeOutMode = value.fadeOutMode; + this.autoFadeOutTime = value.autoFadeOutTime; + this.fadeOutTweenType = value.fadeOutTweenType; + this.actionEnabled = value.actionEnabled; + this.additive = value.additive; + this.displayControl = value.displayControl; + this.pauseFadeIn = value.pauseFadeIn; + this.resetToPose = value.resetToPose; + this.playTimes = value.playTimes; + this.layer = value.layer; + this.position = value.position; + this.duration = value.duration; + this.timeScale = value.timeScale; + this.fadeInTime = value.fadeInTime; + this.fadeOutTime = value.fadeOutTime; + this.fadeInTweenType = value.fadeInTweenType; + this.weight = value.weight; + this.name = value.name; + this.animation = value.animation; + this.group = value.group; + this.boneMask.length = value.boneMask.length; + for (var i = 0, l = this.boneMask.length; i < l; ++i) { + this.boneMask[i] = value.boneMask[i]; + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(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 texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var TextureAtlasData = /** @class */ (function (_super) { + __extends(TextureAtlasData, _super); + function TextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.textures = {}; + return _this; + } + TextureAtlasData.prototype._onClear = function () { + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + this.autoSearch = false; + this.width = 0; + this.height = 0; + this.scale = 1.0; + // this.textures.clear(); + this.name = ""; + this.imagePath = ""; + }; + /** + * @private + */ + TextureAtlasData.prototype.copyFrom = function (value) { + this.autoSearch = value.autoSearch; + this.scale = value.scale; + this.width = value.width; + this.height = value.height; + this.name = value.name; + this.imagePath = value.imagePath; + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + // this.textures.clear(); + for (var k in value.textures) { + var texture = this.createTexture(); + texture.copyFrom(value.textures[k]); + this.textures[k] = texture; + } + }; + /** + * @internal + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Same texture: " + value.name); + return; + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (textureName) { + return textureName in this.textures ? this.textures[textureName] : null; + }; + return TextureAtlasData; + }(dragonBones.BaseObject)); + dragonBones.TextureAtlasData = TextureAtlasData; + /** + * @private + */ + var TextureData = /** @class */ (function (_super) { + __extends(TextureData, _super); + function TextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.region = new dragonBones.Rectangle(); + _this.frame = null; // Initial value. + return _this; + } + TextureData.createRectangle = function () { + return new dragonBones.Rectangle(); + }; + TextureData.prototype._onClear = function () { + this.rotated = false; + this.name = ""; + this.region.clear(); + this.parent = null; // + this.frame = null; + }; + TextureData.prototype.copyFrom = function (value) { + this.rotated = value.rotated; + this.name = value.name; + this.region.copyFrom(value.region); + this.parent = value.parent; + if (this.frame === null && value.frame !== null) { + this.frame = TextureData.createRectangle(); + } + else if (this.frame !== null && value.frame === null) { + this.frame = null; + } + if (this.frame !== null && value.frame !== null) { + this.frame.copyFrom(value.frame); + } + }; + return TextureData; + }(dragonBones.BaseObject)); + dragonBones.TextureData = TextureData; +})(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_1) { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + var Armature = /** @class */ (function (_super) { + __extends(Armature, _super); + function Armature() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._bones = []; + _this._slots = []; + /** + * @internal + */ + _this._constraints = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @internal + */ + _this._replaceTextureAtlasData = null; // Initial value. + _this._clock = null; // Initial value. + return _this; + } + Armature.toString = function () { + return "[class dragonBones.Armature]"; + }; + Armature._onSortSlots = function (a, b) { + return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; + }; + Armature.prototype._onClear = function () { + if (this._clock !== null) { // Remove clock first. + this._clock.remove(this); + } + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone.returnToPool(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot.returnToPool(); + } + for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { + var constraint = _e[_d]; + constraint.returnToPool(); + } + for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { + var action = _g[_f]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.dbClear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.userData = null; + this._lockUpdate = false; + this._slotsDirty = true; + this._zOrderDirty = false; + this._zIndexDirty = false; + this._alphaDirty = true; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._alpha = 1.0; + this._globalAlpha = 1.0; + this._bones.length = 0; + this._slots.length = 0; + this._constraints.length = 0; + this._actions.length = 0; + this._armatureData = null; // + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + /** + * @internal + */ + Armature.prototype._sortZOrder = function (slotIndices, offset) { + var slotDatas = this._armatureData.sortedSlots; + var isOriginal = slotIndices === null; + if (this._zOrderDirty || !isOriginal) { + for (var i = 0, l = slotDatas.length; i < l; ++i) { + var slotIndex = isOriginal ? i : slotIndices[offset + i]; + if (slotIndex < 0 || slotIndex >= l) { + continue; + } + var slotData = slotDatas[slotIndex]; + var slot = this.getSlot(slotData.name); + if (slot !== null) { + slot._setZOrder(i); + } + } + this._slotsDirty = true; + this._zOrderDirty = !isOriginal; + } + }; + /** + * @internal + */ + Armature.prototype._addBone = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bones.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._addSlot = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slots.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._addConstraint = function (value) { + if (this._constraints.indexOf(value) < 0) { + this._constraints.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this._armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @internal + */ + Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { + if (this._armatureData !== null) { + return; + } + this._armatureData = armatureData; + this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); + this._proxy = proxy; + this._display = display; + this._dragonBones = dragonBones; + this._proxy.dbInit(this); + this._animation.init(this); + this._animation.animations = this._armatureData.animations; + }; + /** + * @inheritDoc + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + this._lockUpdate = true; + if (this._armatureData === null) { + console.warn("The armature has been disposed."); + return; + } + else if (this._armatureData.parent === null) { + console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update animation. + this._animation.advanceTime(passedTime); + // Sort slots. + if (this._slotsDirty || this._zIndexDirty) { + this._slots.sort(Armature._onSortSlots); + if (this._zIndexDirty) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i]._setZOrder(i); // + } + } + this._slotsDirty = false; + this._zIndexDirty = false; + } + // Update alpha. + if (this._alphaDirty) { + this._alphaDirty = false; + this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone._updateAlpha(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot._updateAlpha(); + } + } + // Update bones and slots. + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { + var i = 0, l = 0; + for (i = 0, l = this._bones.length; i < l; ++i) { + this._bones[i].update(this._cacheFrameIndex); + } + for (i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].update(this._cacheFrameIndex); + } + } + // Do actions. + if (this._actions.length > 0) { + for (var _d = 0, _e = this._actions; _d < _e.length; _d++) { + var action = _e[_d]; + var actionData = action.actionData; + if (actionData !== null) { + if (actionData.type === 0 /* Play */) { + if (action.slot !== null) { + var childArmature = action.slot.childArmature; + if (childArmature !== null) { + childArmature.animation.fadeIn(actionData.name); + } + } + else if (action.bone !== null) { + for (var _f = 0, _g = this.getSlots(); _f < _g.length; _f++) { + var slot = _g[_f]; + if (slot.parent === action.bone) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.animation.fadeIn(actionData.name); + } + } + } + } + else { + this._animation.fadeIn(actionData.name); + } + } + } + action.returnToPool(); + } + this._actions.length = 0; + } + this._lockUpdate = false; + this._proxy.dbUpdate(); + }; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlot) { + if (boneName === void 0) { boneName = null; } + if (updateSlot === void 0) { updateSlot = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlot) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === bone) { + slot.invalidUpdate(); + } + } + } + } + } + else { + for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { + var bone = _c[_b]; + bone.invalidUpdate(); + } + if (updateSlot) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Armature.prototype.containsPoint = function (x, y) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.containsPoint(x, y)) { + return slot; + } + } + return null; + }; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var isV = xA === xB; + var dMin = 0.0; + var dMax = 0.0; + var intXA = 0.0; + var intYA = 0.0; + var intXB = 0.0; + var intYB = 0.0; + var intAN = 0.0; + var intBN = 0.0; + var intSlotA = null; + var intSlotB = null; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionPointA !== null || intersectionPointB !== null) { + if (intersectionPointA !== null) { + var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; + if (d < 0.0) { + d = -d; + } + if (intSlotA === null || d < dMin) { + dMin = d; + intXA = intersectionPointA.x; + intYA = intersectionPointA.y; + intSlotA = slot; + if (normalRadians) { + intAN = normalRadians.x; + } + } + } + if (intersectionPointB !== null) { + var d = intersectionPointB.x - xA; + if (d < 0.0) { + d = -d; + } + if (intSlotB === null || d > dMax) { + dMax = d; + intXB = intersectionPointB.x; + intYB = intersectionPointB.y; + intSlotB = slot; + if (normalRadians !== null) { + intBN = normalRadians.y; + } + } + } + } + else { + intSlotA = slot; + break; + } + } + } + if (intSlotA !== null && intersectionPointA !== null) { + intersectionPointA.x = intXA; + intersectionPointA.y = intYA; + if (normalRadians !== null) { + normalRadians.x = intAN; + } + } + if (intSlotB !== null && intersectionPointB !== null) { + intersectionPointB.x = intXB; + intersectionPointB.y = intYB; + if (normalRadians !== null) { + normalRadians.y = intBN; + } + } + return intSlotA; + }; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBone = function (name) { + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.name === name) { + return bone; + } + } + return null; + }; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBoneByDisplay = function (display) { + var slot = this.getSlotByDisplay(display); + return slot !== null ? slot.parent : null; + }; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlot = function (name) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.name === name) { + return slot; + } + } + return null; + }; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlotByDisplay = function (display) { + if (display !== null) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.display === display) { + return slot; + } + } + } + return null; + }; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + get: function () { + return this._flipX; + }, + set: function (value) { + if (this._flipX === value) { + return; + } + this._flipX = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "flipY", { + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + get: function () { + return this._flipY; + }, + set: function (value) { + if (this._flipY === value) { + return; + } + this._flipY = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "cacheFrameRate", { + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+             *     armature.cacheFrameRate = 24;
+             * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+             *     armature.cacheFrameRate = 24;
+             * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._armatureData.cacheFrameRate; + }, + set: function (value) { + if (this._armatureData.cacheFrameRate !== value) { + this._armatureData.cacheFrames(value); + // Set child armature frameRate. + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.cacheFrameRate = value; + } + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "name", { + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "armatureData", { + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._armatureData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "proxy", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "eventDispatcher", { + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @private + */ + get: function () { + return this._replacedTexture; + }, + set: function (value) { + if (this._replacedTexture === value) { + return; + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + this._replacedTexture = value; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + slot.invalidUpdate(); + slot.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + if (this._clock !== null) { + this._clock.remove(this); + } + this._clock = value; + if (this._clock) { + this._clock.add(this); + } + // Update childArmature clock. + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.clock = this._clock; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "parent", { + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(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 base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + var TransformObject = /** @class */ (function (_super) { + __extends(TransformObject, _super); + function TransformObject() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + */ + TransformObject.prototype._onClear = function () { + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; + this.userData = null; + this._globalDirty = false; + this._alpha = 1.0; + this._globalAlpha = 1.0; + this._armature = null; // + }; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + TransformObject._helpMatrix = new dragonBones.Matrix(); + TransformObject._helpTransform = new dragonBones.Transform(); + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(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) { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + var Bone = /** @class */ (function (_super) { + __extends(Bone, _super); + function Bone() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @internal + */ + _this.animationPose = new dragonBones.Transform(); + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this._transformDirty = false; + this._childrenTransformDirty = false; + this._localDirty = true; + this._hasConstraint = false; + this._visible = true; + this._cachedFrameIndex = -1; + this._boneData = null; // + this._parent = null; // + this._cachedFrameIndices = null; + }; + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + // For typescript. + var boneData = this._boneData; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var origin = this.origin; + var offset = this.offset; + var animationPose = this.animationPose; + var parent = this._parent; // + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var inherit = parent !== null; + var rotation = 0.0; + if (this.offsetMode === 1 /* Additive */) { + if (origin !== null) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = origin.x + offset.x + animationPose.x; + global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; + global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; + if (dragonBones.DragonBones.yDown) { + global.y = origin.y + offset.y + animationPose.y; + global.skew = origin.skew + offset.skew + animationPose.skew; + global.rotation = origin.rotation + offset.rotation + animationPose.rotation; + } + else { + global.y = origin.y - offset.y + animationPose.y; + global.skew = origin.skew - offset.skew + animationPose.skew; + global.rotation = origin.rotation - offset.rotation + animationPose.rotation; + } + } + else { + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + global.add(animationPose); + } + } + else if (this.offsetMode === 0 /* None */) { + if (origin !== null) { + global.copyFrom(origin).add(animationPose); + } + else { + global.copyFrom(animationPose); + } + } + else { + inherit = false; + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + } + if (inherit) { + var isSurface = parent._boneData.type === 1 /* Surface */; + var surfaceBone = isSurface ? parent._bone : null; + var parentMatrix = isSurface ? parent._getGlobalTransformMatrix(global.x, global.y) : parent.globalTransformMatrix; + if (boneData.inheritScale && (!isSurface || surfaceBone !== null)) { + if (isSurface) { + if (boneData.inheritRotation) { + global.rotation += parent.global.rotation; + } + surfaceBone.updateGlobalTransform(); + global.scaleX *= surfaceBone.global.scaleX; + global.scaleY *= surfaceBone.global.scaleY; + parentMatrix.transformPoint(global.x, global.y, global); + global.toMatrix(globalTransformMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } + else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + } + else { + if (!boneData.inheritRotation) { + parent.updateGlobalTransform(); + if (flipX && flipY) { + rotation = global.rotation - (parent.global.rotation + Math.PI); + } + else if (flipX) { + rotation = global.rotation + parent.global.rotation + Math.PI; + } + else if (flipY) { + rotation = global.rotation + parent.global.rotation; + } + else { + rotation = global.rotation - parent.global.rotation; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } + else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + if (isCache) { + global.fromMatrix(globalTransformMatrix); + } + else { + this._globalDirty = true; + } + } + } + else { + if (boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (boneData.inheritRotation) { + parent.updateGlobalTransform(); + if (parent.global.scaleX < 0.0) { + rotation = global.rotation + parent.global.rotation + Math.PI; + } + else { + rotation = global.rotation + parent.global.rotation; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + rotation -= global.rotation * 2.0; + if (flipX !== flipY || boneData.inheritReflection) { + global.skew += Math.PI; + } + if (!dragonBones.DragonBones.yDown) { + global.skew = -global.skew; + } + } + global.rotation = rotation; + } + else if (flipX || flipY) { + if (flipX && flipY) { + rotation = global.rotation + Math.PI; + } + else { + if (flipX) { + rotation = Math.PI - global.rotation; + } + else { + rotation = -global.rotation; + } + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + rotation = global.rotation + Math.PI; + } + else { + if (flipX) { + rotation = Math.PI - global.rotation; + } + else { + rotation = -global.rotation; + } + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + */ + Bone.prototype._updateAlpha = function () { + if (this._parent !== null) { + this._globalAlpha = this._alpha * this._parent._globalAlpha; + } + else { + this._globalAlpha = this._alpha * this._armature._globalAlpha; + } + }; + /** + * @internal + */ + Bone.prototype.init = function (boneData, armatureValue) { + if (this._boneData !== null) { + return; + } + this._boneData = boneData; + this._armature = armatureValue; + this._alpha = this._boneData.alpha; + if (this._boneData.parent !== null) { + this._parent = this._armature.getBone(this._boneData.parent.name); + } + this._armature._addBone(this); + // + this.origin = this._boneData.transform; + }; + /** + * @internal + */ + Bone.prototype.update = function (cacheFrameIndex) { + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + // + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + // + } + else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + this._localDirty = true; + }; + /** + * @internal + */ + Bone.prototype.updateByConstraint = function () { + if (this._localDirty) { + this._localDirty = false; + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { + this._updateGlobalTransformMatrix(true); + } + this._transformDirty = true; + } + }; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * - Check whether the bone contains a specific bone. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (value) { + if (value === this) { + return false; + } + var ancestor = value; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + Object.defineProperty(Bone.prototype, "boneData", { + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._boneData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "visible", { + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible === value) { + return; + } + this._visible = value; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + slot._updateVisible(); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "name", { + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._boneData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "parent", { + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(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) { + /** + * @internal + */ + var Surface = /** @class */ (function (_super) { + __extends(Surface, _super); + function Surface() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._vertices = []; + _this._deformVertices = []; + /** + * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + _this._hullCache = []; + /** + * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + _this._matrixCahce = []; + return _this; + } + Surface.toString = function () { + return "[class dragonBones.Surface]"; + }; + Surface.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._dX = 0.0; + this._dY = 0.0; + this._k = 0.0; + this._kX = 0.0; + this._kY = 0.0; + this._vertices.length = 0; + this._deformVertices.length = 0; + this._matrixCahce.length = 0; + this._hullCache.length = 0; + this._bone = null; + }; + Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { + var dabX = bX - aX; + var dabY = bY - aY; + var dacX = cX - aX; + var dacY = cY - aY; + transform.rotation = Math.atan2(dabY, dabX); + transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; + if (isDown) { + transform.rotation += Math.PI; + } + transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; + transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; + transform.toMatrix(matrix); + transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); + transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); + }; + Surface.prototype._updateVertices = function () { + var data = this._armature.armatureData.parent; + var geometry = this._boneData.geometry; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; + var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; + var vertices = this._vertices; + var animationVertices = this._deformVertices; + if (this._parent !== null) { + if (this._parent._boneData.type === 1 /* Surface */) { + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + var x = floatArray[verticesOffset + iD] + animationVertices[iD]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + var matrix = this._parent._getGlobalTransformMatrix(x, y); + // + vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; + vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty; + } + } + else { + var parentMatrix = this._parent.globalTransformMatrix; + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + var x = floatArray[verticesOffset + iD] + animationVertices[iD]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + // + vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + } + } + else { + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; + vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + } + } + }; + Surface.prototype._updateGlobalTransformMatrix = function (isCache) { + // tslint:disable-next-line:no-unused-expression + isCache; + var segmentXD = this._boneData.segmentX * 2; + var lastIndex = this._vertices.length - 2; + var lA = 200.0; + // + var raX = this._vertices[0]; + var raY = this._vertices[1]; + var rbX = this._vertices[segmentXD]; + var rbY = this._vertices[segmentXD + 1]; + var rcX = this._vertices[lastIndex]; + var rcY = this._vertices[lastIndex + 1]; + var rdX = this._vertices[lastIndex - segmentXD]; + var rdY = this._vertices[lastIndex - segmentXD + 1]; + // + var dacX = raX + (rcX - raX) * 0.5; + var dacY = raY + (rcY - raY) * 0.5; + var dbdX = rbX + (rdX - rbX) * 0.5; + var dbdY = rbY + (rdY - rbY) * 0.5; + var aX = dacX + (dbdX - dacX) * 0.5; + var aY = dacY + (dbdY - dacY) * 0.5; + var bX = rbX + (rcX - rbX) * 0.5; + var bY = rbY + (rcY - rbY) * 0.5; + var cX = rdX + (rcX - rdX) * 0.5; + var cY = rdY + (rcY - rdY) * 0.5; + // TODO interpolation + this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); + this._globalDirty = false; + }; + Surface.prototype._getGlobalTransformMatrix = function (x, y) { + var lA = 200.0; + var lB = 1000.0; + if (x < -lB || lB < x || y < -lB || lB < y) { + return this.globalTransformMatrix; + } + var isDown = false; + var surfaceData = this._boneData; + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var segmentXD = surfaceData.segmentX * 2; + var dX = this._dX; + var dY = this._dY; + var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 + var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 + var matrixIndex = 0; + var pX = indexX * dX - lA; + var pY = indexY * dY - lA; + // + var matrices = this._matrixCahce; + var helpMatrix = Surface._helpMatrix; + if (x < -lA) { + if (y < -lA || y >= lA) { // Out. + return this.globalTransformMatrix; + } + // Left. + isDown = y > this._kX * (x + lA) + pY; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexY * (segmentXD + 2); + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[2] - (segmentY - indexY) * ddX; + var sY = this._hullCache[3] - (segmentY - indexY) * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (x >= lA) { + if (y < -lA || y >= lA) { // Out. + return this.globalTransformMatrix; + } + // Right. + isDown = y > this._kX * (x - lB) + pY; + matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[0] + indexY * ddX; + var sY = this._hullCache[1] + indexY * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (y < -lA) { + if (x < -lA || x >= lA) { // Out. + return this.globalTransformMatrix; + } + // Up. + isDown = y > this._kY * (x - pX - dX) - lB; + matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexX * 2; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[8] + indexX * ddX; + var sY = this._hullCache[9] + indexX * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (y >= lA) { + if (x < -lA || x >= lA) { // Out. + return this.globalTransformMatrix; + } + // Down + isDown = y > this._kY * (x - pX - dX) + lA; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[6] - (segmentX - indexX) * ddX; + var sY = this._hullCache[7] - (segmentX - indexX) * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else { // Center. + isDown = y > this._k * (x - pX - dX) + pY; + matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + return helpMatrix; + }; + /** + * @internal + * @private + */ + Surface.prototype.init = function (surfaceData, armatureValue) { + if (this._boneData !== null) { + return; + } + _super.prototype.init.call(this, surfaceData, armatureValue); + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; + var lB = 1000.0; + var lA = 200.0; + // + this._dX = lA * 2.0 / segmentX; + this._dY = lA * 2.0 / segmentY; + this._k = -this._dY / this._dX; + this._kX = -this._dY / (lB - lA); + this._kY = -(lB - lA) / this._dX; + this._vertices.length = vertexCount * 2; + this._deformVertices.length = vertexCount * 2; + this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; + this._hullCache.length = 10; + for (var i = 0; i < vertexCount * 2; ++i) { + this._deformVertices[i] = 0.0; + } + if (this._parent !== null) { + if (this._parent.boneData.type === 0 /* Bone */) { + this._bone = this._parent; + } + else { + this._bone = this._parent._bone; + } + } + }; + /** + * @internal + */ + Surface.prototype.update = function (cacheFrameIndex) { + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + // + for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { + this._matrixCahce[i] = -1.0; + } + // + this._updateVertices(); + // + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + // Update hull vertices. + var lB = 1000.0; + var lA = 200.0; + var ddX = 2 * this.global.x; + var ddY = 2 * this.global.y; + // + var helpPoint = Surface._helpPoint; + this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); + this._hullCache[0] = helpPoint.x; + this._hullCache[1] = helpPoint.y; + this._hullCache[2] = ddX - helpPoint.x; + this._hullCache[3] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); + this._hullCache[4] = helpPoint.x; + this._hullCache[5] = helpPoint.y; + // + this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); + this._hullCache[6] = helpPoint.x; + this._hullCache[7] = helpPoint.y; + this._hullCache[8] = ddX - helpPoint.x; + this._hullCache[9] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); + this._hullCache[10] = helpPoint.x; + this._hullCache[11] = helpPoint.y; + } + else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + this._localDirty = true; + }; + return Surface; + }(dragonBones.Bone)); + dragonBones.Surface = Surface; +})(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 DisplayFrame = /** @class */ (function (_super) { + __extends(DisplayFrame, _super); + function DisplayFrame() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.deformVertices = []; + return _this; + } + DisplayFrame.toString = function () { + return "[class dragonBones.DisplayFrame]"; + }; + DisplayFrame.prototype._onClear = function () { + this.rawDisplayData = null; + this.displayData = null; + this.textureData = null; + this.display = null; + this.deformVertices.length = 0; + }; + DisplayFrame.prototype.updateDeformVertices = function () { + if (this.rawDisplayData === null || this.deformVertices.length !== 0) { + return; + } + var rawGeometryData; + if (this.rawDisplayData.type === 2 /* Mesh */) { + rawGeometryData = this.rawDisplayData.geometry; + } + else if (this.rawDisplayData.type === 4 /* Path */) { + rawGeometryData = this.rawDisplayData.geometry; + } + else { + return; + } + var vertexCount = 0; + if (rawGeometryData.weight !== null) { + vertexCount = rawGeometryData.weight.count * 2; + } + else { + vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; + } + this.deformVertices.length = vertexCount; + for (var i = 0, l = this.deformVertices.length; i < l; ++i) { + this.deformVertices[i] = 0.0; + } + }; + DisplayFrame.prototype.getGeometryData = function () { + if (this.displayData !== null) { + if (this.displayData.type === 2 /* Mesh */) { + return this.displayData.geometry; + } + if (this.displayData.type === 4 /* Path */) { + return this.displayData.geometry; + } + } + if (this.rawDisplayData !== null) { + if (this.rawDisplayData.type === 2 /* Mesh */) { + return this.rawDisplayData.geometry; + } + if (this.rawDisplayData.type === 4 /* Path */) { + return this.rawDisplayData.geometry; + } + } + return null; + }; + DisplayFrame.prototype.getBoundingBox = function () { + if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { + return this.displayData.boundingBox; + } + if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { + return this.rawDisplayData.boundingBox; + } + return null; + }; + DisplayFrame.prototype.getTextureData = function () { + if (this.displayData !== null) { + if (this.displayData.type === 0 /* Image */) { + return this.displayData.texture; + } + if (this.displayData.type === 2 /* Mesh */) { + return this.displayData.texture; + } + } + if (this.textureData !== null) { + return this.textureData; + } + if (this.rawDisplayData !== null) { + if (this.rawDisplayData.type === 0 /* Image */) { + return this.rawDisplayData.texture; + } + if (this.rawDisplayData.type === 2 /* Mesh */) { + return this.rawDisplayData.texture; + } + } + return null; + }; + return DisplayFrame; + }(dragonBones.BaseObject)); + dragonBones.DisplayFrame = DisplayFrame; + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + var Slot = /** @class */ (function (_super) { + __extends(Slot, _super); + function Slot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._localMatrix = new dragonBones.Matrix(); + /** + * @internal + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @internal + */ + _this._displayFrames = []; + /** + * @internal + */ + _this._geometryBones = []; + _this._rawDisplay = null; // Initial value. + _this._meshDisplay = null; // Initial value. + _this._display = null; + return _this; + } + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var dispayFrame = _a[_i]; + var display = dispayFrame.display; + if (display !== this._rawDisplay && display !== this._meshDisplay && + disposeDisplayList.indexOf(display) < 0) { + disposeDisplayList.push(display); + } + dispayFrame.returnToPool(); + } + for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { + var eachDisplay = disposeDisplayList_1[_b]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay, true); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. + this._disposeDisplay(this._meshDisplay, false); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay, false); + } + this.displayController = null; + this._displayDataDirty = false; + this._displayDirty = false; + this._geometryDirty = false; + this._textureDirty = false; + this._visibleDirty = false; + this._blendModeDirty = false; + this._zOrderDirty = false; + this._colorDirty = false; + this._verticesDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._zIndex = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._displayFrames.length = 0; + this._geometryBones.length = 0; + this._slotData = null; // + this._displayFrame = null; + this._geometryData = null; + this._boundingBoxData = null; + this._textureData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._parent = null; // + this._cachedFrameIndices = null; + }; + Slot.prototype._hasDisplay = function (display) { + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var displayFrame = _a[_i]; + if (displayFrame.display === display) { + return true; + } + } + return false; + }; + /** + * @internal + */ + Slot.prototype._isBonesUpdate = function () { + for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + */ + Slot.prototype._updateAlpha = function () { + var globalAlpha = this._alpha * this._parent._globalAlpha; + if (this._globalAlpha !== globalAlpha) { + this._globalAlpha = globalAlpha; + this._colorDirty = true; + } + }; + Slot.prototype._updateDisplayData = function () { + var prevDisplayFrame = this._displayFrame; + var prevGeometryData = this._geometryData; + var prevTextureData = this._textureData; + var rawDisplayData = null; + var displayData = null; + this._displayFrame = null; + this._geometryData = null; + this._boundingBoxData = null; + this._textureData = null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { + this._displayFrame = this._displayFrames[this._displayIndex]; + rawDisplayData = this._displayFrame.rawDisplayData; + displayData = this._displayFrame.displayData; + this._geometryData = this._displayFrame.getGeometryData(); + this._boundingBoxData = this._displayFrame.getBoundingBox(); + this._textureData = this._displayFrame.getTextureData(); + } + if (this._displayFrame !== prevDisplayFrame || + this._geometryData !== prevGeometryData || this._textureData !== prevTextureData) { + // Update pivot offset. + if (this._geometryData === null && this._textureData !== null) { + var imageDisplayData = ((displayData !== null && displayData.type === 0 /* Image */) ? displayData : rawDisplayData); // + var scale = this._textureData.parent.scale * this._armature._armatureData.scale; + var frame = this._textureData.frame; + this._pivotX = imageDisplayData.pivot.x; + this._pivotY = imageDisplayData.pivot.y; + var rect = frame !== null ? frame : this._textureData.region; + var width = rect.width; + var height = rect.height; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width * scale; + this._pivotY *= height * scale; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + // Update replace pivot. TODO + if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) { + rawDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); + this._pivotX -= Slot._helpPoint.x; + this._pivotY -= Slot._helpPoint.y; + imageDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); + this._pivotX += Slot._helpPoint.x; + this._pivotY += Slot._helpPoint.y; + } + if (!dragonBones.DragonBones.yDown) { + this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update original transform. + if (rawDisplayData !== null) { // Compatible. + this.origin = rawDisplayData.transform; + } + else if (displayData !== null) { // Compatible. + this.origin = displayData.transform; + } + else { + this.origin = null; + } + // TODO remove slot offset. + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + // Update geometry. + if (this._geometryData !== prevGeometryData) { + this._geometryDirty = true; + this._verticesDirty = true; + if (this._geometryData !== null) { + this._geometryBones.length = 0; + if (this._geometryData.weight !== null) { + for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { + var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); + this._geometryBones.push(bone); + } + } + } + else { + this._geometryBones.length = 0; + this._geometryData = null; + } + } + this._textureDirty = this._textureData !== prevTextureData; + this._transformDirty = true; + } + }; + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayFrame !== null) { + this._display = this._displayFrame.display; + if (this._display !== null && this._display instanceof dragonBones.Armature) { + this._childArmature = this._display; + this._display = this._childArmature.display; + } + else { + this._childArmature = null; + } + } + else { + this._display = null; + this._childArmature = null; + } + // Update display. + var currentDisplay = this._display !== null ? this._display : this._rawDisplay; + if (currentDisplay !== prevDisplay) { + this._textureDirty = true; + this._visibleDirty = true; + this._blendModeDirty = true; + // this._zOrderDirty = true; + this._colorDirty = true; + this._transformDirty = true; + this._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + } + // Update child armature. + if (this._childArmature !== prevChildArmature) { + if (prevChildArmature !== null) { + prevChildArmature._parent = null; // Update child armature parent. + prevChildArmature.clock = null; + if (prevChildArmature.inheritAnimation) { + prevChildArmature.animation.reset(); + } + } + if (this._childArmature !== null) { + this._childArmature._parent = this; // Update child armature parent. + this._childArmature.clock = this._armature.clock; + if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. + if (this._childArmature.cacheFrameRate === 0) { + var cacheFrameRate = this._armature.cacheFrameRate; + if (cacheFrameRate !== 0) { + this._childArmature.cacheFrameRate = cacheFrameRate; + } + } + // Child armature action. + if (this._displayFrame !== null) { + var actions = null; + var displayData = this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; + if (displayData !== null && displayData.type === 1 /* Armature */) { + actions = displayData.actions; + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + eventObject.slot = this; + this._armature._bufferAction(eventObject, false); + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + } + }; + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(parentMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @internal + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return; + } + this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; + this._displayDataDirty = true; + this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; + }; + /** + * @internal + */ + Slot.prototype._setZOrder = function (value) { + if (this._zOrder === value) { + // return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + return this._colorDirty = true; + }; + /** + * @internal + */ + Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { + if (this._slotData !== null) { + return; + } + this._slotData = slotData; + this._colorDirty = true; // + this._blendModeDirty = true; // + this._blendMode = this._slotData.blendMode; + this._zOrder = this._slotData.zOrder; + this._zIndex = this._slotData.zIndex; + this._alpha = this._slotData.alpha; + this._colorTransform.copyFrom(this._slotData.color); + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + // + this._armature = armatureValue; + var slotParent = this._armature.getBone(this._slotData.parent.name); + if (slotParent !== null) { + this._parent = slotParent; + } + else { + // Never; + } + this._armature._addSlot(this); + // + this._initDisplay(this._rawDisplay, false); + if (this._rawDisplay !== this._meshDisplay) { + this._initDisplay(this._meshDisplay, false); + } + this._onUpdateDisplay(); + this._addDisplay(); + }; + /** + * @internal + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDataDirty) { + this._updateDisplayData(); + this._displayDataDirty = false; + } + if (this._displayDirty) { + this._updateDisplay(); + this._displayDirty = false; + } + if (this._geometryDirty || this._textureDirty) { + if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { + this._updateFrame(); + } + this._geometryDirty = false; + this._textureDirty = false; + } + if (this._display === null) { + return; + } + if (this._visibleDirty) { + this._updateVisible(); + this._visibleDirty = false; + } + if (this._blendModeDirty) { + this._updateBlendMode(); + this._blendModeDirty = false; + } + if (this._colorDirty) { + this._updateColor(); + this._colorDirty = false; + } + if (this._zOrderDirty) { + this._updateZOrder(); + this._zOrderDirty = false; + } + if (this._geometryData !== null && this._display === this._meshDisplay) { + var isSkinned = this._geometryData.weight !== null; + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + if (this._verticesDirty || + (isSkinned && this._isBonesUpdate()) || + (isSurface && this._parent._childrenTransformDirty)) { + this._verticesDirty = false; // Allow update mesh to reset the dirty value. + this._updateMesh(); + } + if (isSkinned || isSurface) { // Compatible. + return; + } + } + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + if (this._transformDirty) { + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + this._updateGlobalTransformMatrix(isCache); + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + this._updateTransform(); + this._transformDirty = false; + } + }; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDataDirty = true; + this._displayDirty = true; + // + this._transformDirty = true; + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._updateGlobalTransformMatrix(false); + this._transformDirty = false; + } + }; + /** + * @private + */ + Slot.prototype.replaceRawDisplayData = function (displayData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.rawDisplayData !== displayData) { + displayFrame.deformVertices.length = 0; + displayFrame.rawDisplayData = displayData; + if (displayFrame.rawDisplayData === null) { + var defaultSkin = this._armature._armatureData.defaultSkin; + if (defaultSkin !== null) { + var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); + if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { + displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; + } + } + } + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceDisplayData = function (displayData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { + displayFrame.displayData = displayData; + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceTextureData = function (textureData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.textureData !== textureData) { + displayFrame.textureData = textureData; + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceDisplay = function (value, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.display !== value) { + var prevDisplay = displayFrame.display; + displayFrame.display = value; + if (prevDisplay !== null && + prevDisplay !== this._rawDisplay && prevDisplay !== this._meshDisplay && + !this._hasDisplay(prevDisplay)) { + if (prevDisplay instanceof dragonBones.Armature) { + // (eachDisplay as Armature).dispose(); + } + else { + this._disposeDisplay(prevDisplay, true); + } + } + if (value !== null && + value !== this._rawDisplay && value !== this._meshDisplay && + !this._hasDisplay(prevDisplay) && + !(value instanceof dragonBones.Armature)) { + this._initDisplay(value, true); + } + if (index === this._displayIndex) { + this._displayDirty = true; + } + } + }; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Slot.prototype.containsPoint = function (x, y) { + if (this._boundingBoxData === null) { + return false; + } + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); + return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); + }; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + if (this._boundingBoxData === null) { + return 0; + } + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); + xA = Slot._helpPoint.x; + yA = Slot._helpPoint.y; + Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); + xB = Slot._helpPoint.x; + yB = Slot._helpPoint.y; + var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionCount === 1 || intersectionCount === 2) { + if (intersectionPointA !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + if (intersectionPointB !== null) { + intersectionPointB.x = intersectionPointA.x; + intersectionPointB.y = intersectionPointA.y; + } + } + else if (intersectionPointB !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + } + else { + if (intersectionPointA !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + } + if (intersectionPointB !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + } + if (normalRadians !== null) { + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); + normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); + normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + } + } + return intersectionCount; + }; + /** + * @private + */ + Slot.prototype.getDisplayFrameAt = function (index) { + return this._displayFrames[index]; + }; + Object.defineProperty(Slot.prototype, "visible", { + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible === value) { + return; + } + this._visible = value; + this._updateVisible(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayFrameCount", { + /** + * @private + */ + get: function () { + return this._displayFrames.length; + }, + set: function (value) { + var prevCount = this._displayFrames.length; + if (prevCount < value) { + this._displayFrames.length = value; + for (var i = prevCount; i < value; ++i) { + this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); + } + } + else if (prevCount > value) { + for (var i = prevCount - 1; i < value; --i) { + this.replaceDisplay(null, i); + this._displayFrames[i].returnToPool(); + } + this._displayFrames.length = value; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * - The index of the display object displayed in the display list. + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     slot.displayIndex = 3;
+             *     slot.displayController = "none";
+             * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     slot.displayIndex = 3;
+             *     slot.displayController = "none";
+             * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + this._setDisplayIndex(value); + this.update(-1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "name", { + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._slotData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + var displays = new Array(); + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var displayFrame = _a[_i]; + displays.push(displayFrame.display); + } + return displays; + }, + set: function (value) { + this.displayFrameCount = value.length; + var index = 0; + for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { + var eachDisplay = value_1[_i]; + this.replaceDisplay(eachDisplay, index++); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "slotData", { + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._slotData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return this._boundingBoxData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "rawDisplay", { + /** + * @private + */ + get: function () { + return this._rawDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "meshDisplay", { + /** + * @private + */ + get: function () { + return this._meshDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "display", { + /** + * - The display object that the slot displays at this time. + * @example + *
+             *     let slot = armature.getSlot("text");
+             *     slot.display = new yourEngine.TextField();
+             * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+             *     let slot = armature.getSlot("text");
+             *     slot.display = new yourEngine.TextField();
+             * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + if (this._displayFrames.length === 0) { + this.displayFrameCount = 1; + this._displayIndex = 0; + } + this.replaceDisplay(value, this._displayIndex); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * - The child armature that the slot displayed at current time. + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     let prevChildArmature = slot.childArmature;
+             *     if (prevChildArmature) {
+             *         prevChildArmature.dispose();
+             *     }
+             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+             * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     let prevChildArmature = slot.childArmature;
+             *     if (prevChildArmature) {
+             *         prevChildArmature.dispose();
+             *     }
+             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+             * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._childArmature; + }, + set: function (value) { + if (this._childArmature === value) { + return; + } + this.display = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "parent", { + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(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) { + /** + * @internal + */ + var Constraint = /** @class */ (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this._armature = null; // + this._target = null; // + this._root = null; // + this._bone = null; + }; + Object.defineProperty(Constraint.prototype, "name", { + get: function () { + return this._constraintData.name; + }, + enumerable: true, + configurable: true + }); + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @internal + */ + var IKConstraint = /** @class */ (function (_super) { + __extends(IKConstraint, _super); + function IKConstraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraint.toString = function () { + return "[class dragonBones.IKConstraint]"; + }; + IKConstraint.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._scaleEnabled = false; + this._bendPositive = false; + this._weight = 1.0; + this._constraintData = null; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this._target.global; + var global = this._root.global; + var globalTransformMatrix = this._root.globalTransformMatrix; + var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + radian += Math.PI; + } + global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype._computeB = function () { + var boneLength = this._bone._boneData.length; + var parent = this._root; + var ikGlobal = this._target.global; + var parentGlobal = parent.global; + var global = this._bone.global; + var globalTransformMatrix = this._bone.globalTransformMatrix; + var x = globalTransformMatrix.a * boneLength; + var y = globalTransformMatrix.b * boneLength; + var lLL = x * x + y * y; + var lL = Math.sqrt(lLL); + var dX = global.x - parentGlobal.x; + var dY = global.y - parentGlobal.y; + var lPP = dX * dX + dY * dY; + var lP = Math.sqrt(lPP); + var rawRadian = global.rotation; + var rawParentRadian = parentGlobal.rotation; + var rawRadianA = Math.atan2(dY, dX); + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + var lTT = dX * dX + dY * dY; + var lT = Math.sqrt(lTT); + var radianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + radianA += Math.PI; + } + } + else { + var h = (lPP - lLL + lTT) / (2.0 * lTT); + var r = Math.sqrt(lPP - h * h * lTT) / lT; + var hX = parentGlobal.x + (dX * h); + var hY = parentGlobal.y + (dY * h); + var rX = -dY * r; + var rY = dX * r; + var isPPR = false; + var parentParent = parent.parent; + if (parentParent !== null) { + var parentParentMatrix = parentParent.globalTransformMatrix; + isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; + } + if (isPPR !== this._bendPositive) { + global.x = hX - rX; + global.y = hY - rY; + } + else { + global.x = hX + rX; + global.y = hY + rY; + } + radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); + parentGlobal.rotation = rawParentRadian + dR * this._weight; + parentGlobal.toMatrix(parent.globalTransformMatrix); + // + var currentRadianA = rawRadianA + dR * this._weight; + global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; + global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; + // + var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + radianB += Math.PI; + } + global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.init = function (constraintData, armature) { + if (this._constraintData !== null) { + return; + } + this._constraintData = constraintData; + this._armature = armature; + this._target = this._armature.getBone(this._constraintData.target.name); + this._root = this._armature.getBone(this._constraintData.root.name); + this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; + { + var ikConstraintData = this._constraintData; + this._scaleEnabled = ikConstraintData.scaleEnabled; + this._bendPositive = ikConstraintData.bendPositive; + this._weight = ikConstraintData.weight; + } + this._root._hasConstraint = true; + }; + IKConstraint.prototype.update = function () { + this._root.updateByConstraint(); + if (this._bone !== null) { + this._bone.updateByConstraint(); + this._computeB(); + } + else { + this._computeA(); + } + }; + IKConstraint.prototype.invalidUpdate = function () { + this._root.invalidUpdate(); + if (this._bone !== null) { + this._bone.invalidUpdate(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; + /** + * @internal + */ + var PathConstraint = /** @class */ (function (_super) { + __extends(PathConstraint, _super); + function PathConstraint() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._bones = []; + _this._spaces = []; + _this._positions = []; + _this._curves = []; + _this._boneLengths = []; + _this._pathGlobalVertices = []; + _this._segments = [10]; + return _this; + } + PathConstraint.toString = function () { + return "[class dragonBones.PathConstraint]"; + }; + PathConstraint.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.dirty = false; + this.pathOffset = 0; + this.position = 0.0; + this.spacing = 0.0; + this.rotateOffset = 0.0; + this.rotateMix = 1.0; + this.translateMix = 1.0; + this._pathSlot = null; + this._bones.length = 0; + this._spaces.length = 0; + this._positions.length = 0; + this._curves.length = 0; + this._boneLengths.length = 0; + this._pathGlobalVertices.length = 0; + }; + PathConstraint.prototype._updatePathVertices = function (verticesData) { + //计算曲线的节点数据 + var armature = this._armature; + var dragonBonesData = armature.armatureData.parent; + var scale = armature.armatureData.scale; + var intArray = dragonBonesData.intArray; + var floatArray = dragonBonesData.floatArray; + var pathOffset = verticesData.offset; + var pathVertexCount = intArray[pathOffset + 0 /* GeometryVertexCount */]; + var pathVertexOffset = intArray[pathOffset + 2 /* GeometryFloatOffset */]; + this._pathGlobalVertices.length = pathVertexCount * 2; + var weightData = verticesData.weight; + //没有骨骼约束我,那节点只受自己的Bone控制 + if (weightData === null) { + var parentBone = this._pathSlot.parent; + parentBone.updateByConstraint(); + var matrix = parentBone.globalTransformMatrix; + for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { + var vx = floatArray[iV_1++] * scale; + var vy = floatArray[iV_1++] * scale; + var x = matrix.a * vx + matrix.c * vy + matrix.tx; + var y = matrix.b * vx + matrix.d * vy + matrix.ty; + // + this._pathGlobalVertices[i] = x; + this._pathGlobalVertices[i + 1] = y; + } + return; + } + //有骨骼约束我,那我的节点受骨骼权重控制 + var bones = this._pathSlot._geometryBones; + var weightBoneCount = weightData.bones.length; + var weightOffset = weightData.offset; + var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; + var iV = floatOffset; + var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; + for (var i = 0, iW = 0; i < pathVertexCount; i++) { + var vertexBoneCount = intArray[iB++]; // + var xG = 0.0, yG = 0.0; + for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (bone === null) { + continue; + } + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var vx = floatArray[iV++] * scale; + var vy = floatArray[iV++] * scale; + xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; + yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; + } + this._pathGlobalVertices[iW++] = xG; + this._pathGlobalVertices[iW++] = yG; + } + }; + PathConstraint.prototype._computeVertices = function (start, count, offset, out) { + //TODO优化 + for (var i = offset, iW = start; i < count; i += 2) { + out[i] = this._pathGlobalVertices[iW++]; + out[i + 1] = this._pathGlobalVertices[iW++]; + } + }; + PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { + //计算当前的骨骼在曲线上的位置 + var armature = this._armature; + var intArray = armature.armatureData.parent.intArray; + var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; + var positions = this._positions; + var spaces = this._spaces; + var isClosed = pathDisplayDta.closed; + var curveVertices = Array(); + var verticesLength = vertexCount * 2; + var curveCount = verticesLength / 6; + var preCurve = -1; + var position = this.position; + positions.length = spaceCount * 3 + 2; + var pathLength = 0.0; + //不需要匀速运动,效率高些 + if (!pathDisplayDta.constantSpeed) { + var lenghts = pathDisplayDta.curveLengths; + curveCount -= isClosed ? 1 : 2; + pathLength = lenghts[curveCount]; + if (percentPosition) { + position *= pathLength; + } + if (percentSpacing) { + for (var i = 0; i < spaceCount; i++) { + spaces[i] *= pathLength; + } + } + curveVertices.length = 8; + for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + if (isClosed) { + position %= pathLength; + if (position < 0) { + position += pathLength; + } + curve = 0; + } + else if (position < 0) { + //TODO + continue; + } + else if (position > pathLength) { + //TODO + continue; + } + var percent = 0.0; + for (;; curve++) { + var len = lenghts[curve]; + if (position > len) { + continue; + } + if (curve === 0) { + percent = position / len; + } + else { + var preLen = lenghts[curve - 1]; + percent = (position - preLen) / (len - preLen); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + if (isClosed && curve === curveCount) { + //计算曲线 + this._computeVertices(verticesLength - 4, 4, 0, curveVertices); + this._computeVertices(0, 4, 4, curveVertices); + } + else { + this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); + } + } + // + this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); + } + return; + } + //匀速的 + if (isClosed) { + verticesLength += 2; + curveVertices.length = vertexCount; + this._computeVertices(2, verticesLength - 4, 0, curveVertices); + this._computeVertices(0, 2, verticesLength - 4, curveVertices); + curveVertices[verticesLength - 2] = curveVertices[0]; + curveVertices[verticesLength - 1] = curveVertices[1]; + } + else { + curveCount--; + verticesLength -= 4; + curveVertices.length = verticesLength; + this._computeVertices(2, verticesLength, 0, curveVertices); + } + // + var curves = new Array(curveCount); + pathLength = 0; + var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = curveVertices[w]; + cy1 = curveVertices[w + 1]; + cx2 = curveVertices[w + 2]; + cy2 = curveVertices[w + 3]; + x2 = curveVertices[w + 4]; + y2 = curveVertices[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) { + position *= pathLength; + } + if (percentSpacing) { + for (var i = 0; i < spaceCount; i++) { + spaces[i] *= pathLength; + } + } + var segments = this._segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (isClosed) { + p %= pathLength; + if (p < 0) + p += pathLength; + curve = 0; + } + else if (p < 0) { + continue; + } + else if (p > pathLength) { + continue; + } + // Determine curve containing position. + for (;; curve++) { + var length_1 = curves[curve]; + if (p > length_1) + continue; + if (curve === 0) + p /= length_1; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_1 - prev); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + var ii = curve * 6; + x1 = curveVertices[ii]; + y1 = curveVertices[ii + 1]; + cx1 = curveVertices[ii + 2]; + cy1 = curveVertices[ii + 3]; + cx2 = curveVertices[ii + 4]; + cy2 = curveVertices[ii + 5]; + x2 = curveVertices[ii + 6]; + y2 = curveVertices[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + // Weight by segment length. + p *= curveLength; + for (;; segment++) { + var length_2 = segments[segment]; + if (p > length_2) + continue; + if (segment === 0) + p /= length_2; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_2 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); + } + }; + //Calculates a point on the curve, for a given t value between 0 and 1. + PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { + if (t === 0) { + out[offset] = x1; + out[offset + 1] = y1; + out[offset + 2] = 0; + return; + } + if (t === 1) { + out[offset] = x2; + out[offset + 1] = y2; + out[offset + 2] = 0; + return; + } + var mt = 1 - t; + var mt2 = mt * mt; + var t2 = t * t; + var a = mt2 * mt; + var b = mt2 * t * 3; + var c = mt * t2 * 3; + var d = t * t2; + var x = a * x1 + b * cx1 + c * cx2 + d * x2; + var y = a * y1 + b * cy1 + c * cy2 + d * y2; + out[offset] = x; + out[offset + 1] = y; + if (tangents) { + //Calculates the curve tangent at the specified t value + out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); + } + else { + out[offset + 2] = 0; + } + }; + PathConstraint.prototype.init = function (constraintData, armature) { + this._constraintData = constraintData; + this._armature = armature; + var data = constraintData; + this.pathOffset = data.pathDisplayData.geometry.offset; + // + this.position = data.position; + this.spacing = data.spacing; + this.rotateOffset = data.rotateOffset; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + // + this._root = this._armature.getBone(data.root.name); + this._target = this._armature.getBone(data.target.name); + this._pathSlot = this._armature.getSlot(data.pathSlot.name); + for (var i = 0, l = data.bones.length; i < l; i++) { + var bone = this._armature.getBone(data.bones[i].name); + if (bone !== null) { + this._bones.push(bone); + } + } + if (data.rotateMode === 2 /* ChainScale */) { + this._boneLengths.length = this._bones.length; + } + this._root._hasConstraint = true; + }; + PathConstraint.prototype.update = function () { + var pathSlot = this._pathSlot; + if (pathSlot._geometryData === null || + pathSlot._geometryData.offset !== this.pathOffset) { + return; + } + var constraintData = this._constraintData; + // + //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 + var isPathVerticeDirty = false; + if (this._root._childrenTransformDirty) { + this._updatePathVertices(pathSlot._geometryData); + isPathVerticeDirty = true; + } + else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) { + this._updatePathVertices(pathSlot._geometryData); + pathSlot._verticesDirty = false; + isPathVerticeDirty = true; + } + if (!isPathVerticeDirty && !this.dirty) { + return; + } + // + var positionMode = constraintData.positionMode; + var spacingMode = constraintData.spacingMode; + var rotateMode = constraintData.rotateMode; + var bones = this._bones; + var isLengthMode = spacingMode === 0 /* Length */; + var isChainScaleMode = rotateMode === 2 /* ChainScale */; + var isTangentMode = rotateMode === 0 /* Tangent */; + var boneCount = bones.length; + var spacesCount = isTangentMode ? boneCount : boneCount + 1; + var spacing = this.spacing; + var spaces = this._spaces; + spaces.length = spacesCount; + //计曲线间隔和长度 + if (isChainScaleMode || isLengthMode) { + //Bone改变和spacing改变触发 + spaces[0] = 0; + for (var i = 0, l = spacesCount - 1; i < l; i++) { + var bone = bones[i]; + bone.updateByConstraint(); + var boneLength = bone._boneData.length; + var matrix = bone.globalTransformMatrix; + var x = boneLength * matrix.a; + var y = boneLength * matrix.b; + var len = Math.sqrt(x * x + y * y); + if (isChainScaleMode) { + this._boneLengths[i] = len; + } + spaces[i + 1] = (boneLength + spacing) * len / boneLength; + } + } + else { + for (var i = 0; i < spacesCount; i++) { + spaces[i] = spacing; + } + } + // + this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); + //根据新的节点数据重新采样 + var positions = this._positions; + var rotateOffset = this.rotateOffset; + var boneX = positions[0], boneY = positions[1]; + var tip; + if (rotateOffset === 0) { + tip = rotateMode === 1 /* Chain */; + } + else { + tip = false; + var bone = pathSlot.parent; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; + } + } + // + var rotateMix = this.rotateMix; + var translateMix = this.translateMix; + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + matrix.tx += (boneX - matrix.tx) * translateMix; + matrix.ty += (boneY - matrix.ty) * translateMix; + var x = positions[p], y = positions[p + 1]; + var dx = x - boneX, dy = y - boneY; + if (isChainScaleMode) { + var lenght = this._boneLengths[i]; + var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; + matrix.a *= s; + matrix.b *= s; + } + boneX = x; + boneY = y; + if (rotateMix > 0) { + var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; + if (isTangentMode) { + r = positions[p - 1]; + } + else { + r = Math.atan2(dy, dx); + } + r -= Math.atan2(b, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone._boneData.length; + boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; + } + else { + r += rotateOffset; + } + if (r > dragonBones.Transform.PI) { + r -= dragonBones.Transform.PI_D; + } + else if (r < -dragonBones.Transform.PI) { + r += dragonBones.Transform.PI_D; + } + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + matrix.a = cos * a - sin * b; + matrix.b = sin * a + cos * b; + matrix.c = cos * c - sin * d; + matrix.d = sin * c + cos * d; + } + bone.global.fromMatrix(matrix); + } + this.dirty = false; + }; + PathConstraint.prototype.invalidUpdate = function () { + }; + return PathConstraint; + }(Constraint)); + dragonBones.PathConstraint = PathConstraint; +})(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) { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = /** @class */ (function () { + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = 0.0; } + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._systemTime = 0.0; + this._animatebles = []; + this._clock = null; + this.time = time; + this._systemTime = new Date().getTime() * 0.001; + } + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + var currentTime = Date.now() * 0.001; + if (passedTime < 0.0) { + passedTime = currentTime - this._systemTime; + } + this._systemTime = currentTime; + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime === 0.0) { + return; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + var i = 0, r = 0, l = this._animatebles.length; + for (; i < l; ++i) { + var animatable = this._animatebles[i]; + if (animatable !== null) { + if (r > 0) { + this._animatebles[i - r] = animatable; + this._animatebles[i] = null; + } + animatable.advanceTime(passedTime); + } + else { + r++; + } + } + if (r > 0) { + l = this._animatebles.length; + for (; i < l; ++i) { + var animateble = this._animatebles[i]; + if (animateble !== null) { + this._animatebles[i - r] = animateble; + } + else { + r++; + } + } + this._animatebles.length -= r; + } + }; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + if (value === this) { + return false; + } + var ancestor = value; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.clock; + } + return ancestor === this; + }; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.add = function (value) { + if (this._animatebles.indexOf(value) < 0) { + this._animatebles.push(value); + value.clock = this; + } + }; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.remove = function (value) { + var index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles[index] = null; + value.clock = null; + } + }; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.clear = function () { + for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { + var animatable = _a[_i]; + if (animatable !== null) { + animatable.clock = null; + } + } + }; + Object.defineProperty(WorldClock.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + if (this._clock !== null) { + this._clock.remove(this); + } + this._clock = value; + if (this._clock !== null) { + this._clock.add(this); + } + }, + enumerable: true, + configurable: true + }); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(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 animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + var Animation = /** @class */ (function (_super) { + __extends(Animation, _super); + function Animation() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._animationNames = []; + _this._animationStates = []; + _this._animations = {}; + _this._blendStates = {}; + _this._animationConfig = null; // Initial value. + return _this; + } + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + Animation.prototype._onClear = function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + for (var k in this._animations) { + delete this._animations[k]; + } + for (var k in this._blendStates) { + var blendStates = this._blendStates[k]; + for (var kB in blendStates) { + blendStates[kB].returnToPool(); + } + delete this._blendStates[k]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._inheritTimeScale = 1.0; + this._animationNames.length = 0; + this._animationStates.length = 0; + //this._animations.clear(); + this._armature = null; // + this._animationConfig = null; // + this._lastAnimationState = null; + }; + Animation.prototype._fadeOut = function (animationConfig) { + switch (animationConfig.fadeOutMode) { + case 1 /* SameLayer */: + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState._parent !== null) { + continue; + } + if (animationState.layer === animationConfig.layer) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 2 /* SameGroup */: + for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { + var animationState = _c[_b]; + if (animationState._parent !== null) { + continue; + } + if (animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 3 /* SameLayerAndGroup */: + for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { + var animationState = _e[_d]; + if (animationState._parent !== null) { + continue; + } + if (animationState.layer === animationConfig.layer && + animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 4 /* All */: + for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { + var animationState = _g[_f]; + if (animationState._parent !== null) { + continue; + } + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 5 /* Single */: // TODO + default: + break; + } + }; + /** + * @internal + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { // Only animationState can reverse play. + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. + this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; + } + else { + this._inheritTimeScale = this.timeScale; + } + if (this._inheritTimeScale !== 1.0) { + passedTime *= this._inheritTimeScale; + } + for (var k in this._blendStates) { + var blendStates = this._blendStates[k]; + for (var kB in blendStates) { + blendStates[kB].reset(); + } + } + var animationStateCount = this._animationStates.length; + if (animationStateCount === 1) { + var animationState = this._animationStates[0]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + this._armature._dragonBones.bufferObject(animationState); + this._animationStates.length = 0; + this._lastAnimationState = null; + } + else { + var animationData = animationState.animationData; + var cacheFrameRate = animationData.cacheFrameRate; + if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. + this._animationDirty = false; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + if (slot.displayFrameCount > 0) { + var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; + if (rawDisplayData !== null && + rawDisplayData.parent === this._armature.armatureData.defaultSkin) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + continue; + } + } + slot._cachedFrameIndices = null; + } + } + animationState.advanceTime(passedTime, cacheFrameRate); + } + } + else if (animationStateCount > 1) { + for (var i = 0, r = 0; i < animationStateCount; ++i) { + var animationState = this._animationStates[i]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + r++; + this._armature._dragonBones.bufferObject(animationState); + this._animationDirty = true; + if (this._lastAnimationState === animationState) { // Update last animation state. + this._lastAnimationState = null; + } + } + else { + if (r > 0) { + this._animationStates[i - r] = animationState; + } + animationState.advanceTime(passedTime, 0.0); + } + if (i === animationStateCount - 1 && r > 0) { // Modify animation states size. + this._animationStates.length -= r; + if (this._lastAnimationState === null && this._animationStates.length > 0) { + this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; + } + } + } + this._armature._cacheFrameIndex = -1; + } + else { + this._armature._cacheFrameIndex = -1; + } + }; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.reset = function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + this._animationDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.stop = function (animationName) { + if (animationName === void 0) { animationName = null; } + if (animationName !== null) { + var animationState = this.getState(animationName); + if (animationState !== null) { + animationState.stop(); + } + } + else { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.stop(); + } + } + }; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + Animation.prototype.playConfig = function (animationConfig) { + var animationName = animationConfig.animation; + if (!(animationName in this._animations)) { + console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); + return null; + } + var animationData = this._animations[animationName]; + if (animationConfig.fadeOutMode === 5 /* Single */) { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState_1 = _a[_i]; + if (animationState_1._fadeState < 1 && + animationState_1.layer === animationConfig.layer && + animationState_1.animationData === animationData) { + return animationState_1; + } + } + } + if (this._animationStates.length === 0) { + animationConfig.fadeInTime = 0.0; + } + else if (animationConfig.fadeInTime < 0.0) { + animationConfig.fadeInTime = animationData.fadeInTime; + } + if (animationConfig.fadeOutTime < 0.0) { + animationConfig.fadeOutTime = animationConfig.fadeInTime; + } + if (animationConfig.timeScale <= -100.0) { + animationConfig.timeScale = 1.0 / animationData.scale; + } + if (animationData.frameCount > 0) { + if (animationConfig.position < 0.0) { + animationConfig.position %= animationData.duration; + animationConfig.position = animationData.duration - animationConfig.position; + } + else if (animationConfig.position === animationData.duration) { + animationConfig.position -= 0.000001; // Play a little time before end. + } + else if (animationConfig.position > animationData.duration) { + animationConfig.position %= animationData.duration; + } + if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { + animationConfig.duration = animationData.duration - animationConfig.position; + } + if (animationConfig.playTimes < 0) { + animationConfig.playTimes = animationData.playTimes; + } + } + else { + animationConfig.playTimes = 1; + animationConfig.position = 0.0; + if (animationConfig.duration > 0.0) { + animationConfig.duration = 0.0; + } + } + if (animationConfig.duration === 0.0) { + animationConfig.duration = -1.0; + } + this._fadeOut(animationConfig); + // + var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); + animationState.init(this._armature, animationData, animationConfig); + this._animationDirty = true; + this._armature._cacheFrameIndex = -1; + if (this._animationStates.length > 0) { // Sort animation state. + var added = false; + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + if (animationState.layer > this._animationStates[i].layer) { + added = true; + this._animationStates.splice(i, 0, animationState); + break; + } + else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { // Child armature play same name animation. + var slot = _c[_b]; + var childArmature = slot.childArmature; + if (childArmature !== null && childArmature.inheritAnimation && + childArmature.animation.hasAnimation(animationName) && + childArmature.animation.getState(animationName) === null) { + childArmature.animation.fadeIn(animationName); // + } + } + for (var k in animationData.animationTimelines) { // Blend animation node. + var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); + if (childAnimationState === null) { + continue; + } + var timelines = animationData.animationTimelines[k]; + childAnimationState.actionEnabled = false; + childAnimationState.resetToPose = false; + childAnimationState.stop(); + animationState.addState(childAnimationState, timelines); + // + var index = this._animationStates.indexOf(animationState); + var childIndex = this._animationStates.indexOf(childAnimationState); + if (childIndex < index) { + this._animationStates.splice(index, 1); + this._animationStates.splice(childIndex, 0, animationState); + } + } + // if (!this._armature._lockUpdate && animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. + // this._armature.advanceTime(0.0); + // } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.play = function (animationName, playTimes) { + if (animationName === void 0) { animationName = null; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName !== null ? animationName : ""; + if (animationName !== null && animationName.length > 0) { + this.playConfig(this._animationConfig); + } + else if (this._lastAnimationState === null) { + var defaultAnimation = this._armature.armatureData.defaultAnimation; + if (defaultAnimation !== null) { + this._animationConfig.animation = defaultAnimation.name; + this.playConfig(this._animationConfig); + } + } + else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { + this._lastAnimationState.play(); + } + else { + this._animationConfig.animation = this._lastAnimationState.name; + this.playConfig(this._animationConfig); + } + return this._lastAnimationState; + }; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { + if (fadeInTime === void 0) { fadeInTime = -1.0; } + if (playTimes === void 0) { playTimes = -1; } + if (layer === void 0) { layer = 0; } + if (group === void 0) { group = null; } + if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } + this._animationConfig.clear(); + this._animationConfig.fadeOutMode = fadeOutMode; + this._animationConfig.playTimes = playTimes; + this._animationConfig.layer = layer; + this._animationConfig.fadeInTime = fadeInTime; + this._animationConfig.animation = animationName; + this._animationConfig.group = group !== null ? group : ""; + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { + if (time === void 0) { time = 0.0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.position = time; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { + if (frame === void 0) { frame = 0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.frameCount > 0 ? animationData.duration * frame / animationData.frameCount : 0.0; + } + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { + if (progress === void 0) { progress = 0.0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); + } + return this.playConfig(this._animationConfig); + }; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByTime = function (animationName, time) { + if (time === void 0) { time = 0.0; } + var animationState = this.gotoAndPlayByTime(animationName, time, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { + if (frame === void 0) { frame = 0; } + var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { + if (progress === void 0) { progress = 0.0; } + var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * @internal + */ + Animation.prototype.getBlendState = function (type, name, target) { + if (!(type in this._blendStates)) { + this._blendStates[type] = {}; + } + var blendStates = this._blendStates[type]; + if (!(name in blendStates)) { + var blendState = blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState); + blendState.target = target; + } + return blendStates[name]; + }; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态。 + * @param animationName - 动画状态名称。 + * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName, layer) { + if (layer === void 0) { layer = -1; } + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { + return animationState; + } + } + return null; + }; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState.isPlaying) { + return true; + } + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "isCompleted", { + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (!animationState.isCompleted) { + return false; + } + } + return this._animationStates.length > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationName", { + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationNames", { + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animations; + }, + set: function (value) { + if (this._animations === value) { + return; + } + this._animationNames.length = 0; + for (var k in this._animations) { + delete this._animations[k]; + } + for (var k in value) { + this._animationNames.push(k); + this._animations[k] = value[k]; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + this._animationConfig.clear(); + return this._animationConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationState", { + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(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 animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + var AnimationState = /** @class */ (function (_super) { + __extends(AnimationState, _super); + function AnimationState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._boneMask = []; + _this._boneTimelines = []; + _this._boneBlendTimelines = []; + _this._slotTimelines = []; + _this._slotBlendTimelines = []; + _this._constraintTimelines = []; + _this._animationTimelines = []; + _this._poseTimelines = []; + /** + * @internal + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + AnimationState.prototype._onClear = function () { + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.returnToPool(); + } + for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { + var timeline = _l[_k]; + var animationState = timeline.target; + if (animationState._parent === this) { + animationState._fadeState = 1; + animationState._subFadeState = 1; + animationState._parent = null; + } + timeline.returnToPool(); + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.actionEnabled = false; + this.additive = false; + this.displayControl = false; + this.resetToPose = false; + this.blendType = 0 /* None */; + this.playTimes = 1; + this.layer = 0; + this.timeScale = 1.0; + this._weight = 1.0; + this.parameterX = 0.0; + this.parameterY = 0.0; + this.positionX = 0.0; + this.positionY = 0.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this._timelineDirty = 2; + this._playheadState = 0; + this._fadeState = -1; + this._subFadeState = -1; + this._position = 0.0; + this._duration = 0.0; + this._fadeTime = 0.0; + this._time = 0.0; + this._fadeProgress = 0.0; + this._weightResult = 0.0; + this._boneMask.length = 0; + this._boneTimelines.length = 0; + this._boneBlendTimelines.length = 0; + this._slotTimelines.length = 0; + this._slotBlendTimelines.length = 0; + this._constraintTimelines.length = 0; + this._animationTimelines.length = 0; + this._poseTimelines.length = 0; + // this._bonePoses.clear(); + this._animationData = null; // + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + this._activeChildA = null; + this._activeChildB = null; + this._parent = null; + }; + AnimationState.prototype._updateTimelines = function () { + { // Update constraint timelines. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); + if (timelineDatas !== null) { + for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { + var timelineData = timelineDatas_1[_b]; + switch (timelineData.type) { + case 30 /* IKConstraint */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.target = constraint; + timeline.init(this._armature, this, timelineData); + this._constraintTimelines.push(timeline); + break; + } + default: + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.target = constraint; + timeline.init(this._armature, this, null); + this._constraintTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + }; + AnimationState.prototype._updateBoneAndSlotTimelines = function () { + { // Update bone and surface timelines. + var boneTimelines = {}; + // Create bone timelines map. + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.target.target.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + var timelineName = timeline.target.target.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + // + for (var _d = 0, _e = this._armature.getBones(); _d < _e.length; _d++) { + var bone = _e[_d]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + if (timelineName in boneTimelines) { // Remove bone timeline from map. + delete boneTimelines[timelineName]; + } + else { // Create new bone timeline. + var timelineDatas = this._animationData.getBoneTimelines(timelineName); + var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); + if (timelineDatas !== null) { + for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { + var timelineData = timelineDatas_2[_f]; + switch (timelineData.type) { + case 10 /* BoneAll */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 11 /* BoneTranslate */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 12 /* BoneRotate */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 13 /* BoneScale */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 60 /* BoneAlpha */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); + timeline.init(this._armature, this, timelineData); + this._boneBlendTimelines.push(timeline); + break; + } + case 50 /* Surface */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); + timeline.init(this._armature, this, timelineData); + this._boneBlendTimelines.push(timeline); + break; + } + default: + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + if (bone._boneData.type === 0 /* Bone */) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + else { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); + timeline.init(this._armature, this, null); + this._boneBlendTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + for (var k in boneTimelines) { // Remove bone timelines. + for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { + var timeline = _h[_g]; + var index = this._boneTimelines.indexOf(timeline); + if (index >= 0) { + this._boneTimelines.splice(index, 1); + timeline.returnToPool(); + } + index = this._boneBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._boneBlendTimelines.splice(index, 1); + timeline.returnToPool(); + } + } + } + } + { // Update slot timelines. + var slotTimelines = {}; + var ffdFlags = []; + // Create slot timelines map. + for (var _j = 0, _k = this._slotTimelines; _j < _k.length; _j++) { + var timeline = _k[_j]; + var timelineName = timeline.target.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _l = 0, _m = this._slotBlendTimelines; _l < _m.length; _l++) { + var timeline = _m[_l]; + var timelineName = timeline.target.target.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + // + for (var _o = 0, _p = this._armature.getSlots(); _o < _p.length; _o++) { + var slot = _p[_o]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + if (timelineName in slotTimelines) { // Remove slot timeline from map. + delete slotTimelines[timelineName]; + } + else { // Create new slot timeline. + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + var timelineDatas = this._animationData.getSlotTimelines(timelineName); + if (timelineDatas !== null) { + for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { + var timelineData = timelineDatas_3[_q]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 23 /* SlotZIndex */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); + timeline.init(this._armature, this, timelineData); + this._slotBlendTimelines.push(timeline); + break; + } + case 21 /* SlotColor */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotDeform */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); + timeline.init(this._armature, this, timelineData); + if (timeline.target !== null) { + this._slotBlendTimelines.push(timeline); + ffdFlags.push(timeline.geometryOffset); + } + else { + timeline.returnToPool(); + } + break; + } + case 24 /* SlotAlpha */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); + timeline.init(this._armature, this, timelineData); + this._slotBlendTimelines.push(timeline); + break; + } + default: + break; + } + } + } + if (this.resetToPose) { // Pose timeline. + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayFrame = slot.getDisplayFrameAt(i); + if (displayFrame.deformVertices.length === 0) { + continue; + } + var geometryData = displayFrame.getGeometryData(); + if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.geometryOffset = geometryData.offset; // + timeline.displayFrame = displayFrame; // + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); + timeline.init(this._armature, this, null); + this._slotBlendTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { // Remove slot timelines. + for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { + var timeline = _s[_r]; + var index = this._slotTimelines.indexOf(timeline); + if (index >= 0) { + this._slotTimelines.splice(index, 1); + timeline.returnToPool(); + } + index = this._slotBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._slotBlendTimelines.splice(index, 1); + timeline.returnToPool(); + } + } + } + } + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { // Fade start event. + this._subFadeState = 0; + var eventActive = this._parent === null && this.actionEnabled; + if (eventActive) { + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + if (passedTime < 0.0) { + passedTime = -passedTime; + } + this._fadeTime += passedTime; + if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. + this._subFadeState = 1; + this._fadeProgress = isFadeOut ? 0.0 : 1.0; + } + else if (this._fadeTime > 0.0) { // Fading. + this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); + } + else { // Before fade. + this._fadeProgress = isFadeOut ? 1.0 : 0.0; + } + if (this._subFadeState > 0) { // Fade complete event. + if (!isFadeOut) { + this._playheadState |= 1; // x1 + this._fadeState = 0; + } + var eventActive = this._parent === null && this.actionEnabled; + if (eventActive) { + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + }; + /** + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationData = animationData; + // + this.resetToPose = animationConfig.resetToPose; + this.additive = animationConfig.additive; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.blendType = animationData.blendType; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + // + this._weight = animationConfig.weight; + if (animationConfig.pauseFadeIn) { + this._playheadState = 2; // 10 + } + else { + this._playheadState = 3; // 11 + } + if (animationConfig.duration < 0.0) { + this._position = 0.0; + this._duration = this._animationData.duration; + if (animationConfig.position !== 0.0) { + if (this.timeScale >= 0.0) { + this._time = animationConfig.position; + } + else { + this._time = animationConfig.position - this._duration; + } + } + else { + this._time = 0.0; + } + } + else { + this._position = animationConfig.position; + this._duration = animationConfig.duration; + this._time = 0.0; + } + if (this.timeScale < 0.0 && this._time === 0.0) { + this._time = -0.000001; // Turn to end. + } + if (this.fadeTotalTime <= 0.0) { + this._fadeProgress = 0.999999; // Make different. + } + if (animationConfig.boneMask.length > 0) { + this._boneMask.length = animationConfig.boneMask.length; + for (var i = 0, l = this._boneMask.length; i < l; ++i) { + this._boneMask[i] = animationConfig.boneMask[i]; + } + } + this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); + this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); + this._actionTimeline.currentTime = this._time; + if (this._actionTimeline.currentTime < 0.0) { + this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; + } + if (this._animationData.zOrderTimeline !== null) { + this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); + } + }; + /** + * @internal + */ + AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { + // Update fade time. + if (this._fadeState !== 0 || this._subFadeState !== 0) { + this._advanceFadeTime(passedTime); + } + // Update time. + if (this._playheadState === 3) { // 11 + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + this._time += passedTime; + } + // Update timeline. + if (this._timelineDirty !== 0) { + if (this._timelineDirty === 2) { + this._updateTimelines(); + } + this._timelineDirty = 0; + this._updateBoneAndSlotTimelines(); + } + var isBlendDirty = this._fadeState !== 0 || this._subFadeState === 0; + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this._weight * this._fadeProgress; + if (this._parent !== null) { + this._weightResult *= this._parent._weightResult; + } + if (this._actionTimeline.playState <= 0) { // Update main timeline. + this._actionTimeline.update(time); + } + if (this._weight === 0.0) { + return; + } + if (isCacheEnabled) { // Cache time internval. + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { // Update zOrder timeline. + this._zOrderTimeline.update(time); + } + if (isCacheEnabled) { // Update cache. + var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint + if (this._armature._cacheFrameIndex === cacheFrameIndex) { // Same cache. + isUpdateTimeline = false; + isUpdateBoneTimeline = false; + } + else { + this._armature._cacheFrameIndex = cacheFrameIndex; + if (this._animationData.cachedFrames[cacheFrameIndex]) { // Cached. + isUpdateBoneTimeline = false; + } + else { // Cache. + this._animationData.cachedFrames[cacheFrameIndex] = true; + } + } + } + if (isUpdateTimeline) { + var isBlend = false; + var prevTarget = null; // + if (isUpdateBoneTimeline) { + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (timeline.target !== prevTarget) { + var blendState = timeline.target; + isBlend = blendState.update(this); + prevTarget = blendState; + if (blendState.dirty === 1) { + var pose = blendState.target.animationPose; + pose.x = 0.0; + pose.y = 0.0; + pose.rotation = 0.0; + pose.skew = 0.0; + pose.scaleX = 1.0; + pose.scaleY = 1.0; + } + } + if (isBlend) { + timeline.blend(isBlendDirty); + } + } + } + for (var i = 0, l = this._boneBlendTimelines.length; i < l; ++i) { + var timeline = this._boneBlendTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (timeline.target.update(this)) { + timeline.blend(isBlendDirty); + } + } + if (this.displayControl) { + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (timeline.playState <= 0) { + var slot = timeline.target; + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + timeline.update(time); + } + } + } + } + for (var i = 0, l = this._slotBlendTimelines.length; i < l; ++i) { + var timeline = this._slotBlendTimelines[i]; + if (timeline.playState <= 0) { + var blendState = timeline.target; + timeline.update(time); + if (blendState.update(this)) { + timeline.blend(isBlendDirty); + } + } + } + for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { + var timeline = this._constraintTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + } + if (this._animationTimelines.length > 0) { + var dL = 100.0; + var dR = 100.0; + var leftState = null; + var rightState = null; + for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { + var timeline = this._animationTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (this.blendType === 1 /* E1D */) { // TODO + var animationState = timeline.target; + var d = this.parameterX - animationState.positionX; + if (d >= 0.0) { + if (d < dL) { + dL = d; + leftState = animationState; + } + } + else { + if (-d < dR) { + dR = -d; + rightState = animationState; + } + } + } + } + if (leftState !== null) { + if (this._activeChildA !== leftState) { + if (this._activeChildA !== null) { + this._activeChildA.weight = 0.0; + } + this._activeChildA = leftState; + this._activeChildA.activeTimeline(); + } + if (this._activeChildB !== rightState) { + if (this._activeChildB !== null) { + this._activeChildB.weight = 0.0; + } + this._activeChildB = rightState; + } + leftState.weight = dR / (dL + dR); + if (rightState) { + rightState.weight = 1.0 - leftState.weight; + } + } + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + if (this._poseTimelines.length > 0) { // Remove pose timelines. + for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var index = this._boneTimelines.indexOf(timeline); + if (index >= 0) { + this._boneTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._boneBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._boneBlendTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._slotTimelines.indexOf(timeline); + if (index >= 0) { + this._slotTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._slotBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._slotBlendTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._constraintTimelines.indexOf(timeline); + if (index >= 0) { + this._constraintTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + } + this._poseTimelines.length = 0; + } + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { // Auto fade out. + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { + if (pausePlayhead === void 0) { pausePlayhead = true; } + if (fadeOutTime < 0.0) { + fadeOutTime = 0.0; + } + if (pausePlayhead) { + this._playheadState &= 2; // x0 + } + if (this._fadeState > 0) { + if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { // If the animation is already in fade out, the new fade out will be ignored. + return; + } + } + else { + this._fadeState = 1; + this._subFadeState = -1; + if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { + this._fadeProgress = 0.000001; // Modify fade progress to different value. + } + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.fadeOut(); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.fadeOut(); + } + for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.fadeOut(); + } + for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.fadeOut(); + } + for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { + var timeline = _l[_k]; + timeline.fadeOut(); + // + var animaitonState = timeline.target; + animaitonState.fadeOut(999999.0, true); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * - Check if a specific bone mask is included. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (boneName) { + return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; + }; + /** + * - Add a specific bone mask. + * @param boneName - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (boneName, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(boneName); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(boneName) < 0) { // Add mixing + this._boneMask.push(boneName); + } + if (recursive) { // Add recursive mixing. + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + this._timelineDirty = 1; + }; + /** + * - Remove the mask of a specific bone. + * @param boneName - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (boneName, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(boneName); + if (index >= 0) { // Remove mixing. + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(boneName); + if (currentBone !== null) { + var bones = this._armature.getBones(); + if (this._boneMask.length > 0) { // Remove recursive mixing. + for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { + var bone = bones_1[_i]; + var index_1 = this._boneMask.indexOf(bone.name); + if (index_1 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_1, 1); + } + } + } + else { // Add unrecursive mixing. + for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { + var bone = bones_2[_a]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + } + } + this._timelineDirty = 1; + }; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = 1; + }; + /** + * @private + */ + AnimationState.prototype.addState = function (animationState, timelineDatas) { + if (timelineDatas === void 0) { timelineDatas = null; } + if (timelineDatas !== null) { + for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { + var timelineData = timelineDatas_4[_i]; + switch (timelineData.type) { + case 40 /* AnimationProgress */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + if (this.blendType !== 0 /* None */) { + var animaitonTimelineData = timelineData; + animationState.positionX = animaitonTimelineData.x; + animationState.positionY = animaitonTimelineData.y; + animationState.weight = 0.0; + } + animationState._parent = this; + this.resetToPose = false; + break; + } + case 41 /* AnimationWeight */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + break; + } + case 42 /* AnimationParameter */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + break; + } + default: + break; + } + } + } + if (animationState._parent === null) { + animationState._parent = this; + } + }; + /** + * @internal + */ + AnimationState.prototype.activeTimeline = function () { + for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.dirty = true; + timeline.currentTime = -1.0; + } + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isCompleted", { + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentTime; + }, + set: function (value) { + var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); + if (value < 0 || this._duration < value) { + value = (value % this._duration) + currentPlayTimes * this._duration; + if (value < 0) { + value += this._duration; + } + } + if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && + value === this._duration && this._parent === null) { + value = this._duration - 0.000001; // + } + if (this._time === value) { + return; + } + this._time = value; + this._actionTimeline.setCurrentTime(this._time); + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.playState = -1; + } + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.playState = -1; + } + for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.playState = -1; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "weight", { + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + get: function () { + return this._weight; + }, + set: function (value) { + if (this._weight === value) { + return; + } + this._weight = value; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.dirty = true; + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.dirty = true; + } + for (var _d = 0, _e = this._slotBlendTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.dirty = true; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "animationData", { + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; + /** + * @internal + */ + var BlendState = /** @class */ (function (_super) { + __extends(BlendState, _super); + function BlendState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BlendState.toString = function () { + return "[class dragonBones.BlendState]"; + }; + BlendState.prototype._onClear = function () { + this.reset(); + this.target = null; + }; + BlendState.prototype.update = function (animationState) { + var animationLayer = animationState.layer; + var animationWeight = animationState._weightResult; + if (this.dirty > 0) { + if (this.leftWeight > 0.0) { + if (this.layer !== animationLayer) { + if (this.layerWeight >= this.leftWeight) { + this.dirty++; + this.layer = animationLayer; + this.leftWeight = 0.0; + this.blendWeight = 0.0; + return false; + } + this.layer = animationLayer; + this.leftWeight -= this.layerWeight; + this.layerWeight = 0.0; + } + animationWeight *= this.leftWeight; + this.dirty++; + this.blendWeight = animationWeight; + this.layerWeight += this.blendWeight; + return true; + } + return false; + } + this.dirty++; + this.layer = animationLayer; + this.leftWeight = 1.0; + this.blendWeight = animationWeight; + this.layerWeight = animationWeight; + return true; + }; + BlendState.prototype.reset = function () { + this.dirty = 0; + this.layer = 0; + this.leftWeight = 0.0; + this.layerWeight = 0.0; + this.blendWeight = 0.0; + }; + BlendState.BONE_TRANSFORM = "boneTransform"; + BlendState.BONE_ALPHA = "boneAlpha"; + BlendState.SURFACE = "surface"; + BlendState.SLOT_DEFORM = "slotDeform"; + BlendState.SLOT_ALPHA = "slotAlpha"; + BlendState.SLOT_Z_INDEX = "slotZIndex"; + return BlendState; + }(dragonBones.BaseObject)); + dragonBones.BlendState = BlendState; +})(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) { + /** + * @internal + */ + var TimelineState = /** @class */ (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.dirty = false; + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this.target = null; + this._isTween = false; + this._valueOffset = 0; + this._frameValueOffset = 0; + this._frameOffset = 0; + this._frameRate = 0; + this._frameCount = 0; + this._frameIndex = -1; + this._frameRateR = 0.0; + this._position = 0.0; + this._duration = 0.0; + this._timeScale = 1.0; + this._timeOffset = 0.0; + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._valueArray = null; // + this._timelineArray = null; // + this._frameIndices = null; // + }; + TimelineState.prototype._setCurrentTime = function (passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._actionTimeline !== null && this._frameCount <= 1) { // No frame or only one frame. + this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; + this.currentPlayTimes = 1; + this.currentTime = this._actionTimeline.currentTime; + } + else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { // Action timeline or has scale and offset. + var playTimes = this._animationState.playTimes; + var totalTime = playTimes * this._duration; + passedTime *= this._timeScale; + if (this._timeOffset !== 0.0) { + passedTime += this._timeOffset * this._animationData.duration; + } + if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { + if (this.playState <= 0 && this._animationState._playheadState === 3) { + this.playState = 1; + } + this.currentPlayTimes = playTimes; + if (passedTime < 0.0) { + this.currentTime = 0.0; + } + else { + this.currentTime = this.playState === 1 ? this._duration + 0.000001 : this._duration; // Precision problem + } + } + else { + if (this.playState !== 0 && this._animationState._playheadState === 3) { + this.playState = 0; + } + if (passedTime < 0.0) { + passedTime = -passedTime; + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = this._duration - (passedTime % this._duration); + } + else { + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = passedTime % this._duration; + } + } + this.currentTime += this._position; + } + else { // Multi frames. + this.playState = this._actionTimeline.playState; + this.currentPlayTimes = this._actionTimeline.currentPlayTimes; + this.currentTime = this._actionTimeline.currentTime; + } + if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { + return false; + } + // Clear frame flag when timeline start or loopComplete. + if ((prevState < 0 && this.playState !== prevState) || + (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { + this._frameIndex = -1; + } + return true; + }; + TimelineState.prototype.init = function (armature, animationState, timelineData) { + this._armature = armature; + this._animationState = animationState; + this._timelineData = timelineData; + this._actionTimeline = this._animationState._actionTimeline; + if (this === this._actionTimeline) { + this._actionTimeline = null; // + } + this._animationData = this._animationState.animationData; + // + this._frameRate = this._animationData.parent.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. + this._frameArray = dragonBonesData.frameArray; + this._timelineArray = dragonBonesData.timelineArray; + this._frameIndices = dragonBonesData.frameIndices; + // + this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; + this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; + this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; + } + }; + TimelineState.prototype.fadeOut = function () { + this.dirty = false; + }; + TimelineState.prototype.update = function (passedTime) { + if (this._setCurrentTime(passedTime)) { + if (this._frameCount > 1) { + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { + this._frameIndex = frameIndex; + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; + this._onArriveAtFrame(); + } + } + else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (this._timelineData !== null) { // May be pose timeline. + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; + } + this._onArriveAtFrame(); + } + if (this._isTween || this.dirty) { + this._onUpdateFrame(); + } + } + }; + TimelineState.prototype.blend = function (_isDirty) { + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + */ + var TweenTimelineState = /** @class */ (function (_super) { + __extends(TweenTimelineState, _super); + function TweenTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { + var value = progress; + switch (tweenType) { + case 3 /* QuadIn */: + value = Math.pow(progress, 2.0); + break; + case 4 /* QuadOut */: + value = 1.0 - Math.pow(1.0 - progress, 2.0); + break; + case 5 /* QuadInOut */: + value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); + break; + } + return (value - progress) * easing + progress; + }; + TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { + if (progress <= 0.0) { + return 0.0; + } + else if (progress >= 1.0) { + return 1.0; + } + var isOmited = count > 0; + var segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = 0.0; + var toValue = 0.0; + if (isOmited) { + fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; + } + else { + fromValue = samples[offset + valueIndex - 1]; + toValue = samples[offset + valueIndex]; + } + return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; + }; + TweenTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._tweenType = 0 /* None */; + this._curveCount = 0; + this._framePosition = 0.0; + this._frameDurationR = 0.0; + this._tweenEasing = 0.0; + this._tweenProgress = 0.0; + this._valueScale = 1.0; + }; + TweenTimelineState.prototype._onArriveAtFrame = function () { + if (this._frameCount > 1 && + (this._frameIndex !== this._frameCount - 1 || + this._animationState.playTimes === 0 || + this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { + this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; + this._isTween = this._tweenType !== 0 /* None */; + if (this._isTween) { + if (this._tweenType === 2 /* Curve */) { + this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; + } + else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { + this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; + } + } + else { + this.dirty = true; + } + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; + if (this._frameIndex === this._frameCount - 1) { + this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); + } + else { + var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; + var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; + if (frameDuration > 0) { + this._frameDurationR = 1.0 / frameDuration; + } + else { + this._frameDurationR = 0.0; + } + } + } + else { + this.dirty = true; + this._isTween = false; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._isTween) { + this.dirty = true; + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + if (this._tweenType === 2 /* Curve */) { + this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); + } + else if (this._tweenType !== 1 /* Line */) { + this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); + } + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + */ + var SingleValueTimelineState = /** @class */ (function (_super) { + __extends(SingleValueTimelineState, _super); + function SingleValueTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SingleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._current = 0.0; + this._difference = 0.0; + this._result = 0.0; + }; + SingleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + 1; + if (valueScale === 1.0) { + this._current = valueArray[valueOffset]; + this._difference = valueArray[nextValueOffset] - this._current; + } + else { + this._current = valueArray[valueOffset] * valueScale; + this._difference = valueArray[nextValueOffset] * valueScale - this._current; + } + } + else { + this._result = valueArray[valueOffset] * valueScale; + } + } + else { + this._result = 0.0; + } + }; + SingleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._result = this._current + this._difference * this._tweenProgress; + } + }; + return SingleValueTimelineState; + }(TweenTimelineState)); + dragonBones.SingleValueTimelineState = SingleValueTimelineState; + /** + * @internal + */ + var DoubleValueTimelineState = /** @class */ (function (_super) { + __extends(DoubleValueTimelineState, _super); + function DoubleValueTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + DoubleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._currentA = 0.0; + this._currentB = 0.0; + this._differenceA = 0.0; + this._differenceB = 0.0; + this._resultA = 0.0; + this._resultB = 0.0; + }; + DoubleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + 2; + if (valueScale === 1.0) { + this._currentA = valueArray[valueOffset]; + this._currentB = valueArray[valueOffset + 1]; + this._differenceA = valueArray[nextValueOffset] - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; + } + else { + this._currentA = valueArray[valueOffset] * valueScale; + this._currentB = valueArray[valueOffset + 1] * valueScale; + this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; + } + } + else { + this._resultA = valueArray[valueOffset] * valueScale; + this._resultB = valueArray[valueOffset + 1] * valueScale; + } + } + else { + this._resultA = 0.0; + this._resultB = 0.0; + } + }; + DoubleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._resultA = this._currentA + this._differenceA * this._tweenProgress; + this._resultB = this._currentB + this._differenceB * this._tweenProgress; + } + }; + return DoubleValueTimelineState; + }(TweenTimelineState)); + dragonBones.DoubleValueTimelineState = DoubleValueTimelineState; + /** + * @internal + */ + var MutilpleValueTimelineState = /** @class */ (function (_super) { + __extends(MutilpleValueTimelineState, _super); + function MutilpleValueTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._rd = []; + return _this; + } + MutilpleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._valueCount = 0; + this._rd.length = 0; + }; + MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + var valueCount = this._valueCount; + var rd = this._rd; + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + valueCount; + if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; + } + } + } + else if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i]; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] * valueScale; + } + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = 0.0; + } + } + }; + MutilpleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + var valueCount = this._valueCount; + var valueScale = this._valueScale; + var tweenProgress = this._tweenProgress; + var valueArray = this._valueArray; + var rd = this._rd; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; + if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; + } + } + } + }; + return MutilpleValueTimelineState; + }(TweenTimelineState)); + dragonBones.MutilpleValueTimelineState = MutilpleValueTimelineState; +})(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) { + /** + * @internal + */ + var ActionTimelineState = /** @class */ (function (_super) { + __extends(ActionTimelineState, _super); + function ActionTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + ActionTimelineState.toString = function () { + return "[class dragonBones.ActionTimelineState]"; + }; + ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { + var eventDispatcher = this._armature.eventDispatcher; + if (this._animationState.actionEnabled) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; + var actionCount = this._frameArray[frameOffset + 1]; + var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._bufferAction(eventObject, true); + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + } + }; + ActionTimelineState.prototype._onArriveAtFrame = function () { }; + ActionTimelineState.prototype._onUpdateFrame = function () { }; + ActionTimelineState.prototype.update = function (passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._setCurrentTime(passedTime)) { + var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; + var eventDispatcher = this._armature.eventDispatcher; + if (prevState < 0) { + if (this.playState !== prevState) { + if (this._animationState.displayControl && this._animationState.resetToPose) { // Reset zorder to pose. + this._armature._sortZOrder(null, 0); + } + prevPlayTimes = this.currentPlayTimes; + if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = dragonBones.EventObject.START; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + else { + return; + } + } + var isReverse = this._animationState.timeScale < 0.0; + var loopCompleteEvent = null; + var completeEvent = null; + if (eventActive && this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; + loopCompleteEvent.armature = this._armature; + loopCompleteEvent.animationState = this._animationState; + } + if (this.playState > 0) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { + completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + completeEvent.type = dragonBones.EventObject.COMPLETE; + completeEvent.armature = this._armature; + completeEvent.animationState = this._animationState; + } + } + } + if (this._frameCount > 1) { + var timelineData = this._timelineData; + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { // Arrive at frame. + var crossedFrameIndex = this._frameIndex; + this._frameIndex = frameIndex; + if (this._timelineArray !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; + if (isReverse) { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (crossedFrameIndex === frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + while (crossedFrameIndex >= 0) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && + framePosition <= this._position + this._duration) { // Support interval play. + this._onCrossFrame(crossedFrameIndex); + } + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event after first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex > 0) { + crossedFrameIndex--; + } + else { + crossedFrameIndex = this._frameCount - 1; + } + if (crossedFrameIndex === frameIndex) { + break; + } + } + } + else { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { // Crossed. + if (crossedFrameIndex > 0) { + crossedFrameIndex--; + } + else { + crossedFrameIndex = this._frameCount - 1; + } + } + else if (crossedFrameIndex === frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + while (crossedFrameIndex >= 0) { + if (crossedFrameIndex < this._frameCount - 1) { + crossedFrameIndex++; + } + else { + crossedFrameIndex = 0; + } + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && + framePosition <= this._position + this._duration // + ) { // Support interval play. + this._onCrossFrame(crossedFrameIndex); + } + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event before first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex === frameIndex) { + break; + } + } + } + } + } + } + else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (this._timelineData !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; + // Arrive at frame. + var framePosition = this._frameArray[this._frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { + this._onCrossFrame(this._frameIndex); + } + } + else if (this._position <= framePosition) { // Loop complete. + if (!isReverse && loopCompleteEvent !== null) { // Add loop complete event before first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + this._onCrossFrame(this._frameIndex); + } + } + } + if (loopCompleteEvent !== null) { + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + } + if (completeEvent !== null) { + this._armature._dragonBones.bufferEvent(completeEvent); + } + } + }; + ActionTimelineState.prototype.setCurrentTime = function (value) { + this._setCurrentTime(value); + this._frameIndex = -1; + }; + return ActionTimelineState; + }(dragonBones.TimelineState)); + dragonBones.ActionTimelineState = ActionTimelineState; + /** + * @internal + */ + var ZOrderTimelineState = /** @class */ (function (_super) { + __extends(ZOrderTimelineState, _super); + function ZOrderTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + ZOrderTimelineState.toString = function () { + return "[class dragonBones.ZOrderTimelineState]"; + }; + ZOrderTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var count = this._frameArray[this._frameOffset + 1]; + if (count > 0) { + this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); + } + else { + this._armature._sortZOrder(null, 0); + } + } + }; + ZOrderTimelineState.prototype._onUpdateFrame = function () { }; + return ZOrderTimelineState; + }(dragonBones.TimelineState)); + dragonBones.ZOrderTimelineState = ZOrderTimelineState; + /** + * @internal + */ + var BoneAllTimelineState = /** @class */ (function (_super) { + __extends(BoneAllTimelineState, _super); + function BoneAllTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneAllTimelineState.toString = function () { + return "[class dragonBones.BoneAllTimelineState]"; + }; + BoneAllTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._isTween && this._frameIndex === this._frameCount - 1) { + this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); + this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); + } + if (this._timelineData === null) { // Pose. + this._rd[4] = 1.0; + this._rd[5] = 1.0; + } + }; + BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = 6; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + this.dirty = false; + this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); + this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); + }; + BoneAllTimelineState.prototype.blend = function (isDirty) { + var valueScale = this._armature.armatureData.scale; + var rd = this._rd; + // + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.x += rd[0] * blendWeight * valueScale; + result.y += rd[1] * blendWeight * valueScale; + result.rotation += rd[2] * blendWeight; + result.skew += rd[3] * blendWeight; + result.scaleX += (rd[4] - 1.0) * blendWeight; + result.scaleY += (rd[5] - 1.0) * blendWeight; + } + else { + result.x = rd[0] * blendWeight * valueScale; + result.y = rd[1] * blendWeight * valueScale; + result.rotation = rd[2] * blendWeight; + result.skew = rd[3] * blendWeight; + result.scaleX = (rd[4] - 1.0) * blendWeight + 1.0; // + result.scaleY = (rd[5] - 1.0) * blendWeight + 1.0; // + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneAllTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + */ + var BoneTranslateTimelineState = /** @class */ (function (_super) { + __extends(BoneTranslateTimelineState, _super); + function BoneTranslateTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTranslateTimelineState.toString = function () { + return "[class dragonBones.BoneTranslateTimelineState]"; + }; + BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneTranslateTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.x += this._resultA * blendWeight; + result.y += this._resultB * blendWeight; + } + else if (blendWeight !== 1.0) { + result.x = this._resultA * blendWeight; + result.y = this._resultB * blendWeight; + } + else { + result.x = this._resultA; + result.y = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneTranslateTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; + /** + * @internal + */ + var BoneRotateTimelineState = /** @class */ (function (_super) { + __extends(BoneRotateTimelineState, _super); + function BoneRotateTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneRotateTimelineState.toString = function () { + return "[class dragonBones.BoneRotateTimelineState]"; + }; + BoneRotateTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._isTween && this._frameIndex === this._frameCount - 1) { + this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); + this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); + } + }; + BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneRotateTimelineState.prototype.fadeOut = function () { + this.dirty = false; + this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); + this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); + }; + BoneRotateTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.rotation += this._resultA * blendWeight; + result.skew += this._resultB * blendWeight; + } + else if (blendWeight !== 1.0) { + result.rotation = this._resultA * blendWeight; + result.skew = this._resultB * blendWeight; + } + else { + result.rotation = this._resultA; + result.skew = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneRotateTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; + /** + * @internal + */ + var BoneScaleTimelineState = /** @class */ (function (_super) { + __extends(BoneScaleTimelineState, _super); + function BoneScaleTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneScaleTimelineState.toString = function () { + return "[class dragonBones.BoneScaleTimelineState]"; + }; + BoneScaleTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + this._resultA = 1.0; + this._resultB = 1.0; + } + }; + BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneScaleTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.scaleX += (this._resultA - 1.0) * blendWeight; + result.scaleY += (this._resultB - 1.0) * blendWeight; + } + else if (blendWeight !== 1.0) { + result.scaleX = (this._resultA - 1.0) * blendWeight + 1.0; + result.scaleY = (this._resultB - 1.0) * blendWeight + 1.0; + } + else { + result.scaleX = this._resultA; + result.scaleY = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneScaleTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; + /** + * @internal + */ + var SurfaceTimelineState = /** @class */ (function (_super) { + __extends(SurfaceTimelineState, _super); + function SurfaceTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SurfaceTimelineState.toString = function () { + return "[class dragonBones.SurfaceTimelineState]"; + }; + SurfaceTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._deformCount = 0; + this._deformOffset = 0; + this._sameValueOffset = 0; + }; + SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; + var frameIntArray = dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = dragonBonesData.frameFloatArray; + this._rd.length = this._valueCount * 2; + } + else { + this._deformCount = this.target.target._deformVertices.length; + } + }; + SurfaceTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var surface = blendState.target; + var blendWeight = blendState.blendWeight; + var result = surface._deformVertices; + var valueArray = this._valueArray; + if (valueArray !== null) { + var valueCount = this._valueCount; + var deformOffset = this._deformOffset; + var sameValueOffset = this._sameValueOffset; + var rd = this._rd; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0.0; + if (i < deformOffset) { + value = valueArray[sameValueOffset + i]; + } + else if (i < deformOffset + valueCount) { + value = rd[i - deformOffset]; + } + else { + value = valueArray[sameValueOffset + i - valueCount]; + } + if (blendState.dirty > 1) { + result[i] += value * blendWeight; + } + else { + result[i] = value * blendWeight; + } + } + } + else if (blendState.dirty === 1) { + for (var i = 0; i < this._deformCount; ++i) { + result[i] = 0.0; + } + } + if (isDirty || this.dirty) { + this.dirty = false; + surface._transformDirty = true; + } + }; + return SurfaceTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.SurfaceTimelineState = SurfaceTimelineState; + /** + * @internal + */ + var AlphaTimelineState = /** @class */ (function (_super) { + __extends(AlphaTimelineState, _super); + function AlphaTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AlphaTimelineState.toString = function () { + return "[class dragonBones.AlphaTimelineState]"; + }; + AlphaTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + this._result = 1.0; + } + }; + AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.01; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + AlphaTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var alphaTarget = blendState.target; + var blendWeight = blendState.blendWeight; + if (blendState.dirty > 1) { + alphaTarget._alpha += this._result * blendWeight; + if (alphaTarget._alpha > 1.0) { + alphaTarget._alpha = 1.0; + } + } + else { + alphaTarget._alpha = this._result * blendWeight; + } + if (isDirty || this.dirty) { + this.dirty = false; + this._armature._alphaDirty = true; + } + }; + return AlphaTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AlphaTimelineState = AlphaTimelineState; + /** + * @internal + */ + var SlotDisplayTimelineState = /** @class */ (function (_super) { + __extends(SlotDisplayTimelineState, _super); + function SlotDisplayTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDisplayTimelineState.toString = function () { + return "[class dragonBones.SlotDisplayTimelineState]"; + }; + SlotDisplayTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var slot = this.target; + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; + if (slot.displayIndex !== displayIndex) { + slot._setDisplayIndex(displayIndex, true); + } + } + }; + SlotDisplayTimelineState.prototype._onUpdateFrame = function () { + }; + return SlotDisplayTimelineState; + }(dragonBones.TimelineState)); + dragonBones.SlotDisplayTimelineState = SlotDisplayTimelineState; + /** + * @internal + */ + var SlotColorTimelineState = /** @class */ (function (_super) { + __extends(SlotColorTimelineState, _super); + function SlotColorTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; + _this._difference = [0, 0, 0, 0, 0, 0, 0, 0]; + _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; + return _this; + } + SlotColorTimelineState.toString = function () { + return "[class dragonBones.SlotColorTimelineState]"; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; + var colorArray = dragonBonesData.colorArray; + var frameIntArray = dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; + var colorOffset = frameIntArray[valueOffset]; + if (colorOffset < 0) { + colorOffset += 65536; // Fixed out of bounds bug. + } + if (this._isTween) { + this._current[0] = colorArray[colorOffset++]; + this._current[1] = colorArray[colorOffset++]; + this._current[2] = colorArray[colorOffset++]; + this._current[3] = colorArray[colorOffset++]; + this._current[4] = colorArray[colorOffset++]; + this._current[5] = colorArray[colorOffset++]; + this._current[6] = colorArray[colorOffset++]; + this._current[7] = colorArray[colorOffset++]; + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1]; + } + if (colorOffset < 0) { + colorOffset += 65536; // Fixed out of bounds bug. + } + this._difference[0] = colorArray[colorOffset++] - this._current[0]; + this._difference[1] = colorArray[colorOffset++] - this._current[1]; + this._difference[2] = colorArray[colorOffset++] - this._current[2]; + this._difference[3] = colorArray[colorOffset++] - this._current[3]; + this._difference[4] = colorArray[colorOffset++] - this._current[4]; + this._difference[5] = colorArray[colorOffset++] - this._current[5]; + this._difference[6] = colorArray[colorOffset++] - this._current[6]; + this._difference[7] = colorArray[colorOffset++] - this._current[7]; + } + else { + this._result[0] = colorArray[colorOffset++] * 0.01; + this._result[1] = colorArray[colorOffset++] * 0.01; + this._result[2] = colorArray[colorOffset++] * 0.01; + this._result[3] = colorArray[colorOffset++] * 0.01; + this._result[4] = colorArray[colorOffset++]; + this._result[5] = colorArray[colorOffset++]; + this._result[6] = colorArray[colorOffset++]; + this._result[7] = colorArray[colorOffset++]; + } + } + else { // Pose. + var slot = this.target; + var color = slot.slotData.color; + this._result[0] = color.alphaMultiplier; + this._result[1] = color.redMultiplier; + this._result[2] = color.greenMultiplier; + this._result[3] = color.blueMultiplier; + this._result[4] = color.alphaOffset; + this._result[5] = color.redOffset; + this._result[6] = color.greenOffset; + this._result[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; + } + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._isTween = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._isTween || this.dirty) { + var slot = this.target; + var result = slot._colorTransform; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + if (result.alphaMultiplier !== this._result[0] || + result.redMultiplier !== this._result[1] || + result.greenMultiplier !== this._result[2] || + result.blueMultiplier !== this._result[3] || + result.alphaOffset !== this._result[4] || + result.redOffset !== this._result[5] || + result.greenOffset !== this._result[6] || + result.blueOffset !== this._result[7]) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); + result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; + result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; + result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; + result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; + result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; + result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; + result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; + result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; + slot._colorDirty = true; + } + } + else if (this.dirty) { + this.dirty = false; + if (result.alphaMultiplier !== this._result[0] || + result.redMultiplier !== this._result[1] || + result.greenMultiplier !== this._result[2] || + result.blueMultiplier !== this._result[3] || + result.alphaOffset !== this._result[4] || + result.redOffset !== this._result[5] || + result.greenOffset !== this._result[6] || + result.blueOffset !== this._result[7]) { + result.alphaMultiplier = this._result[0]; + result.redMultiplier = this._result[1]; + result.greenMultiplier = this._result[2]; + result.blueMultiplier = this._result[3]; + result.alphaOffset = this._result[4]; + result.redOffset = this._result[5]; + result.greenOffset = this._result[6]; + result.blueOffset = this._result[7]; + slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.TweenTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + */ + var SlotZIndexTimelineState = /** @class */ (function (_super) { + __extends(SlotZIndexTimelineState, _super); + function SlotZIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotZIndexTimelineState.toString = function () { + return "[class dragonBones.SlotZIndexTimelineState]"; + }; + SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + var blendState = this.target; + var slot = blendState.target; + this._result = slot.slotData.zIndex; + } + }; + SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + SlotZIndexTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var slot = blendState.target; + var blendWeight = blendState.blendWeight; + if (blendState.dirty > 1) { + slot._zIndex += this._result * blendWeight; + } + else { + slot._zIndex = this._result * blendWeight; + } + if (isDirty || this.dirty) { + this.dirty = false; + this._armature._zIndexDirty = true; + } + }; + return SlotZIndexTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.SlotZIndexTimelineState = SlotZIndexTimelineState; + /** + * @internal + */ + var DeformTimelineState = /** @class */ (function (_super) { + __extends(DeformTimelineState, _super); + function DeformTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + DeformTimelineState.toString = function () { + return "[class dragonBones.DeformTimelineState]"; + }; + DeformTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.geometryOffset = 0; + this.displayFrame = null; + this._deformCount = 0; + this._deformOffset = 0; + this._sameValueOffset = 0; + }; + DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + var dragonBonesData = this._animationData.parent.parent; + var frameIntArray = dragonBonesData.frameIntArray; + var slot = this.target.target; + this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; + if (this.geometryOffset < 0) { + this.geometryOffset += 65536; // Fixed out of bounds bug. + } + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayFrame = slot.getDisplayFrameAt(i); + var geometryData = displayFrame.getGeometryData(); + if (geometryData === null) { + continue; + } + if (geometryData.offset === this.geometryOffset) { + this.displayFrame = displayFrame; + this.displayFrame.updateDeformVertices(); + break; + } + } + if (this.displayFrame === null) { + this.returnToPool(); // + return; + } + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = dragonBonesData.frameFloatArray; + this._rd.length = this._valueCount * 2; + } + else { + this._deformCount = this.displayFrame.deformVertices.length; + } + }; + DeformTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var slot = blendState.target; + var blendWeight = blendState.blendWeight; + var result = this.displayFrame.deformVertices; + var valueArray = this._valueArray; + if (valueArray !== null) { + var valueCount = this._valueCount; + var deformOffset = this._deformOffset; + var sameValueOffset = this._sameValueOffset; + var rd = this._rd; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0.0; + if (i < deformOffset) { + value = valueArray[sameValueOffset + i]; + } + else if (i < deformOffset + valueCount) { + value = rd[i - deformOffset]; + } + else { + value = valueArray[sameValueOffset + i - valueCount]; + } + if (blendState.dirty > 1) { + result[i] += value * blendWeight; + } + else { + result[i] = value * blendWeight; + } + } + } + else if (blendState.dirty === 1) { + for (var i = 0; i < this._deformCount; ++i) { + result[i] = 0.0; + } + } + if (isDirty || this.dirty) { + this.dirty = false; + if (slot._geometryData === this.displayFrame.getGeometryData()) { + slot._verticesDirty = true; + } + } + }; + return DeformTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.DeformTimelineState = DeformTimelineState; + /** + * @internal + */ + var IKConstraintTimelineState = /** @class */ (function (_super) { + __extends(IKConstraintTimelineState, _super); + function IKConstraintTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraintTimelineState.toString = function () { + return "[class dragonBones.IKConstraintTimelineState]"; + }; + IKConstraintTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var ikConstraint = this.target; + if (this._timelineData !== null) { + ikConstraint._bendPositive = this._currentA > 0.0; + ikConstraint._weight = this._currentB; + } + else { + var ikConstraintData = ikConstraint._constraintData; + ikConstraint._bendPositive = ikConstraintData.bendPositive; + ikConstraint._weight = ikConstraintData.weight; + } + ikConstraint.invalidUpdate(); + this.dirty = false; + }; + IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.01; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return IKConstraintTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; + /** + * @internal + */ + var AnimationProgressTimelineState = /** @class */ (function (_super) { + __extends(AnimationProgressTimelineState, _super); + function AnimationProgressTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationProgressTimelineState.toString = function () { + return "[class dragonBones.AnimationProgressTimelineState]"; + }; + AnimationProgressTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.currentTime = this._result * animationState.totalTime; + } + this.dirty = false; + }; + AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationProgressTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AnimationProgressTimelineState = AnimationProgressTimelineState; + /** + * @internal + */ + var AnimationWeightTimelineState = /** @class */ (function (_super) { + __extends(AnimationWeightTimelineState, _super); + function AnimationWeightTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationWeightTimelineState.toString = function () { + return "[class dragonBones.AnimationWeightTimelineState]"; + }; + AnimationWeightTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.weight = this._result; + } + this.dirty = false; + }; + AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationWeightTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AnimationWeightTimelineState = AnimationWeightTimelineState; + /** + * @internal + */ + var AnimationParametersTimelineState = /** @class */ (function (_super) { + __extends(AnimationParametersTimelineState, _super); + function AnimationParametersTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationParametersTimelineState.toString = function () { + return "[class dragonBones.AnimationParametersTimelineState]"; + }; + AnimationParametersTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.parameterX = this._resultA; + animationState.parameterY = this._resultB; + } + this.dirty = false; + }; + AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationParametersTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.AnimationParametersTimelineState = AnimationParametersTimelineState; +})(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 properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = /** @class */ (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @internal + * @private + */ + EventObject.actionDataToInstance = function (data, instance, armature) { + if (data.type === 0 /* Play */) { + instance.type = EventObject.FRAME_EVENT; + } + else { + instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; + } + instance.name = data.name; + instance.armature = armature; + instance.actionData = data; + instance.data = data.data; + if (data.bone !== null) { + instance.bone = armature.getBone(data.bone.name); + } + if (data.slot !== null) { + instance.slot = armature.getSlot(data.slot.name); + } + }; + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + EventObject.prototype._onClear = function () { + this.time = 0.0; + this.type = ""; + this.name = ""; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.actionData = null; + this.data = null; + }; + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(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 DataParser = /** @class */ (function () { + function DataParser() { + } + DataParser._getArmatureType = function (value) { + switch (value.toLowerCase()) { + case "stage": + return 2 /* Stage */; + case "armature": + return 0 /* Armature */; + case "movieclip": + return 1 /* MovieClip */; + default: + return 0 /* Armature */; + } + }; + DataParser._getBoneType = function (value) { + switch (value.toLowerCase()) { + case "bone": + return 0 /* Bone */; + case "surface": + return 1 /* Surface */; + default: + return 0 /* Bone */; + } + }; + DataParser._getPositionMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "percent": + return 1 /* Percent */; + case "fixed": + return 0 /* Fixed */; + default: + return 1 /* Percent */; + } + }; + DataParser._getSpacingMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "length": + return 0 /* Length */; + case "percent": + return 2 /* Percent */; + case "fixed": + return 1 /* Fixed */; + default: + return 0 /* Length */; + } + }; + DataParser._getRotateMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "tangent": + return 0 /* Tangent */; + case "chain": + return 1 /* Chain */; + case "chainscale": + return 2 /* ChainScale */; + default: + return 0 /* Tangent */; + } + }; + DataParser._getDisplayType = function (value) { + switch (value.toLowerCase()) { + case "image": + return 0 /* Image */; + case "mesh": + return 2 /* Mesh */; + case "armature": + return 1 /* Armature */; + case "boundingbox": + return 3 /* BoundingBox */; + case "path": + return 4 /* Path */; + default: + return 0 /* Image */; + } + }; + DataParser._getBoundingBoxType = function (value) { + switch (value.toLowerCase()) { + case "rectangle": + return 0 /* Rectangle */; + case "ellipse": + return 1 /* Ellipse */; + case "polygon": + return 2 /* Polygon */; + default: + return 0 /* Rectangle */; + } + }; + DataParser._getBlendMode = function (value) { + switch (value.toLowerCase()) { + case "normal": + return 0 /* Normal */; + case "add": + return 1 /* Add */; + case "alpha": + return 2 /* Alpha */; + case "darken": + return 3 /* Darken */; + case "difference": + return 4 /* Difference */; + case "erase": + return 5 /* Erase */; + case "hardlight": + return 6 /* HardLight */; + case "invert": + return 7 /* Invert */; + case "layer": + return 8 /* Layer */; + case "lighten": + return 9 /* Lighten */; + case "multiply": + return 10 /* Multiply */; + case "overlay": + return 11 /* Overlay */; + case "screen": + return 12 /* Screen */; + case "subtract": + return 13 /* Subtract */; + default: + return 0 /* Normal */; + } + }; + DataParser._getAnimationBlendType = function (value) { + switch (value.toLowerCase()) { + case "none": + return 0 /* None */; + case "1d": + return 1 /* E1D */; + default: + return 0 /* None */; + } + }; + DataParser._getActionType = function (value) { + switch (value.toLowerCase()) { + case "play": + return 0 /* Play */; + case "frame": + return 10 /* Frame */; + case "sound": + return 11 /* Sound */; + default: + return 0 /* Play */; + } + }; + DataParser.DATA_VERSION_2_3 = "2.3"; + DataParser.DATA_VERSION_3_0 = "3.0"; + DataParser.DATA_VERSION_4_0 = "4.0"; + DataParser.DATA_VERSION_4_5 = "4.5"; + DataParser.DATA_VERSION_5_0 = "5.0"; + DataParser.DATA_VERSION_5_5 = "5.5"; + DataParser.DATA_VERSION_5_6 = "5.6"; + DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_6; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0, + DataParser.DATA_VERSION_5_5, + DataParser.DATA_VERSION_5_6 + ]; + DataParser.TEXTURE_ATLAS = "textureAtlas"; + DataParser.SUB_TEXTURE = "SubTexture"; + DataParser.FORMAT = "format"; + DataParser.IMAGE_PATH = "imagePath"; + DataParser.WIDTH = "width"; + DataParser.HEIGHT = "height"; + DataParser.ROTATED = "rotated"; + DataParser.FRAME_X = "frameX"; + DataParser.FRAME_Y = "frameY"; + DataParser.FRAME_WIDTH = "frameWidth"; + DataParser.FRAME_HEIGHT = "frameHeight"; + DataParser.DRADON_BONES = "dragonBones"; + DataParser.USER_DATA = "userData"; + DataParser.ARMATURE = "armature"; + DataParser.CANVAS = "canvas"; + DataParser.BONE = "bone"; + DataParser.SURFACE = "surface"; + DataParser.SLOT = "slot"; + DataParser.CONSTRAINT = "constraint"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.FRAME = "frame"; + DataParser.IK = "ik"; + DataParser.PATH_CONSTRAINT = "path"; + DataParser.ANIMATION = "animation"; + DataParser.TIMELINE = "timeline"; + DataParser.FFD = "ffd"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.DISPLAY_FRAME = "displayFrame"; + DataParser.COLOR_FRAME = "colorFrame"; + DataParser.DEFAULT_ACTIONS = "defaultActions"; + DataParser.ACTIONS = "actions"; + DataParser.EVENTS = "events"; + DataParser.INTS = "ints"; + DataParser.FLOATS = "floats"; + DataParser.STRINGS = "strings"; + DataParser.TRANSFORM = "transform"; + DataParser.PIVOT = "pivot"; + DataParser.AABB = "aabb"; + DataParser.COLOR = "color"; + DataParser.VERSION = "version"; + DataParser.COMPATIBLE_VERSION = "compatibleVersion"; + DataParser.FRAME_RATE = "frameRate"; + DataParser.TYPE = "type"; + DataParser.SUB_TYPE = "subType"; + DataParser.NAME = "name"; + DataParser.PARENT = "parent"; + DataParser.TARGET = "target"; + DataParser.STAGE = "stage"; + DataParser.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + DataParser.Z_ORDER = "zOrder"; + DataParser.Z_INDEX = "zIndex"; + DataParser.BLEND_MODE = "blendMode"; + DataParser.INHERIT_TRANSLATION = "inheritTranslation"; + DataParser.INHERIT_ROTATION = "inheritRotation"; + DataParser.INHERIT_SCALE = "inheritScale"; + DataParser.INHERIT_REFLECTION = "inheritReflection"; + DataParser.INHERIT_ANIMATION = "inheritAnimation"; + DataParser.INHERIT_DEFORM = "inheritDeform"; + DataParser.SEGMENT_X = "segmentX"; + DataParser.SEGMENT_Y = "segmentY"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.BLEND_TYPE = "blendType"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + DataParser.CLOCK_WISE = "clockwise"; + DataParser.CURVE = "curve"; + DataParser.SOUND = "sound"; + DataParser.EVENT = "event"; + DataParser.ACTION = "action"; + DataParser.X = "x"; + DataParser.Y = "y"; + DataParser.SKEW_X = "skX"; + DataParser.SKEW_Y = "skY"; + DataParser.SCALE_X = "scX"; + DataParser.SCALE_Y = "scY"; + DataParser.VALUE = "value"; + DataParser.ROTATE = "rotate"; + DataParser.SKEW = "skew"; + DataParser.ALPHA = "alpha"; + DataParser.ALPHA_OFFSET = "aO"; + DataParser.RED_OFFSET = "rO"; + DataParser.GREEN_OFFSET = "gO"; + DataParser.BLUE_OFFSET = "bO"; + DataParser.ALPHA_MULTIPLIER = "aM"; + DataParser.RED_MULTIPLIER = "rM"; + DataParser.GREEN_MULTIPLIER = "gM"; + DataParser.BLUE_MULTIPLIER = "bM"; + DataParser.UVS = "uvs"; + DataParser.VERTICES = "vertices"; + DataParser.TRIANGLES = "triangles"; + DataParser.WEIGHTS = "weights"; + DataParser.SLOT_POSE = "slotPose"; + DataParser.BONE_POSE = "bonePose"; + DataParser.BONES = "bones"; + DataParser.POSITION_MODE = "positionMode"; + DataParser.SPACING_MODE = "spacingMode"; + DataParser.ROTATE_MODE = "rotateMode"; + DataParser.SPACING = "spacing"; + DataParser.ROTATE_OFFSET = "rotateOffset"; + DataParser.ROTATE_MIX = "rotateMix"; + DataParser.TRANSLATE_MIX = "translateMix"; + DataParser.TARGET_DISPLAY = "targetDisplay"; + DataParser.CLOSED = "closed"; + DataParser.CONSTANT_SPEED = "constantSpeed"; + DataParser.VERTEX_COUNT = "vertexCount"; + DataParser.LENGTHS = "lengths"; + DataParser.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(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 ObjectDataParser = /** @class */ (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._geometry = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._frameValueType = 0 /* Step */; + _this._defaultColorOffset = -1; + _this._prevClockwise = 0; + _this._prevRotation = 0.0; + _this._frameDefaultValue = 0.0; + _this._frameValueScale = 1.0; + _this._helpMatrixA = new dragonBones.Matrix(); + _this._helpMatrixB = new dragonBones.Matrix(); + _this._helpTransform = new dragonBones.Transform(); + _this._helpColorTransform = new dragonBones.ColorTransform(); + _this._helpPoint = new dragonBones.Point(); + _this._helpArray = []; + _this._intArray = []; + _this._floatArray = []; + _this._frameIntArray = []; + _this._frameFloatArray = []; + _this._frameArray = []; + _this._timelineArray = []; + _this._colorArray = []; + _this._cacheRawMeshes = []; + _this._cacheMeshes = []; + _this._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._cacheBones = {}; + _this._slotChildActions = {}; + return _this; + } + ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "boolean") { + return value; + } + else if (type === "string") { + switch (value) { + case "0": + case "NaN": + case "": + case "false": + case "null": + case "undefined": + return false; + default: + return true; + } + } + else { + return !!value; + } + } + return defaultValue; + }; + ObjectDataParser._getNumber = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + if (value === null || value === "NaN") { + return defaultValue; + } + return +value || 0; + } + return defaultValue; + }; + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + return value; + } + return String(value); + } + return defaultValue; + }; + ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { + var l_t = 1.0 - t; + var powA = l_t * l_t; + var powB = t * t; + var kA = l_t * powA; + var kB = 3.0 * t * powA; + var kC = 3.0 * l_t * powB; + var kD = t * powB; + result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; + result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; + }; + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + if (curveCount % 3 === 1) { + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); // float + while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; + var x1 = isInCurve ? curve[stepIndex] : 0.0; + var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; + var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; + var lower = 0.0; + var higher = 1.0; + while (higher - lower > 0.0001) { + var percentage = (higher + lower) * 0.5; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0.0) { + lower = percentage; + } + else { + higher = percentage; + } + } + samples[i] = this._helpPoint.y; + } + return true; + } + else { + var stepIndex = 0; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); // float + while (curve[stepIndex + 6] < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + var x1 = curve[stepIndex]; + var y1 = curve[stepIndex + 1]; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = curve[stepIndex + 6]; + var y4 = curve[stepIndex + 7]; + var lower = 0.0; + var higher = 1.0; + while (higher - lower > 0.0001) { + var percentage = (higher + lower) * 0.5; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0.0) { + lower = percentage; + } + else { + higher = percentage; + } + } + samples[i] = this._helpPoint.y; + } + return false; + } + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (dragonBones.DataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (dragonBones.DataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (dragonBones.DataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (dragonBones.DataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (dragonBones.DataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = this._armature.actions.length; + var actions = this._parseActionData(rawData, type, bone, slot); + var frameIndex = 0; + var frame = null; + for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + this._armature.addAction(action, false); + } + if (this._actionFrames.length === 0) { // First frame. + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { // Get same frame. + var eachFrame = _b[_a]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + else if (eachFrame.frameStart > frameStart) { + break; + } + frameIndex++; + } + if (frame === null) { // Create and cache frame. + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.splice(frameIndex, 0, frame); + } + for (var i = 0; i < actions.length; ++i) { // Cache action offsets. + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { // Data error. + armature.frameRate = 24; + } + this._armature = armature; + if (dragonBones.DataParser.CANVAS in rawData) { + var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (dragonBones.DataParser.COLOR in rawCanvas) { + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; + canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; + canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; + canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; + armature.canvas = canvas; + } + if (dragonBones.DataParser.AABB in rawData) { + var rawAABB = rawData[dragonBones.DataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; + } + if (dragonBones.DataParser.BONE in rawData) { + var rawBones = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); + var bone = this._parseBone(rawBone); + if (parentName.length > 0) { // Get bone parent. + var parent_1 = armature.getBone(parentName); + if (parent_1 !== null) { + bone.parent = parent_1; + } + else { // Cache. + if (!(parentName in this._cacheBones)) { + this._cacheBones[parentName] = []; + } + this._cacheBones[parentName].push(bone); + } + } + if (bone.name in this._cacheBones) { + for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { + var child = _b[_a]; + child.parent = bone; + } + delete this._cacheBones[bone.name]; + } + armature.addBone(bone); + this._rawBones.push(bone); // Cache raw bones sort. + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawIKS = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + var constraint = this._parseIKConstraint(rawIK); + if (constraint) { + armature.addConstraint(constraint); + } + } + } + armature.sortBones(); + if (dragonBones.DataParser.SLOT in rawData) { + var zOrder = 0; + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot, zOrder++)); + } + } + if (dragonBones.DataParser.SKIN in rawData) { + var rawSkins = rawData[dragonBones.DataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { + var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; + for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { + var rawPath = rawPaths_1[_f]; + var constraint = this._parsePathConstraint(rawPath); + if (constraint) { + armature.addConstraint(constraint); + } + } + } + for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { // Link mesh. + var rawData_1 = this._cacheRawMeshes[i]; + var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); + if (shareName.length === 0) { + continue; + } + var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + if (skinName.length === 0) { // + skinName = dragonBones.DataParser.DEFAULT_NAME; + } + var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; + if (shareMesh === null) { + continue; // Error. + } + var mesh = this._cacheMeshes[i]; + mesh.geometry.shareFrom(shareMesh.geometry); + } + if (dragonBones.DataParser.ANIMATION in rawData) { + var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; + for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { + var rawAnimation = rawAnimations_1[_g]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); + for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { + var action = actions_3[_h]; + armature.addAction(action, true); + if (action.type === 0 /* Play */) { // Set default animation from default action. + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + } + } + } + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { + var action = actions_4[_j]; + armature.addAction(action, false); + } + } + // Clear helper. + this._rawBones.length = 0; + this._cacheRawMeshes.length = 0; + this._cacheMeshes.length = 0; + this._armature = null; + for (var k in this._weightSlotPose) { + delete this._weightSlotPose[k]; + } + for (var k in this._weightBonePoses) { + delete this._weightBonePoses[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + return armature; + }; + ObjectDataParser.prototype._parseBone = function (rawData) { + var type = 0 /* Bone */; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); + } + if (type === 0 /* Bone */) { + var scale = this._armature.scale; + var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; + bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + if (dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); + } + return bone; + } + var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); + surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); + surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); + this._parseGeometry(rawData, surface.geometry); + return surface; + }; + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); + if (bone === null) { + return null; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (target === null) { + return null; + } + var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); + constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 0 /* IK */; + constraint.target = target; + if (chain > 0 && bone.parent !== null) { + constraint.root = bone.parent; + constraint.bone = bone; + } + else { + constraint.root = bone; + constraint.bone = null; + } + return constraint; + }; + ObjectDataParser.prototype._parsePathConstraint = function (rawData) { + var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (target === null) { + return null; + } + var defaultSkin = this._armature.defaultSkin; + if (defaultSkin === null) { + return null; + } + //TODO + var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); + if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { + return null; + } + var bones = rawData[dragonBones.DataParser.BONES]; + if (bones === null || bones.length === 0) { + return null; + } + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 1 /* Path */; + constraint.pathSlot = target; + constraint.pathDisplayData = targetDisplay; + constraint.target = target.parent; + constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); + constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); + constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); + constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); + constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); + constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); + constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); + constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); + // + for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { + var boneName = bones_3[_i]; + var bone = this._armature.getBone(boneName); + if (bone !== null) { + constraint.AddBone(bone); + if (constraint.root === null) { + constraint.root = bone; + } + } + } + return constraint; + }; + ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + slot.zOrder = zOrder; + slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); + slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // + if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { + slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); + } + if (dragonBones.DataParser.COLOR in rawData) { + slot.color = dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); + } + else { + slot.color = dragonBones.SlotData.DEFAULT_COLOR; + } + if (dragonBones.DataParser.ACTIONS in rawData) { + this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + } + return slot; + }; + ObjectDataParser.prototype._parseSkin = function (rawData) { + var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = dragonBones.DataParser.DEFAULT_NAME; + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + this._skin = skin; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (dragonBones.DataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + if (rawDisplay) { + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + else { + skin.addDisplay(slotName, null); + } + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); + var type = 0 /* Image */; + var display = null; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: { + var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + } + case 1 /* Armature */: { + var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { + var action = actions_5[_i]; + armatureDisplay.addAction(action); + } + } + else if (this._slot.name in this._slotChildActions) { + var displays = this._skin.getDisplays(this._slot.name); + if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { + for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { + var action = _b[_a]; + armatureDisplay.addAction(action); + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + } + case 2 /* Mesh */: { + var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + if (dragonBones.DataParser.SHARE in rawData) { + meshDisplay.geometry.data = this._data; + this._cacheRawMeshes.push(rawData); + this._cacheMeshes.push(meshDisplay); + } + else { + this._parseMesh(rawData, meshDisplay); + } + break; + } + case 3 /* BoundingBox */: { + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + case 4 /* Path */: { + var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; + var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); + pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); + pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); + pathDisplay.name = name; + pathDisplay.path = path.length > 0 ? path : name; + pathDisplay.curveLengths.length = rawCurveLengths.length; + for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { + pathDisplay.curveLengths[i] = rawCurveLengths[i]; + } + this._parsePath(rawData, pathDisplay); + break; + } + } + if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); + } + return display; + }; + ObjectDataParser.prototype._parsePath = function (rawData, display) { + this._parseGeometry(rawData, display.geometry); + }; + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (dragonBones.DataParser.PIVOT in rawData) { + var rawPivot = rawData[dragonBones.DataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + this._parseGeometry(rawData, mesh.geometry); + if (dragonBones.DataParser.WEIGHTS in rawData) { // Cache pose data. + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; + this._weightSlotPose[meshName] = rawSlotPose; + this._weightBonePoses[meshName] = rawBonePoses; + } + }; + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { + type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + if (dragonBones.DataParser.VERTICES in rawData) { + var scale = this._armature.scale; + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertices = polygonBoundingBox.vertices; + vertices.length = rawVertices.length; + for (var i = 0, l = rawVertices.length; i < l; i += 2) { + var x = rawVertices[i] * scale; + var y = rawVertices[i + 1] * scale; + vertices[i] = x; + vertices[i + 1] = y; + // AABB. + if (i === 0) { + polygonBoundingBox.x = x; + polygonBoundingBox.y = y; + polygonBoundingBox.width = x; + polygonBoundingBox.height = y; + } + else { + if (x < polygonBoundingBox.x) { + polygonBoundingBox.x = x; + } + else if (x > polygonBoundingBox.width) { + polygonBoundingBox.width = x; + } + if (y < polygonBoundingBox.y) { + polygonBoundingBox.y = y; + } + else if (y > polygonBoundingBox.height) { + polygonBoundingBox.height = y; + } + } + } + polygonBoundingBox.width -= polygonBoundingBox.x; + polygonBoundingBox.height -= polygonBoundingBox.y; + } + else { + console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); + } + return polygonBoundingBox; + }; + ObjectDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.blendType = dragonBones.DataParser._getAnimationBlendType(ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); + animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; // float + animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.DataParser.DEFAULT_NAME; + } + animation.frameIntOffset = this._frameIntArray.length; + animation.frameFloatOffset = this._frameFloatArray.length; + animation.frameOffset = this._frameArray.length; + this._animation = animation; + if (dragonBones.DataParser.FRAME in rawData) { + var rawFrames = rawData[dragonBones.DataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount > 0) { + for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { + var rawFrame = rawFrames[i]; + this._parseActionDataInFrame(rawFrame, frameStart, null, null); + frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + } + if (dragonBones.DataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, 0 /* Step */, 0, this._parseZOrderFrame); + } + if (dragonBones.DataParser.BONE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.FFD in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + if (skinName.length === 0) { // + skinName = dragonBones.DataParser.DEFAULT_NAME; + } + this._slot = this._armature.getSlot(slotName); + this._mesh = this._armature.getMesh(skinName, slotName, displayName); + if (this._slot === null || this._mesh === null) { + continue; + } + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, 2 /* Float */, 0, this._parseSlotDeformFrame); + if (timeline !== null) { + this._animation.addSlotTimeline(slotName, timeline); + } + this._slot = null; // + this._mesh = null; // + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { + var rawTimeline = rawTimelines_4[_c]; + var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var constraint = this._armature.getConstraint(constraintName); + if (constraint === null) { + continue; + } + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, 1 /* Int */, 2, this._parseIKConstraintFrame); + if (timeline !== null) { + this._animation.addConstraintTimeline(constraintName, timeline); + } + } + } + if (this._actionFrames.length > 0) { + this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, 0 /* Step */, 0, this._parseActionFrame); + this._actionFrames.length = 0; + } + if (dragonBones.DataParser.TIMELINE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; + for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { + var rawTimeline = rawTimelines_5[_d]; + var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = null; + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 20 /* SlotDisplay */: // TODO + case 23 /* SlotZIndex */: + case 60 /* BoneAlpha */: + case 24 /* SlotAlpha */: + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + if (timelineType === 20 /* SlotDisplay */) { + this._frameValueType = 0 /* Step */; + this._frameValueScale = 1.0; + } + else { + this._frameValueType = 1 /* Int */; + if (timelineType === 23 /* SlotZIndex */) { + this._frameValueScale = 1.0; + } + else if (timelineType === 40 /* AnimationProgress */ || + timelineType === 41 /* AnimationWeight */) { + this._frameValueScale = 10000.0; + } + else { + this._frameValueScale = 100.0; + } + } + if (timelineType === 60 /* BoneAlpha */ || + timelineType === 24 /* SlotAlpha */ || + timelineType === 41 /* AnimationWeight */) { + this._frameDefaultValue = 1.0; + } + else { + this._frameDefaultValue = 0.0; + } + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); + var animaitonTimeline = timeline; + animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 1, this._parseSingleValueFrame, timeline); + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 30 /* IKConstraint */: + case 42 /* AnimationParameter */: + if (timelineType === 30 /* IKConstraint */ || + timelineType === 42 /* AnimationParameter */) { + this._frameValueType = 1 /* Int */; + if (timelineType === 42 /* AnimationParameter */) { + this._frameValueScale = 10000.0; + } + else { + this._frameValueScale = 100.0; + } + } + else { + if (timelineType === 12 /* BoneRotate */) { + this._frameValueScale = dragonBones.Transform.DEG_RAD; + } + else { + this._frameValueScale = 1.0; + } + this._frameValueType = 2 /* Float */; + } + if (timelineType === 13 /* BoneScale */ || + timelineType === 30 /* IKConstraint */) { + this._frameDefaultValue = 1.0; + } + else { + this._frameDefaultValue = 0.0; + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 2, this._parseDoubleValueFrame); + break; + case 1 /* ZOrder */: + // TODO + break; + case 50 /* Surface */: { + var surface = this._armature.getBone(timelineName); + if (surface === null) { + continue; + } + this._geometry = surface.geometry; + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); + this._geometry = null; // + break; + } + case 22 /* SlotDeform */: { + this._geometry = null; // + for (var skinName in this._armature.skins) { + var skin = this._armature.skins[skinName]; + for (var slontName in skin.displays) { + var displays = skin.displays[slontName]; + for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { + var display = displays_1[_e]; + if (display !== null && display.name === timelineName) { + this._geometry = display.geometry; + break; + } + } + } + } + if (this._geometry === null) { + continue; + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); + this._geometry = null; // + break; + } + case 21 /* SlotColor */: + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 1 /* Int */, 1, this._parseSlotColorFrame); + break; + } + if (timeline !== null) { + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 1 /* ZOrder */: + // TODO + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 50 /* Surface */: + case 60 /* BoneAlpha */: + this._animation.addBoneTimeline(timelineName, timeline); + break; + case 20 /* SlotDisplay */: + case 21 /* SlotColor */: + case 22 /* SlotDeform */: + case 23 /* SlotZIndex */: + case 24 /* SlotAlpha */: + this._animation.addSlotTimeline(timelineName, timeline); + break; + case 30 /* IKConstraint */: + this._animation.addConstraintTimeline(timelineName, timeline); + break; + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + case 42 /* AnimationParameter */: + this._animation.addAnimationTimeline(timelineName, timeline); + break; + } + } + } + } + this._animation = null; // + return animation; + }; + ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, timelineType, frameValueType, frameValueCount, frameParser, timeline) { + if (timeline === void 0) { timeline = null; } + if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { + rawFrames = rawData[framesKey]; + } + if (rawFrames === null) { + return null; + } + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var frameIntArrayLength = this._frameIntArray.length; + var frameFloatArrayLength = this._frameFloatArray.length; + var timelineOffset = this._timelineArray.length; + if (timeline === null) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + } + timeline.type = timelineType; + timeline.offset = timelineOffset; + this._frameValueType = frameValueType; + this._timeline = timeline; + this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + if (rawData !== null) { + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); + } + else { + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; + } + this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; + switch (this._frameValueType) { + case 0 /* Step */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; + break; + case 1 /* Int */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + break; + case 2 /* Float */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + break; + } + if (keyFrameCount === 1) { // Only one frame. + timeline.frameIndicesOffset = -1; + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + var frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var rawFrame = rawFrames[iK]; + frameStart = i; // frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + if (rawFrame instanceof ActionFrame) { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + else { + frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; // + return timeline; + }; + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { + this._frameDefaultValue = 0.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, 2 /* Float */, 2, this._parseDoubleValueFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.ROTATE_FRAME in rawData) { + this._frameDefaultValue = 0.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, 2 /* Float */, 2, this._parseBoneRotateFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.SCALE_FRAME in rawData) { + this._frameDefaultValue = 1.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, 2 /* Float */, 2, this._parseBoneScaleFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, 2 /* Float */, 6, this._parseBoneAllFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + this._bone = null; // + this._slot = null; // + }; + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (slot === null) { + return; + } + var displayTimeline = null; + var colorTimeline = null; + this._slot = slot; + if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { + displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); + } + else { + displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); + } + if (dragonBones.DataParser.COLOR_FRAME in rawData) { + colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); + } + else { + colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); + } + if (displayTimeline !== null) { + this._animation.addSlotTimeline(slot.name, displayTimeline); + } + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot.name, colorTimeline); + } + this._slot = null; // + }; + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { + // tslint:disable-next-line:no-unused-expression + rawData; + // tslint:disable-next-line:no-unused-expression + frameCount; + var frameOffset = this._frameArray.length; + this._frameArray.length += 1; + this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (frameCount > 0) { + if (dragonBones.DataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); + this._frameArray.length += 1 + 1 + this._helpArray.length; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited ? sampleCount : -sampleCount; + for (var i = 0; i < sampleCount; ++i) { + this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (dragonBones.DataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { + var frameOffset = 0; + switch (this._frameValueType) { + case 0: { + frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue); + break; + } + case 1: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale); + break; + } + case 2: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 1; + this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale; + break; + } + } + return frameOffset; + }; + ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { + var frameOffset = 0; + switch (this._frameValueType) { + case 0: { + frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 2; + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue); + this._frameArray[frameOffset + 2] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue); + break; + } + case 1: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale); + this._frameIntArray[frameValueOffset + 1] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale); + break; + } + case 2: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale; + this._frameFloatArray[frameValueOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale; + break; + } + } + return frameOffset; + }; + ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { + // tslint:disable-next-line:no-unused-expression + frameCount; + var frameOffset = this._frameArray.length; + var actionCount = frame.actions.length; + this._frameArray.length += 1 + 1 + actionCount; + this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { // Action offsets. + this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (dragonBones.DataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; + if (rawZOrder.length > 0) { + var slotCount = this._armature.sortedSlots.length; + var unchanged = new Array(slotCount - rawZOrder.length / 2); + var zOrders = new Array(slotCount); + for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { + unchanged[i_1] = 0; + } + for (var i_2 = 0; i_2 < slotCount; ++i_2) { + zOrders[i_2] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { + var slotIndex = rawZOrder[i_3]; + var zOrderOffset = rawZOrder[i_3 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + var index = originalIndex + zOrderOffset; + zOrders[index] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + this._frameArray.length += 1 + slotCount; + this._frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; + } + else { + this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; + } + } + return frameOffset; + } + } + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { + this._helpTransform.identity(); + if (dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevClockwise === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + // + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 6; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { + // Modify rotation. + var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; + if (frameStart !== 0) { + if (this._prevClockwise === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); + this._prevRotation = rotation; + // + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + if (dragonBones.DataParser.VALUE in rawData) { + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); + } + else { + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + } + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var colorOffset = -1; + if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { + var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; + for (var k in rawColor) { // Detects the presence of color. + // tslint:disable-next-line:no-unused-expression + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = this._colorArray.length; + this._colorArray.length += 8; + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defaultColorOffset < 0) { + this._defaultColorOffset = colorOffset = this._colorArray.length; + this._colorArray.length += 8; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + } + colorOffset = this._defaultColorOffset; + } + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; + var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; + var weight = this._mesh.geometry.weight; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (weight !== null) { + var rawSlotPose = this._weightSlotPose[meshName]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + this._frameFloatArray.length += weight.count * 2; + iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; + } + else { + this._frameFloatArray.length += vertexCount * 2; + } + for (var i = 0; i < vertexCount * 2; i += 2) { + if (rawVertices === null) { // Fill 0. + x = 0.0; + y = 0.0; + } + else { + if (i < offset || i - offset >= rawVertices.length) { + x = 0.0; + } + else { + x = rawVertices[i - offset]; + } + if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { + y = 0.0; + } + else { + y = rawVertices[i + 1 - offset]; + } + } + if (weight !== null) { // If mesh is skinned, transform point by bone bind pose. + var rawBonePoses = this._weightBonePoses[meshName]; + var vertexBoneCount = this._intArray[iB++]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var boneIndex = this._intArray[iB++]; + this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; + this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; + this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { + var actions = new Array(); + if (typeof rawData === "string") { + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + actions.push(action); + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { + var rawAction = rawData_2[_i]; + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); + } + else { + if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { + action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); + } + if (dragonBones.DataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (dragonBones.DataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + var userData = null; + if (dragonBones.DataParser.INTS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[dragonBones.DataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + userData.addInt(rawValue); + } + } + if (dragonBones.DataParser.FLOATS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + userData.addFloat(rawValue); + } + } + if (dragonBones.DataParser.STRINGS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + userData.addString(rawValue); + } + } + action.data = userData; + actions.push(action); + } + } + return actions; + }; + ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? + rawData[dragonBones.DataParser.VERTICES] : + (dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null); + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; + var weight = this._geometry.weight; + var x = 0.0; + var y = 0.0; + if (weight !== null) { + // TODO + } + else { + this._frameFloatArray.length += vertexCount * 2; + for (var i = 0; i < vertexCount * 2; i += 2) { + if (rawVertices !== null) { + if (i < offset || i - offset >= rawVertices.length) { + x = 0.0; + } + else { + x = rawVertices[i - offset]; + } + if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { + y = 0.0; + } + else { + y = rawVertices[i + 1 - offset]; + } + } + else { + x = 0.0; + y = 0.0; + } + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; + this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; + if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); + }; + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); + }; + ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = 0; + var geometryOffset = this._intArray.length; + var verticesOffset = this._floatArray.length; + // + geometry.offset = geometryOffset; + geometry.data = this._data; + // + this._intArray.length += 1 + 1 + 1 + 1; + this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; + this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; + this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // + // + this._floatArray.length += vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + this._floatArray[verticesOffset + i] = rawVertices[i]; + } + if (dragonBones.DataParser.TRIANGLES in rawData) { + var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; + triangleCount = Math.floor(rawTriangles.length / 3); // uint + // + this._intArray.length += triangleCount * 3; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; + } + } + // Fill triangle count. + this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; + if (dragonBones.DataParser.UVS in rawData) { + var rawUVs = rawData[dragonBones.DataParser.UVS]; + var uvOffset = verticesOffset + vertexCount * 2; + this._floatArray.length += vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + this._floatArray[uvOffset + i] = rawUVs[i]; + } + } + if (dragonBones.DataParser.WEIGHTS in rawData) { + var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; + var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint + var weightOffset = this._intArray.length; + var floatOffset = this._floatArray.length; + var weightBoneCount = 0; + var sortedBones = this._armature.sortedBones; + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = weightCount; + weight.offset = weightOffset; + this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; + this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; + if (dragonBones.DataParser.BONE_POSE in rawData) { + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + weightBoneIndices.length = weightBoneCount; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + weightBoneIndices[i] = rawBoneIndex; + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += weightCount * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint + var x = this._floatArray[verticesOffset + iD]; + var y = this._floatArray[verticesOffset + iD + 1]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var rawBoneIndex = rawWeights[iW++]; // uint + var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); + this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + this._intArray[iB++] = boneIndex; + this._floatArray[iV++] = rawWeights[iW++]; + this._floatArray[iV++] = this._helpPoint.x; + this._floatArray[iV++] = this._helpPoint.y; + } + } + } + else { + var rawBones = rawData[dragonBones.DataParser.BONES]; + weightBoneCount = rawBones.length; + for (var i = 0; i < weightBoneCount; i++) { + var rawBoneIndex = rawBones[i]; + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += weightCount * 3; + for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { + var vertexBoneCount = rawWeights[iW++]; + this._intArray[iB++] = vertexBoneCount; + for (var j = 0; j < vertexBoneCount; j++) { + var boneIndex = rawWeights[iW++]; + var boneWeight = rawWeights[iW++]; + var x = rawVertices[iV++]; + var y = rawVertices[iV++]; + this._intArray[iB++] = rawBones.indexOf(boneIndex); + this._floatArray[iF++] = boneWeight; + this._floatArray[iF++] = x; + this._floatArray[iF++] = y; + } + } + } + geometry.weight = weight; + } + }; + ObjectDataParser.prototype._parseArray = function (rawData) { + // tslint:disable-next-line:no-unused-expression + rawData; + this._intArray.length = 0; + this._floatArray.length = 0; + this._frameIntArray.length = 0; + this._frameFloatArray.length = 0; + this._frameArray.length = 0; + this._timelineArray.length = 0; + this._colorArray.length = 0; + }; + ObjectDataParser.prototype._modifyArray = function () { + // Align. + if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._intArray.push(0); + } + if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._frameIntArray.push(0); + } + if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._frameArray.push(0); + } + if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { + this._timelineArray.push(0); + } + if ((this._timelineArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._colorArray.push(0); + } + var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; + var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; + var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; + var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; + var l7 = this._colorArray.length * Int16Array.BYTES_PER_ELEMENT; + var lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7; + // + var binary = new ArrayBuffer(lTotal); + var intArray = new Int16Array(binary, 0, this._intArray.length); + var floatArray = new Float32Array(binary, l1, this._floatArray.length); + var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); + var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); + var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); + var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); + var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); + for (var i = 0, l = this._intArray.length; i < l; ++i) { + intArray[i] = this._intArray[i]; + } + for (var i = 0, l = this._floatArray.length; i < l; ++i) { + floatArray[i] = this._floatArray[i]; + } + for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { + frameIntArray[i] = this._frameIntArray[i]; + } + for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { + frameFloatArray[i] = this._frameFloatArray[i]; + } + for (var i = 0, l = this._frameArray.length; i < l; ++i) { + frameArray[i] = this._frameArray[i]; + } + for (var i = 0, l = this._timelineArray.length; i < l; ++i) { + timelineArray[i] = this._timelineArray[i]; + } + for (var i = 0, l = this._colorArray.length; i < l; ++i) { + colorArray[i] = this._colorArray[i]; + } + this._data.binary = binary; + this._data.intArray = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = frameArray; + this._data.timelineArray = timelineArray; + this._data.colorArray = colorArray; + this._defaultColorOffset = -1; + }; + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined, "Data error."); + var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); + if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || + dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { // Data error. + data.frameRate = 24; + } + if (dragonBones.DataParser.ARMATURE in rawData) { + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; + for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { + var rawArmature = rawArmatures_1[_i]; + data.addArmature(this._parseArmature(rawArmature, scale)); + } + if (!this._data.binary) { // DragonBones.webAssembly ? 0 : null; + this._modifyArray(); + } + if (dragonBones.DataParser.STAGE in rawData) { + data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); + } + else if (data.armatureNames.length > 0) { + data.stage = data.getArmature(data.armatureNames[0]); + } + this._data = null; + } + if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; + } + return data; + } + else { + console.assert(false, "Nonsupport data version: " + version + "\n" + + "Please convert DragonBones data to support version.\n" + + "Read more: https://github.com/DragonBones/Tools/"); + } + return null; + }; + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 1.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { + return false; + } + var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; + this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); + if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { + this._rawTextureAtlasIndex = 0; + this._rawTextureAtlases = null; + } + return true; + } + // Texture format. + textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); + textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; + textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); + if (dragonBones.DataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); + textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); + textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); + textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); + textureData.frame.width = frameWidth; + textureData.frame.height = frameHeight; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + /** + * @private + */ + var ActionFrame = /** @class */ (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); + dragonBones.ActionFrame = ActionFrame; +})(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 BinaryDataParser = /** @class */ (function (_super) { + __extends(BinaryDataParser, _super); + function BinaryDataParser() { + return _super !== null && _super.apply(this, arguments) || this; + } + BinaryDataParser.prototype._inRange = function (a, min, max) { + return min <= a && a <= max; + }; + BinaryDataParser.prototype._decodeUTF8 = function (data) { + var EOF_byte = -1; + var EOF_code_point = -1; + var FATAL_POINT = 0xFFFD; + var pos = 0; + var result = ""; + var code_point; + var utf8_code_point = 0; + var utf8_bytes_needed = 0; + var utf8_bytes_seen = 0; + var utf8_lower_boundary = 0; + while (data.length > pos) { + var _byte = data[pos++]; + if (_byte === EOF_byte) { + if (utf8_bytes_needed !== 0) { + code_point = FATAL_POINT; + } + else { + code_point = EOF_code_point; + } + } + else { + if (utf8_bytes_needed === 0) { + if (this._inRange(_byte, 0x00, 0x7F)) { + code_point = _byte; + } + else { + if (this._inRange(_byte, 0xC2, 0xDF)) { + utf8_bytes_needed = 1; + utf8_lower_boundary = 0x80; + utf8_code_point = _byte - 0xC0; + } + else if (this._inRange(_byte, 0xE0, 0xEF)) { + utf8_bytes_needed = 2; + utf8_lower_boundary = 0x800; + utf8_code_point = _byte - 0xE0; + } + else if (this._inRange(_byte, 0xF0, 0xF4)) { + utf8_bytes_needed = 3; + utf8_lower_boundary = 0x10000; + utf8_code_point = _byte - 0xF0; + } + else { + } + utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); + code_point = null; + } + } + else if (!this._inRange(_byte, 0x80, 0xBF)) { + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + pos--; + code_point = _byte; + } + else { + utf8_bytes_seen += 1; + utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + if (utf8_bytes_seen !== utf8_bytes_needed) { + code_point = null; + } + else { + var cp = utf8_code_point; + var lower_boundary = utf8_lower_boundary; + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { + code_point = cp; + } + else { + code_point = _byte; + } + } + } + } + //Decode string + if (code_point !== null && code_point !== EOF_code_point) { + if (code_point <= 0xFFFF) { + if (code_point > 0) + result += String.fromCharCode(code_point); + } + else { + code_point -= 0x10000; + result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); + result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); + } + } + } + return result; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var frameIndicesOffset = 0; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; // + return timeline; + }; + BinaryDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.blendType = dragonBones.DataParser._getAnimationBlendType(dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); + animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; // float + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.DataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.DataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.DataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); + } + if (dragonBones.DataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); + } + if (dragonBones.DataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var bone = this._armature.getBone(k); + if (bone === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addBoneTimeline(bone.name, timeline); + } + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var slot = this._armature.getSlot(k); + if (slot === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addSlotTimeline(slot.name, timeline); + } + } + } + if (dragonBones.DataParser.CONSTRAINT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var constraint = this._armature.getConstraint(k); + if (constraint === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addConstraintTimeline(constraint.name, timeline); + } + } + } + if (dragonBones.DataParser.TIMELINE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; + for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { + var rawTimeline = rawTimelines_6[_i]; + var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); + if (timelineOffset >= 0) { + var timelineType = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = null; + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); + var animaitonTimeline = timeline; + animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); + } + timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 1 /* ZOrder */: + // TODO + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 50 /* Surface */: + case 60 /* BoneAlpha */: + this._animation.addBoneTimeline(timelineName, timeline); + break; + case 20 /* SlotDisplay */: + case 21 /* SlotColor */: + case 22 /* SlotDeform */: + case 23 /* SlotZIndex */: + case 24 /* SlotAlpha */: + this._animation.addSlotTimeline(timelineName, timeline); + break; + case 30 /* IKConstraint */: + this._animation.addConstraintTimeline(timelineName, timeline); + break; + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + case 42 /* AnimationParameter */: + this._animation.addAnimationTimeline(timelineName, timeline); + break; + } + } + } + } + this._animation = null; + return animation; + }; + BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { + geometry.offset = rawData[dragonBones.DataParser.OFFSET]; + geometry.data = this._data; + var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; + if (weightOffset >= 0) { + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; + var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.addBone(this._rawBones[boneIndex]); + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + var weightCount = 0; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; + weightCount += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + weight.count = weightCount; + geometry.weight = weight; + } + }; + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.DataParser.OFFSET]; + var l1 = offsets[1]; + var l2 = offsets[3]; + var l3 = offsets[5]; + var l4 = offsets[7]; + var l5 = offsets[9]; + var l6 = offsets[11]; + var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. + var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); + var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); + var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); + var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); + var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); + var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); + var colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. + this._data.binary = this._binary; + this._data.intArray = this._intArrayBuffer = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = this._frameArrayBuffer = frameArray; + this._data.timelineArray = this._timelineArrayBuffer = timelineArray; + this._data.colorArray = colorArray; + }; + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); + var tag = new Uint8Array(rawData, 0, 8); + if (tag[0] !== "D".charCodeAt(0) || + tag[1] !== "B".charCodeAt(0) || + tag[2] !== "D".charCodeAt(0) || + tag[3] !== "T".charCodeAt(0)) { + console.assert(false, "Nonsupport data."); + return null; + } + var headerLength = new Uint32Array(rawData, 8, 1)[0]; + var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); + var headerString = this._decodeUTF8(headerBytes); + var header = JSON.parse(headerString); + // + this._binaryOffset = 8 + 4 + headerLength; + this._binary = rawData; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(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) { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = /** @class */ (function () { + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * @private + */ + this.autoSearch = false; + this._dragonBonesDataMap = {}; + this._textureAtlasDataMap = {}; + this._dragonBones = null; + this._dataParser = null; + if (BaseFactory._objectParser === null) { + BaseFactory._objectParser = new dragonBones.ObjectDataParser(); + } + if (BaseFactory._binaryParser === null) { + BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); + } + this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; + } + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { + if (textureAtlasName in this._textureAtlasDataMap) { + for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { + var textureAtlasData = _a[_i]; + var textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + if (this.autoSearch) { // Will be search all data, if the autoSearch is true. + for (var k in this._textureAtlasDataMap) { + for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { + var textureAtlasData = _c[_b]; + if (textureAtlasData.autoSearch) { + var textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + } + } + return null; + }; + BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { + var dragonBonesData = null; + var armatureData = null; + if (dragonBonesName.length > 0) { + if (dragonBonesName in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; + armatureData = dragonBonesData.getArmature(armatureName); + } + } + if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { // Will be search all data, if do not give a data name or the autoSearch is true. + for (var k in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[k]; + if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { + armatureData = dragonBonesData.getArmature(armatureName); + if (armatureData !== null) { + dragonBonesName = k; + break; + } + } + } + } + if (armatureData !== null) { + dataPackage.dataName = dragonBonesName; + dataPackage.textureAtlasName = textureAtlasName; + dataPackage.data = dragonBonesData; + dataPackage.armature = armatureData; + dataPackage.skin = null; + if (skinName.length > 0) { + dataPackage.skin = armatureData.getSkin(skinName); + if (dataPackage.skin === null && this.autoSearch) { + for (var k in this._dragonBonesDataMap) { + var skinDragonBonesData = this._dragonBonesDataMap[k]; + var skinArmatureData = skinDragonBonesData.getArmature(skinName); + if (skinArmatureData !== null) { + dataPackage.skin = skinArmatureData.defaultSkin; + break; + } + } + } + } + if (dataPackage.skin === null) { + dataPackage.skin = armatureData.defaultSkin; + } + return true; + } + return false; + }; + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { + var boneData = _a[_i]; + var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); + bone.init(boneData, armature); + } + }; + /** + * @private + */ + BaseFactory.prototype._buildSlots = function (dataPackage, armature) { + var currentSkin = dataPackage.skin; + var defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin === null || defaultSkin === null) { + return; + } + var skinSlots = {}; + for (var k in defaultSkin.displays) { + var displays = defaultSkin.getDisplays(k); + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.getDisplays(k); + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; + var slot = this._buildSlot(dataPackage, slotData, armature); + if (displayDatas !== null) { + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + slot.replaceRawDisplayData(displayData, i); + if (displayData !== null) { + if (dataPackage.textureAtlasName.length > 0) { + var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + slot.replaceTextureData(textureData, i); + } + var display = this._getSlotDisplay(dataPackage, displayData, slot); + slot.replaceDisplay(display, i); + } + else { + slot.replaceDisplay(null); + } + } + } + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { + var constraints = dataPackage.armature.constraints; + for (var k in constraints) { + var constraintData = constraints[k]; + // TODO more constraint type. + switch (constraintData.type) { + case 0 /* IK */: + var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + ikConstraint.init(constraintData, armature); + armature._addConstraint(ikConstraint); + break; + case 1 /* Path */: + var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); + pathConstraint.init(constraintData, armature); + armature._addConstraint(pathConstraint); + break; + default: + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + constraint.init(constraintData, armature); + armature._addConstraint(constraint); + break; + } + } + }; + BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { + return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); + }; + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; + var display = null; + switch (displayData.type) { + case 0 /* Image */: { + var imageDisplayData = displayData; + if (imageDisplayData.texture === null) { + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); + } + display = slot.rawDisplay; + break; + } + case 2 /* Mesh */: { + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + } + case 1 /* Armature */: { + var armatureDisplayData = displayData; + var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); + if (childArmature !== null) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.length > 0) { + for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { + var action = actions_6[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); + eventObject.slot = slot; + slot.armature._bufferAction(eventObject, false); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + case 3 /* BoundingBox */: + break; + default: + break; + } + return display; + }; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 1.0; } + var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; + var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 1.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * - Update texture atlases. + * @param textureAtlases - The texture atlas objects. + * @param name - The texture atlas name. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 更新贴图集对象。 + * @param textureAtlases - 多个贴图集对象。 + * @param name - 贴图集名称。 + * @version DragonBones 5.7 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { + var textureAtlasDatas = this.getTextureAtlasData(name); + if (textureAtlasDatas !== null) { + for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { + if (i < textureAtlases.length) { + this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); + } + } + } + }; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.getDragonBonesData = function (name) { + return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; + }; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.addDragonBonesData = function (data, name) { + if (name === void 0) { name = null; } + name = name !== null ? name : data.name; + if (name in this._dragonBonesDataMap) { + if (this._dragonBonesDataMap[name] === data) { + return; + } + console.warn("Can not add same name data: " + name); + return; + } + this._dragonBonesDataMap[name] = data; + }; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { + if (disposeData === void 0) { disposeData = true; } + if (name in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); + } + delete this._dragonBonesDataMap[name]; + } + }; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.getTextureAtlasData = function (name) { + return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; + }; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.addTextureAtlasData = function (data, name) { + if (name === void 0) { name = null; } + name = name !== null ? name : data.name; + var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); + if (textureAtlasList.indexOf(data) < 0) { + textureAtlasList.push(data); + } + }; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { + if (disposeData === void 0) { disposeData = true; } + if (name in this._textureAtlasDataMap) { + var textureAtlasDataList = this._textureAtlasDataMap[name]; + if (disposeData) { + for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { + var textureAtlasData = textureAtlasDataList_1[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[name]; + } + }; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { + return null; + } + return dataPackage.armature; + }; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.clear = function (disposeData) { + if (disposeData === void 0) { disposeData = true; } + for (var k in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); + } + delete this._dragonBonesDataMap[k]; + } + for (var k in this._textureAtlasDataMap) { + if (disposeData) { + var textureAtlasDataList = this._textureAtlasDataMap[k]; + for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { + var textureAtlasData = textureAtlasDataList_2[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[k]; + } + }; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + if (skinName === void 0) { skinName = ""; } + if (textureAtlasName === void 0) { textureAtlasName = ""; } + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { + console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); + return null; + } + var armature = this._buildArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + this._buildConstraints(dataPackage, armature); + armature.invalidUpdate(null, true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * @private + */ + BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + slot.replaceDisplayData(displayData, displayIndex); + if (displayData !== null) { + var display = this._getSlotDisplay(null, displayData, slot); + if (displayData.type === 0 /* Image */) { + var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; + if (rawDisplayData !== null && + rawDisplayData.type === 2 /* Mesh */) { + display = slot.meshDisplay; + } + } + slot.replaceDisplay(display, displayIndex); + } + else { + slot.replaceDisplay(null, displayIndex); + } + }; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (armatureData === null || armatureData.defaultSkin === null) { + return false; + } + var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); + this.replaceDisplay(slot, displayData, displayIndex); + return true; + }; + /** + * @private + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (!armatureData || !armatureData.defaultSkin) { + return false; + } + var displayDatas = armatureData.defaultSkin.getDisplays(slotName); + if (!displayDatas) { + return false; + } + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + this.replaceDisplay(slot, displayData, i); + } + return true; + }; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { + if (isOverride === void 0) { isOverride = false; } + if (exclude === void 0) { exclude = null; } + var success = false; + var defaultSkin = skin.parent.defaultSkin; + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (exclude !== null && exclude.indexOf(slot.name) >= 0) { + continue; + } + var displayDatas = skin.getDisplays(slot.name); + if (displayDatas === null) { + if (defaultSkin !== null && skin !== defaultSkin) { + displayDatas = defaultSkin.getDisplays(slot.name); + } + if (displayDatas === null) { + if (isOverride) { + slot.displayFrameCount = 0; + } + continue; + } + } + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + slot.replaceRawDisplayData(displayData, i); + if (displayData !== null) { + slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); + } + else { + slot.replaceDisplay(null, i); + } + } + success = true; + } + return success; + }; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { + if (isOverride === void 0) { isOverride = true; } + var skinData = armatureData.defaultSkin; + if (skinData === null) { + return false; + } + if (isOverride) { + armature.animation.animations = armatureData.animations; + } + else { + var rawAnimations = armature.animation.animations; + var animations = {}; + for (var k in rawAnimations) { + animations[k] = rawAnimations[k]; + } + for (var k in armatureData.animations) { + animations[k] = armatureData.animations[k]; + } + armature.animation.animations = animations; + } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var index = 0; + for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { + var display = _c[_b]; + if (display instanceof dragonBones.Armature) { + var displayDatas = skinData.getDisplays(slot.name); + if (displayDatas !== null && index < displayDatas.length) { + var displayData = displayDatas[index]; + if (displayData !== null && displayData.type === 1 /* Armature */) { + var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); + if (childArmatureData) { + this.replaceAnimation(display, childArmatureData, isOverride); + } + } + } + } + index++; + } + } + return true; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + Object.defineProperty(BaseFactory.prototype, "clock", { + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + get: function () { + return this._dragonBones.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseFactory.prototype, "dragonBones", { + /** + * @private + */ + get: function () { + return this._dragonBones; + }, + enumerable: true, + configurable: true + }); + BaseFactory._objectParser = null; + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; + /** + * @private + */ + var BuildArmaturePackage = /** @class */ (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; +})(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. + */ +if (CC_EDITOR) { + _Scene.Sandbox._globalsVerifier_loadPluginScript.ignoreNames['dragonBones'] = true; +} +var dragonBones; +(function (dragonBones) { + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; + var DragonBonesAsset = /** @class */ (function (_super) { + __extends(DragonBonesAsset, _super); + function DragonBonesAsset() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.dragonBonesData = ""; + _this.textureAtlases = []; + _this.textures = []; + return _this; + } + __decorate([ + property + ], DragonBonesAsset.prototype, "dragonBonesData", void 0); + __decorate([ + property([cc.String]) + ], DragonBonesAsset.prototype, "textureAtlases", void 0); + __decorate([ + property([cc.Texture2D]) + ], DragonBonesAsset.prototype, "textures", void 0); + DragonBonesAsset = __decorate([ + ccclass("DragonBones.DragonBonesAsset") + ], DragonBonesAsset); + return DragonBonesAsset; + }(cc.Asset)); + dragonBones.DragonBonesAsset = DragonBonesAsset; +})(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 Cocos texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosTextureAtlasData = /** @class */ (function (_super) { + __extends(CocosTextureAtlasData, _super); + function CocosTextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._renderTexture = null; // Initial value. + return _this; + } + CocosTextureAtlasData.toString = function () { + return "[class dragonBones.CocosTextureAtlasData]"; + }; + CocosTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this._renderTexture !== null) { + // this._renderTexture.dispose(); + } + this._renderTexture = null; + }; + CocosTextureAtlasData.prototype.createTexture = function () { + return dragonBones.BaseObject.borrowObject(CocosTextureData); + }; + Object.defineProperty(CocosTextureAtlasData.prototype, "renderTexture", { + /** + * - The Cocos texture. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._renderTexture; + }, + set: function (value) { + if (this._renderTexture === value) { + return; + } + this._renderTexture = value; + if (this._renderTexture !== null) { + for (var k in this.textures) { + var textureData = this.textures[k]; + if (textureData.renderTexture !== null) { + textureData.renderTexture.destroy(); + } + var reat = cc.rect(textureData.region.x, textureData.region.y, textureData.rotated ? textureData.region.height : textureData.region.width, textureData.rotated ? textureData.region.width : textureData.region.height); + var offset = cc.v2(); + var originSize = cc.size(reat.size.width, reat.size.height); + textureData.renderTexture = new cc.SpriteFrame(this._renderTexture, reat, textureData.rotated, offset, originSize); + } + } + else { + for (var k in this.textures) { + var textureData = this.textures[k]; + if (textureData.renderTexture !== null) { + textureData.renderTexture.destroy(); + } + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + return CocosTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.CocosTextureAtlasData = CocosTextureAtlasData; + /** + * @internal + */ + var CocosTextureData = /** @class */ (function (_super) { + __extends(CocosTextureData, _super); + function CocosTextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.renderTexture = null; // Initial value. + return _this; + } + CocosTextureData.toString = function () { + return "[class dragonBones.CocosTextureData]"; + }; + CocosTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + this.renderTexture.destroy(); + } + this.renderTexture = null; + }; + return CocosTextureData; + }(dragonBones.TextureData)); + dragonBones.CocosTextureData = CocosTextureData; +})(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) { + // const _defaultItems = cc.Enum({ "None": -1 }); + // function _setItems(object: any, key: string, items: any) { + // (cc.Class as any).attr( // creator.d.ts error. + // object, + // key, + // { + // type: "Enum", + // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. + // } + // ); + // } + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, executeInEditMode = _a.executeInEditMode, disallowMultiple = _a.disallowMultiple, playOnFocus = _a.playOnFocus, menu = _a.menu, help = _a.help; + /** + * @see dragonBones.IArmatureProxy + */ + var CocosArmatureComponent = /** @class */ (function (_super) { + __extends(CocosArmatureComponent, _super); + function CocosArmatureComponent() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.debugDraw = false; + _this._debugDraw = false; + /** + * @internal + */ + _this._armature = null; + // Editor. + /** + * @internal + */ + _this._armatureName = ""; + _this.dragonBonesName = ''; + /** + * @internal + */ + _this._animationName = ""; + // Visibie. + /** + * @internal + */ + _this._dragonBonesAsset = null; + /** + * @internal + */ + _this._armatureNames = []; + /** + * @internal + */ + _this._animationNames = []; + /** + * @internal + */ + _this._playTimes = -1; + /** + * @internal + */ + _this._timeScale = 1.0; + return _this; + } + CocosArmatureComponent_1 = CocosArmatureComponent; + CocosArmatureComponent.prototype.dbInit = function (armature) { + this._armature = armature; + }; + CocosArmatureComponent.prototype.dbClear = function () { + this._armature = null; + _super.prototype.destroy.call(this); + }; + CocosArmatureComponent.prototype.dbUpdate = function () { + var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + } + }; + CocosArmatureComponent.prototype.dispose = function (_isposeProxy) { + if (_isposeProxy === void 0) { _isposeProxy = true; } + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + CocosArmatureComponent.prototype.destroy = function () { + this.dispose(); + if (false) { // `super.destroy()` will be called in `dbClear()`. + _super.prototype.destroy.call(this); + } + return true; + }; + /** + * @private + */ + CocosArmatureComponent.prototype.dispatchDBEvent = function (type, eventObject) { + var event = new cc.Event.EventCustom(type, false); + event.setUserData(eventObject); + this.node.dispatchEvent(event); + }; + CocosArmatureComponent.prototype.hasDBEventListener = function (type) { + return this.node.hasEventListener(type, false); // creator.d.ts error. + }; + CocosArmatureComponent.prototype.addDBEventListener = function (type, listener, target) { + this.node.on(type, listener, target); + }; + CocosArmatureComponent.prototype.removeDBEventListener = function (type, listener, target) { + this.node.off(type, listener, target); + }; + Object.defineProperty(CocosArmatureComponent.prototype, "armature", { + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CocosArmatureComponent.prototype, "animation", { + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CocosArmatureComponent.prototype, "dragonBonesAsset", { + get: function () { + return this._dragonBonesAsset || null; + }, + set: function (value) { + this._dragonBonesAsset = value; + this._loadAndDisplayDragonBones(); + }, + enumerable: true, + configurable: true + }); + CocosArmatureComponent.prototype._loadAndDisplayDragonBones = function () { + console.warn("\u5F00\u59CB\u521B\u5EFA DragonBones Armature"); + var notExistAsset = !this.dragonBonesAsset + || !this.dragonBonesAsset.dragonBonesData + || !this.dragonBonesAsset.textureAtlases + || !this.dragonBonesAsset.textures; + if (notExistAsset) { + console.error("dragonBonesAsset \u4E3A\u7A7A"); + return; + } + console.warn("\u521B\u5EFA DragonBones Armature"); + this._parseDragonAsset(); + this._parseDragonAtlasAsset(); + this.display(); + }; + CocosArmatureComponent.prototype._parseDragonAsset = function () { + var dragonBonesData; + if (typeof this.dragonBonesAsset.dragonBonesData === 'string') { + console.log("JSON.parse(this.dragonBonesAsset.dragonBonesData)"); + dragonBonesData = JSON.parse(this.dragonBonesAsset.dragonBonesData); + } + else { + dragonBonesData = this.dragonBonesAsset.dragonBonesData; + } + var data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); + if (!data) { + console.warn("DragonBones Armature not exist"); + return; + } + this._armatureName = data.armatureNames[0]; + console.log("parseDragonBonesData", data); + }; + CocosArmatureComponent.prototype._parseDragonAtlasAsset = function () { + var _this = this; + var textureAtlases = this.dragonBonesAsset.textureAtlases; + if (typeof textureAtlases[0] === 'string') { + console.log('JSON.parse(this.dragonBonesAsset.textureAtlases)'); + textureAtlases = JSON.parse(textureAtlases); + } + else { + textureAtlases = this.dragonBonesAsset.textureAtlases; + } + var texture = Array.isArray(this.dragonBonesAsset.textures) ? this.dragonBonesAsset.textures[0] : this.dragonBonesAsset.textures; + if (typeof texture === 'string') { + cc.textureCache.addImage(texture, function (tex, error) { + if (error) { + console.error("error:" + error.message, error); + return; + } + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); + console.log("parseTextureAtlasData", data); + console.log("dragonBonesAsset", _this.dragonBonesAsset); + console.log("textureAtlases", textureAtlases); + console.log("texture", tex); + }, this); + } + else { + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); + console.log("string parseTextureAtlasData", data); + console.log("string dragonBonesAsset", this.dragonBonesAsset); + } + }; + CocosArmatureComponent.prototype.display = function () { + console.warn("Armature name:" + this._armatureName + ",dragonBonesName:" + this.dragonBonesName); + var armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); + if (!armatureComponent) { + console.log("armatureComponent is null"); + return; + } + armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); + armatureComponent.node.x = 0.0; + armatureComponent.node.y = 0; + this.node.addChild(armatureComponent.node); + this._dragonBonesNode = armatureComponent.node; + console.log("play animation default animation"); + }; + CocosArmatureComponent.prototype.onLoad = function () { + // this.display(); + if (this._dragonBonesNode) { + var component = this._dragonBonesNode.getComponent(CocosArmatureComponent_1); + var state = component.animation.play(component.animation.animationNames[0], 0); + if (!state) { + return; + } + console.warn("\u64AD\u653E\u52A8\u753B\uFF1A" + state.name, state); + } + else { + this._loadAndDisplayDragonBones(); + // this.onLoad(); + // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); + // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); + } + }; + var CocosArmatureComponent_1; + __decorate([ + property + ], CocosArmatureComponent.prototype, "_armatureName", void 0); + __decorate([ + property + ], CocosArmatureComponent.prototype, "_animationName", void 0); + __decorate([ + property(dragonBones.DragonBonesAsset) + ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); + __decorate([ + property({ + type: dragonBones.DragonBonesAsset, + displayName: "DragonBones", + tooltip: "DragonBones Asset", + }) + ], CocosArmatureComponent.prototype, "dragonBonesAsset", null); + __decorate([ + property({ + type: [cc.String], + displayName: "Armature", + tooltip: "The armature name.", + visible: true, + serializable: false, + }) + ], CocosArmatureComponent.prototype, "_armatureNames", void 0); + __decorate([ + property({ + type: [cc.String], + displayName: "Animation", + tooltip: "The animation name.", + visible: true, + serializable: false, + }) + ], CocosArmatureComponent.prototype, "_animationNames", void 0); + __decorate([ + property({ + type: cc.Integer, + displayName: "Play times", + tooltip: "The animation play times.", + visible: true, + slide: true, + range: [-1, 99, 1], + }) + ], CocosArmatureComponent.prototype, "_playTimes", void 0); + __decorate([ + property({ + type: cc.Float, + displayName: "TimeScale", + tooltip: "The animation play speed.", + visible: true, + slide: true, + range: [-2, 2, 0.01], + }) + ], CocosArmatureComponent.prototype, "_timeScale", void 0); + CocosArmatureComponent = CocosArmatureComponent_1 = __decorate([ + ccclass("CocosArmatureComponent"), + executeInEditMode, + disallowMultiple, + playOnFocus, + menu("DragonBones/Armature"), + executeInEditMode, + help("https://github.com/DragonBones/") + ], CocosArmatureComponent); + return CocosArmatureComponent; + }(cc.Component)); + dragonBones.CocosArmatureComponent = CocosArmatureComponent; +})(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 Cocos slot. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosSlot = /** @class */ (function (_super) { + __extends(CocosSlot, _super); + function CocosSlot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._ccMeshDirty = false; + return _this; + } + CocosSlot.toString = function () { + return "[class dragonBones.CocosSlot]"; + }; + CocosSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._textureScale = 1.0; + this._renderDisplay = null; + }; + CocosSlot.prototype._initDisplay = function (_value, _isRetain) { + }; + CocosSlot.prototype._disposeDisplay = function (value, isRelease) { + if (!isRelease) { + value.destroy(); + } + }; + CocosSlot.prototype._onUpdateDisplay = function () { + this._renderDisplay = (this._display ? this._display : this._rawDisplay); + }; + CocosSlot.prototype._addDisplay = function () { + var container = this._armature.display; + container.addChild(this._renderDisplay, this._zOrder); + }; + CocosSlot.prototype._replaceDisplay = function (value) { + var container = this._armature.display; + var prevDisplay = value; + if (this._renderDisplay.parent !== container) { + container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder()); + } + // container.removeChild(prevDisplay, false); + this._renderDisplay.active = true; + prevDisplay.active = false; + this._textureScale = 1.0; + }; + CocosSlot.prototype._removeDisplay = function () { + this._renderDisplay.parent.removeChild(this._renderDisplay, false); + }; + CocosSlot.prototype._updateZOrder = function () { + if (this._renderDisplay.getLocalZOrder() === this._zOrder) { + return; + } + this._renderDisplay.setLocalZOrder(this._zOrder); + }; + /** + * @internal + */ + CocosSlot.prototype._updateVisible = function () { + this._renderDisplay.active = this._parent.visible && this._visible; + }; + CocosSlot.prototype._updateBlendMode = function () { + var sprite = this._renderDisplay.getComponent(cc.Sprite); + if (sprite) { + switch (this._blendMode) { + case 0 /* Normal */: + break; + case 1 /* Add */: + var texture = sprite.spriteFrame.getTexture(); + var BlendFunc = cc.BlendFunc; // creator.d.ts error. + if (texture && texture.hasPremultipliedAlpha()) { + sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.ONE, BlendFunc.BlendFactor.ONE); // creator.d.ts error. + } + else { + sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.SRC_ALPHA, BlendFunc.BlendFactor.ONE); // creator.d.ts error. + } + break; + case 3 /* Darken */: + break; + case 4 /* Difference */: + break; + case 6 /* HardLight */: + break; + case 9 /* Lighten */: + break; + case 10 /* Multiply */: + break; + case 11 /* Overlay */: + break; + case 12 /* Screen */: + break; + default: + break; + } + } + else if (this._childArmature !== null) { + for (var _i = 0, _a = this._childArmature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + slot._blendMode = this._blendMode; + slot._updateBlendMode(); + } + } + }; + CocosSlot.prototype._updateColor = function () { + var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha * 255; + var color = this._renderDisplay.color; + this._renderDisplay.opacity = alpha; + color.setR(this._colorTransform.redMultiplier * 0xFF); + color.setG(this._colorTransform.greenMultiplier * 0xFF); + color.setB(this._colorTransform.blueMultiplier * 0xFF); + this._renderDisplay.setColor(color); // creator.d.ts error. + }; + CocosSlot.prototype._updateFrame = function () { + var currentTextureData = this._textureData; + var sprite = this._renderDisplay.getComponent(cc.Sprite); + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + var currentTextureAtlasData = currentTextureData.parent; + if (this._armature.replacedTexture !== null) { // Update replaced texture atlas. + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData; + } + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); + } + var renderTexture = currentTextureData.renderTexture; + if (renderTexture !== null) { + if (this._geometryData !== null) { // Mesh. + var data = this._geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; + var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; + var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; + if (vertexOffset < 0) { + vertexOffset += 65536; // Fixed out of bouds bug. + } + var uvOffset = vertexOffset + vertexCount * 2; + var scale = this._armature._armatureData.scale; + var textureAtlasSize = renderTexture.getTexture().getContentSizeInPixels(); + var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : textureAtlasSize.width; + var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : textureAtlasSize.height; + var region = currentTextureData.region; + var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); + var polygonInfo = { + triangles: { + verts: [], + indices: [] + }, + rect: boundsRect + }; + for (var i = 0, l = vertexCount * 2; i < l; i += 2) { + var vertex = { + x: floatArray[vertexOffset + i] * scale, + y: -floatArray[vertexOffset + i + 1] * scale, + u: floatArray[uvOffset + i], + v: floatArray[uvOffset + i + 1] + }; + if (currentTextureData.rotated) { + var backU = vertex.u; + vertex.u = (region.x + (1.0 - vertex.v) * region.width) / textureAtlasWidth; + vertex.v = (region.y + backU * region.height) / textureAtlasHeight; + } + else { + vertex.u = (region.x + vertex.u * region.width) / textureAtlasWidth; + vertex.v = (region.y + vertex.v * region.height) / textureAtlasHeight; + } + polygonInfo.triangles.verts[i / 2] = vertex; + if (boundsRect.x > vertex.x) { + boundsRect.x = vertex.x; + } + if (boundsRect.width < vertex.x) { + boundsRect.width = vertex.x; + } + if (boundsRect.y > vertex.y) { + boundsRect.y = vertex.y; + } + if (boundsRect.height < vertex.y) { + boundsRect.height = vertex.y; + } + } + for (var i = 0; i < triangleCount * 3; ++i) { + polygonInfo.triangles.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; + } + this._textureScale = 1.0; + sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.MESH); // creator.d.ts error. + sprite.spriteFrame = renderTexture; + sprite._sgNode.setMeshPolygonInfo(polygonInfo); // creator.d.ts error. + sprite._sgNode.setContentSize(cc.size(boundsRect.width, boundsRect.height)); // creator.d.ts error. + var isSkinned = this._geometryData.weight !== null; + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + if (isSkinned || isSurface) { + this._identityTransform(); + } + // Delay to update cocos mesh. (some cocos bug.) + this._ccMeshDirty = true; + } + else { // Normal texture. + this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; + sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. + sprite.spriteFrame = renderTexture; + sprite._sgNode.setContentSize(renderTexture.getOriginalSize()); // creator.d.ts error. + } + this._visibleDirty = true; + // this._blendModeDirty = true; + // this._colorDirty = true; + return; + } + } + this._renderDisplay.active = false; + this._renderDisplay.setPosition(0.0, 0.0); + }; + CocosSlot.prototype._updateMesh = function () { + var scale = this._armature._armatureData.scale; + var deformVertices = this._displayFrame.deformVertices; + var bones = this._geometryBones; + var geometryData = this._geometryData; + var weightData = geometryData.weight; + var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform; + var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite; + var polygonInfo = meshDisplay.getMeshPolygonInfo(); + if (!polygonInfo) { + return; + } + var verticesAndUVs = polygonInfo.triangles.verts; + var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); + if (weightData !== null) { + var data = geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; + if (weightFloatOffset < 0) { + weightFloatOffset += 65536; // Fixed out of bouds bug. + } + for (var i = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { + var boneCount = intArray[iB++]; + var xG = 0.0, yG = 0.0; + for (var j = 0; j < boneCount; ++j) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var xL = floatArray[iV++] * scale; + var yL = floatArray[iV++] * scale; + if (hasDeform) { + xL += deformVertices[iF++]; + yL += deformVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + var vertex = verticesAndUVs[i]; + vertex.x = xG; + vertex.y = yG; + if (boundsRect.x > xG) { + boundsRect.x = xG; + } + if (boundsRect.width < xG) { + boundsRect.width = xG; + } + if (boundsRect.y > yG) { + boundsRect.y = yG; + } + if (boundsRect.height < yG) { + boundsRect.height = yG; + } + } + } + else { + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + var data = geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; + if (vertexOffset < 0) { + vertexOffset += 65536; // Fixed out of bouds bug. + } + for (var i = 0, l = vertexCount * 2; i < l; i += 2) { + var iH = i / 2; // int. + var x = floatArray[vertexOffset + i] * scale; + var y = floatArray[vertexOffset + i + 1] * scale; + if (hasDeform) { + x += deformVertices[i]; + y += deformVertices[i + 1]; + } + var vertex = verticesAndUVs[iH]; + if (isSurface) { + var matrix = this._parent._getGlobalTransformMatrix(x, y); + vertex.x = matrix.a * x + matrix.c * y + matrix.tx; + vertex.y = matrix.b * x + matrix.d * y + matrix.ty; + // + x = vertex.x; + y = vertex.y; + } + else { + vertex.x = x; + y = vertex.y = -y; + } + if (boundsRect.x > x) { + boundsRect.x = x; + } + if (boundsRect.width < x) { + boundsRect.width = x; + } + if (boundsRect.y > y) { + boundsRect.y = y; + } + if (boundsRect.height < y) { + boundsRect.height = y; + } + } + } + boundsRect.width -= boundsRect.x; + boundsRect.height -= boundsRect.y; + polygonInfo.rect = boundsRect; + meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height)); + meshDisplay.setMeshPolygonInfo(polygonInfo); + if (weightData !== null) { + this._identityTransform(); + } + else { + var transform = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); + this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); + this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; + this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; + this._renderDisplay.scaleX = transform.scaleX * this._textureScale; + this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; + } + if (this._ccMeshDirty) { + this._ccMeshDirty = false; + this._verticesDirty = true; + } + }; + CocosSlot.prototype._updateTransform = function () { + // const globalTransformMatrix = this.globalTransformMatrix; + // const helpMatrix = TransformObject._helpMatrix; + // helpMatrix.a = globalTransformMatrix.a; + // helpMatrix.b = globalTransformMatrix.b; + // helpMatrix.c = -globalTransformMatrix.c; + // helpMatrix.d = -globalTransformMatrix.d; + // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + // helpMatrix.tx = globalTransformMatrix.tx - (globalTransformMatrix.a * this._pivotX + globalTransformMatrix.c * this._pivotY); + // helpMatrix.ty = (globalTransformMatrix.ty - (globalTransformMatrix.b * this._pivotX + globalTransformMatrix.d * this._pivotY)); + // } + // else { + // helpMatrix.tx = globalTransformMatrix.tx; + // helpMatrix.ty = globalTransformMatrix.ty; + // } + // (this._renderDisplay as any)._sgNode._renderCmd.setNodeToParentTransform(helpMatrix); // creator.d.ts error. + this.updateGlobalTransform(); + var transform = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); + this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); + } + else { + this._renderDisplay.x = transform.x; + this._renderDisplay.y = transform.y; + } + this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; + this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; + this._renderDisplay.scaleX = transform.scaleX * this._textureScale; + this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; + }; + CocosSlot.prototype._identityTransform = function () { + // const helpMatrix = TransformObject._helpMatrix; + // helpMatrix.a = 1.0; + // helpMatrix.b = 0.0; + // helpMatrix.c = -0.0; + // helpMatrix.d = -1.0; + // helpMatrix.tx = 0.0; + // helpMatrix.ty = 0.0; + // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix); + this._renderDisplay.x = 0.0; + this._renderDisplay.y = 0.0; + this._renderDisplay.rotationX = 0.0; + this._renderDisplay.rotationY = 0.0; + this._renderDisplay.scaleX = 1.0; + this._renderDisplay.scaleY = 1.0; + }; + return CocosSlot; + }(dragonBones.Slot)); + dragonBones.CocosSlot = CocosSlot; +})(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) { + var ccclass = cc._decorator.ccclass; + var ClockHandler = /** @class */ (function (_super) { + __extends(ClockHandler, _super); + function ClockHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ClockHandler.prototype.update = function (passedTime) { + CocosFactory.factory.dragonBones.advanceTime(passedTime); + }; + ClockHandler = __decorate([ + ccclass + ], ClockHandler); + return ClockHandler; + }(cc.Component)); + /** + * - The Cocos factory. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosFactory = /** @class */ (function (_super) { + __extends(CocosFactory, _super); + function CocosFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + var _this = _super.call(this, dataParser) || this; + _this._node = null; + _this._armatureNode = null; + if (!CC_EDITOR) { // Is playing. + if (_this._node === null) { + var nodeName = "DragonBones Node"; + _this._node = cc.find(nodeName); + if (_this._node === null) { + _this._node = new cc.Node(nodeName); + cc.game.addPersistRootNode(_this._node); + } + } + if (!_this._node.getComponent(ClockHandler)) { + _this._node.addComponent(ClockHandler); + } + var eventManager = _this._node.getComponent(dragonBones.CocosArmatureComponent) || _this._node.addComponent(dragonBones.CocosArmatureComponent); + if (CocosFactory._dragonBonesInstance === null) { + CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); + // + dragonBones.DragonBones.yDown = false; + } + } + else { + if (CocosFactory._dragonBonesInstance === null) { + CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(null); + // + dragonBones.DragonBones.yDown = false; + } + } + _this._dragonBones = CocosFactory._dragonBonesInstance; + return _this; + } + Object.defineProperty(CocosFactory, "factory", { + /** + * - A global factory instance that can be used directly. + * @version DragonBones 4.7 + * @language en_US + */ + /** + * - 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + if (this._factory === null) { + this._factory = new CocosFactory(); + } + return this._factory; + }, + enumerable: true, + configurable: true + }); + CocosFactory.prototype._isSupportMesh = function () { + if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { // creator.d.ts error. + console.warn("Only webgl mode can support mesh."); + return false; + } + return true; + }; + CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); + } + return textureAtlasData; + }; + CocosFactory.prototype._buildArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplay = this._armatureNode === null ? new cc.Node(dataPackage.armature.name) : this._armatureNode; + var armatureComponent = armatureDisplay.getComponent(dragonBones.CocosArmatureComponent) || armatureDisplay.addComponent(dragonBones.CocosArmatureComponent); + armatureDisplay.setOpacityModifyRGB(false); + armatureDisplay.setCascadeOpacityEnabled(true); + armatureDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. + this._armatureNode = null; + armatureComponent._armature = armature; + armature.init(dataPackage.armature, armatureComponent, armatureDisplay, this._dragonBones); + return armature; + }; + CocosFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { + var childDisplayName = slot.slotData.name + " (" + displayData.path.replace("/", "_") + ")"; // + var proxy = slot.armature.proxy; + var childNode = cc.find(childDisplayName, proxy.node); + var childArmature = null; + if (!childNode) { + if (dataPackage !== null) { + childArmature = this.buildArmature(displayData.path, dataPackage.dataName); + } + else { + childArmature = this.buildArmature(displayData.path, displayData.parent.parent.parent.name); + } + } + else { + var childArmatureComponent = childNode.getComponent(dragonBones.CocosArmatureComponent) || null; + if (childArmatureComponent === null) { + if (dataPackage !== null) { + childArmatureComponent = this.buildArmatureComponent(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage.textureAtlasName, childNode); + } + else { + childArmatureComponent = this.buildArmatureComponent(displayData.path, "", "", "", childNode); + } + } + if (childArmatureComponent !== null) { + childArmature = childArmatureComponent.armature; + } + } + if (childArmature === null) { + return null; + } + var childArmatureDisplay = childArmature.display; + childArmatureDisplay.name = childDisplayName; + if (childArmatureDisplay.parent !== proxy.node) { + proxy.node.addChild(childArmatureDisplay, slot._zOrder); + } + childArmatureDisplay.active = false; + return childArmature; + }; + CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.CocosSlot); + var armatureDisplay = armature.display; + var rawSlotDisplay = cc.find(slotData.name, armatureDisplay) || new cc.Node(slotData.name); + rawSlotDisplay.addComponent(cc.Sprite); + rawSlotDisplay.setAnchorPoint(0.0, 0.0); + rawSlotDisplay.setOpacityModifyRGB(false); + rawSlotDisplay.setCascadeOpacityEnabled(true); + rawSlotDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. + slot.init(slotData, armature, rawSlotDisplay, rawSlotDisplay); + return slot; + }; + /** + * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. + * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. + * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature component. + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 + * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 + * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架组件。 + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language zh_CN + */ + CocosFactory.prototype.buildArmatureComponent = function (armatureName, dragonBonesName, skinName, textureAtlasName, node) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + if (skinName === void 0) { skinName = ""; } + if (textureAtlasName === void 0) { textureAtlasName = ""; } + if (node === void 0) { node = null; } + this._armatureNode = node; + var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.proxy; + } + return null; + }; + /** + * - Create the display object with the specified texture. + * @param textureName - The texture data name. + * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建带有指定贴图的显示对象。 + * @param textureName - 贴图数据名称。 + * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { + if (textureAtlasName === void 0) { textureAtlasName = null; } + var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); + if (textureData !== null && textureData.renderTexture !== null) { + var texture = textureData.renderTexture; + var sprite = new cc.Sprite(); + sprite.spriteFrame = texture; + return sprite; + } + return null; + }; + Object.defineProperty(CocosFactory.prototype, "soundEventManager", { + /** + * - A global sound event manager. + * Sound events can be listened to uniformly from the manager. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 全局声音事件管理器。 + * 声音事件可以从该管理器统一侦听。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._dragonBones.eventManager.node; + }, + enumerable: true, + configurable: true + }); + CocosFactory._dragonBonesInstance = null; + CocosFactory._factory = null; + return CocosFactory; + }(dragonBones.BaseFactory)); + dragonBones.CocosFactory = CocosFactory; +})(dragonBones || (dragonBones = {})); diff --git a/Cocos/1.x/out/dragonBones.min.js b/Cocos/1.x/out/dragonBones.min.js index 3257a318..9ed499d9 100755 --- a/Cocos/1.x/out/dragonBones.min.js +++ b/Cocos/1.x/out/dragonBones.min.js @@ -1 +1 @@ -"use strict";var __extends=this&&this.__extends||function(){var r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var a in e)if(e.hasOwnProperty(a))t[a]=e[a]};return function(t,e){r(t,e);function a(){this.constructor=t}t.prototype=e===null?Object.create(e):(a.prototype=e.prototype,new a)}}();var __decorate=this&&this.__decorate||function(t,e,a,r){var i=arguments.length,n=i<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,a):r,s;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")n=Reflect.decorate(t,e,a,r);else for(var o=t.length-1;o>=0;o--)if(s=t[o])n=(i<3?s(n):i>3?s(e,a,n):s(e,a))||n;return i>3&&n&&Object.defineProperty(e,a,n),n};var dragonBones;(function(o){var t=function(){function e(t){this._clock=new o.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=t;console.info("YuPeng DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}e.prototype.advanceTime=function(t){if(this._objects.length>0){for(var e=0,a=this._objects;e0){for(var i=0;ie){r.length=e}n._maxCountMap[a]=e}else{n._defaultMaxCount=e;for(var a in n._poolsMap){var r=n._poolsMap[a];if(r.length>e){r.length=e}if(a in n._maxCountMap){n._maxCountMap[a]=e}}}};n.clearPool=function(t){if(t===void 0){t=null}if(t!==null){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in n._poolsMap){var a=n._poolsMap[r];a.length=0}}};n.borrowObject=function(t){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var i=new t;i._onClear();return i};n.prototype.returnToPool=function(){this._onClear();n._returnObject(this)};n._hashCode=0;n._defaultMaxCount=3e3;n._maxCountMap={};n._poolsMap={};return n}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=1}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=a;this.d=r;this.tx=i;this.ty=n}t.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};t.prototype.copyFrom=function(t){this.a=t.a;this.b=t.b;this.c=t.c;this.d=t.d;this.tx=t.tx;this.ty=t.ty;return this};t.prototype.copyFromArray=function(t,e){if(e===void 0){e=0}this.a=t[e];this.b=t[e+1];this.c=t[e+2];this.d=t[e+3];this.tx=t[e+4];this.ty=t[e+5];return this};t.prototype.identity=function(){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this};t.prototype.concat=function(t){var e=this.a*t.a;var a=0;var r=0;var i=this.d*t.d;var n=this.tx*t.a+t.tx;var s=this.ty*t.d+t.ty;if(this.b!==0||this.c!==0){e+=this.b*t.c;a+=this.b*t.d;r+=this.c*t.a;i+=this.c*t.b}if(t.b!==0||t.c!==0){a+=this.a*t.b;r+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=a;this.c=r;this.d=i;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var a=this.c;var r=this.d;var i=this.tx;var n=this.ty;if(e===0&&a===0){this.b=this.c=0;if(t===0||r===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;r=this.d=1/r;this.tx=-t*i;this.ty=-r*n}return this}var s=t*r-e*a;if(s===0){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this}s=1/s;var o=this.a=r*s;e=this.b=-e*s;a=this.c=-a*s;r=this.d=t*s;this.tx=-(o*i+a*n);this.ty=-(e*i+r*n);return this};t.prototype.transformPoint=function(t,e,a,r){if(r===void 0){r=false}a.x=this.a*t+this.c*e;a.y=this.b*t+this.d*e;if(!r){a.x+=this.tx;a.y+=this.ty}};t.prototype.transformRectangle=function(t,e){if(e===void 0){e=false}var a=this.a;var r=this.b;var i=this.c;var n=this.d;var s=e?0:this.tx;var o=e?0:this.ty;var l=t.x;var h=t.y;var u=l+t.width;var f=h+t.height;var _=a*l+i*h+s;var m=r*l+n*h+o;var c=a*u+i*h+s;var p=r*u+n*h+o;var d=a*u+i*f+s;var y=r*u+n*f+o;var v=a*l+i*f+s;var g=r*l+n*f+o;var D=0;if(_>c){D=_;_=c;c=D}if(d>v){D=d;d=v;v=D}t.x=Math.floor(_v?c:v)-t.x);if(m>p){D=m;m=p;p=D}if(y>g){D=y;y=g;g=D}t.y=Math.floor(mg?p:g)-t.y)};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function n(t,e,a,r,i,n){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}if(i===void 0){i=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=a;this.rotation=r;this.scaleX=i;this.scaleY=n}n.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};n.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY};n.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.skew=t.skew;this.rotation=t.rotation;this.scaleX=t.scaleX;this.scaleY=t.scaleY;return this};n.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};n.prototype.add=function(t){this.x+=t.x;this.y+=t.y;this.skew+=t.skew;this.rotation+=t.rotation;this.scaleX*=t.scaleX;this.scaleY*=t.scaleY;return this};n.prototype.minus=function(t){this.x-=t.x;this.y-=t.y;this.skew-=t.skew;this.rotation-=t.rotation;this.scaleX/=t.scaleX;this.scaleY/=t.scaleY;return this};n.prototype.fromMatrix=function(t){var e=this.scaleX,a=this.scaleY;var r=n.PI_Q;this.x=t.tx;this.y=t.ty;this.rotation=Math.atan(t.b/t.a);var i=Math.atan(-t.c/t.d);this.scaleX=this.rotation>-r&&this.rotation-r&&i=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;i=i-Math.PI}this.skew=i-this.rotation;return this};n.prototype.toMatrix=function(t){if(this.rotation===0){t.a=1;t.b=0}else{t.a=Math.cos(this.rotation);t.b=Math.sin(this.rotation)}if(this.skew===0){t.c=-t.b;t.d=t.a}else{t.c=-Math.sin(this.skew+this.rotation);t.d=Math.cos(this.skew+this.rotation)}if(this.scaleX!==1){t.a*=this.scaleX;t.b*=this.scaleX}if(this.scaleY!==1){t.c*=this.scaleY;t.d*=this.scaleY}t.tx=this.x;t.ty=this.y;return this};n.PI=Math.PI;n.PI_D=Math.PI*2;n.PI_H=Math.PI/2;n.PI_Q=Math.PI/4;n.RAD_DEG=180/Math.PI;n.DEG_RAD=Math.PI/180;return n}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(a===void 0){a=1}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}if(s===void 0){s=0}if(o===void 0){o=0}this.alphaMultiplier=t;this.redMultiplier=e;this.greenMultiplier=a;this.blueMultiplier=r;this.alphaOffset=i;this.redOffset=n;this.greenOffset=s;this.blueOffset=o}t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier;this.redMultiplier=t.redMultiplier;this.greenMultiplier=t.greenMultiplier;this.blueMultiplier=t.blueMultiplier;this.alphaOffset=t.alphaOffset;this.redOffset=t.redOffset;this.greenOffset=t.greenOffset;this.blueOffset=t.blueOffset};t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1;this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0};return t}();t.ColorTransform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e){if(t===void 0){t=0}if(e===void 0){e=0}this.x=t;this.y=e}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y};t.prototype.clear=function(){this.x=this.y=0};return t}();t.Point=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}this.x=t;this.y=e;this.width=a;this.height=r}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.width=t.width;this.height=t.height};t.prototype.clear=function(){this.x=this.y=0;this.width=this.height=0};return t}();t.Rectangle=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.ints=[];t.floats=[];t.strings=[];return t}t.toString=function(){return"[class dragonBones.UserData]"};t.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};t.prototype.addInt=function(t){this.ints.push(t)};t.prototype.addFloat=function(t){this.floats.push(t)};t.prototype.addString=function(t){this.strings.push(t)};t.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){a=0}if(this.sortedBones.indexOf(i)>=0){continue}var n=false;for(var s in this.constraints){var o=this.constraints[s];if(o.root===i&&this.sortedBones.indexOf(o.target)<0){n=true;break}}if(n){continue}if(i.parent!==null&&this.sortedBones.indexOf(i.parent)<0){continue}this.sortedBones.push(i);r++}};t.prototype.cacheFrames=function(t){if(this.cacheFrameRate>0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};t.prototype.setCacheFrame=function(t,e){var a=this.parent.cachedFrames;var r=a.length;a.length+=10;a[r]=t.a;a[r+1]=t.b;a[r+2]=t.c;a[r+3]=t.d;a[r+4]=t.tx;a[r+5]=t.ty;a[r+6]=e.rotation;a[r+7]=e.skew;a[r+8]=e.scaleX;a[r+9]=e.scaleY;return r};t.prototype.getCacheFrame=function(t,e,a){var r=this.parent.cachedFrames;t.a=r[a];t.b=r[a+1];t.c=r[a+2];t.d=r[a+3];t.tx=r[a+4];t.ty=r[a+5];e.rotation=r[a+6];e.skew=r[a+7];e.scaleX=r[a+8];e.scaleY=r[a+9];e.x=t.tx;e.y=t.ty};t.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t;this.sortedBones.push(t)};t.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t;this.sortedSlots.push(t)};t.prototype.addConstraint=function(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t};t.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this;this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}if(t.name==="default"){this.defaultSkin=t}};t.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};t.prototype.addAction=function(t,e){if(e){this.defaultActions.push(t)}else{this.actions.push(t)}};t.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};t.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};t.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null};t.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};t.prototype.getMesh=function(t,e,a){var r=this.getSkin(t);if(r===null){return null}return r.getDisplay(e,a)};t.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return t}(a.BaseObject);a.ArmatureData=t;var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.transform=new a.Transform;t.userData=null;return t}t.toString=function(){return"[class dragonBones.BoneData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.inheritTranslation=false;this.inheritRotation=false;this.inheritScale=false;this.inheritReflection=false;this.type=0;this.length=0;this.alpha=1;this.name="";this.transform.identity();this.userData=null;this.parent=null};return t}(a.BaseObject);a.BoneData=e;var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.geometry=new a.GeometryData;return t}t.toString=function(){return"[class dragonBones.SurfaceData]"};t.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=1;this.segmentX=0;this.segmentY=0;this.geometry.clear()};return t}(e);a.SurfaceData=r;var i=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.color=null;t.userData=null;return t}t.createColor=function(){return new a.ColorTransform};t.toString=function(){return"[class dragonBones.SlotData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.blendMode=0;this.displayIndex=0;this.zOrder=0;this.zIndex=0;this.alpha=1;this.name="";this.color=null;this.userData=null;this.parent=null};t.DEFAULT_COLOR=new a.ColorTransform;return t}(a.BaseObject);a.SlotData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.CanvasData]"};e.prototype._onClear=function(){this.hasBackground=false;this.color=0;this.x=0;this.y=0;this.width=0;this.height=0};return e}(t.BaseObject);t.CanvasData=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.displays={};return t}t.toString=function(){return"[class dragonBones.SkinData]"};t.prototype._onClear=function(){for(var t in this.displays){var e=this.displays[t];for(var a=0,r=e;ai){s|=2}if(en){s|=8}return s};D.rectangleIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=t>i&&tn&&ei&&an&&r=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){return true}}return false};D.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=this.width*.5;var l=this.height*.5;var h=D.rectangleIntersectsSegment(t,e,a,r,-o,-l,o,l,i,n,s);return h};return D}(e);t.RectangleBoundingBoxData=h;var a=function(t){__extends(l,t);function l(){return t!==null&&t.apply(this,arguments)||this}l.toString=function(){return"[class dragonBones.EllipseData]"};l.ellipseIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=s/o;var _=f*f;e*=f;r*=f;var m=a-t;var c=r-e;var p=Math.sqrt(m*m+c*c);var d=m/p;var y=c/p;var v=(i-t)*d+(n-e)*y;var g=v*v;var D=t*t+e*e;var T=s*s;var b=T-D+g;var A=0;if(b>=0){var S=Math.sqrt(b);var P=v-S;var O=v+S;var x=P<0?-1:P<=p?0:1;var B=O<0?-1:O<=p?0:1;var E=x*B;if(E<0){return-1}else if(E===0){if(x===-1){A=2;a=t+O*d;r=(e+O*y)/f;if(l!==null){l.x=a;l.y=r}if(h!==null){h.x=a;h.y=r}if(u!==null){u.x=Math.atan2(r/T*_,a/T);u.y=u.x+Math.PI}}else if(B===1){A=1;t=t+P*d;e=(e+P*y)/f;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(u!==null){u.x=Math.atan2(e/T*_,t/T);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+P*d;l.y=(e+P*y)/f;if(u!==null){u.x=Math.atan2(l.y/T*_,l.x/T)}}if(h!==null){h.x=t+O*d;h.y=(e+O*y)/f;if(u!==null){u.y=Math.atan2(h.y/T*_,h.x/T)}}}}}return A};l.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};l.prototype.containsPoint=function(t,e){var a=this.width*.5;if(t>=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){e*=a/r;return Math.sqrt(t*t+e*e)<=a}}return false};l.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=l.ellipseIntersectsSegment(t,e,a,r,0,0,this.width*.5,this.height*.5,i,n,s);return o};return l}(e);t.EllipseBoundingBoxData=a;var r=function(e){__extends(l,e);function l(){var t=e!==null&&e.apply(this,arguments)||this;t.vertices=[];return t}l.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};l.polygonIntersectsSegment=function(t,e,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(t===a){t=a+1e-6}if(e===r){e=r+1e-6}var l=i.length;var h=t-a;var u=e-r;var f=t*r-e*a;var _=0;var m=i[l-2];var c=i[l-1];var p=0;var d=0;var y=0;var v=0;var g=0;var D=0;for(var T=0;T=m&&B<=b||B>=b&&B<=m)&&(h===0||B>=t&&B<=a||B>=a&&B<=t)){var E=(f*P-u*O)/x;if((E>=c&&E<=A||E>=A&&E<=c)&&(u===0||E>=e&&E<=r||E>=r&&E<=e)){if(s!==null){var M=B-t;if(M<0){M=-M}if(_===0){p=M;d=M;y=B;v=E;g=B;D=E;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}}else{if(Md){d=M;g=B;D=E;if(o!==null){o.y=Math.atan2(A-c,b-m)-Math.PI*.5}}}_++}else{y=B;v=E;g=B;D=E;_++;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}break}}}m=b;c=A}if(_===1){if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=y;s.y=v}if(o!==null){o.y=o.x+Math.PI}}else if(_>1){_++;if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=g;s.y=D}}return _};l.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=2;this.x=0;this.y=0;this.vertices.length=0};l.prototype.containsPoint=function(t,e){var a=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var r=0,i=this.vertices.length,n=i-2;r=e||s=e){var l=this.vertices[n];var h=this.vertices[r];if((e-o)*(l-h)/(s-o)+h0){return}this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var a=0,r=this.cacheFrames.length;ae._zIndex*1e3+e._zOrder?1:-1};y.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=n){continue}var o=a[s];var l=this.getSlot(o.name);if(l!==null){l._setZOrder(i)}}this._slotsDirty=true;this._zOrderDirty=!r}};y.prototype._addBone=function(t){if(this._bones.indexOf(t)<0){this._bones.push(t)}};y.prototype._addSlot=function(t){if(this._slots.indexOf(t)<0){this._slots.push(t)}};y.prototype._addConstraint=function(t){if(this._constraints.indexOf(t)<0){this._constraints.push(t)}};y.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};y.prototype.dispose=function(){if(this._armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};y.prototype.init=function(t,e,a,r){if(this._armatureData!==null){return}this._armatureData=t;this._animation=i.BaseObject.borrowObject(i.Animation);this._proxy=e;this._display=a;this._dragonBones=r;this._proxy.dbInit(this);this._animation.init(this);this._animation.animations=this._armatureData.animations};y.prototype.advanceTime=function(t){if(this._lockUpdate){return}this._lockUpdate=true;if(this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");return}var e=this._cacheFrameIndex;this._animation.advanceTime(t);if(this._slotsDirty||this._zIndexDirty){this._slots.sort(y._onSortSlots);if(this._zIndexDirty){for(var a=0,r=this._slots.length;a0){for(var u=0,f=this._actions;u0){var a=this.getBone(t);if(a!==null){a.invalidUpdate();if(e){for(var r=0,i=this._slots;r0){if(i!==null||n!==null){if(i!==null){var b=o?i.y-e:i.x-t;if(b<0){b=-b}if(d===null||bh){h=b;_=n.x;m=n.y;y=D;if(s!==null){p=s.y}}}}else{d=D;break}}}if(d!==null&&i!==null){i.x=u;i.y=f;if(s!==null){s.x=c}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=p}}return d};y.prototype.getBone=function(t){for(var e=0,a=this._bones;e=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(o)}if(o&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};t.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};t.prototype.invalidUpdate=function(){this._transformDirty=true};t.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};Object.defineProperty(t.prototype,"boneData",{get:function(){return this._boneData},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;for(var e=0,a=this._armature.getSlots();e=a){return this.globalTransformMatrix}i=e>this._kX*(t+a)+p;m=((s*o+s+o+o+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=_*(l+2);var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[2]-(o-_)*g;var b=this._hullCache[3]-(o-_)*D;var A=this._vertices;if(i){this._getAffineTransform(-a,p+u,r-a,u,A[v+l+2],A[v+l+3],T+g,b+D,A[v],A[v+1],S._helpTransform,y,true)}else{this._getAffineTransform(-r,p,r-a,u,T,b,A[v],A[v+1],T+g,b+D,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(t>=a){if(e<-a||e>=a){return this.globalTransformMatrix}i=e>this._kX*(t-r)+p;m=((s*o+s+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=(_+1)*(l+2)-2;var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[0]+_*g;var b=this._hullCache[1]+_*D;var A=this._vertices;if(i){this._getAffineTransform(r,p+u,r-a,u,T+g,b+D,A[v+l+2],A[v+l+3],T,b,S._helpTransform,y,true)}else{this._getAffineTransform(a,p,r-a,u,A[v],A[v+1],T,b,A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e<-a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)-r;m=((s*o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[8]+f*g;var b=this._hullCache[9]+f*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,-a,h,r-a,A[v+2],A[v+3],A[v],A[v+1],T+g,b+D,S._helpTransform,y,true)}else{this._getAffineTransform(c,-r,h,r-a,T,b,T+g,b+D,A[v],A[v+1],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e>=a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)+a;m=((s*o+s+o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=o*(l+2)+f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[6]-(s-f)*g;var b=this._hullCache[7]-(s-f)*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,r,h,r-a,T+g,b+D,T,b,A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,a,h,r-a,A[v],A[v+1],A[v+2],A[v+3],T,b,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else{i=e>this._k*(t-c-h)+p;m=((s*_+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2+_*(l+2);var A=this._vertices;if(i){this._getAffineTransform(c+h,p+u,h,u,A[v+l+4],A[v+l+5],A[v+l+2],A[v+l+3],A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,p,h,u,A[v],A[v+1],A[v+2],A[v+3],A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}return y};S.prototype.init=function(t,e){if(this._boneData!==null){return}l.prototype.init.call(this,t,e);var a=t.segmentX;var r=t.segmentY;var i=this._armature.armatureData.parent.intArray[t.geometry.offset+0];var n=1e3;var s=200;this._dX=s*2/a;this._dY=s*2/r;this._k=-this._dY/this._dX;this._kX=-this._dY/(n-s);this._kY=-(n-s)/this._dX;this._vertices.length=i*2;this._deformVertices.length=i*2;this._matrixCahce.length=(a*r+a*2+r*2)*2*7;this._hullCache.length=10;for(var o=0;o=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(h)}if(h&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}var u=1e3;var f=200;var _=2*this.global.x;var m=2*this.global.y;var c=S._helpPoint;this.globalTransformMatrix.transformPoint(u,-f,c);this._hullCache[0]=c.x;this._hullCache[1]=c.y;this._hullCache[2]=_-c.x;this._hullCache[3]=m-c.y;this.globalTransformMatrix.transformPoint(0,this._dY,c,true);this._hullCache[4]=c.x;this._hullCache[5]=c.y;this.globalTransformMatrix.transformPoint(f,u,c);this._hullCache[6]=c.x;this._hullCache[7]=c.y;this._hullCache[8]=_-c.x;this._hullCache[9]=m-c.y;this.globalTransformMatrix.transformPoint(this._dX,0,c,true);this._hullCache[10]=c.x;this._hullCache[11]=c.y}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};return S}(t.Bone);t.Surface=e})(dragonBones||(dragonBones={}));var dragonBones;(function(p){var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.deformVertices=[];return t}t.toString=function(){return"[class dragonBones.DisplayFrame]"};t.prototype._onClear=function(){this.rawDisplayData=null;this.displayData=null;this.textureData=null;this.display=null;this.deformVertices.length=0};t.prototype.updateDeformVertices=function(){if(this.rawDisplayData===null||this.deformVertices.length!==0){return}var t;if(this.rawDisplayData.type===2){t=this.rawDisplayData.geometry}else if(this.rawDisplayData.type===4){t=this.rawDisplayData.geometry}else{return}var e=0;if(t.weight!==null){e=t.weight.count*2}else{e=t.data.intArray[t.offset+0]*2}this.deformVertices.length=e;for(var a=0,r=this.deformVertices.length;a=0&&this._displayIndex0){for(var s=0,o=i;s=0&&this._cachedFrameIndices!==null){var r=this._cachedFrameIndices[t];if(r>=0&&this._cachedFrameIndex===r){this._transformDirty=false}else if(r>=0){this._transformDirty=true;this._cachedFrameIndex=r}else if(this._transformDirty||this._parent._childrenTransformDirty){this._transformDirty=true;this._cachedFrameIndex=-1}else if(this._cachedFrameIndex>=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}else if(this._transformDirty||this._parent._childrenTransformDirty){t=-1;this._transformDirty=true;this._cachedFrameIndex=-1}if(this._transformDirty){if(this._cachedFrameIndex<0){var i=t>=0;this._updateGlobalTransformMatrix(i);if(i&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}this._updateTransform();this._transformDirty=false}};c.prototype.invalidUpdate=function(){this._displayDataDirty=true;this._displayDirty=true;this._transformDirty=true};c.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._updateGlobalTransformMatrix(false);this._transformDirty=false}};c.prototype.replaceRawDisplayData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.rawDisplayData!==t){a.deformVertices.length=0;a.rawDisplayData=t;if(a.rawDisplayData===null){var r=this._armature._armatureData.defaultSkin;if(r!==null){var i=r.getDisplays(this._slotData.name);if(i!==null&&e=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.displayData!==t&&a.rawDisplayData!==t){a.displayData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceTextureData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.textureData!==t){a.textureData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceDisplay=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.display!==t){var r=a.display;a.display=t;if(r!==null&&r!==this._rawDisplay&&r!==this._meshDisplay&&!this._hasDisplay(r)){if(r instanceof p.Armature){}else{this._disposeDisplay(r,true)}}if(t!==null&&t!==this._rawDisplay&&t!==this._meshDisplay&&!this._hasDisplay(r)&&!(t instanceof p.Armature)){this._initDisplay(t,true)}if(e===this._displayIndex){this._displayDirty=true}}};c.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);return this._boundingBoxData.containsPoint(c._helpPoint.x,c._helpPoint.y)};c.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);t=c._helpPoint.x;e=c._helpPoint.y;c._helpMatrix.transformPoint(a,r,c._helpPoint);a=c._helpPoint.x;r=c._helpPoint.y;var o=this._boundingBoxData.intersectsSegment(t,e,a,r,i,n,s);if(o>0){if(o===1||o===2){if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i);if(n!==null){n.x=i.x;n.y=i.y}}else if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}else{if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i)}if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}if(s!==null){this.globalTransformMatrix.transformPoint(Math.cos(s.x),Math.sin(s.x),c._helpPoint,true);s.x=Math.atan2(c._helpPoint.y,c._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(s.y),Math.sin(s.y),c._helpPoint,true);s.y=Math.atan2(c._helpPoint.y,c._helpPoint.x)}}return o};c.prototype.getDisplayFrameAt=function(t){return this._displayFrames[t]};Object.defineProperty(c.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;this._updateVisible()},enumerable:true,configurable:true});Object.defineProperty(c.prototype,"displayFrameCount",{get:function(){return this._displayFrames.length},set:function(t){var e=this._displayFrames.length;if(et){for(var a=e-1;ad){continue}var b=0;for(;;D++){var A=y[D];if(p>A){continue}if(D===0){b=p/A}else{var S=y[D-1];b=(p-S)/(A-S)}break}if(D!==c){c=D;if(u&&D===m){this._computeVertices(_-4,4,0,f);this._computeVertices(0,4,4,f)}else{this._computeVertices(D*6+2,8,0,f)}}this.addCurvePosition(b,f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],l,g,a)}return}if(u){_+=2;f.length=o;this._computeVertices(2,_-4,0,f);this._computeVertices(0,2,_-4,f);f[_-2]=f[0];f[_-1]=f[1]}else{m--;_-=4;f.length=_;this._computeVertices(2,_,0,f)}var P=new Array(m);d=0;var O=f[0],x=f[1],B=0,E=0,M=0,I=0,C=0,F=0;var w,N,R,j,k,L,V,Y;for(var v=0,U=2;vd){continue}for(;;D++){var W=P[D];if(H>W)continue;if(D===0)H/=W;else{var K=P[D-1];H=(H-K)/(W-K)}break}if(D!==c){c=D;var Z=D*6;O=f[Z];x=f[Z+1];B=f[Z+2];E=f[Z+3];M=f[Z+4];I=f[Z+5];C=f[Z+6];F=f[Z+7];w=(O-B*2+M)*.03;N=(x-E*2+I)*.03;R=((B-M)*3-O+C)*.006;j=((E-I)*3-x+F)*.006;k=w*2+R;L=N*2+j;V=(B-O)*.3+w+R*.16666667;Y=(E-x)*.3+N+j*.16666667;G=Math.sqrt(V*V+Y*Y);X[0]=G;for(Z=1;Z<8;Z++){V+=k;Y+=L;k+=R;L+=j;G+=Math.sqrt(V*V+Y*Y);X[Z]=G}V+=k;Y+=L;G+=Math.sqrt(V*V+Y*Y);X[8]=G;V+=k+R;Y+=L+j;G+=Math.sqrt(V*V+Y*Y);X[9]=G;z=0}H*=G;for(;;z++){var q=X[z];if(H>q)continue;if(z===0)H/=q;else{var K=X[z-1];H=z+(H-K)/(q-K)}break}this.addCurvePosition(H*.1,O,x,B,E,M,I,C,F,l,g,a)}};t.prototype.addCurvePosition=function(t,e,a,r,i,n,s,o,l,h,u,f){if(t===0){h[u]=e;h[u+1]=a;h[u+2]=0;return}if(t===1){h[u]=o;h[u+1]=l;h[u+2]=0;return}var _=1-t;var m=_*_;var c=t*t;var p=m*_;var d=m*t*3;var y=_*c*3;var v=t*c;var g=p*e+d*r+y*n+v*o;var D=p*a+d*i+y*s+v*l;h[u]=g;h[u+1]=D;if(f){h[u+2]=Math.atan2(D-(p*a+d*i+y*s),g-(p*e+d*r+y*n))}else{h[u+2]=0}};t.prototype.init=function(t,e){this._constraintData=t;this._armature=e;var a=t;this.pathOffset=a.pathDisplayData.geometry.offset;this.position=a.position;this.spacing=a.spacing;this.rotateOffset=a.rotateOffset;this.rotateMix=a.rotateMix;this.translateMix=a.translateMix;this._root=this._armature.getBone(a.root.name);this._target=this._armature.getBone(a.target.name);this._pathSlot=this._armature.getSlot(a.pathSlot.name);for(var r=0,i=a.bones.length;r0?U.Transform.DEG_RAD:-U.Transform.DEG_RAD}}var x=this.rotateMix;var B=this.translateMix;for(var c=0,E=3;c0){var w=v.a,N=v.b,R=v.c,j=v.d,k=void 0,L=void 0,V=void 0;if(h){k=b[E-1]}else{k=Math.atan2(I,M)}k-=Math.atan2(N,w);if(O){L=Math.cos(k);V=Math.sin(k);var Y=d._boneData.length;S+=(Y*(L*w-V*N)-M)*x;P+=(Y*(V*w+L*N)-I)*x}else{k+=A}if(k>U.Transform.PI){k-=U.Transform.PI_D}else if(k<-U.Transform.PI){k+=U.Transform.PI_D}k*=x;L=Math.cos(k);V=Math.sin(k);v.a=L*w-V*N;v.b=V*w+L*N;v.c=L*R-V*j;v.d=V*R+L*j}d.global.fromMatrix(v)}this.dirty=false};t.prototype.invalidUpdate=function(){};return t}(t);U.PathConstraint=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t){if(t===void 0){t=0}this.time=0;this.timeScale=1;this._systemTime=0;this._animatebles=[];this._clock=null;this.time=t;this._systemTime=(new Date).getTime()*.001}t.prototype.advanceTime=function(t){if(t!==t){t=0}var e=Date.now()*.001;if(t<0){t=e-this._systemTime}this._systemTime=e;if(this.timeScale!==1){t*=this.timeScale}if(t===0){return}if(t<0){this.time-=t}else{this.time+=t}var a=0,r=0,i=this._animatebles.length;for(;a0){this._animatebles[a-r]=n;this._animatebles[a]=null}n.advanceTime(t)}else{r++}}if(r>0){i=this._animatebles.length;for(;a=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&n._subFadeState>0){this._armature._dragonBones.bufferObject(n);this._animationStates.length=0;this._lastAnimationState=null}else{var s=n.animationData;var o=s.cacheFrameRate;if(this._animationDirty&&o>0){this._animationDirty=false;for(var l=0,h=this._armature.getBones();l0){var c=m.getDisplayFrameAt(0).rawDisplayData;if(c!==null&&c.parent===this._armature.armatureData.defaultSkin){m._cachedFrameIndices=s.getSlotCachedFrameIndices(m.name);continue}}m._cachedFrameIndices=null}}n.advanceTime(t,o)}}else if(i>1){for(var p=0,d=0;p0&&n._subFadeState>0){d++;this._armature._dragonBones.bufferObject(n);this._animationDirty=true;if(this._lastAnimationState===n){this._lastAnimationState=null}}else{if(d>0){this._animationStates[p-d]=n}n.advanceTime(t,0)}if(p===i-1&&d>0){this._animationStates.length-=d;if(this._lastAnimationState===null&&this._animationStates.length>0){this._lastAnimationState=this._animationStates[this._animationStates.length-1]}}}this._armature._cacheFrameIndex=-1}else{this._armature._cacheFrameIndex=-1}};t.prototype.reset=function(){for(var t=0,e=this._animationStates;t0){if(t.position<0){t.position%=a.duration;t.position=a.duration-t.position}else if(t.position===a.duration){t.position-=1e-6}else if(t.position>a.duration){t.position%=a.duration}if(t.duration>0&&t.position+t.duration>a.duration){t.duration=a.duration-t.position}if(t.playTimes<0){t.playTimes=a.playTimes}}else{t.playTimes=1;t.position=0;if(t.duration>0){t.duration=0}}if(t.duration===0){t.duration=-1}this._fadeOut(t);var s=g.BaseObject.borrowObject(g.AnimationState);s.init(this._armature,a,t);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var o=false;for(var l=0,h=this._animationStates.length;lthis._animationStates[l].layer){o=true;this._animationStates.splice(l,0,s);break}else if(l!==h-1&&s.layer>this._animationStates[l+1].layer){o=true;this._animationStates.splice(l+1,0,s);break}}if(!o){this._animationStates.push(s)}}else{this._animationStates.push(s)}for(var u=0,f=this._armature.getSlots();u0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var a=this._armature.armatureData.defaultAnimation;if(a!==null){this._animationConfig.animation=a.name;this.playConfig(this._animationConfig)}}else if(!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted){this._lastAnimationState.play()}else{this._animationConfig.animation=this._lastAnimationState.name;this.playConfig(this._animationConfig)}return this._lastAnimationState};t.prototype.fadeIn=function(t,e,a,r,i,n){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(i===void 0){i=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=i!==null?i:"";return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByTime=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByFrame=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.frameCount>0?r.duration*e/r.frameCount:0}return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByProgress=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};t.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByTime(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByFrame(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByProgress(t,e,1);if(a!==null){a.stop()}return a};t.prototype.getBlendState=function(t,e,a){if(!(t in this._blendStates)){this._blendStates[t]={}}var r=this._blendStates[t];if(!(e in r)){var i=r[e]=g.BaseObject.borrowObject(g.BlendState);i.target=a}return r[e]};t.prototype.getState=function(t,e){if(e===void 0){e=-1}var a=this._animationStates.length;while(a--){var r=this._animationStates[a];if(r.name===t&&(e<0||r.layer===e)){return r}}return null};t.prototype.hasAnimation=function(t){return t in this._animations};t.prototype.getStates=function(){return this._animationStates};Object.defineProperty(t.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations===t){return}this._animationNames.length=0;for(var e in this._animations){delete this._animations[e]}for(var e in t){this._animationNames.push(e);this._animations[e]=t[e]}},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});return t}(g.BaseObject);g.Animation=t})(dragonBones||(dragonBones={}));var dragonBones;(function(L){var t=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t._boneMask=[];t._boneTimelines=[];t._boneBlendTimelines=[];t._slotTimelines=[];t._slotBlendTimelines=[];t._constraintTimelines=[];t._animationTimelines=[];t._poseTimelines=[];t._actionTimeline=null;t._zOrderTimeline=null;return t}t.toString=function(){return"[class dragonBones.AnimationState]"};t.prototype._onClear=function(){for(var t=0,e=this._boneTimelines;t=0){this._boneTimelines.splice(v,1);r.returnToPool()}v=this._boneBlendTimelines.indexOf(r);if(v>=0){this._boneBlendTimelines.splice(v,1);r.returnToPool()}}}}{var g={};var D=[];for(var T=0,b=this._slotTimelines;T=0){this._slotTimelines.splice(v,1);r.returnToPool()}v=this._slotBlendTimelines.indexOf(r);if(v>=0){this._slotBlendTimelines.splice(v,1);r.returnToPool()}}}}};t.prototype._advanceFadeTime=function(t){var e=this._fadeState>0;if(this._subFadeState<0){this._subFadeState=0;var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT:L.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}if(t<0){t=-t}this._fadeTime+=t;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=e?0:1}else if(this._fadeTime>0){this._fadeProgress=e?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=e?1:0}if(this._subFadeState>0){if(!e){this._playheadState|=1;this._fadeState=0}var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT_COMPLETE:L.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}};t.prototype.init=function(t,e,a){if(this._armature!==null){return}this._armature=t;this._animationData=e;this.resetToPose=a.resetToPose;this.additive=a.additive;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.blendType=e.blendType;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;this._weight=a.weight;if(a.pauseFadeIn){this._playheadState=2}else{this._playheadState=3}if(a.duration<0){this._position=0;this._duration=this._animationData.duration;if(a.position!==0){if(this.timeScale>=0){this._time=a.position}else{this._time=a.position-this._duration}}else{this._time=0}}else{this._position=a.position;this._duration=a.duration;this._time=0}if(this.timeScale<0&&this._time===0){this._time=-1e-6}if(this.fadeTotalTime<=0){this._fadeProgress=.999999}if(a.boneMask.length>0){this._boneMask.length=a.boneMask.length;for(var r=0,i=this._boneMask.length;r0;var i=true;var n=true;var s=this._time;this._weightResult=this._weight*this._fadeProgress;if(this._parent!==null){this._weightResult*=this._parent._weightResult}if(this._actionTimeline.playState<=0){this._actionTimeline.update(s)}if(this._weight===0){return}if(r){var o=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0){this._zOrderTimeline.update(s)}if(r){var l=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===l){i=false;n=false}else{this._armature._cacheFrameIndex=l;if(this._animationData.cachedFrames[l]){n=false}else{this._animationData.cachedFrames[l]=true}}}if(i){var h=false;var u=null;if(n){for(var f=0,_=this._boneTimelines.length;f<_;++f){var m=this._boneTimelines[f];if(m.playState<=0){m.update(s)}if(m.target!==u){var c=m.target;h=c.update(this);u=c;if(c.dirty===1){var p=c.target.animationPose;p.x=0;p.y=0;p.rotation=0;p.skew=0;p.scaleX=1;p.scaleY=1}}if(h){m.blend(a)}}}for(var f=0,_=this._boneBlendTimelines.length;f<_;++f){var m=this._boneBlendTimelines[f];if(m.playState<=0){m.update(s)}if(m.target.update(this)){m.blend(a)}}if(this.displayControl){for(var f=0,_=this._slotTimelines.length;f<_;++f){var m=this._slotTimelines[f];if(m.playState<=0){var d=m.target;var y=d.displayController;if(y===null||y===this.name||y===this.group){m.update(s)}}}}for(var f=0,_=this._slotBlendTimelines.length;f<_;++f){var m=this._slotBlendTimelines[f];if(m.playState<=0){var c=m.target;m.update(s);if(c.update(this)){m.blend(a)}}}for(var f=0,_=this._constraintTimelines.length;f<_;++f){var m=this._constraintTimelines[f];if(m.playState<=0){m.update(s)}}if(this._animationTimelines.length>0){var v=100;var g=100;var D=null;var T=null;for(var f=0,_=this._animationTimelines.length;f<_;++f){var m=this._animationTimelines[f];if(m.playState<=0){m.update(s)}if(this.blendType===1){var b=m.target;var A=this.parameterX-b.positionX;if(A>=0){if(A0){this._subFadeState=0;if(this._poseTimelines.length>0){for(var S=0,P=this._poseTimelines;S=0){this._boneTimelines.splice(O,1);m.returnToPool();continue}O=this._boneBlendTimelines.indexOf(m);if(O>=0){this._boneBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._slotTimelines.indexOf(m);if(O>=0){this._slotTimelines.splice(O,1);m.returnToPool();continue}O=this._slotBlendTimelines.indexOf(m);if(O>=0){this._slotBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._constraintTimelines.indexOf(m);if(O>=0){this._constraintTimelines.splice(O,1);m.returnToPool();continue}}this._poseTimelines.length=0}}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};t.prototype.play=function(){this._playheadState=3};t.prototype.stop=function(){this._playheadState&=1};t.prototype.fadeOut=function(t,e){if(e===void 0){e=true}if(t<0){t=0}if(e){this._playheadState&=2}if(this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime){return}}else{this._fadeState=1;this._subFadeState=-1;if(t<=0||this._fadeProgress<=0){this._fadeProgress=1e-6}for(var a=0,r=this._boneTimelines;a1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};t.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};t.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var a=this._armature.getBone(t);if(a===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var r=0,i=this._armature.getBones();r=0){this._boneMask.splice(a,1)}if(e){var r=this._armature.getBone(t);if(r!==null){var i=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=i;n=0&&r.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=i;h0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if(t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&this._parent===null){t=this._duration-1e-6}if(this._time===t){return}this._time=t;this._actionTimeline.setCurrentTime(this._time);if(this._zOrderTimeline!==null){this._zOrderTimeline.playState=-1}for(var a=0,r=this._boneTimelines;a0){if(this.leftWeight>0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight){this.dirty++;this.layer=e;this.leftWeight=0;this.blendWeight=0;return false}this.layer=e;this.leftWeight-=this.layerWeight;this.layerWeight=0}a*=this.leftWeight;this.dirty++;this.blendWeight=a;this.layerWeight+=this.blendWeight;return true}return false}this.dirty++;this.layer=e;this.leftWeight=1;this.blendWeight=a;this.layerWeight=a;return true};e.prototype.reset=function(){this.dirty=0;this.layer=0;this.leftWeight=0;this.layerWeight=0;this.blendWeight=0};e.BONE_TRANSFORM="boneTransform";e.BONE_ALPHA="boneAlpha";e.SURFACE="surface";e.SLOT_DEFORM="slotDeform";e.SLOT_ALPHA="slotAlpha";e.SLOT_Z_INDEX="slotZIndex";return e}(L.BaseObject);L.BlendState=V})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){this.dirty=false;this.playState=-1;this.currentPlayTimes=-1;this.currentTime=-1;this.target=null;this._isTween=false;this._valueOffset=0;this._frameValueOffset=0;this._frameOffset=0;this._frameRate=0;this._frameCount=0;this._frameIndex=-1;this._frameRateR=0;this._position=0;this._duration=0;this._timeScale=1;this._timeOffset=0;this._animationData=null;this._timelineData=null;this._armature=null;this._animationState=null;this._actionTimeline=null;this._frameArray=null;this._valueArray=null;this._timelineArray=null;this._frameIndices=null};e.prototype._setCurrentTime=function(t){var e=this.playState;var a=this.currentPlayTimes;var r=this.currentTime;if(this._actionTimeline!==null&&this._frameCount<=1){this.playState=this._actionTimeline.playState>=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var i=this._animationState.playTimes;var n=i*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(i>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=i;if(t<0){this.currentTime=0}else{this.currentTime=this.playState===1?this._duration+1e-6:this._duration}}else{if(this.playState!==0&&this._animationState._playheadState===3){this.playState=0}if(t<0){t=-t;this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=this._duration-t%this._duration}else{this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=t%this._duration}}this.currentTime+=this._position}else{this.playState=this._actionTimeline.playState;this.currentPlayTimes=this._actionTimeline.currentPlayTimes;this.currentTime=this._actionTimeline.currentTime}if(this.currentPlayTimes===a&&this.currentTime===r){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==a){this._frameIndex=-1}return true};e.prototype.init=function(t,e,a){this._armature=t;this._animationState=e;this._timelineData=a;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._animationData=this._animationState.animationData;this._frameRate=this._animationData.parent.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;if(this._timelineData!==null){var r=this._animationData.parent.parent;this._frameArray=r.frameArray;this._timelineArray=r.timelineArray;this._frameIndices=r.frameIndices;this._frameCount=this._timelineArray[this._timelineData.offset+2];this._frameValueOffset=this._timelineArray[this._timelineData.offset+4];this._timeScale=100/this._timelineArray[this._timelineData.offset+0];this._timeOffset=this._timelineArray[this._timelineData.offset+1]*.01}};e.prototype.fadeOut=function(){this.dirty=false};e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var a=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==a){this._frameIndex=a;this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex];this._onArriveAtFrame()}}else if(this._frameIndex<0){this._frameIndex=0;if(this._timelineData!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]}this._onArriveAtFrame()}if(this._isTween||this.dirty){this._onUpdateFrame()}}};e.prototype.blend=function(t){};return e}(t.BaseObject);t.TimelineState=e;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,a){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI));break}return(r-e)*a+e};e._getEasingCurveValue=function(t,e,a,r){if(t<=0){return 0}else if(t>=1){return 1}var i=a>0;var n=a+1;var s=Math.floor(t*n);var o=0;var l=0;if(i){o=s===0?0:e[r+s-1];l=s===n-1?1e4:e[r+s]}else{o=e[r+s-1];l=e[r+s]}return(o+(l-o)*(t*n-s))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenEasing=0;this._tweenProgress=0;this._valueScale=1};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){this._frameDurationR=1/e}else{this._frameDurationR=0}}}else{this.dirty=true;this._isTween=false}};e.prototype._onUpdateFrame=function(){if(this._isTween){this.dirty=true;this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR;if(this._tweenType===2){this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3)}else if(this._tweenType!==1){this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)}}};return e}(e);t.TweenTimelineState=a;var r=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._current=0;this._difference=0;this._result=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+1;if(t===1){this._current=e[a];this._difference=e[r]-this._current}else{this._current=e[a]*t;this._difference=e[r]*t-this._current}}else{this._result=e[a]*t}}else{this._result=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._result=this._current+this._difference*this._tweenProgress}};return t}(a);t.SingleValueTimelineState=r;var i=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._currentA=0;this._currentB=0;this._differenceA=0;this._differenceB=0;this._resultA=0;this._resultB=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex*2;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+2;if(t===1){this._currentA=e[a];this._currentB=e[a+1];this._differenceA=e[r]-this._currentA;this._differenceB=e[r+1]-this._currentB}else{this._currentA=e[a]*t;this._currentB=e[a+1]*t;this._differenceA=e[r]*t-this._currentA;this._differenceB=e[r+1]*t-this._currentB}}else{this._resultA=e[a]*t;this._resultB=e[a+1]*t}}else{this._resultA=0;this._resultB=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._resultA=this._currentA+this._differenceA*this._tweenProgress;this._resultB=this._currentB+this._differenceB*this._tweenProgress}};return t}(a);t.DoubleValueTimelineState=i;var n=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._rd=[];return t}t.prototype._onClear=function(){o.prototype._onClear.call(this);this._valueCount=0;this._rd.length=0};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);var t=this._valueCount;var e=this._rd;if(this._timelineData!==null){var a=this._valueScale;var r=this._valueArray;var i=this._valueOffset+this._frameValueOffset+this._frameIndex*t;if(this._isTween){var n=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:i+t;if(a===1){for(var s=0;s0){if(n.hasDBEventListener(y.EventObject.COMPLETE)){h=y.BaseObject.borrowObject(y.EventObject);h.type=y.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var u=this._timelineData;var f=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[u.frameIndicesOffset+f];if(this._frameIndex!==_){var m=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[u.offset+5+this._frameIndex];if(o){if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(m)}if(l!==null&&m===0){this._armature._dragonBones.bufferEvent(l);l=null}if(m>0){m--}else{m=this._frameCount-1}if(m===_){break}}}else{if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this.currentPlayTimes===a){if(r<=d){if(m>0){m--}else{m=this._frameCount-1}}else if(m===_){m=-1}}}while(m>=0){if(m=0){var t=this._frameArray[this._frameOffset+1];if(t>0){this._armature._sortZOrder(this._frameArray,this._frameOffset+2)}else{this._armature._sortZOrder(null,0)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.ZOrderTimelineState=e;var a=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])}if(this._timelineData===null){this._rd[4]=1;this._rd[5]=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=6;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])};t.prototype.blend=function(t){var e=this._armature.armatureData.scale;var a=this._rd;var r=this.target;var i=r.target;var n=r.blendWeight;var s=i.animationPose;if(r.dirty>1){s.x+=a[0]*n*e;s.y+=a[1]*n*e;s.rotation+=a[2]*n;s.skew+=a[3]*n;s.scaleX+=(a[4]-1)*n;s.scaleY+=(a[5]-1)*n}else{s.x=a[0]*n*e;s.y=a[1]*n*e;s.rotation=a[2]*n;s.skew=a[3]*n;s.scaleX=(a[4]-1)*n+1;s.scaleY=(a[5]-1)*n+1}if(t||this.dirty){this.dirty=false;i._transformDirty=true}};return t}(y.MutilpleValueTimelineState);y.BoneAllTimelineState=a;var r=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.x+=this._resultA*r;i.y+=this._resultB*r}else if(r!==1){i.x=this._resultA*r;i.y=this._resultB*r}else{i.x=this._resultA;i.y=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneTranslateTimelineState=r;var i=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._differenceA=y.Transform.normalizeRadian(this._differenceA);this._differenceB=y.Transform.normalizeRadian(this._differenceB)}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._resultA=y.Transform.normalizeRadian(this._resultA);this._resultB=y.Transform.normalizeRadian(this._resultB)};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.rotation+=this._resultA*r;i.skew+=this._resultB*r}else if(r!==1){i.rotation=this._resultA*r;i.skew=this._resultB*r}else{i.rotation=this._resultA;i.skew=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneRotateTimelineState=i;var n=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){this._resultA=1;this._resultB=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.scaleX+=(this._resultA-1)*r;i.scaleY+=(this._resultB-1)*r}else if(r!==1){i.scaleX=(this._resultA-1)*r+1;i.scaleY=(this._resultB-1)*r+1}else{i.scaleX=this._resultA;i.scaleY=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneScaleTimelineState=n;var s=function(s){__extends(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SurfaceTimelineState]"};t.prototype._onClear=function(){s.prototype._onClear.call(this);this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){s.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.parent.parent;var i=r.frameIntArray;var n=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=i[n+2];this._deformCount=i[n+1];this._deformOffset=i[n+3];this._sameValueOffset=i[n+4]+this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=r.frameFloatArray;this._rd.length=this._valueCount*2}else{this._deformCount=this.target.target._deformVertices.length}};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a._deformVertices;var n=this._valueArray;if(n!==null){var s=this._valueCount;var o=this._deformOffset;var l=this._sameValueOffset;var h=this._rd;for(var u=0;u1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u1){a._alpha+=this._result*r;if(a._alpha>1){a._alpha=1}}else{a._alpha=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._alphaDirty=true}};return t}(y.SingleValueTimelineState);y.AlphaTimelineState=o;var l=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDisplayTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this.target;var e=this._timelineData!==null?this._frameArray[this._frameOffset+1]:t._slotData.displayIndex;if(t.displayIndex!==e){t._setDisplayIndex(e,true)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.SlotDisplayTimelineState=l;var h=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._current=[0,0,0,0,0,0,0,0];t._difference=[0,0,0,0,0,0,0,0];t._result=[0,0,0,0,0,0,0,0];return t}t.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._animationData.parent.parent;var e=t.colorArray;var a=t.frameIntArray;var r=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex;var i=a[r];if(i<0){i+=65536}if(this._isTween){this._current[0]=e[i++];this._current[1]=e[i++];this._current[2]=e[i++];this._current[3]=e[i++];this._current[4]=e[i++];this._current[5]=e[i++];this._current[6]=e[i++];this._current[7]=e[i++];if(this._frameIndex===this._frameCount-1){i=a[this._animationData.frameIntOffset+this._frameValueOffset]}else{i=a[r+1]}if(i<0){i+=65536}this._difference[0]=e[i++]-this._current[0];this._difference[1]=e[i++]-this._current[1];this._difference[2]=e[i++]-this._current[2];this._difference[3]=e[i++]-this._current[3];this._difference[4]=e[i++]-this._current[4];this._difference[5]=e[i++]-this._current[5];this._difference[6]=e[i++]-this._current[6];this._difference[7]=e[i++]-this._current[7]}else{this._result[0]=e[i++]*.01;this._result[1]=e[i++]*.01;this._result[2]=e[i++]*.01;this._result[3]=e[i++]*.01;this._result[4]=e[i++];this._result[5]=e[i++];this._result[6]=e[i++];this._result[7]=e[i++]}}else{var n=this.target;var s=n.slotData.color;this._result[0]=s.alphaMultiplier;this._result[1]=s.redMultiplier;this._result[2]=s.greenMultiplier;this._result[3]=s.blueMultiplier;this._result[4]=s.alphaOffset;this._result[5]=s.redOffset;this._result[6]=s.greenOffset;this._result[7]=s.blueOffset}};t.prototype._onUpdateFrame=function(){o.prototype._onUpdateFrame.call(this);if(this._isTween){this._result[0]=(this._current[0]+this._difference[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._difference[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._difference[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._difference[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._difference[4]*this._tweenProgress;this._result[5]=this._current[5]+this._difference[5]*this._tweenProgress;this._result[6]=this._current[6]+this._difference[6]*this._tweenProgress;this._result[7]=this._current[7]+this._difference[7]*this._tweenProgress}};t.prototype.fadeOut=function(){this._isTween=false};t.prototype.update=function(t){o.prototype.update.call(this,t);if(this._isTween||this.dirty){var e=this.target;var a=e._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);a.alphaMultiplier+=(this._result[0]-a.alphaMultiplier)*r;a.redMultiplier+=(this._result[1]-a.redMultiplier)*r;a.greenMultiplier+=(this._result[2]-a.greenMultiplier)*r;a.blueMultiplier+=(this._result[3]-a.blueMultiplier)*r;a.alphaOffset+=(this._result[4]-a.alphaOffset)*r;a.redOffset+=(this._result[5]-a.redOffset)*r;a.greenOffset+=(this._result[6]-a.greenOffset)*r;a.blueOffset+=(this._result[7]-a.blueOffset)*r;e._colorDirty=true}}else if(this.dirty){this.dirty=false;if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){a.alphaMultiplier=this._result[0];a.redMultiplier=this._result[1];a.greenMultiplier=this._result[2];a.blueMultiplier=this._result[3];a.alphaOffset=this._result[4];a.redOffset=this._result[5];a.greenOffset=this._result[6];a.blueOffset=this._result[7];e._colorDirty=true}}}};return t}(y.TweenTimelineState);y.SlotColorTimelineState=h;var u=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SlotZIndexTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){var t=this.target;var e=t.target;this._result=e.slotData.zIndex}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueArray=this._animationData.parent.parent.frameIntArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;if(e.dirty>1){a._zIndex+=this._result*r}else{a._zIndex=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._zIndexDirty=true}};return t}(y.SingleValueTimelineState);y.SlotZIndexTimelineState=u;var f=function(f){__extends(t,f);function t(){return f!==null&&f.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.DeformTimelineState]"};t.prototype._onClear=function(){f.prototype._onClear.call(this);this.geometryOffset=0;this.displayFrame=null;this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){f.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];var i=this._animationData.parent.parent;var n=i.frameIntArray;var s=this.target.target;this.geometryOffset=n[r+0];if(this.geometryOffset<0){this.geometryOffset+=65536}for(var o=0,l=s.displayFrameCount;o1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u0;t._weight=this._currentB}else{var e=t._constraintData;t._bendPositive=e.bendPositive;t._weight=e.weight}t.invalidUpdate();this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=.01;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.IKConstraintTimelineState=_;var m=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationProgressTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.currentTime=this._result*t.totalTime}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationProgressTimelineState=m;var c=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationWeightTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.weight=this._result}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationWeightTimelineState=c;var p=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationParametersTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.parameterX=this._resultA;t.parameterY=this._resultB}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.AnimationParametersTimelineState=p})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}r.actionDataToInstance=function(t,e,a){if(t.type===0){e.type=r.FRAME_EVENT}else{e.type=t.type===10?r.FRAME_EVENT:r.SOUND_EVENT}e.name=t.name;e.armature=a;e.actionData=t;e.data=t.data;if(t.bone!==null){e.bone=a.getBone(t.bone.name)}if(t.slot!==null){e.slot=a.getSlot(t.slot.name)}};r.toString=function(){return"[class dragonBones.EventObject]"};r.prototype._onClear=function(){this.time=0;this.type="";this.name="";this.armature=null;this.bone=null;this.slot=null;this.animationState=null;this.actionData=null;this.data=null};r.START="start";r.LOOP_COMPLETE="loopComplete";r.COMPLETE="complete";r.FADE_IN="fadeIn";r.FADE_IN_COMPLETE="fadeInComplete";r.FADE_OUT="fadeOut";r.FADE_OUT_COMPLETE="fadeOutComplete";r.FRAME_EVENT="frameEvent";r.SOUND_EVENT="soundEvent";return r}(t.BaseObject);t.EventObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(){}t._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}};t._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}};t._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}};t._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}};t._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}};t._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}};t._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}};t._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}};t._getAnimationBlendType=function(t){switch(t.toLowerCase()){case"none":return 0;case"1d":return 1;default:return 0}};t._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}};t.DATA_VERSION_2_3="2.3";t.DATA_VERSION_3_0="3.0";t.DATA_VERSION_4_0="4.0";t.DATA_VERSION_4_5="4.5";t.DATA_VERSION_5_0="5.0";t.DATA_VERSION_5_5="5.5";t.DATA_VERSION_5_6="5.6";t.DATA_VERSION=t.DATA_VERSION_5_6;t.DATA_VERSIONS=[t.DATA_VERSION_4_0,t.DATA_VERSION_4_5,t.DATA_VERSION_5_0,t.DATA_VERSION_5_5,t.DATA_VERSION_5_6];t.TEXTURE_ATLAS="textureAtlas";t.SUB_TEXTURE="SubTexture";t.FORMAT="format";t.IMAGE_PATH="imagePath";t.WIDTH="width";t.HEIGHT="height";t.ROTATED="rotated";t.FRAME_X="frameX";t.FRAME_Y="frameY";t.FRAME_WIDTH="frameWidth";t.FRAME_HEIGHT="frameHeight";t.DRADON_BONES="dragonBones";t.USER_DATA="userData";t.ARMATURE="armature";t.CANVAS="canvas";t.BONE="bone";t.SURFACE="surface";t.SLOT="slot";t.CONSTRAINT="constraint";t.SKIN="skin";t.DISPLAY="display";t.FRAME="frame";t.IK="ik";t.PATH_CONSTRAINT="path";t.ANIMATION="animation";t.TIMELINE="timeline";t.FFD="ffd";t.TRANSLATE_FRAME="translateFrame";t.ROTATE_FRAME="rotateFrame";t.SCALE_FRAME="scaleFrame";t.DISPLAY_FRAME="displayFrame";t.COLOR_FRAME="colorFrame";t.DEFAULT_ACTIONS="defaultActions";t.ACTIONS="actions";t.EVENTS="events";t.INTS="ints";t.FLOATS="floats";t.STRINGS="strings";t.TRANSFORM="transform";t.PIVOT="pivot";t.AABB="aabb";t.COLOR="color";t.VERSION="version";t.COMPATIBLE_VERSION="compatibleVersion";t.FRAME_RATE="frameRate";t.TYPE="type";t.SUB_TYPE="subType";t.NAME="name";t.PARENT="parent";t.TARGET="target";t.STAGE="stage";t.SHARE="share";t.PATH="path";t.LENGTH="length";t.DISPLAY_INDEX="displayIndex";t.Z_ORDER="zOrder";t.Z_INDEX="zIndex";t.BLEND_MODE="blendMode";t.INHERIT_TRANSLATION="inheritTranslation";t.INHERIT_ROTATION="inheritRotation";t.INHERIT_SCALE="inheritScale";t.INHERIT_REFLECTION="inheritReflection";t.INHERIT_ANIMATION="inheritAnimation";t.INHERIT_DEFORM="inheritDeform";t.SEGMENT_X="segmentX";t.SEGMENT_Y="segmentY";t.BEND_POSITIVE="bendPositive";t.CHAIN="chain";t.WEIGHT="weight";t.BLEND_TYPE="blendType";t.FADE_IN_TIME="fadeInTime";t.PLAY_TIMES="playTimes";t.SCALE="scale";t.OFFSET="offset";t.POSITION="position";t.DURATION="duration";t.TWEEN_EASING="tweenEasing";t.TWEEN_ROTATE="tweenRotate";t.TWEEN_SCALE="tweenScale";t.CLOCK_WISE="clockwise";t.CURVE="curve";t.SOUND="sound";t.EVENT="event";t.ACTION="action";t.X="x";t.Y="y";t.SKEW_X="skX";t.SKEW_Y="skY";t.SCALE_X="scX";t.SCALE_Y="scY";t.VALUE="value";t.ROTATE="rotate";t.SKEW="skew";t.ALPHA="alpha";t.ALPHA_OFFSET="aO";t.RED_OFFSET="rO";t.GREEN_OFFSET="gO";t.BLUE_OFFSET="bO";t.ALPHA_MULTIPLIER="aM";t.RED_MULTIPLIER="rM";t.GREEN_MULTIPLIER="gM";t.BLUE_MULTIPLIER="bM";t.UVS="uvs";t.VERTICES="vertices";t.TRIANGLES="triangles";t.WEIGHTS="weights";t.SLOT_POSE="slotPose";t.BONE_POSE="bonePose";t.BONES="bones";t.POSITION_MODE="positionMode";t.SPACING_MODE="spacingMode";t.ROTATE_MODE="rotateMode";t.SPACING="spacing";t.ROTATE_OFFSET="rotateOffset";t.ROTATE_MIX="rotateMix";t.TRANSLATE_MIX="translateMix";t.TARGET_DISPLAY="targetDisplay";t.CLOSED="closed";t.CONSTANT_SPEED="constantSpeed";t.VERTEX_COUNT="vertexCount";t.LENGTHS="lengths";t.GOTO_AND_PLAY="gotoAndPlay";t.DEFAULT_NAME="default";return t}();t.DataParser=e})(dragonBones||(dragonBones={}));var dragonBones;(function(tt){var t=function(e){__extends($,e);function $(){var t=e!==null&&e.apply(this,arguments)||this;t._rawTextureAtlasIndex=0;t._rawBones=[];t._data=null;t._armature=null;t._bone=null;t._geometry=null;t._slot=null;t._skin=null;t._mesh=null;t._animation=null;t._timeline=null;t._rawTextureAtlases=null;t._frameValueType=0;t._defaultColorOffset=-1;t._prevClockwise=0;t._prevRotation=0;t._frameDefaultValue=0;t._frameValueScale=1;t._helpMatrixA=new tt.Matrix;t._helpMatrixB=new tt.Matrix;t._helpTransform=new tt.Transform;t._helpColorTransform=new tt.ColorTransform;t._helpPoint=new tt.Point;t._helpArray=[];t._intArray=[];t._floatArray=[];t._frameIntArray=[];t._frameFloatArray=[];t._frameArray=[];t._timelineArray=[];t._colorArray=[];t._cacheRawMeshes=[];t._cacheMeshes=[];t._actionFrames=[];t._weightSlotPose={};t._weightBonePoses={};t._cacheBones={};t._slotChildActions={};return t}$._getBoolean=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="boolean"){return r}else if(i==="string"){switch(r){case"0":case"NaN":case"":case"false":case"null":case"undefined":return false;default:return true}}else{return!!r}}return a};$._getNumber=function(t,e,a){if(e in t){var r=t[e];if(r===null||r==="NaN"){return a}return+r||0}return a};$._getString=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="string"){return r}return String(r)}return a};$.prototype._getCurvePoint=function(t,e,a,r,i,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var m=u*f;var c=3*l*f;var p=3*u*_;var d=l*_;h.x=m*t+c*a+p*i+d*s;h.y=m*e+c*r+p*n+d*o};$.prototype._samplingEasingCurve=function(t,e){var a=t.length;if(a%3===1){var r=-2;for(var i=0,n=e.length;i=0&&r+61e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return true}else{var r=0;for(var i=0,n=e.length;i1e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return false}};$.prototype._parseActionDataInFrame=function(t,e,a,r){if(tt.DataParser.EVENT in t){this._mergeActionFrame(t[tt.DataParser.EVENT],e,10,a,r)}if(tt.DataParser.SOUND in t){this._mergeActionFrame(t[tt.DataParser.SOUND],e,11,a,r)}if(tt.DataParser.ACTION in t){this._mergeActionFrame(t[tt.DataParser.ACTION],e,0,a,r)}if(tt.DataParser.EVENTS in t){this._mergeActionFrame(t[tt.DataParser.EVENTS],e,10,a,r)}if(tt.DataParser.ACTIONS in t){this._mergeActionFrame(t[tt.DataParser.ACTIONS],e,0,a,r)}};$.prototype._mergeActionFrame=function(t,e,a,r,i){var n=this._armature.actions.length;var s=this._parseActionData(t,a,r,i);var o=0;var l=null;for(var h=0,u=s;he){break}o++}if(l===null){l=new D;l.frameStart=e;this._actionFrames.splice(o,0,l)}for(var p=0;p0){var _=a.getBone(u);if(_!==null){f.parent=_}else{if(!(u in this._cacheBones)){this._cacheBones[u]=[]}this._cacheBones[u].push(f)}}if(f.name in this._cacheBones){for(var m=0,c=this._cacheBones[f.name];m0&&e.parent!==null){i.root=e.parent;i.bone=e}else{i.root=e;i.bone=null}return i};$.prototype._parsePathConstraint=function(t){var e=this._armature.getSlot($._getString(t,tt.DataParser.TARGET,""));if(e===null){return null}var a=this._armature.defaultSkin;if(a===null){return null}var r=a.getDisplay(e.name,$._getString(t,tt.DataParser.TARGET_DISPLAY,e.name));if(r===null||!(r instanceof tt.PathDisplayData)){return null}var i=t[tt.DataParser.BONES];if(i===null||i.length===0){return null}var n=tt.BaseObject.borrowObject(tt.PathConstraintData);n.name=$._getString(t,tt.DataParser.NAME,"");n.type=1;n.pathSlot=e;n.pathDisplayData=r;n.target=e.parent;n.positionMode=tt.DataParser._getPositionMode($._getString(t,tt.DataParser.POSITION_MODE,""));n.spacingMode=tt.DataParser._getSpacingMode($._getString(t,tt.DataParser.SPACING_MODE,""));n.rotateMode=tt.DataParser._getRotateMode($._getString(t,tt.DataParser.ROTATE_MODE,""));n.position=$._getNumber(t,tt.DataParser.POSITION,0);n.spacing=$._getNumber(t,tt.DataParser.SPACING,0);n.rotateOffset=$._getNumber(t,tt.DataParser.ROTATE_OFFSET,0);n.rotateMix=$._getNumber(t,tt.DataParser.ROTATE_MIX,1);n.translateMix=$._getNumber(t,tt.DataParser.TRANSLATE_MIX,1);for(var s=0,o=i;s0?a:e;this._parsePivot(t,n);break}case 1:{var s=i=tt.BaseObject.borrowObject(tt.ArmatureDisplayData);s.name=e;s.path=a.length>0?a:e;s.inheritAnimation=true;if(tt.DataParser.ACTIONS in t){var o=this._parseActionData(t[tt.DataParser.ACTIONS],0,null,null);for(var l=0,h=o;l0?a:e;if(tt.DataParser.SHARE in t){c.geometry.data=this._data;this._cacheRawMeshes.push(t);this._cacheMeshes.push(c)}else{this._parseMesh(t,c)}break}case 3:{var p=this._parseBoundingBox(t);if(p!==null){var d=i=tt.BaseObject.borrowObject(tt.BoundingBoxDisplayData);d.name=e;d.path=a.length>0?a:e;d.boundingBox=p}break}case 4:{var y=t[tt.DataParser.LENGTHS];var v=i=tt.BaseObject.borrowObject(tt.PathDisplayData);v.closed=$._getBoolean(t,tt.DataParser.CLOSED,false);v.constantSpeed=$._getBoolean(t,tt.DataParser.CONSTANT_SPEED,false);v.name=e;v.path=a.length>0?a:e;v.curveLengths.length=y.length;for(var g=0,D=y.length;ge.width){e.width=o}if(le.height){e.height=l}}}e.width-=e.x;e.height-=e.y}else{console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.")}return e};$.prototype._parseAnimation=function(t){var e=tt.BaseObject.borrowObject(tt.AnimationData);e.blendType=tt.DataParser._getAnimationBlendType($._getString(t,tt.DataParser.BLEND_TYPE,""));e.frameCount=$._getNumber(t,tt.DataParser.DURATION,0);e.playTimes=$._getNumber(t,tt.DataParser.PLAY_TIMES,1);e.duration=e.frameCount/this._armature.frameRate;e.fadeInTime=$._getNumber(t,tt.DataParser.FADE_IN_TIME,0);e.scale=$._getNumber(t,tt.DataParser.SCALE,1);e.name=$._getString(t,tt.DataParser.NAME,tt.DataParser.DEFAULT_NAME);if(e.name.length===0){e.name=tt.DataParser.DEFAULT_NAME}e.frameIntOffset=this._frameIntArray.length;e.frameFloatOffset=this._frameFloatArray.length;e.frameOffset=this._frameArray.length;this._animation=e;if(tt.DataParser.FRAME in t){var a=t[tt.DataParser.FRAME];var r=a.length;if(r>0){for(var i=0,n=0;i0){this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,0,0,this._parseActionFrame);this._actionFrames.length=0}if(tt.DataParser.TIMELINE in t){var o=t[tt.DataParser.TIMELINE];for(var A=0,S=o;A0&&a in t){e=t[a]}if(e===null){return null}var l=e.length;if(l===0){return null}var h=this._frameIntArray.length;var u=this._frameFloatArray.length;var f=this._timelineArray.length;if(o===null){o=tt.BaseObject.borrowObject(tt.TimelineData)}o.type=r;o.offset=f;this._frameValueType=i;this._timeline=o;this._timelineArray.length+=1+1+1+1+1+l;if(t!==null){this._timelineArray[f+0]=Math.round($._getNumber(t,tt.DataParser.SCALE,1)*100);this._timelineArray[f+1]=Math.round($._getNumber(t,tt.DataParser.OFFSET,0)*100)}else{this._timelineArray[f+0]=100;this._timelineArray[f+1]=0}this._timelineArray[f+2]=l;this._timelineArray[f+3]=n;switch(this._frameValueType){case 0:this._timelineArray[f+4]=0;break;case 1:this._timelineArray[f+4]=h-this._animation.frameIntOffset;break;case 2:this._timelineArray[f+4]=u-this._animation.frameFloatOffset;break}if(l===1){o.frameIndicesOffset=-1;this._timelineArray[f+5+0]=s.call(this,e[0],0,0)-this._animation.frameOffset}else{var _=this._animation.frameCount+1;var m=this._data.frameIndices;var c=m.length;m.length+=_;o.frameIndicesOffset=c;for(var p=0,d=0,y=0,v=0;p<_;++p){if(y+v<=p&&d0){if(tt.DataParser.CURVE in t){var i=a+1;this._helpArray.length=i;var n=this._samplingEasingCurve(t[tt.DataParser.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length;this._frameArray[r+1]=2;this._frameArray[r+2]=n?i:-i;for(var s=0;s0){var n=this._armature.sortedSlots.length;var s=new Array(n-i.length/2);var o=new Array(n);for(var l=0;l0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.TWEEN_ROTATE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=6;this._frameFloatArray[n++]=this._helpTransform.x;this._frameFloatArray[n++]=this._helpTransform.y;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=this._helpTransform.skew;this._frameFloatArray[n++]=this._helpTransform.scaleX;this._frameFloatArray[n++]=this._helpTransform.scaleY;this._parseActionDataInFrame(t,e,this._bone,this._slot);return i};$.prototype._parseBoneTranslateFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,0);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,0);return r};$.prototype._parseBoneRotateFrame=function(t,e,a){var r=$._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD;if(e!==0){if(this._prevClockwise===0){r=this._prevRotation+tt.Transform.normalizeRadian(r-this._prevRotation)}else{if(this._prevClockwise>0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.CLOCK_WISE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=$._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD;return i};$.prototype._parseBoneScaleFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,1);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,1);return r};$.prototype._parseSlotDisplayFrame=function(t,e,a){var r=this._parseFrame(t,e,a);this._frameArray.length+=1;if(tt.DataParser.VALUE in t){this._frameArray[r+1]=$._getNumber(t,tt.DataParser.VALUE,0)}else{this._frameArray[r+1]=$._getNumber(t,tt.DataParser.DISPLAY_INDEX,0)}this._parseActionDataInFrame(t,e,this._slot.parent,this._slot);return r};$.prototype._parseSlotColorFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=-1;if(tt.DataParser.VALUE in t||tt.DataParser.COLOR in t){var n=tt.DataParser.VALUE in t?t[tt.DataParser.VALUE]:t[tt.DataParser.COLOR];for(var s in n){s;this._parseColorTransform(n,this._helpColorTransform);i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=Math.round(this._helpColorTransform.alphaMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.redMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.greenMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.blueMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.alphaOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.redOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.greenOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.blueOffset);i-=8;break}}if(i<0){if(this._defaultColorOffset<0){this._defaultColorOffset=i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0}i=this._defaultColorOffset}var o=this._frameIntArray.length;this._frameIntArray.length+=1;this._frameIntArray[o]=i;return r};$.prototype._parseSlotDeformFrame=function(t,e,a){var r=this._frameFloatArray.length;var i=this._parseTweenFrame(t,e,a);var n=tt.DataParser.VERTICES in t?t[tt.DataParser.VERTICES]:null;var s=$._getNumber(t,tt.DataParser.OFFSET,0);var o=this._intArray[this._mesh.geometry.offset+0];var l=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name;var h=this._mesh.geometry.weight;var u=0;var f=0;var _=0;var m=0;if(h!==null){var c=this._weightSlotPose[l];this._helpMatrixA.copyFromArray(c,0);this._frameFloatArray.length+=h.count*2;_=h.offset+2+h.bones.length}else{this._frameFloatArray.length+=o*2}for(var p=0;p=n.length){u=0}else{u=n[p-s]}if(p+1=n.length){f=0}else{f=n[p+1-s]}}if(h!==null){var d=this._weightBonePoses[l];var y=this._intArray[_++];this._helpMatrixA.transformPoint(u,f,this._helpPoint,true);u=this._helpPoint.x;f=this._helpPoint.y;for(var v=0;v=n.length){h=0}else{h=n[f-s]}if(f+1=n.length){u=0}else{u=n[f+1-s]}}else{h=0;u=0}this._frameFloatArray[r+f]=h;this._frameFloatArray[r+f+1]=u}}if(e===0){var _=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1;this._frameIntArray[_+0]=this._geometry.offset;this._frameIntArray[_+1]=this._frameFloatArray.length-r;this._frameIntArray[_+2]=this._frameFloatArray.length-r;this._frameIntArray[_+3]=0;this._frameIntArray[_+4]=r-this._animation.frameFloatOffset;this._timelineArray[this._timeline.offset+3]=_-this._animation.frameIntOffset}return i};$.prototype._parseTransform=function(t,e,a){e.x=$._getNumber(t,tt.DataParser.X,0)*a;e.y=$._getNumber(t,tt.DataParser.Y,0)*a;if(tt.DataParser.ROTATE in t||tt.DataParser.SKEW in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD)}else if(tt.DataParser.SKEW_X in t||tt.DataParser.SKEW_Y in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_Y,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_X,0)*tt.Transform.DEG_RAD)-e.rotation}e.scaleX=$._getNumber(t,tt.DataParser.SCALE_X,1);e.scaleY=$._getNumber(t,tt.DataParser.SCALE_Y,1)};$.prototype._parseColorTransform=function(t,e){e.alphaMultiplier=$._getNumber(t,tt.DataParser.ALPHA_MULTIPLIER,100)*.01;e.redMultiplier=$._getNumber(t,tt.DataParser.RED_MULTIPLIER,100)*.01;e.greenMultiplier=$._getNumber(t,tt.DataParser.GREEN_MULTIPLIER,100)*.01;e.blueMultiplier=$._getNumber(t,tt.DataParser.BLUE_MULTIPLIER,100)*.01;e.alphaOffset=$._getNumber(t,tt.DataParser.ALPHA_OFFSET,0);e.redOffset=$._getNumber(t,tt.DataParser.RED_OFFSET,0);e.greenOffset=$._getNumber(t,tt.DataParser.GREEN_OFFSET,0);e.blueOffset=$._getNumber(t,tt.DataParser.BLUE_OFFSET,0)};$.prototype._parseGeometry=function(t,e){var a=t[tt.DataParser.VERTICES];var r=Math.floor(a.length/2);var i=0;var n=this._intArray.length;var s=this._floatArray.length;e.offset=n;e.data=this._data;this._intArray.length+=1+1+1+1;this._intArray[n+0]=r;this._intArray[n+2]=s;this._intArray[n+3]=-1;this._floatArray.length+=r*2;for(var o=0,l=r*2;o=0||tt.DataParser.DATA_VERSIONS.indexOf(r)>=0){var i=tt.BaseObject.borrowObject(tt.DragonBonesData);i.version=a;i.name=$._getString(t,tt.DataParser.NAME,"");i.frameRate=$._getNumber(t,tt.DataParser.FRAME_RATE,24);if(i.frameRate===0){i.frameRate=24}if(tt.DataParser.ARMATURE in t){this._data=i;this._parseArray(t);var n=t[tt.DataParser.ARMATURE];for(var s=0,o=n;s0){i.stage=i.getArmature(i.armatureNames[0])}this._data=null}if(tt.DataParser.TEXTURE_ATLAS in t){this._rawTextureAtlases=t[tt.DataParser.TEXTURE_ATLAS]}return i}else{console.assert(false,"Nonsupport data version: "+a+"\n"+"Please convert DragonBones data to support version.\n"+"Read more: https://github.com/DragonBones/Tools/")}return null};$.prototype.parseTextureAtlasData=function(t,e,a){if(a===void 0){a=1}console.assert(t!==undefined);if(t===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0){return false}var r=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(r,e,a);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}e.width=$._getNumber(t,tt.DataParser.WIDTH,0);e.height=$._getNumber(t,tt.DataParser.HEIGHT,0);e.scale=a===1?1/$._getNumber(t,tt.DataParser.SCALE,1):a;e.name=$._getString(t,tt.DataParser.NAME,"");e.imagePath=$._getString(t,tt.DataParser.IMAGE_PATH,"");if(tt.DataParser.SUB_TEXTURE in t){var i=t[tt.DataParser.SUB_TEXTURE];for(var n=0,s=i.length;n0&&h>0){u.frame=tt.TextureData.createRectangle();u.frame.x=$._getNumber(o,tt.DataParser.FRAME_X,0);u.frame.y=$._getNumber(o,tt.DataParser.FRAME_Y,0);u.frame.width=l;u.frame.height=h}e.addTexture(u)}}return true};$.getInstance=function(){if($._objectDataParserInstance===null){$._objectDataParserInstance=new $}return $._objectDataParserInstance};$._objectDataParserInstance=null;return $}(tt.DataParser);tt.ObjectDataParser=t;var D=function(){function t(){this.frameStart=0;this.actions=[]}return t}();tt.ActionFrame=D})(dragonBones||(dragonBones={}));var dragonBones;(function(g){var t=function(o){__extends(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}t.prototype._inRange=function(t,e,a){return e<=t&&t<=a};t.prototype._decodeUTF8=function(t){var e=-1;var a=-1;var r=65533;var i=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>i){var f=t[i++];if(f===e){if(l!==0){s=r}else{s=a}}else{if(l===0){if(this._inRange(f,0,127)){s=f}else{if(this._inRange(f,194,223)){l=1;u=128;o=f-192}else if(this._inRange(f,224,239)){l=2;u=2048;o=f-224}else if(this._inRange(f,240,244)){l=3;u=65536;o=f-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(f,128,191)){o=0;l=0;h=0;u=0;i--;s=f}else{h+=1;o=o+(f-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var m=u;o=0;l=0;h=0;u=0;if(this._inRange(_,m,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=f}}}}if(s!==null&&s!==a){if(s<=65535){if(s>0)n+=String.fromCharCode(s)}else{s-=65536;n+=String.fromCharCode(55296+(s>>10&1023));n+=String.fromCharCode(56320+(s&1023))}}}return n};t.prototype._parseBinaryTimeline=function(t,e,a){if(a===void 0){a=null}var r=a!==null?a:g.BaseObject.borrowObject(g.TimelineData);r.type=t;r.offset=e;this._timeline=r;var i=this._timelineArrayBuffer[r.offset+2];if(i===1){r.frameIndicesOffset=-1}else{var n=0;var s=this._animation.frameCount+1;var o=this._data.frameIndices;n=o.length;o.length+=s;r.frameIndicesOffset=n;for(var l=0,h=0,u=0,f=0;l=0){var h=g.ObjectDataParser._getNumber(d,g.DataParser.TYPE,0);var y=g.ObjectDataParser._getString(d,g.DataParser.NAME,"");var f=null;if(h===40&&e.blendType!==0){f=g.BaseObject.borrowObject(g.AnimationTimelineData);var v=f;v.x=g.ObjectDataParser._getNumber(d,g.DataParser.X,0);v.y=g.ObjectDataParser._getNumber(d,g.DataParser.Y,0)}f=this._parseBinaryTimeline(h,u,f);switch(h){case 0:break;case 1:break;case 11:case 12:case 13:case 50:case 60:this._animation.addBoneTimeline(y,f);break;case 20:case 21:case 22:case 23:case 24:this._animation.addSlotTimeline(y,f);break;case 30:this._animation.addConstraintTimeline(y,f);break;case 40:case 41:case 42:this._animation.addAnimationTimeline(y,f);break}}}}this._animation=null;return e};t.prototype._parseGeometry=function(t,e){e.offset=t[g.DataParser.OFFSET];e.data=this._data;var a=this._intArrayBuffer[e.offset+3];if(a>=0){var r=g.BaseObject.borrowObject(g.WeightData);var i=this._intArrayBuffer[e.offset+0];var n=this._intArrayBuffer[a+0];r.offset=a;for(var s=0;s12?e[13]:0;var h=new Int16Array(this._binary,this._binaryOffset+e[0],a/Int16Array.BYTES_PER_ELEMENT);var u=new Float32Array(this._binary,this._binaryOffset+e[2],r/Float32Array.BYTES_PER_ELEMENT);var f=new Int16Array(this._binary,this._binaryOffset+e[4],i/Int16Array.BYTES_PER_ELEMENT);var _=new Float32Array(this._binary,this._binaryOffset+e[6],n/Float32Array.BYTES_PER_ELEMENT);var m=new Int16Array(this._binary,this._binaryOffset+e[8],s/Int16Array.BYTES_PER_ELEMENT);var c=new Uint16Array(this._binary,this._binaryOffset+e[10],o/Uint16Array.BYTES_PER_ELEMENT);var p=l>0?new Int16Array(this._binary,this._binaryOffset+e[12],l/Int16Array.BYTES_PER_ELEMENT):h;this._data.binary=this._binary;this._data.intArray=this._intArrayBuffer=h;this._data.floatArray=u;this._data.frameIntArray=f;this._data.frameFloatArray=_;this._data.frameArray=this._frameArrayBuffer=m;this._data.timelineArray=this._timelineArrayBuffer=c;this._data.colorArray=p};t.prototype.parseDragonBonesData=function(t,e){if(e===void 0){e=1}console.assert(t!==null&&t!==undefined&&t instanceof ArrayBuffer,"Data error.");var a=new Uint8Array(t,0,8);if(a[0]!=="D".charCodeAt(0)||a[1]!=="B".charCodeAt(0)||a[2]!=="D".charCodeAt(0)||a[3]!=="T".charCodeAt(0)){console.assert(false,"Nonsupport data.");return null}var r=new Uint32Array(t,8,1)[0];var i=new Uint8Array(t,8+4,r);var n=this._decodeUTF8(i);var s=JSON.parse(n);this._binaryOffset=8+4+r;this._binary=t;return o.prototype.parseDragonBonesData.call(this,s,e)};t.getInstance=function(){if(t._binaryDataParserInstance===null){t._binaryDataParserInstance=new t}return t._binaryDataParserInstance};t._binaryDataParserInstance=null;return t}(g.ObjectDataParser);g.BinaryDataParser=t})(dragonBones||(dragonBones={}));var dragonBones;(function(y){var t=function(){function s(t){if(t===void 0){t=null}this.autoSearch=false;this._dragonBonesDataMap={};this._textureAtlasDataMap={};this._dragonBones=null;this._dataParser=null;if(s._objectParser===null){s._objectParser=new y.ObjectDataParser}if(s._binaryParser===null){s._binaryParser=new y.BinaryDataParser}this._dataParser=t!==null?t:s._objectParser}s.prototype._isSupportMesh=function(){return true};s.prototype._getTextureData=function(t,e){if(t in this._textureAtlasDataMap){for(var a=0,r=this._textureAtlasDataMap[t];a0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(a)}}if(s===null&&(e.length===0||this.autoSearch)){for(var o in this._dragonBonesDataMap){n=this._dragonBonesDataMap[o];if(e.length===0||n.autoSearch){s=n.getArmature(a);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=i;t.data=n;t.armature=s;t.skin=null;if(r.length>0){t.skin=s.getSkin(r);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(r);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};s.prototype._buildBones=function(t,e){for(var a=0,r=t.armature.sortedBones;a0){var p=this._getTextureData(t.textureAtlasName,c.path);f.replaceTextureData(p,_)}var d=this._getSlotDisplay(t,c,f);f.replaceDisplay(d,_)}else{f.replaceDisplay(null)}}}f._setDisplayIndex(h.displayIndex,true)}};s.prototype._buildConstraints=function(t,e){var a=t.armature.constraints;for(var r in a){var i=a[r];switch(i.type){case 0:var n=y.BaseObject.borrowObject(y.IKConstraint);n.init(i,e);e._addConstraint(n);break;case 1:var s=y.BaseObject.borrowObject(y.PathConstraint);s.init(i,e);e._addConstraint(s);break;default:var o=y.BaseObject.borrowObject(y.IKConstraint);o.init(i,e);e._addConstraint(o);break}}};s.prototype._buildChildArmature=function(t,e,a){return this.buildArmature(a.path,t!==null?t.dataName:"","",t!==null?t.textureAtlasName:"")};s.prototype._getSlotDisplay=function(t,e,a){var r=t!==null?t.dataName:e.parent.parent.parent.name;var i=null;switch(e.type){case 0:{var n=e;if(n.texture===null){n.texture=this._getTextureData(r,e.path)}i=a.rawDisplay;break}case 2:{var s=e;if(s.texture===null){s.texture=this._getTextureData(r,s.path)}if(this._isSupportMesh()){i=a.meshDisplay}else{i=a.rawDisplay}break}case 1:{var o=e;var l=this._buildChildArmature(t,a,o);if(l!==null){l.inheritAnimation=o.inheritAnimation;if(!l.inheritAnimation){var h=o.actions.length>0?o.actions:l.armatureData.defaultActions;if(h.length>0){for(var u=0,f=h;u=0){continue}var h=e.getDisplays(l.name);if(h===null){if(n!==null&&e!==n){h=n.getDisplays(l.name)}if(h===null){if(a){l.displayFrameCount=0}continue}}l.displayFrameCount=h.length;for(var u=0,f=l.displayFrameCount;u=0&&this._display!==null&&t!==null){var a=t.parent;if(this._armature.replacedTexture!==null){if(this._armature._replaceTextureAtlasData===null){a=k.BaseObject.borrowObject(k.CocosTextureAtlasData);a.copyFrom(t.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}t=a.getTexture(t.name)}var r=t.renderTexture;if(r!==null){if(this._geometryData!==null){var i=this._geometryData.data;var n=i.intArray;var s=i.floatArray;var o=n[this._geometryData.offset+0];var l=n[this._geometryData.offset+1];var h=n[this._geometryData.offset+2];if(h<0){h+=65536}var u=h+o*2;var f=this._armature._armatureData.scale;var _=r.getTexture().getContentSizeInPixels();var m=a.width>0?a.width:_.width;var c=a.height>0?a.height:_.height;var p=t.region;var d=cc.rect(999999,999999,-999999,-999999);var y={triangles:{verts:[],indices:[]},rect:d};for(var v=0,g=o*2;vD.x){d.x=D.x}if(d.widthD.y){d.y=D.y}if(d.height0&&r.inheritDeform;var s=this._renderDisplay.getComponent(cc.Sprite)._sgNode;var o=s.getMeshPolygonInfo();if(!o){return}var l=o.triangles.verts;var h=cc.rect(999999,999999,-999999,-999999);if(i!==null){var u=r.data;var f=u.intArray;var _=u.floatArray;var m=f[r.offset+0];var c=f[i.offset+1];if(c<0){c+=65536}for(var p=0,d=i.offset+2+a.length,y=c,v=0;pD){h.x=D}if(h.widthT){h.y=T}if(h.heightw){h.x=w}if(h.widthN){h.y=N}if(h.height=0;o--)if(s=t[o])n=(i<3?s(n):i>3?s(e,a,n):s(e,a))||n;return i>3&&n&&Object.defineProperty(e,a,n),n};var dragonBones;(function(o){var t=function(){function e(t){this._clock=new o.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=t;console.info("DragonBones: "+e.VERSION+"\nWebsite: http://dragonbones.com/\nSource and Demo: https://github.com/DragonBones/")}e.prototype.advanceTime=function(t){if(this._objects.length>0){for(var e=0,a=this._objects;e0){for(var i=0;ie){r.length=e}n._maxCountMap[a]=e}else{n._defaultMaxCount=e;for(var a in n._poolsMap){var r=n._poolsMap[a];if(r.length>e){r.length=e}if(a in n._maxCountMap){n._maxCountMap[a]=e}}}};n.clearPool=function(t){if(t===void 0){t=null}if(t!==null){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in n._poolsMap){var a=n._poolsMap[r];a.length=0}}};n.borrowObject=function(t){var e=String(t);var a=e in n._poolsMap?n._poolsMap[e]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var i=new t;i._onClear();return i};n.prototype.returnToPool=function(){this._onClear();n._returnObject(this)};n._hashCode=0;n._defaultMaxCount=3e3;n._maxCountMap={};n._poolsMap={};return n}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n){if(t===void 0){t=1}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=a;this.d=r;this.tx=i;this.ty=n}t.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};t.prototype.copyFrom=function(t){this.a=t.a;this.b=t.b;this.c=t.c;this.d=t.d;this.tx=t.tx;this.ty=t.ty;return this};t.prototype.copyFromArray=function(t,e){if(e===void 0){e=0}this.a=t[e];this.b=t[e+1];this.c=t[e+2];this.d=t[e+3];this.tx=t[e+4];this.ty=t[e+5];return this};t.prototype.identity=function(){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this};t.prototype.concat=function(t){var e=this.a*t.a;var a=0;var r=0;var i=this.d*t.d;var n=this.tx*t.a+t.tx;var s=this.ty*t.d+t.ty;if(this.b!==0||this.c!==0){e+=this.b*t.c;a+=this.b*t.d;r+=this.c*t.a;i+=this.c*t.b}if(t.b!==0||t.c!==0){a+=this.a*t.b;r+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=a;this.c=r;this.d=i;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var a=this.c;var r=this.d;var i=this.tx;var n=this.ty;if(e===0&&a===0){this.b=this.c=0;if(t===0||r===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;r=this.d=1/r;this.tx=-t*i;this.ty=-r*n}return this}var s=t*r-e*a;if(s===0){this.a=this.d=1;this.b=this.c=0;this.tx=this.ty=0;return this}s=1/s;var o=this.a=r*s;e=this.b=-e*s;a=this.c=-a*s;r=this.d=t*s;this.tx=-(o*i+a*n);this.ty=-(e*i+r*n);return this};t.prototype.transformPoint=function(t,e,a,r){if(r===void 0){r=false}a.x=this.a*t+this.c*e;a.y=this.b*t+this.d*e;if(!r){a.x+=this.tx;a.y+=this.ty}};t.prototype.transformRectangle=function(t,e){if(e===void 0){e=false}var a=this.a;var r=this.b;var i=this.c;var n=this.d;var s=e?0:this.tx;var o=e?0:this.ty;var l=t.x;var h=t.y;var u=l+t.width;var f=h+t.height;var _=a*l+i*h+s;var m=r*l+n*h+o;var c=a*u+i*h+s;var p=r*u+n*h+o;var d=a*u+i*f+s;var y=r*u+n*f+o;var v=a*l+i*f+s;var g=r*l+n*f+o;var D=0;if(_>c){D=_;_=c;c=D}if(d>v){D=d;d=v;v=D}t.x=Math.floor(_v?c:v)-t.x);if(m>p){D=m;m=p;p=D}if(y>g){D=y;y=g;g=D}t.y=Math.floor(mg?p:g)-t.y)};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function n(t,e,a,r,i,n){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}if(i===void 0){i=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=a;this.rotation=r;this.scaleX=i;this.scaleY=n}n.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};n.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+this.skew*180/Math.PI+" skewY:"+this.rotation*180/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY};n.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.skew=t.skew;this.rotation=t.rotation;this.scaleX=t.scaleX;this.scaleY=t.scaleY;return this};n.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};n.prototype.add=function(t){this.x+=t.x;this.y+=t.y;this.skew+=t.skew;this.rotation+=t.rotation;this.scaleX*=t.scaleX;this.scaleY*=t.scaleY;return this};n.prototype.minus=function(t){this.x-=t.x;this.y-=t.y;this.skew-=t.skew;this.rotation-=t.rotation;this.scaleX/=t.scaleX;this.scaleY/=t.scaleY;return this};n.prototype.fromMatrix=function(t){var e=this.scaleX,a=this.scaleY;var r=n.PI_Q;this.x=t.tx;this.y=t.ty;this.rotation=Math.atan(t.b/t.a);var i=Math.atan(-t.c/t.d);this.scaleX=this.rotation>-r&&this.rotation-r&&i=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;i=i-Math.PI}this.skew=i-this.rotation;return this};n.prototype.toMatrix=function(t){if(this.rotation===0){t.a=1;t.b=0}else{t.a=Math.cos(this.rotation);t.b=Math.sin(this.rotation)}if(this.skew===0){t.c=-t.b;t.d=t.a}else{t.c=-Math.sin(this.skew+this.rotation);t.d=Math.cos(this.skew+this.rotation)}if(this.scaleX!==1){t.a*=this.scaleX;t.b*=this.scaleX}if(this.scaleY!==1){t.c*=this.scaleY;t.d*=this.scaleY}t.tx=this.x;t.ty=this.y;return this};n.PI=Math.PI;n.PI_D=Math.PI*2;n.PI_H=Math.PI/2;n.PI_Q=Math.PI/4;n.RAD_DEG=180/Math.PI;n.DEG_RAD=Math.PI/180;return n}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r,i,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(a===void 0){a=1}if(r===void 0){r=1}if(i===void 0){i=0}if(n===void 0){n=0}if(s===void 0){s=0}if(o===void 0){o=0}this.alphaMultiplier=t;this.redMultiplier=e;this.greenMultiplier=a;this.blueMultiplier=r;this.alphaOffset=i;this.redOffset=n;this.greenOffset=s;this.blueOffset=o}t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier;this.redMultiplier=t.redMultiplier;this.greenMultiplier=t.greenMultiplier;this.blueMultiplier=t.blueMultiplier;this.alphaOffset=t.alphaOffset;this.redOffset=t.redOffset;this.greenOffset=t.greenOffset;this.blueOffset=t.blueOffset};t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1;this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0};return t}();t.ColorTransform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e){if(t===void 0){t=0}if(e===void 0){e=0}this.x=t;this.y=e}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y};t.prototype.clear=function(){this.x=this.y=0};return t}();t.Point=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,a,r){if(t===void 0){t=0}if(e===void 0){e=0}if(a===void 0){a=0}if(r===void 0){r=0}this.x=t;this.y=e;this.width=a;this.height=r}t.prototype.copyFrom=function(t){this.x=t.x;this.y=t.y;this.width=t.width;this.height=t.height};t.prototype.clear=function(){this.x=this.y=0;this.width=this.height=0};return t}();t.Rectangle=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.ints=[];t.floats=[];t.strings=[];return t}t.toString=function(){return"[class dragonBones.UserData]"};t.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};t.prototype.addInt=function(t){this.ints.push(t)};t.prototype.addFloat=function(t){this.floats.push(t)};t.prototype.addString=function(t){this.strings.push(t)};t.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){a=0}if(this.sortedBones.indexOf(i)>=0){continue}var n=false;for(var s in this.constraints){var o=this.constraints[s];if(o.root===i&&this.sortedBones.indexOf(o.target)<0){n=true;break}}if(n){continue}if(i.parent!==null&&this.sortedBones.indexOf(i.parent)<0){continue}this.sortedBones.push(i);r++}};t.prototype.cacheFrames=function(t){if(this.cacheFrameRate>0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};t.prototype.setCacheFrame=function(t,e){var a=this.parent.cachedFrames;var r=a.length;a.length+=10;a[r]=t.a;a[r+1]=t.b;a[r+2]=t.c;a[r+3]=t.d;a[r+4]=t.tx;a[r+5]=t.ty;a[r+6]=e.rotation;a[r+7]=e.skew;a[r+8]=e.scaleX;a[r+9]=e.scaleY;return r};t.prototype.getCacheFrame=function(t,e,a){var r=this.parent.cachedFrames;t.a=r[a];t.b=r[a+1];t.c=r[a+2];t.d=r[a+3];t.tx=r[a+4];t.ty=r[a+5];e.rotation=r[a+6];e.skew=r[a+7];e.scaleX=r[a+8];e.scaleY=r[a+9];e.x=t.tx;e.y=t.ty};t.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Same bone: "+t.name);return}this.bones[t.name]=t;this.sortedBones.push(t)};t.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Same slot: "+t.name);return}this.slots[t.name]=t;this.sortedSlots.push(t)};t.prototype.addConstraint=function(t){if(t.name in this.constraints){console.warn("Same constraint: "+t.name);return}this.constraints[t.name]=t};t.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Same skin: "+t.name);return}t.parent=this;this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}if(t.name==="default"){this.defaultSkin=t}};t.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Same animation: "+t.name);return}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};t.prototype.addAction=function(t,e){if(e){this.defaultActions.push(t)}else{this.actions.push(t)}};t.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};t.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};t.prototype.getConstraint=function(t){return t in this.constraints?this.constraints[t]:null};t.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};t.prototype.getMesh=function(t,e,a){var r=this.getSkin(t);if(r===null){return null}return r.getDisplay(e,a)};t.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return t}(a.BaseObject);a.ArmatureData=t;var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.transform=new a.Transform;t.userData=null;return t}t.toString=function(){return"[class dragonBones.BoneData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.inheritTranslation=false;this.inheritRotation=false;this.inheritScale=false;this.inheritReflection=false;this.type=0;this.length=0;this.alpha=1;this.name="";this.transform.identity();this.userData=null;this.parent=null};return t}(a.BaseObject);a.BoneData=e;var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.geometry=new a.GeometryData;return t}t.toString=function(){return"[class dragonBones.SurfaceData]"};t.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=1;this.segmentX=0;this.segmentY=0;this.geometry.clear()};return t}(e);a.SurfaceData=r;var i=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.color=null;t.userData=null;return t}t.createColor=function(){return new a.ColorTransform};t.toString=function(){return"[class dragonBones.SlotData]"};t.prototype._onClear=function(){if(this.userData!==null){this.userData.returnToPool()}this.blendMode=0;this.displayIndex=0;this.zOrder=0;this.zIndex=0;this.alpha=1;this.name="";this.color=null;this.userData=null;this.parent=null};t.DEFAULT_COLOR=new a.ColorTransform;return t}(a.BaseObject);a.SlotData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.CanvasData]"};e.prototype._onClear=function(){this.hasBackground=false;this.color=0;this.x=0;this.y=0;this.width=0;this.height=0};return e}(t.BaseObject);t.CanvasData=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.displays={};return t}t.toString=function(){return"[class dragonBones.SkinData]"};t.prototype._onClear=function(){for(var t in this.displays){var e=this.displays[t];for(var a=0,r=e;ai){s|=2}if(en){s|=8}return s};D.rectangleIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=t>i&&tn&&ei&&an&&r=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){return true}}return false};D.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=this.width*.5;var l=this.height*.5;var h=D.rectangleIntersectsSegment(t,e,a,r,-o,-l,o,l,i,n,s);return h};return D}(e);t.RectangleBoundingBoxData=h;var a=function(t){__extends(l,t);function l(){return t!==null&&t.apply(this,arguments)||this}l.toString=function(){return"[class dragonBones.EllipseData]"};l.ellipseIntersectsSegment=function(t,e,a,r,i,n,s,o,l,h,u){if(l===void 0){l=null}if(h===void 0){h=null}if(u===void 0){u=null}var f=s/o;var _=f*f;e*=f;r*=f;var m=a-t;var c=r-e;var p=Math.sqrt(m*m+c*c);var d=m/p;var y=c/p;var v=(i-t)*d+(n-e)*y;var g=v*v;var D=t*t+e*e;var T=s*s;var b=T-D+g;var A=0;if(b>=0){var S=Math.sqrt(b);var P=v-S;var O=v+S;var x=P<0?-1:P<=p?0:1;var B=O<0?-1:O<=p?0:1;var E=x*B;if(E<0){return-1}else if(E===0){if(x===-1){A=2;a=t+O*d;r=(e+O*y)/f;if(l!==null){l.x=a;l.y=r}if(h!==null){h.x=a;h.y=r}if(u!==null){u.x=Math.atan2(r/T*_,a/T);u.y=u.x+Math.PI}}else if(B===1){A=1;t=t+P*d;e=(e+P*y)/f;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(u!==null){u.x=Math.atan2(e/T*_,t/T);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+P*d;l.y=(e+P*y)/f;if(u!==null){u.x=Math.atan2(l.y/T*_,l.x/T)}}if(h!==null){h.x=t+O*d;h.y=(e+O*y)/f;if(u!==null){u.y=Math.atan2(h.y/T*_,h.x/T)}}}}}return A};l.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};l.prototype.containsPoint=function(t,e){var a=this.width*.5;if(t>=-a&&t<=a){var r=this.height*.5;if(e>=-r&&e<=r){e*=a/r;return Math.sqrt(t*t+e*e)<=a}}return false};l.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}var o=l.ellipseIntersectsSegment(t,e,a,r,0,0,this.width*.5,this.height*.5,i,n,s);return o};return l}(e);t.EllipseBoundingBoxData=a;var r=function(e){__extends(l,e);function l(){var t=e!==null&&e.apply(this,arguments)||this;t.vertices=[];return t}l.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};l.polygonIntersectsSegment=function(t,e,a,r,i,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(t===a){t=a+1e-6}if(e===r){e=r+1e-6}var l=i.length;var h=t-a;var u=e-r;var f=t*r-e*a;var _=0;var m=i[l-2];var c=i[l-1];var p=0;var d=0;var y=0;var v=0;var g=0;var D=0;for(var T=0;T=m&&B<=b||B>=b&&B<=m)&&(h===0||B>=t&&B<=a||B>=a&&B<=t)){var E=(f*P-u*O)/x;if((E>=c&&E<=A||E>=A&&E<=c)&&(u===0||E>=e&&E<=r||E>=r&&E<=e)){if(s!==null){var M=B-t;if(M<0){M=-M}if(_===0){p=M;d=M;y=B;v=E;g=B;D=E;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}}else{if(Md){d=M;g=B;D=E;if(o!==null){o.y=Math.atan2(A-c,b-m)-Math.PI*.5}}}_++}else{y=B;v=E;g=B;D=E;_++;if(o!==null){o.x=Math.atan2(A-c,b-m)-Math.PI*.5;o.y=o.x}break}}}m=b;c=A}if(_===1){if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=y;s.y=v}if(o!==null){o.y=o.x+Math.PI}}else if(_>1){_++;if(n!==null){n.x=y;n.y=v}if(s!==null){s.x=g;s.y=D}}return _};l.prototype._onClear=function(){e.prototype._onClear.call(this);this.type=2;this.x=0;this.y=0;this.vertices.length=0};l.prototype.containsPoint=function(t,e){var a=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var r=0,i=this.vertices.length,n=i-2;r=e||s=e){var l=this.vertices[n];var h=this.vertices[r];if((e-o)*(l-h)/(s-o)+h0){return}this.cacheFrameRate=Math.max(Math.ceil(t*this.scale),1);var e=Math.ceil(this.cacheFrameRate*this.duration)+1;this.cachedFrames.length=e;for(var a=0,r=this.cacheFrames.length;ae._zIndex*1e3+e._zOrder?1:-1};y.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=n){continue}var o=a[s];var l=this.getSlot(o.name);if(l!==null){l._setZOrder(i)}}this._slotsDirty=true;this._zOrderDirty=!r}};y.prototype._addBone=function(t){if(this._bones.indexOf(t)<0){this._bones.push(t)}};y.prototype._addSlot=function(t){if(this._slots.indexOf(t)<0){this._slots.push(t)}};y.prototype._addConstraint=function(t){if(this._constraints.indexOf(t)<0){this._constraints.push(t)}};y.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};y.prototype.dispose=function(){if(this._armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};y.prototype.init=function(t,e,a,r){if(this._armatureData!==null){return}this._armatureData=t;this._animation=i.BaseObject.borrowObject(i.Animation);this._proxy=e;this._display=a;this._dragonBones=r;this._proxy.dbInit(this);this._animation.init(this);this._animation.animations=this._armatureData.animations};y.prototype.advanceTime=function(t){if(this._lockUpdate){return}this._lockUpdate=true;if(this._armatureData===null){console.warn("The armature has been disposed.");return}else if(this._armatureData.parent===null){console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear().");return}var e=this._cacheFrameIndex;this._animation.advanceTime(t);if(this._slotsDirty||this._zIndexDirty){this._slots.sort(y._onSortSlots);if(this._zIndexDirty){for(var a=0,r=this._slots.length;a0){for(var u=0,f=this._actions;u0){var a=this.getBone(t);if(a!==null){a.invalidUpdate();if(e){for(var r=0,i=this._slots;r0){if(i!==null||n!==null){if(i!==null){var b=o?i.y-e:i.x-t;if(b<0){b=-b}if(d===null||bh){h=b;_=n.x;m=n.y;y=D;if(s!==null){p=s.y}}}}else{d=D;break}}}if(d!==null&&i!==null){i.x=u;i.y=f;if(s!==null){s.x=c}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=p}}return d};y.prototype.getBone=function(t){for(var e=0,a=this._bones;e=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(o)}if(o&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};t.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};t.prototype.invalidUpdate=function(){this._transformDirty=true};t.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};Object.defineProperty(t.prototype,"boneData",{get:function(){return this._boneData},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;for(var e=0,a=this._armature.getSlots();e=a){return this.globalTransformMatrix}i=e>this._kX*(t+a)+p;m=((s*o+s+o+o+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=_*(l+2);var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[2]-(o-_)*g;var b=this._hullCache[3]-(o-_)*D;var A=this._vertices;if(i){this._getAffineTransform(-a,p+u,r-a,u,A[v+l+2],A[v+l+3],T+g,b+D,A[v],A[v+1],S._helpTransform,y,true)}else{this._getAffineTransform(-r,p,r-a,u,T,b,A[v],A[v+1],T+g,b+D,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(t>=a){if(e<-a||e>=a){return this.globalTransformMatrix}i=e>this._kX*(t-r)+p;m=((s*o+s+_)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=(_+1)*(l+2)-2;var g=this._hullCache[4];var D=this._hullCache[5];var T=this._hullCache[0]+_*g;var b=this._hullCache[1]+_*D;var A=this._vertices;if(i){this._getAffineTransform(r,p+u,r-a,u,T+g,b+D,A[v+l+2],A[v+l+3],T,b,S._helpTransform,y,true)}else{this._getAffineTransform(a,p,r-a,u,A[v],A[v+1],T,b,A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e<-a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)-r;m=((s*o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[8]+f*g;var b=this._hullCache[9]+f*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,-a,h,r-a,A[v+2],A[v+3],A[v],A[v+1],T+g,b+D,S._helpTransform,y,true)}else{this._getAffineTransform(c,-r,h,r-a,T,b,T+g,b+D,A[v],A[v+1],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else if(e>=a){if(t<-a||t>=a){return this.globalTransformMatrix}i=e>this._kY*(t-c-h)+a;m=((s*o+s+o+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=o*(l+2)+f*2;var g=this._hullCache[10];var D=this._hullCache[11];var T=this._hullCache[6]-(s-f)*g;var b=this._hullCache[7]-(s-f)*D;var A=this._vertices;if(i){this._getAffineTransform(c+h,r,h,r-a,T+g,b+D,T,b,A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,a,h,r-a,A[v],A[v+1],A[v+2],A[v+3],T,b,S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}else{i=e>this._k*(t-c-h)+p;m=((s*_+f)*2+(i?1:0))*7;if(d[m]>0){y.copyFromArray(d,m+1)}else{var v=f*2+_*(l+2);var A=this._vertices;if(i){this._getAffineTransform(c+h,p+u,h,u,A[v+l+4],A[v+l+5],A[v+l+2],A[v+l+3],A[v+2],A[v+3],S._helpTransform,y,true)}else{this._getAffineTransform(c,p,h,u,A[v],A[v+1],A[v+2],A[v+3],A[v+l+2],A[v+l+3],S._helpTransform,y,false)}d[m]=1;d[m+1]=y.a;d[m+2]=y.b;d[m+3]=y.c;d[m+4]=y.d;d[m+5]=y.tx;d[m+6]=y.ty}}return y};S.prototype.init=function(t,e){if(this._boneData!==null){return}l.prototype.init.call(this,t,e);var a=t.segmentX;var r=t.segmentY;var i=this._armature.armatureData.parent.intArray[t.geometry.offset+0];var n=1e3;var s=200;this._dX=s*2/a;this._dY=s*2/r;this._k=-this._dY/this._dX;this._kX=-this._dY/(n-s);this._kY=-(n-s)/this._dX;this._vertices.length=i*2;this._deformVertices.length=i*2;this._matrixCahce.length=(a*r+a*2+r*2)*2*7;this._hullCache.length=10;for(var o=0;o=0&&this._cachedFrameIndices!==null){var e=this._cachedFrameIndices[t];if(e>=0&&this._cachedFrameIndex===e){this._transformDirty=false}else if(e>=0){this._transformDirty=true;this._cachedFrameIndex=e}else{if(this._hasConstraint){for(var a=0,r=this._armature._constraints;a=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this._hasConstraint){for(var n=0,s=this._armature._constraints;n=0;if(this._localDirty){this._updateGlobalTransformMatrix(h)}if(h&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}var u=1e3;var f=200;var _=2*this.global.x;var m=2*this.global.y;var c=S._helpPoint;this.globalTransformMatrix.transformPoint(u,-f,c);this._hullCache[0]=c.x;this._hullCache[1]=c.y;this._hullCache[2]=_-c.x;this._hullCache[3]=m-c.y;this.globalTransformMatrix.transformPoint(0,this._dY,c,true);this._hullCache[4]=c.x;this._hullCache[5]=c.y;this.globalTransformMatrix.transformPoint(f,u,c);this._hullCache[6]=c.x;this._hullCache[7]=c.y;this._hullCache[8]=_-c.x;this._hullCache[9]=m-c.y;this.globalTransformMatrix.transformPoint(this._dX,0,c,true);this._hullCache[10]=c.x;this._hullCache[11]=c.y}else if(this._childrenTransformDirty){this._childrenTransformDirty=false}this._localDirty=true};return S}(t.Bone);t.Surface=e})(dragonBones||(dragonBones={}));var dragonBones;(function(p){var r=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t.deformVertices=[];return t}t.toString=function(){return"[class dragonBones.DisplayFrame]"};t.prototype._onClear=function(){this.rawDisplayData=null;this.displayData=null;this.textureData=null;this.display=null;this.deformVertices.length=0};t.prototype.updateDeformVertices=function(){if(this.rawDisplayData===null||this.deformVertices.length!==0){return}var t;if(this.rawDisplayData.type===2){t=this.rawDisplayData.geometry}else if(this.rawDisplayData.type===4){t=this.rawDisplayData.geometry}else{return}var e=0;if(t.weight!==null){e=t.weight.count*2}else{e=t.data.intArray[t.offset+0]*2}this.deformVertices.length=e;for(var a=0,r=this.deformVertices.length;a=0&&this._displayIndex0){for(var s=0,o=i;s=0&&this._cachedFrameIndices!==null){var r=this._cachedFrameIndices[t];if(r>=0&&this._cachedFrameIndex===r){this._transformDirty=false}else if(r>=0){this._transformDirty=true;this._cachedFrameIndex=r}else if(this._transformDirty||this._parent._childrenTransformDirty){this._transformDirty=true;this._cachedFrameIndex=-1}else if(this._cachedFrameIndex>=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}else if(this._transformDirty||this._parent._childrenTransformDirty){t=-1;this._transformDirty=true;this._cachedFrameIndex=-1}if(this._transformDirty){if(this._cachedFrameIndex<0){var i=t>=0;this._updateGlobalTransformMatrix(i);if(i&&this._cachedFrameIndices!==null){this._cachedFrameIndex=this._cachedFrameIndices[t]=this._armature._armatureData.setCacheFrame(this.globalTransformMatrix,this.global)}}else{this._armature._armatureData.getCacheFrame(this.globalTransformMatrix,this.global,this._cachedFrameIndex)}this._updateTransform();this._transformDirty=false}};c.prototype.invalidUpdate=function(){this._displayDataDirty=true;this._displayDirty=true;this._transformDirty=true};c.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._updateGlobalTransformMatrix(false);this._transformDirty=false}};c.prototype.replaceRawDisplayData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.rawDisplayData!==t){a.deformVertices.length=0;a.rawDisplayData=t;if(a.rawDisplayData===null){var r=this._armature._armatureData.defaultSkin;if(r!==null){var i=r.getDisplays(this._slotData.name);if(i!==null&&e=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.displayData!==t&&a.rawDisplayData!==t){a.displayData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceTextureData=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.textureData!==t){a.textureData=t;if(e===this._displayIndex){this._displayDataDirty=true}}};c.prototype.replaceDisplay=function(t,e){if(e===void 0){e=-1}if(e<0){e=this._displayIndex<0?0:this._displayIndex}else if(e>=this._displayFrames.length){return}var a=this._displayFrames[e];if(a.display!==t){var r=a.display;a.display=t;if(r!==null&&r!==this._rawDisplay&&r!==this._meshDisplay&&!this._hasDisplay(r)){if(r instanceof p.Armature){}else{this._disposeDisplay(r,true)}}if(t!==null&&t!==this._rawDisplay&&t!==this._meshDisplay&&!this._hasDisplay(r)&&!(t instanceof p.Armature)){this._initDisplay(t,true)}if(e===this._displayIndex){this._displayDirty=true}}};c.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);return this._boundingBoxData.containsPoint(c._helpPoint.x,c._helpPoint.y)};c.prototype.intersectsSegment=function(t,e,a,r,i,n,s){if(i===void 0){i=null}if(n===void 0){n=null}if(s===void 0){s=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();c._helpMatrix.copyFrom(this.globalTransformMatrix);c._helpMatrix.invert();c._helpMatrix.transformPoint(t,e,c._helpPoint);t=c._helpPoint.x;e=c._helpPoint.y;c._helpMatrix.transformPoint(a,r,c._helpPoint);a=c._helpPoint.x;r=c._helpPoint.y;var o=this._boundingBoxData.intersectsSegment(t,e,a,r,i,n,s);if(o>0){if(o===1||o===2){if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i);if(n!==null){n.x=i.x;n.y=i.y}}else if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}else{if(i!==null){this.globalTransformMatrix.transformPoint(i.x,i.y,i)}if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}}if(s!==null){this.globalTransformMatrix.transformPoint(Math.cos(s.x),Math.sin(s.x),c._helpPoint,true);s.x=Math.atan2(c._helpPoint.y,c._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(s.y),Math.sin(s.y),c._helpPoint,true);s.y=Math.atan2(c._helpPoint.y,c._helpPoint.x)}}return o};c.prototype.getDisplayFrameAt=function(t){return this._displayFrames[t]};Object.defineProperty(c.prototype,"visible",{get:function(){return this._visible},set:function(t){if(this._visible===t){return}this._visible=t;this._updateVisible()},enumerable:true,configurable:true});Object.defineProperty(c.prototype,"displayFrameCount",{get:function(){return this._displayFrames.length},set:function(t){var e=this._displayFrames.length;if(et){for(var a=e-1;ad){continue}var b=0;for(;;D++){var A=y[D];if(p>A){continue}if(D===0){b=p/A}else{var S=y[D-1];b=(p-S)/(A-S)}break}if(D!==c){c=D;if(u&&D===m){this._computeVertices(_-4,4,0,f);this._computeVertices(0,4,4,f)}else{this._computeVertices(D*6+2,8,0,f)}}this.addCurvePosition(b,f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],l,g,a)}return}if(u){_+=2;f.length=o;this._computeVertices(2,_-4,0,f);this._computeVertices(0,2,_-4,f);f[_-2]=f[0];f[_-1]=f[1]}else{m--;_-=4;f.length=_;this._computeVertices(2,_,0,f)}var P=new Array(m);d=0;var O=f[0],x=f[1],B=0,E=0,M=0,I=0,C=0,F=0;var w,N,R,j,k,L,V,Y;for(var v=0,U=2;vd){continue}for(;;D++){var W=P[D];if(H>W)continue;if(D===0)H/=W;else{var K=P[D-1];H=(H-K)/(W-K)}break}if(D!==c){c=D;var Z=D*6;O=f[Z];x=f[Z+1];B=f[Z+2];E=f[Z+3];M=f[Z+4];I=f[Z+5];C=f[Z+6];F=f[Z+7];w=(O-B*2+M)*.03;N=(x-E*2+I)*.03;R=((B-M)*3-O+C)*.006;j=((E-I)*3-x+F)*.006;k=w*2+R;L=N*2+j;V=(B-O)*.3+w+R*.16666667;Y=(E-x)*.3+N+j*.16666667;G=Math.sqrt(V*V+Y*Y);X[0]=G;for(Z=1;Z<8;Z++){V+=k;Y+=L;k+=R;L+=j;G+=Math.sqrt(V*V+Y*Y);X[Z]=G}V+=k;Y+=L;G+=Math.sqrt(V*V+Y*Y);X[8]=G;V+=k+R;Y+=L+j;G+=Math.sqrt(V*V+Y*Y);X[9]=G;z=0}H*=G;for(;;z++){var q=X[z];if(H>q)continue;if(z===0)H/=q;else{var K=X[z-1];H=z+(H-K)/(q-K)}break}this.addCurvePosition(H*.1,O,x,B,E,M,I,C,F,l,g,a)}};t.prototype.addCurvePosition=function(t,e,a,r,i,n,s,o,l,h,u,f){if(t===0){h[u]=e;h[u+1]=a;h[u+2]=0;return}if(t===1){h[u]=o;h[u+1]=l;h[u+2]=0;return}var _=1-t;var m=_*_;var c=t*t;var p=m*_;var d=m*t*3;var y=_*c*3;var v=t*c;var g=p*e+d*r+y*n+v*o;var D=p*a+d*i+y*s+v*l;h[u]=g;h[u+1]=D;if(f){h[u+2]=Math.atan2(D-(p*a+d*i+y*s),g-(p*e+d*r+y*n))}else{h[u+2]=0}};t.prototype.init=function(t,e){this._constraintData=t;this._armature=e;var a=t;this.pathOffset=a.pathDisplayData.geometry.offset;this.position=a.position;this.spacing=a.spacing;this.rotateOffset=a.rotateOffset;this.rotateMix=a.rotateMix;this.translateMix=a.translateMix;this._root=this._armature.getBone(a.root.name);this._target=this._armature.getBone(a.target.name);this._pathSlot=this._armature.getSlot(a.pathSlot.name);for(var r=0,i=a.bones.length;r0?U.Transform.DEG_RAD:-U.Transform.DEG_RAD}}var x=this.rotateMix;var B=this.translateMix;for(var c=0,E=3;c0){var w=v.a,N=v.b,R=v.c,j=v.d,k=void 0,L=void 0,V=void 0;if(h){k=b[E-1]}else{k=Math.atan2(I,M)}k-=Math.atan2(N,w);if(O){L=Math.cos(k);V=Math.sin(k);var Y=d._boneData.length;S+=(Y*(L*w-V*N)-M)*x;P+=(Y*(V*w+L*N)-I)*x}else{k+=A}if(k>U.Transform.PI){k-=U.Transform.PI_D}else if(k<-U.Transform.PI){k+=U.Transform.PI_D}k*=x;L=Math.cos(k);V=Math.sin(k);v.a=L*w-V*N;v.b=V*w+L*N;v.c=L*R-V*j;v.d=V*R+L*j}d.global.fromMatrix(v)}this.dirty=false};t.prototype.invalidUpdate=function(){};return t}(t);U.PathConstraint=a})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t){if(t===void 0){t=0}this.time=0;this.timeScale=1;this._systemTime=0;this._animatebles=[];this._clock=null;this.time=t;this._systemTime=(new Date).getTime()*.001}t.prototype.advanceTime=function(t){if(t!==t){t=0}var e=Date.now()*.001;if(t<0){t=e-this._systemTime}this._systemTime=e;if(this.timeScale!==1){t*=this.timeScale}if(t===0){return}if(t<0){this.time-=t}else{this.time+=t}var a=0,r=0,i=this._animatebles.length;for(;a0){this._animatebles[a-r]=n;this._animatebles[a]=null}n.advanceTime(t)}else{r++}}if(r>0){i=this._animatebles.length;for(;a=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&n._subFadeState>0){this._armature._dragonBones.bufferObject(n);this._animationStates.length=0;this._lastAnimationState=null}else{var s=n.animationData;var o=s.cacheFrameRate;if(this._animationDirty&&o>0){this._animationDirty=false;for(var l=0,h=this._armature.getBones();l0){var c=m.getDisplayFrameAt(0).rawDisplayData;if(c!==null&&c.parent===this._armature.armatureData.defaultSkin){m._cachedFrameIndices=s.getSlotCachedFrameIndices(m.name);continue}}m._cachedFrameIndices=null}}n.advanceTime(t,o)}}else if(i>1){for(var p=0,d=0;p0&&n._subFadeState>0){d++;this._armature._dragonBones.bufferObject(n);this._animationDirty=true;if(this._lastAnimationState===n){this._lastAnimationState=null}}else{if(d>0){this._animationStates[p-d]=n}n.advanceTime(t,0)}if(p===i-1&&d>0){this._animationStates.length-=d;if(this._lastAnimationState===null&&this._animationStates.length>0){this._lastAnimationState=this._animationStates[this._animationStates.length-1]}}}this._armature._cacheFrameIndex=-1}else{this._armature._cacheFrameIndex=-1}};t.prototype.reset=function(){for(var t=0,e=this._animationStates;t0){if(t.position<0){t.position%=a.duration;t.position=a.duration-t.position}else if(t.position===a.duration){t.position-=1e-6}else if(t.position>a.duration){t.position%=a.duration}if(t.duration>0&&t.position+t.duration>a.duration){t.duration=a.duration-t.position}if(t.playTimes<0){t.playTimes=a.playTimes}}else{t.playTimes=1;t.position=0;if(t.duration>0){t.duration=0}}if(t.duration===0){t.duration=-1}this._fadeOut(t);var s=g.BaseObject.borrowObject(g.AnimationState);s.init(this._armature,a,t);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var o=false;for(var l=0,h=this._animationStates.length;lthis._animationStates[l].layer){o=true;this._animationStates.splice(l,0,s);break}else if(l!==h-1&&s.layer>this._animationStates[l+1].layer){o=true;this._animationStates.splice(l+1,0,s);break}}if(!o){this._animationStates.push(s)}}else{this._animationStates.push(s)}for(var u=0,f=this._armature.getSlots();u0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var a=this._armature.armatureData.defaultAnimation;if(a!==null){this._animationConfig.animation=a.name;this.playConfig(this._animationConfig)}}else if(!this._lastAnimationState.isPlaying&&!this._lastAnimationState.isCompleted){this._lastAnimationState.play()}else{this._animationConfig.animation=this._lastAnimationState.name;this.playConfig(this._animationConfig)}return this._lastAnimationState};t.prototype.fadeIn=function(t,e,a,r,i,n){if(e===void 0){e=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(i===void 0){i=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=i!==null?i:"";return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByTime=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByFrame=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.frameCount>0?r.duration*e/r.frameCount:0}return this.playConfig(this._animationConfig)};t.prototype.gotoAndPlayByProgress=function(t,e,a){if(e===void 0){e=0}if(a===void 0){a=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=a;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var r=t in this._animations?this._animations[t]:null;if(r!==null){this._animationConfig.position=r.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};t.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByTime(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByFrame(t,e,1);if(a!==null){a.stop()}return a};t.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var a=this.gotoAndPlayByProgress(t,e,1);if(a!==null){a.stop()}return a};t.prototype.getBlendState=function(t,e,a){if(!(t in this._blendStates)){this._blendStates[t]={}}var r=this._blendStates[t];if(!(e in r)){var i=r[e]=g.BaseObject.borrowObject(g.BlendState);i.target=a}return r[e]};t.prototype.getState=function(t,e){if(e===void 0){e=-1}var a=this._animationStates.length;while(a--){var r=this._animationStates[a];if(r.name===t&&(e<0||r.layer===e)){return r}}return null};t.prototype.hasAnimation=function(t){return t in this._animations};t.prototype.getStates=function(){return this._animationStates};Object.defineProperty(t.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animations",{get:function(){return this._animations},set:function(t){if(this._animations===t){return}this._animationNames.length=0;for(var e in this._animations){delete this._animations[e]}for(var e in t){this._animationNames.push(e);this._animations[e]=t[e]}},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});return t}(g.BaseObject);g.Animation=t})(dragonBones||(dragonBones={}));var dragonBones;(function(L){var t=function(e){__extends(t,e);function t(){var t=e!==null&&e.apply(this,arguments)||this;t._boneMask=[];t._boneTimelines=[];t._boneBlendTimelines=[];t._slotTimelines=[];t._slotBlendTimelines=[];t._constraintTimelines=[];t._animationTimelines=[];t._poseTimelines=[];t._actionTimeline=null;t._zOrderTimeline=null;return t}t.toString=function(){return"[class dragonBones.AnimationState]"};t.prototype._onClear=function(){for(var t=0,e=this._boneTimelines;t=0){this._boneTimelines.splice(v,1);r.returnToPool()}v=this._boneBlendTimelines.indexOf(r);if(v>=0){this._boneBlendTimelines.splice(v,1);r.returnToPool()}}}}{var g={};var D=[];for(var T=0,b=this._slotTimelines;T=0){this._slotTimelines.splice(v,1);r.returnToPool()}v=this._slotBlendTimelines.indexOf(r);if(v>=0){this._slotBlendTimelines.splice(v,1);r.returnToPool()}}}}};t.prototype._advanceFadeTime=function(t){var e=this._fadeState>0;if(this._subFadeState<0){this._subFadeState=0;var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT:L.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}if(t<0){t=-t}this._fadeTime+=t;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=e?0:1}else if(this._fadeTime>0){this._fadeProgress=e?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=e?1:0}if(this._subFadeState>0){if(!e){this._playheadState|=1;this._fadeState=0}var a=this._parent===null&&this.actionEnabled;if(a){var r=e?L.EventObject.FADE_OUT_COMPLETE:L.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasDBEventListener(r)){var i=L.BaseObject.borrowObject(L.EventObject);i.type=r;i.armature=this._armature;i.animationState=this;this._armature._dragonBones.bufferEvent(i)}}}};t.prototype.init=function(t,e,a){if(this._armature!==null){return}this._armature=t;this._animationData=e;this.resetToPose=a.resetToPose;this.additive=a.additive;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.blendType=e.blendType;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;this._weight=a.weight;if(a.pauseFadeIn){this._playheadState=2}else{this._playheadState=3}if(a.duration<0){this._position=0;this._duration=this._animationData.duration;if(a.position!==0){if(this.timeScale>=0){this._time=a.position}else{this._time=a.position-this._duration}}else{this._time=0}}else{this._position=a.position;this._duration=a.duration;this._time=0}if(this.timeScale<0&&this._time===0){this._time=-1e-6}if(this.fadeTotalTime<=0){this._fadeProgress=.999999}if(a.boneMask.length>0){this._boneMask.length=a.boneMask.length;for(var r=0,i=this._boneMask.length;r0;var i=true;var n=true;var s=this._time;this._weightResult=this._weight*this._fadeProgress;if(this._parent!==null){this._weightResult*=this._parent._weightResult}if(this._actionTimeline.playState<=0){this._actionTimeline.update(s)}if(this._weight===0){return}if(r){var o=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*o)/o}if(this._zOrderTimeline!==null&&this._zOrderTimeline.playState<=0){this._zOrderTimeline.update(s)}if(r){var l=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===l){i=false;n=false}else{this._armature._cacheFrameIndex=l;if(this._animationData.cachedFrames[l]){n=false}else{this._animationData.cachedFrames[l]=true}}}if(i){var h=false;var u=null;if(n){for(var f=0,_=this._boneTimelines.length;f<_;++f){var m=this._boneTimelines[f];if(m.playState<=0){m.update(s)}if(m.target!==u){var c=m.target;h=c.update(this);u=c;if(c.dirty===1){var p=c.target.animationPose;p.x=0;p.y=0;p.rotation=0;p.skew=0;p.scaleX=1;p.scaleY=1}}if(h){m.blend(a)}}}for(var f=0,_=this._boneBlendTimelines.length;f<_;++f){var m=this._boneBlendTimelines[f];if(m.playState<=0){m.update(s)}if(m.target.update(this)){m.blend(a)}}if(this.displayControl){for(var f=0,_=this._slotTimelines.length;f<_;++f){var m=this._slotTimelines[f];if(m.playState<=0){var d=m.target;var y=d.displayController;if(y===null||y===this.name||y===this.group){m.update(s)}}}}for(var f=0,_=this._slotBlendTimelines.length;f<_;++f){var m=this._slotBlendTimelines[f];if(m.playState<=0){var c=m.target;m.update(s);if(c.update(this)){m.blend(a)}}}for(var f=0,_=this._constraintTimelines.length;f<_;++f){var m=this._constraintTimelines[f];if(m.playState<=0){m.update(s)}}if(this._animationTimelines.length>0){var v=100;var g=100;var D=null;var T=null;for(var f=0,_=this._animationTimelines.length;f<_;++f){var m=this._animationTimelines[f];if(m.playState<=0){m.update(s)}if(this.blendType===1){var b=m.target;var A=this.parameterX-b.positionX;if(A>=0){if(A0){this._subFadeState=0;if(this._poseTimelines.length>0){for(var S=0,P=this._poseTimelines;S=0){this._boneTimelines.splice(O,1);m.returnToPool();continue}O=this._boneBlendTimelines.indexOf(m);if(O>=0){this._boneBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._slotTimelines.indexOf(m);if(O>=0){this._slotTimelines.splice(O,1);m.returnToPool();continue}O=this._slotBlendTimelines.indexOf(m);if(O>=0){this._slotBlendTimelines.splice(O,1);m.returnToPool();continue}O=this._constraintTimelines.indexOf(m);if(O>=0){this._constraintTimelines.splice(O,1);m.returnToPool();continue}}this._poseTimelines.length=0}}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};t.prototype.play=function(){this._playheadState=3};t.prototype.stop=function(){this._playheadState&=1};t.prototype.fadeOut=function(t,e){if(e===void 0){e=true}if(t<0){t=0}if(e){this._playheadState&=2}if(this._fadeState>0){if(t>this.fadeTotalTime-this._fadeTime){return}}else{this._fadeState=1;this._subFadeState=-1;if(t<=0||this._fadeProgress<=0){this._fadeProgress=1e-6}for(var a=0,r=this._boneTimelines;a1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};t.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};t.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var a=this._armature.getBone(t);if(a===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var r=0,i=this._armature.getBones();r=0){this._boneMask.splice(a,1)}if(e){var r=this._armature.getBone(t);if(r!==null){var i=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=i;n=0&&r.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=i;h0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(t.prototype,"currentTime",{get:function(){return this._actionTimeline.currentTime},set:function(t){var e=this._actionTimeline.currentPlayTimes-(this._actionTimeline.playState>0?1:0);if(t<0||this._duration0&&e===this.playTimes-1&&t===this._duration&&this._parent===null){t=this._duration-1e-6}if(this._time===t){return}this._time=t;this._actionTimeline.setCurrentTime(this._time);if(this._zOrderTimeline!==null){this._zOrderTimeline.playState=-1}for(var a=0,r=this._boneTimelines;a0){if(this.leftWeight>0){if(this.layer!==e){if(this.layerWeight>=this.leftWeight){this.dirty++;this.layer=e;this.leftWeight=0;this.blendWeight=0;return false}this.layer=e;this.leftWeight-=this.layerWeight;this.layerWeight=0}a*=this.leftWeight;this.dirty++;this.blendWeight=a;this.layerWeight+=this.blendWeight;return true}return false}this.dirty++;this.layer=e;this.leftWeight=1;this.blendWeight=a;this.layerWeight=a;return true};e.prototype.reset=function(){this.dirty=0;this.layer=0;this.leftWeight=0;this.layerWeight=0;this.blendWeight=0};e.BONE_TRANSFORM="boneTransform";e.BONE_ALPHA="boneAlpha";e.SURFACE="surface";e.SLOT_DEFORM="slotDeform";e.SLOT_ALPHA="slotAlpha";e.SLOT_Z_INDEX="slotZIndex";return e}(L.BaseObject);L.BlendState=V})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.prototype._onClear=function(){this.dirty=false;this.playState=-1;this.currentPlayTimes=-1;this.currentTime=-1;this.target=null;this._isTween=false;this._valueOffset=0;this._frameValueOffset=0;this._frameOffset=0;this._frameRate=0;this._frameCount=0;this._frameIndex=-1;this._frameRateR=0;this._position=0;this._duration=0;this._timeScale=1;this._timeOffset=0;this._animationData=null;this._timelineData=null;this._armature=null;this._animationState=null;this._actionTimeline=null;this._frameArray=null;this._valueArray=null;this._timelineArray=null;this._frameIndices=null};e.prototype._setCurrentTime=function(t){var e=this.playState;var a=this.currentPlayTimes;var r=this.currentTime;if(this._actionTimeline!==null&&this._frameCount<=1){this.playState=this._actionTimeline.playState>=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var i=this._animationState.playTimes;var n=i*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(i>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=i;if(t<0){this.currentTime=0}else{this.currentTime=this.playState===1?this._duration+1e-6:this._duration}}else{if(this.playState!==0&&this._animationState._playheadState===3){this.playState=0}if(t<0){t=-t;this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=this._duration-t%this._duration}else{this.currentPlayTimes=Math.floor(t/this._duration);this.currentTime=t%this._duration}}this.currentTime+=this._position}else{this.playState=this._actionTimeline.playState;this.currentPlayTimes=this._actionTimeline.currentPlayTimes;this.currentTime=this._actionTimeline.currentTime}if(this.currentPlayTimes===a&&this.currentTime===r){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==a){this._frameIndex=-1}return true};e.prototype.init=function(t,e,a){this._armature=t;this._animationState=e;this._timelineData=a;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._animationData=this._animationState.animationData;this._frameRate=this._animationData.parent.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;if(this._timelineData!==null){var r=this._animationData.parent.parent;this._frameArray=r.frameArray;this._timelineArray=r.timelineArray;this._frameIndices=r.frameIndices;this._frameCount=this._timelineArray[this._timelineData.offset+2];this._frameValueOffset=this._timelineArray[this._timelineData.offset+4];this._timeScale=100/this._timelineArray[this._timelineData.offset+0];this._timeOffset=this._timelineArray[this._timelineData.offset+1]*.01}};e.prototype.fadeOut=function(){this.dirty=false};e.prototype.update=function(t){if(this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var a=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==a){this._frameIndex=a;this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5+this._frameIndex];this._onArriveAtFrame()}}else if(this._frameIndex<0){this._frameIndex=0;if(this._timelineData!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[this._timelineData.offset+5]}this._onArriveAtFrame()}if(this._isTween||this.dirty){this._onUpdateFrame()}}};e.prototype.blend=function(t){};return e}(t.BaseObject);t.TimelineState=e;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,a){var r=e;switch(t){case 3:r=Math.pow(e,2);break;case 4:r=1-Math.pow(1-e,2);break;case 5:r=.5*(1-Math.cos(e*Math.PI));break}return(r-e)*a+e};e._getEasingCurveValue=function(t,e,a,r){if(t<=0){return 0}else if(t>=1){return 1}var i=a>0;var n=a+1;var s=Math.floor(t*n);var o=0;var l=0;if(i){o=s===0?0:e[r+s-1];l=s===n-1?1e4:e[r+s]}else{o=e[r+s-1];l=e[r+s]}return(o+(l-o)*(t*n-s))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenEasing=0;this._tweenProgress=0;this._valueScale=1};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){this._frameDurationR=1/e}else{this._frameDurationR=0}}}else{this.dirty=true;this._isTween=false}};e.prototype._onUpdateFrame=function(){if(this._isTween){this.dirty=true;this._tweenProgress=(this.currentTime-this._framePosition)*this._frameDurationR;if(this._tweenType===2){this._tweenProgress=e._getEasingCurveValue(this._tweenProgress,this._frameArray,this._curveCount,this._frameOffset+3)}else if(this._tweenType!==1){this._tweenProgress=e._getEasingValue(this._tweenType,this._tweenProgress,this._tweenEasing)}}};return e}(e);t.TweenTimelineState=a;var r=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._current=0;this._difference=0;this._result=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+1;if(t===1){this._current=e[a];this._difference=e[r]-this._current}else{this._current=e[a]*t;this._difference=e[r]*t-this._current}}else{this._result=e[a]*t}}else{this._result=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._result=this._current+this._difference*this._tweenProgress}};return t}(a);t.SingleValueTimelineState=r;var i=function(i){__extends(t,i);function t(){return i!==null&&i.apply(this,arguments)||this}t.prototype._onClear=function(){i.prototype._onClear.call(this);this._currentA=0;this._currentB=0;this._differenceA=0;this._differenceB=0;this._resultA=0;this._resultB=0};t.prototype._onArriveAtFrame=function(){i.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._valueScale;var e=this._valueArray;var a=this._valueOffset+this._frameValueOffset+this._frameIndex*2;if(this._isTween){var r=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:a+2;if(t===1){this._currentA=e[a];this._currentB=e[a+1];this._differenceA=e[r]-this._currentA;this._differenceB=e[r+1]-this._currentB}else{this._currentA=e[a]*t;this._currentB=e[a+1]*t;this._differenceA=e[r]*t-this._currentA;this._differenceB=e[r+1]*t-this._currentB}}else{this._resultA=e[a]*t;this._resultB=e[a+1]*t}}else{this._resultA=0;this._resultB=0}};t.prototype._onUpdateFrame=function(){i.prototype._onUpdateFrame.call(this);if(this._isTween){this._resultA=this._currentA+this._differenceA*this._tweenProgress;this._resultB=this._currentB+this._differenceB*this._tweenProgress}};return t}(a);t.DoubleValueTimelineState=i;var n=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._rd=[];return t}t.prototype._onClear=function(){o.prototype._onClear.call(this);this._valueCount=0;this._rd.length=0};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);var t=this._valueCount;var e=this._rd;if(this._timelineData!==null){var a=this._valueScale;var r=this._valueArray;var i=this._valueOffset+this._frameValueOffset+this._frameIndex*t;if(this._isTween){var n=this._frameIndex===this._frameCount-1?this._valueOffset+this._frameValueOffset:i+t;if(a===1){for(var s=0;s0){if(n.hasDBEventListener(y.EventObject.COMPLETE)){h=y.BaseObject.borrowObject(y.EventObject);h.type=y.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var u=this._timelineData;var f=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[u.frameIndicesOffset+f];if(this._frameIndex!==_){var m=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[u.offset+5+this._frameIndex];if(o){if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(m)}if(l!==null&&m===0){this._armature._dragonBones.bufferEvent(l);l=null}if(m>0){m--}else{m=this._frameCount-1}if(m===_){break}}}else{if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+c];var p=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[p]/this._frameRate;if(this.currentPlayTimes===a){if(r<=d){if(m>0){m--}else{m=this._frameCount-1}}else if(m===_){m=-1}}}while(m>=0){if(m=0){var t=this._frameArray[this._frameOffset+1];if(t>0){this._armature._sortZOrder(this._frameArray,this._frameOffset+2)}else{this._armature._sortZOrder(null,0)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.ZOrderTimelineState=e;var a=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])}if(this._timelineData===null){this._rd[4]=1;this._rd[5]=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=6;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._rd[2]=y.Transform.normalizeRadian(this._rd[2]);this._rd[3]=y.Transform.normalizeRadian(this._rd[3])};t.prototype.blend=function(t){var e=this._armature.armatureData.scale;var a=this._rd;var r=this.target;var i=r.target;var n=r.blendWeight;var s=i.animationPose;if(r.dirty>1){s.x+=a[0]*n*e;s.y+=a[1]*n*e;s.rotation+=a[2]*n;s.skew+=a[3]*n;s.scaleX+=(a[4]-1)*n;s.scaleY+=(a[5]-1)*n}else{s.x=a[0]*n*e;s.y=a[1]*n*e;s.rotation=a[2]*n;s.skew=a[3]*n;s.scaleX=(a[4]-1)*n+1;s.scaleY=(a[5]-1)*n+1}if(t||this.dirty){this.dirty=false;i._transformDirty=true}};return t}(y.MutilpleValueTimelineState);y.BoneAllTimelineState=a;var r=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneTranslateTimelineState]"};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.x+=this._resultA*r;i.y+=this._resultB*r}else if(r!==1){i.x=this._resultA*r;i.y=this._resultB*r}else{i.x=this._resultA;i.y=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneTranslateTimelineState=r;var i=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneRotateTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._isTween&&this._frameIndex===this._frameCount-1){this._differenceA=y.Transform.normalizeRadian(this._differenceA);this._differenceB=y.Transform.normalizeRadian(this._differenceB)}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.fadeOut=function(){this.dirty=false;this._resultA=y.Transform.normalizeRadian(this._resultA);this._resultB=y.Transform.normalizeRadian(this._resultB)};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.rotation+=this._resultA*r;i.skew+=this._resultB*r}else if(r!==1){i.rotation=this._resultA*r;i.skew=this._resultB*r}else{i.rotation=this._resultA;i.skew=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneRotateTimelineState=i;var n=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.BoneScaleTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){this._resultA=1;this._resultB=1}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameFloatOffset;this._valueArray=this._animationData.parent.parent.frameFloatArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a.animationPose;if(e.dirty>1){i.scaleX+=(this._resultA-1)*r;i.scaleY+=(this._resultB-1)*r}else if(r!==1){i.scaleX=(this._resultA-1)*r+1;i.scaleY=(this._resultB-1)*r+1}else{i.scaleX=this._resultA;i.scaleY=this._resultB}if(t||this.dirty){this.dirty=false;a._transformDirty=true}};return t}(y.DoubleValueTimelineState);y.BoneScaleTimelineState=n;var s=function(s){__extends(t,s);function t(){return s!==null&&s.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SurfaceTimelineState]"};t.prototype._onClear=function(){s.prototype._onClear.call(this);this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){s.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.parent.parent;var i=r.frameIntArray;var n=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];this._valueOffset=this._animationData.frameFloatOffset;this._valueCount=i[n+2];this._deformCount=i[n+1];this._deformOffset=i[n+3];this._sameValueOffset=i[n+4]+this._animationData.frameFloatOffset;this._valueScale=this._armature.armatureData.scale;this._valueArray=r.frameFloatArray;this._rd.length=this._valueCount*2}else{this._deformCount=this.target.target._deformVertices.length}};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;var i=a._deformVertices;var n=this._valueArray;if(n!==null){var s=this._valueCount;var o=this._deformOffset;var l=this._sameValueOffset;var h=this._rd;for(var u=0;u1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u1){a._alpha+=this._result*r;if(a._alpha>1){a._alpha=1}}else{a._alpha=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._alphaDirty=true}};return t}(y.SingleValueTimelineState);y.AlphaTimelineState=o;var l=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDisplayTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this.target;var e=this._timelineData!==null?this._frameArray[this._frameOffset+1]:t._slotData.displayIndex;if(t.displayIndex!==e){t._setDisplayIndex(e,true)}}};e.prototype._onUpdateFrame=function(){};return e}(y.TimelineState);y.SlotDisplayTimelineState=l;var h=function(o){__extends(t,o);function t(){var t=o!==null&&o.apply(this,arguments)||this;t._current=[0,0,0,0,0,0,0,0];t._difference=[0,0,0,0,0,0,0,0];t._result=[0,0,0,0,0,0,0,0];return t}t.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};t.prototype._onArriveAtFrame=function(){o.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._animationData.parent.parent;var e=t.colorArray;var a=t.frameIntArray;var r=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex;var i=a[r];if(i<0){i+=65536}if(this._isTween){this._current[0]=e[i++];this._current[1]=e[i++];this._current[2]=e[i++];this._current[3]=e[i++];this._current[4]=e[i++];this._current[5]=e[i++];this._current[6]=e[i++];this._current[7]=e[i++];if(this._frameIndex===this._frameCount-1){i=a[this._animationData.frameIntOffset+this._frameValueOffset]}else{i=a[r+1]}if(i<0){i+=65536}this._difference[0]=e[i++]-this._current[0];this._difference[1]=e[i++]-this._current[1];this._difference[2]=e[i++]-this._current[2];this._difference[3]=e[i++]-this._current[3];this._difference[4]=e[i++]-this._current[4];this._difference[5]=e[i++]-this._current[5];this._difference[6]=e[i++]-this._current[6];this._difference[7]=e[i++]-this._current[7]}else{this._result[0]=e[i++]*.01;this._result[1]=e[i++]*.01;this._result[2]=e[i++]*.01;this._result[3]=e[i++]*.01;this._result[4]=e[i++];this._result[5]=e[i++];this._result[6]=e[i++];this._result[7]=e[i++]}}else{var n=this.target;var s=n.slotData.color;this._result[0]=s.alphaMultiplier;this._result[1]=s.redMultiplier;this._result[2]=s.greenMultiplier;this._result[3]=s.blueMultiplier;this._result[4]=s.alphaOffset;this._result[5]=s.redOffset;this._result[6]=s.greenOffset;this._result[7]=s.blueOffset}};t.prototype._onUpdateFrame=function(){o.prototype._onUpdateFrame.call(this);if(this._isTween){this._result[0]=(this._current[0]+this._difference[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._difference[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._difference[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._difference[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._difference[4]*this._tweenProgress;this._result[5]=this._current[5]+this._difference[5]*this._tweenProgress;this._result[6]=this._current[6]+this._difference[6]*this._tweenProgress;this._result[7]=this._current[7]+this._difference[7]*this._tweenProgress}};t.prototype.fadeOut=function(){this._isTween=false};t.prototype.update=function(t){o.prototype.update.call(this,t);if(this._isTween||this.dirty){var e=this.target;var a=e._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){var r=Math.pow(this._animationState._fadeProgress,4);a.alphaMultiplier+=(this._result[0]-a.alphaMultiplier)*r;a.redMultiplier+=(this._result[1]-a.redMultiplier)*r;a.greenMultiplier+=(this._result[2]-a.greenMultiplier)*r;a.blueMultiplier+=(this._result[3]-a.blueMultiplier)*r;a.alphaOffset+=(this._result[4]-a.alphaOffset)*r;a.redOffset+=(this._result[5]-a.redOffset)*r;a.greenOffset+=(this._result[6]-a.greenOffset)*r;a.blueOffset+=(this._result[7]-a.blueOffset)*r;e._colorDirty=true}}else if(this.dirty){this.dirty=false;if(a.alphaMultiplier!==this._result[0]||a.redMultiplier!==this._result[1]||a.greenMultiplier!==this._result[2]||a.blueMultiplier!==this._result[3]||a.alphaOffset!==this._result[4]||a.redOffset!==this._result[5]||a.greenOffset!==this._result[6]||a.blueOffset!==this._result[7]){a.alphaMultiplier=this._result[0];a.redMultiplier=this._result[1];a.greenMultiplier=this._result[2];a.blueMultiplier=this._result[3];a.alphaOffset=this._result[4];a.redOffset=this._result[5];a.greenOffset=this._result[6];a.blueOffset=this._result[7];e._colorDirty=true}}}};return t}(y.TweenTimelineState);y.SlotColorTimelineState=h;var u=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.SlotZIndexTimelineState]"};t.prototype._onArriveAtFrame=function(){r.prototype._onArriveAtFrame.call(this);if(this._timelineData===null){var t=this.target;var e=t.target;this._result=e.slotData.zIndex}};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueArray=this._animationData.parent.parent.frameIntArray};t.prototype.blend=function(t){var e=this.target;var a=e.target;var r=e.blendWeight;if(e.dirty>1){a._zIndex+=this._result*r}else{a._zIndex=this._result*r}if(t||this.dirty){this.dirty=false;this._armature._zIndexDirty=true}};return t}(y.SingleValueTimelineState);y.SlotZIndexTimelineState=u;var f=function(f){__extends(t,f);function t(){return f!==null&&f.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.DeformTimelineState]"};t.prototype._onClear=function(){f.prototype._onClear.call(this);this.geometryOffset=0;this.displayFrame=null;this._deformCount=0;this._deformOffset=0;this._sameValueOffset=0};t.prototype.init=function(t,e,a){f.prototype.init.call(this,t,e,a);if(this._timelineData!==null){var r=this._animationData.frameIntOffset+this._timelineArray[this._timelineData.offset+3];var i=this._animationData.parent.parent;var n=i.frameIntArray;var s=this.target.target;this.geometryOffset=n[r+0];if(this.geometryOffset<0){this.geometryOffset+=65536}for(var o=0,l=s.displayFrameCount;o1){i[u]+=f*r}else{i[u]=f*r}}}else if(e.dirty===1){for(var u=0;u0;t._weight=this._currentB}else{var e=t._constraintData;t._bendPositive=e.bendPositive;t._weight=e.weight}t.invalidUpdate();this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=.01;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.IKConstraintTimelineState=_;var m=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationProgressTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.currentTime=this._result*t.totalTime}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationProgressTimelineState=m;var c=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationWeightTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.weight=this._result}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.SingleValueTimelineState);y.AnimationWeightTimelineState=c;var p=function(r){__extends(t,r);function t(){return r!==null&&r.apply(this,arguments)||this}t.toString=function(){return"[class dragonBones.AnimationParametersTimelineState]"};t.prototype._onUpdateFrame=function(){r.prototype._onUpdateFrame.call(this);var t=this.target;if(t._parent!==null){t.parameterX=this._resultA;t.parameterY=this._resultB}this.dirty=false};t.prototype.init=function(t,e,a){r.prototype.init.call(this,t,e,a);this._valueOffset=this._animationData.frameIntOffset;this._valueScale=1e-4;this._valueArray=this._animationData.parent.parent.frameIntArray};return t}(y.DoubleValueTimelineState);y.AnimationParametersTimelineState=p})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(t){__extends(r,t);function r(){return t!==null&&t.apply(this,arguments)||this}r.actionDataToInstance=function(t,e,a){if(t.type===0){e.type=r.FRAME_EVENT}else{e.type=t.type===10?r.FRAME_EVENT:r.SOUND_EVENT}e.name=t.name;e.armature=a;e.actionData=t;e.data=t.data;if(t.bone!==null){e.bone=a.getBone(t.bone.name)}if(t.slot!==null){e.slot=a.getSlot(t.slot.name)}};r.toString=function(){return"[class dragonBones.EventObject]"};r.prototype._onClear=function(){this.time=0;this.type="";this.name="";this.armature=null;this.bone=null;this.slot=null;this.animationState=null;this.actionData=null;this.data=null};r.START="start";r.LOOP_COMPLETE="loopComplete";r.COMPLETE="complete";r.FADE_IN="fadeIn";r.FADE_IN_COMPLETE="fadeInComplete";r.FADE_OUT="fadeOut";r.FADE_OUT_COMPLETE="fadeOutComplete";r.FRAME_EVENT="frameEvent";r.SOUND_EVENT="soundEvent";return r}(t.BaseObject);t.EventObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(){}t._getArmatureType=function(t){switch(t.toLowerCase()){case"stage":return 2;case"armature":return 0;case"movieclip":return 1;default:return 0}};t._getBoneType=function(t){switch(t.toLowerCase()){case"bone":return 0;case"surface":return 1;default:return 0}};t._getPositionMode=function(t){switch(t.toLocaleLowerCase()){case"percent":return 1;case"fixed":return 0;default:return 1}};t._getSpacingMode=function(t){switch(t.toLocaleLowerCase()){case"length":return 0;case"percent":return 2;case"fixed":return 1;default:return 0}};t._getRotateMode=function(t){switch(t.toLocaleLowerCase()){case"tangent":return 0;case"chain":return 1;case"chainscale":return 2;default:return 0}};t._getDisplayType=function(t){switch(t.toLowerCase()){case"image":return 0;case"mesh":return 2;case"armature":return 1;case"boundingbox":return 3;case"path":return 4;default:return 0}};t._getBoundingBoxType=function(t){switch(t.toLowerCase()){case"rectangle":return 0;case"ellipse":return 1;case"polygon":return 2;default:return 0}};t._getBlendMode=function(t){switch(t.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}};t._getAnimationBlendType=function(t){switch(t.toLowerCase()){case"none":return 0;case"1d":return 1;default:return 0}};t._getActionType=function(t){switch(t.toLowerCase()){case"play":return 0;case"frame":return 10;case"sound":return 11;default:return 0}};t.DATA_VERSION_2_3="2.3";t.DATA_VERSION_3_0="3.0";t.DATA_VERSION_4_0="4.0";t.DATA_VERSION_4_5="4.5";t.DATA_VERSION_5_0="5.0";t.DATA_VERSION_5_5="5.5";t.DATA_VERSION_5_6="5.6";t.DATA_VERSION=t.DATA_VERSION_5_6;t.DATA_VERSIONS=[t.DATA_VERSION_4_0,t.DATA_VERSION_4_5,t.DATA_VERSION_5_0,t.DATA_VERSION_5_5,t.DATA_VERSION_5_6];t.TEXTURE_ATLAS="textureAtlas";t.SUB_TEXTURE="SubTexture";t.FORMAT="format";t.IMAGE_PATH="imagePath";t.WIDTH="width";t.HEIGHT="height";t.ROTATED="rotated";t.FRAME_X="frameX";t.FRAME_Y="frameY";t.FRAME_WIDTH="frameWidth";t.FRAME_HEIGHT="frameHeight";t.DRADON_BONES="dragonBones";t.USER_DATA="userData";t.ARMATURE="armature";t.CANVAS="canvas";t.BONE="bone";t.SURFACE="surface";t.SLOT="slot";t.CONSTRAINT="constraint";t.SKIN="skin";t.DISPLAY="display";t.FRAME="frame";t.IK="ik";t.PATH_CONSTRAINT="path";t.ANIMATION="animation";t.TIMELINE="timeline";t.FFD="ffd";t.TRANSLATE_FRAME="translateFrame";t.ROTATE_FRAME="rotateFrame";t.SCALE_FRAME="scaleFrame";t.DISPLAY_FRAME="displayFrame";t.COLOR_FRAME="colorFrame";t.DEFAULT_ACTIONS="defaultActions";t.ACTIONS="actions";t.EVENTS="events";t.INTS="ints";t.FLOATS="floats";t.STRINGS="strings";t.TRANSFORM="transform";t.PIVOT="pivot";t.AABB="aabb";t.COLOR="color";t.VERSION="version";t.COMPATIBLE_VERSION="compatibleVersion";t.FRAME_RATE="frameRate";t.TYPE="type";t.SUB_TYPE="subType";t.NAME="name";t.PARENT="parent";t.TARGET="target";t.STAGE="stage";t.SHARE="share";t.PATH="path";t.LENGTH="length";t.DISPLAY_INDEX="displayIndex";t.Z_ORDER="zOrder";t.Z_INDEX="zIndex";t.BLEND_MODE="blendMode";t.INHERIT_TRANSLATION="inheritTranslation";t.INHERIT_ROTATION="inheritRotation";t.INHERIT_SCALE="inheritScale";t.INHERIT_REFLECTION="inheritReflection";t.INHERIT_ANIMATION="inheritAnimation";t.INHERIT_DEFORM="inheritDeform";t.SEGMENT_X="segmentX";t.SEGMENT_Y="segmentY";t.BEND_POSITIVE="bendPositive";t.CHAIN="chain";t.WEIGHT="weight";t.BLEND_TYPE="blendType";t.FADE_IN_TIME="fadeInTime";t.PLAY_TIMES="playTimes";t.SCALE="scale";t.OFFSET="offset";t.POSITION="position";t.DURATION="duration";t.TWEEN_EASING="tweenEasing";t.TWEEN_ROTATE="tweenRotate";t.TWEEN_SCALE="tweenScale";t.CLOCK_WISE="clockwise";t.CURVE="curve";t.SOUND="sound";t.EVENT="event";t.ACTION="action";t.X="x";t.Y="y";t.SKEW_X="skX";t.SKEW_Y="skY";t.SCALE_X="scX";t.SCALE_Y="scY";t.VALUE="value";t.ROTATE="rotate";t.SKEW="skew";t.ALPHA="alpha";t.ALPHA_OFFSET="aO";t.RED_OFFSET="rO";t.GREEN_OFFSET="gO";t.BLUE_OFFSET="bO";t.ALPHA_MULTIPLIER="aM";t.RED_MULTIPLIER="rM";t.GREEN_MULTIPLIER="gM";t.BLUE_MULTIPLIER="bM";t.UVS="uvs";t.VERTICES="vertices";t.TRIANGLES="triangles";t.WEIGHTS="weights";t.SLOT_POSE="slotPose";t.BONE_POSE="bonePose";t.BONES="bones";t.POSITION_MODE="positionMode";t.SPACING_MODE="spacingMode";t.ROTATE_MODE="rotateMode";t.SPACING="spacing";t.ROTATE_OFFSET="rotateOffset";t.ROTATE_MIX="rotateMix";t.TRANSLATE_MIX="translateMix";t.TARGET_DISPLAY="targetDisplay";t.CLOSED="closed";t.CONSTANT_SPEED="constantSpeed";t.VERTEX_COUNT="vertexCount";t.LENGTHS="lengths";t.GOTO_AND_PLAY="gotoAndPlay";t.DEFAULT_NAME="default";return t}();t.DataParser=e})(dragonBones||(dragonBones={}));var dragonBones;(function(tt){var t=function(e){__extends($,e);function $(){var t=e!==null&&e.apply(this,arguments)||this;t._rawTextureAtlasIndex=0;t._rawBones=[];t._data=null;t._armature=null;t._bone=null;t._geometry=null;t._slot=null;t._skin=null;t._mesh=null;t._animation=null;t._timeline=null;t._rawTextureAtlases=null;t._frameValueType=0;t._defaultColorOffset=-1;t._prevClockwise=0;t._prevRotation=0;t._frameDefaultValue=0;t._frameValueScale=1;t._helpMatrixA=new tt.Matrix;t._helpMatrixB=new tt.Matrix;t._helpTransform=new tt.Transform;t._helpColorTransform=new tt.ColorTransform;t._helpPoint=new tt.Point;t._helpArray=[];t._intArray=[];t._floatArray=[];t._frameIntArray=[];t._frameFloatArray=[];t._frameArray=[];t._timelineArray=[];t._colorArray=[];t._cacheRawMeshes=[];t._cacheMeshes=[];t._actionFrames=[];t._weightSlotPose={};t._weightBonePoses={};t._cacheBones={};t._slotChildActions={};return t}$._getBoolean=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="boolean"){return r}else if(i==="string"){switch(r){case"0":case"NaN":case"":case"false":case"null":case"undefined":return false;default:return true}}else{return!!r}}return a};$._getNumber=function(t,e,a){if(e in t){var r=t[e];if(r===null||r==="NaN"){return a}return+r||0}return a};$._getString=function(t,e,a){if(e in t){var r=t[e];var i=typeof r;if(i==="string"){return r}return String(r)}return a};$.prototype._getCurvePoint=function(t,e,a,r,i,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var m=u*f;var c=3*l*f;var p=3*u*_;var d=l*_;h.x=m*t+c*a+p*i+d*s;h.y=m*e+c*r+p*n+d*o};$.prototype._samplingEasingCurve=function(t,e){var a=t.length;if(a%3===1){var r=-2;for(var i=0,n=e.length;i=0&&r+61e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return true}else{var r=0;for(var i=0,n=e.length;i1e-4){var v=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,v,this._helpPoint);if(s-this._helpPoint.x>0){d=v}else{y=v}}e[i]=this._helpPoint.y}return false}};$.prototype._parseActionDataInFrame=function(t,e,a,r){if(tt.DataParser.EVENT in t){this._mergeActionFrame(t[tt.DataParser.EVENT],e,10,a,r)}if(tt.DataParser.SOUND in t){this._mergeActionFrame(t[tt.DataParser.SOUND],e,11,a,r)}if(tt.DataParser.ACTION in t){this._mergeActionFrame(t[tt.DataParser.ACTION],e,0,a,r)}if(tt.DataParser.EVENTS in t){this._mergeActionFrame(t[tt.DataParser.EVENTS],e,10,a,r)}if(tt.DataParser.ACTIONS in t){this._mergeActionFrame(t[tt.DataParser.ACTIONS],e,0,a,r)}};$.prototype._mergeActionFrame=function(t,e,a,r,i){var n=this._armature.actions.length;var s=this._parseActionData(t,a,r,i);var o=0;var l=null;for(var h=0,u=s;he){break}o++}if(l===null){l=new D;l.frameStart=e;this._actionFrames.splice(o,0,l)}for(var p=0;p0){var _=a.getBone(u);if(_!==null){f.parent=_}else{if(!(u in this._cacheBones)){this._cacheBones[u]=[]}this._cacheBones[u].push(f)}}if(f.name in this._cacheBones){for(var m=0,c=this._cacheBones[f.name];m0&&e.parent!==null){i.root=e.parent;i.bone=e}else{i.root=e;i.bone=null}return i};$.prototype._parsePathConstraint=function(t){var e=this._armature.getSlot($._getString(t,tt.DataParser.TARGET,""));if(e===null){return null}var a=this._armature.defaultSkin;if(a===null){return null}var r=a.getDisplay(e.name,$._getString(t,tt.DataParser.TARGET_DISPLAY,e.name));if(r===null||!(r instanceof tt.PathDisplayData)){return null}var i=t[tt.DataParser.BONES];if(i===null||i.length===0){return null}var n=tt.BaseObject.borrowObject(tt.PathConstraintData);n.name=$._getString(t,tt.DataParser.NAME,"");n.type=1;n.pathSlot=e;n.pathDisplayData=r;n.target=e.parent;n.positionMode=tt.DataParser._getPositionMode($._getString(t,tt.DataParser.POSITION_MODE,""));n.spacingMode=tt.DataParser._getSpacingMode($._getString(t,tt.DataParser.SPACING_MODE,""));n.rotateMode=tt.DataParser._getRotateMode($._getString(t,tt.DataParser.ROTATE_MODE,""));n.position=$._getNumber(t,tt.DataParser.POSITION,0);n.spacing=$._getNumber(t,tt.DataParser.SPACING,0);n.rotateOffset=$._getNumber(t,tt.DataParser.ROTATE_OFFSET,0);n.rotateMix=$._getNumber(t,tt.DataParser.ROTATE_MIX,1);n.translateMix=$._getNumber(t,tt.DataParser.TRANSLATE_MIX,1);for(var s=0,o=i;s0?a:e;this._parsePivot(t,n);break}case 1:{var s=i=tt.BaseObject.borrowObject(tt.ArmatureDisplayData);s.name=e;s.path=a.length>0?a:e;s.inheritAnimation=true;if(tt.DataParser.ACTIONS in t){var o=this._parseActionData(t[tt.DataParser.ACTIONS],0,null,null);for(var l=0,h=o;l0?a:e;if(tt.DataParser.SHARE in t){c.geometry.data=this._data;this._cacheRawMeshes.push(t);this._cacheMeshes.push(c)}else{this._parseMesh(t,c)}break}case 3:{var p=this._parseBoundingBox(t);if(p!==null){var d=i=tt.BaseObject.borrowObject(tt.BoundingBoxDisplayData);d.name=e;d.path=a.length>0?a:e;d.boundingBox=p}break}case 4:{var y=t[tt.DataParser.LENGTHS];var v=i=tt.BaseObject.borrowObject(tt.PathDisplayData);v.closed=$._getBoolean(t,tt.DataParser.CLOSED,false);v.constantSpeed=$._getBoolean(t,tt.DataParser.CONSTANT_SPEED,false);v.name=e;v.path=a.length>0?a:e;v.curveLengths.length=y.length;for(var g=0,D=y.length;ge.width){e.width=o}if(le.height){e.height=l}}}e.width-=e.x;e.height-=e.y}else{console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.")}return e};$.prototype._parseAnimation=function(t){var e=tt.BaseObject.borrowObject(tt.AnimationData);e.blendType=tt.DataParser._getAnimationBlendType($._getString(t,tt.DataParser.BLEND_TYPE,""));e.frameCount=$._getNumber(t,tt.DataParser.DURATION,0);e.playTimes=$._getNumber(t,tt.DataParser.PLAY_TIMES,1);e.duration=e.frameCount/this._armature.frameRate;e.fadeInTime=$._getNumber(t,tt.DataParser.FADE_IN_TIME,0);e.scale=$._getNumber(t,tt.DataParser.SCALE,1);e.name=$._getString(t,tt.DataParser.NAME,tt.DataParser.DEFAULT_NAME);if(e.name.length===0){e.name=tt.DataParser.DEFAULT_NAME}e.frameIntOffset=this._frameIntArray.length;e.frameFloatOffset=this._frameFloatArray.length;e.frameOffset=this._frameArray.length;this._animation=e;if(tt.DataParser.FRAME in t){var a=t[tt.DataParser.FRAME];var r=a.length;if(r>0){for(var i=0,n=0;i0){this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,0,0,this._parseActionFrame);this._actionFrames.length=0}if(tt.DataParser.TIMELINE in t){var o=t[tt.DataParser.TIMELINE];for(var A=0,S=o;A0&&a in t){e=t[a]}if(e===null){return null}var l=e.length;if(l===0){return null}var h=this._frameIntArray.length;var u=this._frameFloatArray.length;var f=this._timelineArray.length;if(o===null){o=tt.BaseObject.borrowObject(tt.TimelineData)}o.type=r;o.offset=f;this._frameValueType=i;this._timeline=o;this._timelineArray.length+=1+1+1+1+1+l;if(t!==null){this._timelineArray[f+0]=Math.round($._getNumber(t,tt.DataParser.SCALE,1)*100);this._timelineArray[f+1]=Math.round($._getNumber(t,tt.DataParser.OFFSET,0)*100)}else{this._timelineArray[f+0]=100;this._timelineArray[f+1]=0}this._timelineArray[f+2]=l;this._timelineArray[f+3]=n;switch(this._frameValueType){case 0:this._timelineArray[f+4]=0;break;case 1:this._timelineArray[f+4]=h-this._animation.frameIntOffset;break;case 2:this._timelineArray[f+4]=u-this._animation.frameFloatOffset;break}if(l===1){o.frameIndicesOffset=-1;this._timelineArray[f+5+0]=s.call(this,e[0],0,0)-this._animation.frameOffset}else{var _=this._animation.frameCount+1;var m=this._data.frameIndices;var c=m.length;m.length+=_;o.frameIndicesOffset=c;for(var p=0,d=0,y=0,v=0;p<_;++p){if(y+v<=p&&d0){if(tt.DataParser.CURVE in t){var i=a+1;this._helpArray.length=i;var n=this._samplingEasingCurve(t[tt.DataParser.CURVE],this._helpArray);this._frameArray.length+=1+1+this._helpArray.length;this._frameArray[r+1]=2;this._frameArray[r+2]=n?i:-i;for(var s=0;s0){var n=this._armature.sortedSlots.length;var s=new Array(n-i.length/2);var o=new Array(n);for(var l=0;l0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.TWEEN_ROTATE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=6;this._frameFloatArray[n++]=this._helpTransform.x;this._frameFloatArray[n++]=this._helpTransform.y;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=this._helpTransform.skew;this._frameFloatArray[n++]=this._helpTransform.scaleX;this._frameFloatArray[n++]=this._helpTransform.scaleY;this._parseActionDataInFrame(t,e,this._bone,this._slot);return i};$.prototype._parseBoneTranslateFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,0);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,0);return r};$.prototype._parseBoneRotateFrame=function(t,e,a){var r=$._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD;if(e!==0){if(this._prevClockwise===0){r=this._prevRotation+tt.Transform.normalizeRadian(r-this._prevRotation)}else{if(this._prevClockwise>0?r>=this._prevRotation:r<=this._prevRotation){this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1}r=this._prevRotation+r-this._prevRotation+tt.Transform.PI_D*this._prevClockwise}}this._prevClockwise=$._getNumber(t,tt.DataParser.CLOCK_WISE,0);this._prevRotation=r;var i=this._parseTweenFrame(t,e,a);var n=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[n++]=r;this._frameFloatArray[n++]=$._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD;return i};$.prototype._parseBoneScaleFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=this._frameFloatArray.length;this._frameFloatArray.length+=2;this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.X,1);this._frameFloatArray[i++]=$._getNumber(t,tt.DataParser.Y,1);return r};$.prototype._parseSlotDisplayFrame=function(t,e,a){var r=this._parseFrame(t,e,a);this._frameArray.length+=1;if(tt.DataParser.VALUE in t){this._frameArray[r+1]=$._getNumber(t,tt.DataParser.VALUE,0)}else{this._frameArray[r+1]=$._getNumber(t,tt.DataParser.DISPLAY_INDEX,0)}this._parseActionDataInFrame(t,e,this._slot.parent,this._slot);return r};$.prototype._parseSlotColorFrame=function(t,e,a){var r=this._parseTweenFrame(t,e,a);var i=-1;if(tt.DataParser.VALUE in t||tt.DataParser.COLOR in t){var n=tt.DataParser.VALUE in t?t[tt.DataParser.VALUE]:t[tt.DataParser.COLOR];for(var s in n){s;this._parseColorTransform(n,this._helpColorTransform);i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=Math.round(this._helpColorTransform.alphaMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.redMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.greenMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.blueMultiplier*100);this._colorArray[i++]=Math.round(this._helpColorTransform.alphaOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.redOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.greenOffset);this._colorArray[i++]=Math.round(this._helpColorTransform.blueOffset);i-=8;break}}if(i<0){if(this._defaultColorOffset<0){this._defaultColorOffset=i=this._colorArray.length;this._colorArray.length+=8;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=100;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0;this._colorArray[i++]=0}i=this._defaultColorOffset}var o=this._frameIntArray.length;this._frameIntArray.length+=1;this._frameIntArray[o]=i;return r};$.prototype._parseSlotDeformFrame=function(t,e,a){var r=this._frameFloatArray.length;var i=this._parseTweenFrame(t,e,a);var n=tt.DataParser.VERTICES in t?t[tt.DataParser.VERTICES]:null;var s=$._getNumber(t,tt.DataParser.OFFSET,0);var o=this._intArray[this._mesh.geometry.offset+0];var l=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name;var h=this._mesh.geometry.weight;var u=0;var f=0;var _=0;var m=0;if(h!==null){var c=this._weightSlotPose[l];this._helpMatrixA.copyFromArray(c,0);this._frameFloatArray.length+=h.count*2;_=h.offset+2+h.bones.length}else{this._frameFloatArray.length+=o*2}for(var p=0;p=n.length){u=0}else{u=n[p-s]}if(p+1=n.length){f=0}else{f=n[p+1-s]}}if(h!==null){var d=this._weightBonePoses[l];var y=this._intArray[_++];this._helpMatrixA.transformPoint(u,f,this._helpPoint,true);u=this._helpPoint.x;f=this._helpPoint.y;for(var v=0;v=n.length){h=0}else{h=n[f-s]}if(f+1=n.length){u=0}else{u=n[f+1-s]}}else{h=0;u=0}this._frameFloatArray[r+f]=h;this._frameFloatArray[r+f+1]=u}}if(e===0){var _=this._frameIntArray.length;this._frameIntArray.length+=1+1+1+1+1;this._frameIntArray[_+0]=this._geometry.offset;this._frameIntArray[_+1]=this._frameFloatArray.length-r;this._frameIntArray[_+2]=this._frameFloatArray.length-r;this._frameIntArray[_+3]=0;this._frameIntArray[_+4]=r-this._animation.frameFloatOffset;this._timelineArray[this._timeline.offset+3]=_-this._animation.frameIntOffset}return i};$.prototype._parseTransform=function(t,e,a){e.x=$._getNumber(t,tt.DataParser.X,0)*a;e.y=$._getNumber(t,tt.DataParser.Y,0)*a;if(tt.DataParser.ROTATE in t||tt.DataParser.SKEW in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.ROTATE,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW,0)*tt.Transform.DEG_RAD)}else if(tt.DataParser.SKEW_X in t||tt.DataParser.SKEW_Y in t){e.rotation=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_Y,0)*tt.Transform.DEG_RAD);e.skew=tt.Transform.normalizeRadian($._getNumber(t,tt.DataParser.SKEW_X,0)*tt.Transform.DEG_RAD)-e.rotation}e.scaleX=$._getNumber(t,tt.DataParser.SCALE_X,1);e.scaleY=$._getNumber(t,tt.DataParser.SCALE_Y,1)};$.prototype._parseColorTransform=function(t,e){e.alphaMultiplier=$._getNumber(t,tt.DataParser.ALPHA_MULTIPLIER,100)*.01;e.redMultiplier=$._getNumber(t,tt.DataParser.RED_MULTIPLIER,100)*.01;e.greenMultiplier=$._getNumber(t,tt.DataParser.GREEN_MULTIPLIER,100)*.01;e.blueMultiplier=$._getNumber(t,tt.DataParser.BLUE_MULTIPLIER,100)*.01;e.alphaOffset=$._getNumber(t,tt.DataParser.ALPHA_OFFSET,0);e.redOffset=$._getNumber(t,tt.DataParser.RED_OFFSET,0);e.greenOffset=$._getNumber(t,tt.DataParser.GREEN_OFFSET,0);e.blueOffset=$._getNumber(t,tt.DataParser.BLUE_OFFSET,0)};$.prototype._parseGeometry=function(t,e){var a=t[tt.DataParser.VERTICES];var r=Math.floor(a.length/2);var i=0;var n=this._intArray.length;var s=this._floatArray.length;e.offset=n;e.data=this._data;this._intArray.length+=1+1+1+1;this._intArray[n+0]=r;this._intArray[n+2]=s;this._intArray[n+3]=-1;this._floatArray.length+=r*2;for(var o=0,l=r*2;o=0||tt.DataParser.DATA_VERSIONS.indexOf(r)>=0){var i=tt.BaseObject.borrowObject(tt.DragonBonesData);i.version=a;i.name=$._getString(t,tt.DataParser.NAME,"");i.frameRate=$._getNumber(t,tt.DataParser.FRAME_RATE,24);if(i.frameRate===0){i.frameRate=24}if(tt.DataParser.ARMATURE in t){this._data=i;this._parseArray(t);var n=t[tt.DataParser.ARMATURE];for(var s=0,o=n;s0){i.stage=i.getArmature(i.armatureNames[0])}this._data=null}if(tt.DataParser.TEXTURE_ATLAS in t){this._rawTextureAtlases=t[tt.DataParser.TEXTURE_ATLAS]}return i}else{console.assert(false,"Nonsupport data version: "+a+"\n"+"Please convert DragonBones data to support version.\n"+"Read more: https://github.com/DragonBones/Tools/")}return null};$.prototype.parseTextureAtlasData=function(t,e,a){if(a===void 0){a=1}console.assert(t!==undefined);if(t===null){if(this._rawTextureAtlases===null||this._rawTextureAtlases.length===0){return false}var r=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(r,e,a);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}e.width=$._getNumber(t,tt.DataParser.WIDTH,0);e.height=$._getNumber(t,tt.DataParser.HEIGHT,0);e.scale=a===1?1/$._getNumber(t,tt.DataParser.SCALE,1):a;e.name=$._getString(t,tt.DataParser.NAME,"");e.imagePath=$._getString(t,tt.DataParser.IMAGE_PATH,"");if(tt.DataParser.SUB_TEXTURE in t){var i=t[tt.DataParser.SUB_TEXTURE];for(var n=0,s=i.length;n0&&h>0){u.frame=tt.TextureData.createRectangle();u.frame.x=$._getNumber(o,tt.DataParser.FRAME_X,0);u.frame.y=$._getNumber(o,tt.DataParser.FRAME_Y,0);u.frame.width=l;u.frame.height=h}e.addTexture(u)}}return true};$.getInstance=function(){if($._objectDataParserInstance===null){$._objectDataParserInstance=new $}return $._objectDataParserInstance};$._objectDataParserInstance=null;return $}(tt.DataParser);tt.ObjectDataParser=t;var D=function(){function t(){this.frameStart=0;this.actions=[]}return t}();tt.ActionFrame=D})(dragonBones||(dragonBones={}));var dragonBones;(function(g){var t=function(o){__extends(t,o);function t(){return o!==null&&o.apply(this,arguments)||this}t.prototype._inRange=function(t,e,a){return e<=t&&t<=a};t.prototype._decodeUTF8=function(t){var e=-1;var a=-1;var r=65533;var i=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>i){var f=t[i++];if(f===e){if(l!==0){s=r}else{s=a}}else{if(l===0){if(this._inRange(f,0,127)){s=f}else{if(this._inRange(f,194,223)){l=1;u=128;o=f-192}else if(this._inRange(f,224,239)){l=2;u=2048;o=f-224}else if(this._inRange(f,240,244)){l=3;u=65536;o=f-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(f,128,191)){o=0;l=0;h=0;u=0;i--;s=f}else{h+=1;o=o+(f-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var m=u;o=0;l=0;h=0;u=0;if(this._inRange(_,m,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=f}}}}if(s!==null&&s!==a){if(s<=65535){if(s>0)n+=String.fromCharCode(s)}else{s-=65536;n+=String.fromCharCode(55296+(s>>10&1023));n+=String.fromCharCode(56320+(s&1023))}}}return n};t.prototype._parseBinaryTimeline=function(t,e,a){if(a===void 0){a=null}var r=a!==null?a:g.BaseObject.borrowObject(g.TimelineData);r.type=t;r.offset=e;this._timeline=r;var i=this._timelineArrayBuffer[r.offset+2];if(i===1){r.frameIndicesOffset=-1}else{var n=0;var s=this._animation.frameCount+1;var o=this._data.frameIndices;n=o.length;o.length+=s;r.frameIndicesOffset=n;for(var l=0,h=0,u=0,f=0;l=0){var h=g.ObjectDataParser._getNumber(d,g.DataParser.TYPE,0);var y=g.ObjectDataParser._getString(d,g.DataParser.NAME,"");var f=null;if(h===40&&e.blendType!==0){f=g.BaseObject.borrowObject(g.AnimationTimelineData);var v=f;v.x=g.ObjectDataParser._getNumber(d,g.DataParser.X,0);v.y=g.ObjectDataParser._getNumber(d,g.DataParser.Y,0)}f=this._parseBinaryTimeline(h,u,f);switch(h){case 0:break;case 1:break;case 11:case 12:case 13:case 50:case 60:this._animation.addBoneTimeline(y,f);break;case 20:case 21:case 22:case 23:case 24:this._animation.addSlotTimeline(y,f);break;case 30:this._animation.addConstraintTimeline(y,f);break;case 40:case 41:case 42:this._animation.addAnimationTimeline(y,f);break}}}}this._animation=null;return e};t.prototype._parseGeometry=function(t,e){e.offset=t[g.DataParser.OFFSET];e.data=this._data;var a=this._intArrayBuffer[e.offset+3];if(a>=0){var r=g.BaseObject.borrowObject(g.WeightData);var i=this._intArrayBuffer[e.offset+0];var n=this._intArrayBuffer[a+0];r.offset=a;for(var s=0;s12?e[13]:0;var h=new Int16Array(this._binary,this._binaryOffset+e[0],a/Int16Array.BYTES_PER_ELEMENT);var u=new Float32Array(this._binary,this._binaryOffset+e[2],r/Float32Array.BYTES_PER_ELEMENT);var f=new Int16Array(this._binary,this._binaryOffset+e[4],i/Int16Array.BYTES_PER_ELEMENT);var _=new Float32Array(this._binary,this._binaryOffset+e[6],n/Float32Array.BYTES_PER_ELEMENT);var m=new Int16Array(this._binary,this._binaryOffset+e[8],s/Int16Array.BYTES_PER_ELEMENT);var c=new Uint16Array(this._binary,this._binaryOffset+e[10],o/Uint16Array.BYTES_PER_ELEMENT);var p=l>0?new Int16Array(this._binary,this._binaryOffset+e[12],l/Int16Array.BYTES_PER_ELEMENT):h;this._data.binary=this._binary;this._data.intArray=this._intArrayBuffer=h;this._data.floatArray=u;this._data.frameIntArray=f;this._data.frameFloatArray=_;this._data.frameArray=this._frameArrayBuffer=m;this._data.timelineArray=this._timelineArrayBuffer=c;this._data.colorArray=p};t.prototype.parseDragonBonesData=function(t,e){if(e===void 0){e=1}console.assert(t!==null&&t!==undefined&&t instanceof ArrayBuffer,"Data error.");var a=new Uint8Array(t,0,8);if(a[0]!=="D".charCodeAt(0)||a[1]!=="B".charCodeAt(0)||a[2]!=="D".charCodeAt(0)||a[3]!=="T".charCodeAt(0)){console.assert(false,"Nonsupport data.");return null}var r=new Uint32Array(t,8,1)[0];var i=new Uint8Array(t,8+4,r);var n=this._decodeUTF8(i);var s=JSON.parse(n);this._binaryOffset=8+4+r;this._binary=t;return o.prototype.parseDragonBonesData.call(this,s,e)};t.getInstance=function(){if(t._binaryDataParserInstance===null){t._binaryDataParserInstance=new t}return t._binaryDataParserInstance};t._binaryDataParserInstance=null;return t}(g.ObjectDataParser);g.BinaryDataParser=t})(dragonBones||(dragonBones={}));var dragonBones;(function(y){var t=function(){function s(t){if(t===void 0){t=null}this.autoSearch=false;this._dragonBonesDataMap={};this._textureAtlasDataMap={};this._dragonBones=null;this._dataParser=null;if(s._objectParser===null){s._objectParser=new y.ObjectDataParser}if(s._binaryParser===null){s._binaryParser=new y.BinaryDataParser}this._dataParser=t!==null?t:s._objectParser}s.prototype._isSupportMesh=function(){return true};s.prototype._getTextureData=function(t,e){if(t in this._textureAtlasDataMap){for(var a=0,r=this._textureAtlasDataMap[t];a0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(a)}}if(s===null&&(e.length===0||this.autoSearch)){for(var o in this._dragonBonesDataMap){n=this._dragonBonesDataMap[o];if(e.length===0||n.autoSearch){s=n.getArmature(a);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=i;t.data=n;t.armature=s;t.skin=null;if(r.length>0){t.skin=s.getSkin(r);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(r);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};s.prototype._buildBones=function(t,e){for(var a=0,r=t.armature.sortedBones;a0){var p=this._getTextureData(t.textureAtlasName,c.path);f.replaceTextureData(p,_)}var d=this._getSlotDisplay(t,c,f);f.replaceDisplay(d,_)}else{f.replaceDisplay(null)}}}f._setDisplayIndex(h.displayIndex,true)}};s.prototype._buildConstraints=function(t,e){var a=t.armature.constraints;for(var r in a){var i=a[r];switch(i.type){case 0:var n=y.BaseObject.borrowObject(y.IKConstraint);n.init(i,e);e._addConstraint(n);break;case 1:var s=y.BaseObject.borrowObject(y.PathConstraint);s.init(i,e);e._addConstraint(s);break;default:var o=y.BaseObject.borrowObject(y.IKConstraint);o.init(i,e);e._addConstraint(o);break}}};s.prototype._buildChildArmature=function(t,e,a){return this.buildArmature(a.path,t!==null?t.dataName:"","",t!==null?t.textureAtlasName:"")};s.prototype._getSlotDisplay=function(t,e,a){var r=t!==null?t.dataName:e.parent.parent.parent.name;var i=null;switch(e.type){case 0:{var n=e;if(n.texture===null){n.texture=this._getTextureData(r,e.path)}i=a.rawDisplay;break}case 2:{var s=e;if(s.texture===null){s.texture=this._getTextureData(r,s.path)}if(this._isSupportMesh()){i=a.meshDisplay}else{i=a.rawDisplay}break}case 1:{var o=e;var l=this._buildChildArmature(t,a,o);if(l!==null){l.inheritAnimation=o.inheritAnimation;if(!l.inheritAnimation){var h=o.actions.length>0?o.actions:l.armatureData.defaultActions;if(h.length>0){for(var u=0,f=h;u=0){continue}var h=e.getDisplays(l.name);if(h===null){if(n!==null&&e!==n){h=n.getDisplays(l.name)}if(h===null){if(a){l.displayFrameCount=0}continue}}l.displayFrameCount=h.length;for(var u=0,f=l.displayFrameCount;u=0&&this._display!==null&&t!==null){var a=t.parent;if(this._armature.replacedTexture!==null){if(this._armature._replaceTextureAtlasData===null){a=k.BaseObject.borrowObject(k.CocosTextureAtlasData);a.copyFrom(t.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}t=a.getTexture(t.name)}var r=t.renderTexture;if(r!==null){if(this._geometryData!==null){var i=this._geometryData.data;var n=i.intArray;var s=i.floatArray;var o=n[this._geometryData.offset+0];var l=n[this._geometryData.offset+1];var h=n[this._geometryData.offset+2];if(h<0){h+=65536}var u=h+o*2;var f=this._armature._armatureData.scale;var _=r.getTexture().getContentSizeInPixels();var m=a.width>0?a.width:_.width;var c=a.height>0?a.height:_.height;var p=t.region;var d=cc.rect(999999,999999,-999999,-999999);var y={triangles:{verts:[],indices:[]},rect:d};for(var v=0,g=o*2;vD.x){d.x=D.x}if(d.widthD.y){d.y=D.y}if(d.height0&&r.inheritDeform;var s=this._renderDisplay.getComponent(cc.Sprite)._sgNode;var o=s.getMeshPolygonInfo();if(!o){return}var l=o.triangles.verts;var h=cc.rect(999999,999999,-999999,-999999);if(i!==null){var u=r.data;var f=u.intArray;var _=u.floatArray;var m=f[r.offset+0];var c=f[i.offset+1];if(c<0){c+=65536}for(var p=0,d=i.offset+2+a.length,y=c,v=0;pD){h.x=D}if(h.widthT){h.y=T}if(h.heightw){h.x=w}if(h.widthN){h.y=N}if(h.height = []; @@ -180,7 +175,6 @@ namespace dragonBones { displayName: "Animation", tooltip: "The animation name.", visible: true, - editorOnly: true, serializable: false, }) public readonly _animationNames: Array = []; @@ -209,6 +203,8 @@ namespace dragonBones { }) public _timeScale: number = 1.0; + _dragonBonesNode: cc.Node; + _loadAndDisplayDragonBones() { console.warn(`开始创建 DragonBones Armature`); let notExistAsset = !this.dragonBonesAsset @@ -233,14 +229,14 @@ namespace dragonBones { dragonBonesData = this.dragonBonesAsset.dragonBonesData; } let data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); - if (data === null) { + if (!data) { console.warn(`DragonBones Armature not exist`); return; } this._armatureName = data.armatureNames[0]; console.log(`parseDragonBonesData`, data); - } + _parseDragonAtlasAsset() { let textureAtlases = this.dragonBonesAsset.textureAtlases; if (typeof textureAtlases[0] === 'string') { @@ -262,8 +258,6 @@ namespace dragonBones { console.log(`dragonBonesAsset`, this.dragonBonesAsset); console.log(`textureAtlases`, textureAtlases); console.log(`texture`, tex); - - }, this); } else { let data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); @@ -271,7 +265,7 @@ namespace dragonBones { console.log(`string dragonBonesAsset`, this.dragonBonesAsset); } } - _dragonBonesNode: cc.Node; + display() { console.warn(`Armature name:${this._armatureName},dragonBonesName:${this.dragonBonesName}`); const armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); @@ -287,9 +281,10 @@ namespace dragonBones { this._dragonBonesNode = armatureComponent.node; console.log(`play animation default animation`); } + onLoad() { // this.display(); - if (!!this._dragonBonesNode) { + if (this._dragonBonesNode) { let component = this._dragonBonesNode.getComponent(CocosArmatureComponent); let state = component.animation.play(component.animation.animationNames[0], 0); if (!state) { diff --git a/Cocos/Demos/packages/dragonbones/assets/dragonBones.js b/Cocos/Demos/packages/dragonbones/assets/dragonBones.js index d95dfa76..41459d7c 100755 --- a/Cocos/Demos/packages/dragonbones/assets/dragonBones.js +++ b/Cocos/Demos/packages/dragonbones/assets/dragonBones.js @@ -1,16368 +1,16363 @@ -"use strict"; -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 __decorate = (this && this.__decorate) || function (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; -}; -/** - * 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("YuPeng 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.
- * 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) 确定)以及宽度和高度定义的区域。
- * 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, 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 armature data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var ArmatureData = /** @class */ (function (_super) { - __extends(ArmatureData, _super); - function ArmatureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.aabb = new dragonBones.Rectangle(); - /** - * - The names of all the animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所有的动画数据名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.animationNames = []; - /** - * @private - */ - _this.sortedBones = []; - /** - * @private - */ - _this.sortedSlots = []; - /** - * @private - */ - _this.defaultActions = []; - /** - * @private - */ - _this.actions = []; - /** - * @private - */ - _this.bones = {}; - /** - * @private - */ - _this.slots = {}; - /** - * @private - */ - _this.constraints = {}; - /** - * @private - */ - _this.skins = {}; - /** - * @private - */ - _this.animations = {}; - /** - * @private - */ - _this.canvas = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - ArmatureData.toString = function () { - return "[class dragonBones.ArmatureData]"; - }; - ArmatureData.prototype._onClear = function () { - for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { - var action = _c[_b]; - action.returnToPool(); - } - for (var k in this.bones) { - this.bones[k].returnToPool(); - delete this.bones[k]; - } - for (var k in this.slots) { - this.slots[k].returnToPool(); - delete this.slots[k]; - } - for (var k in this.constraints) { - this.constraints[k].returnToPool(); - delete this.constraints[k]; - } - for (var k in this.skins) { - this.skins[k].returnToPool(); - delete this.skins[k]; - } - for (var k in this.animations) { - this.animations[k].returnToPool(); - delete this.animations[k]; - } - if (this.canvas !== null) { - this.canvas.returnToPool(); - } - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.type = 0 /* Armature */; - this.frameRate = 0; - this.cacheFrameRate = 0; - this.scale = 1.0; - this.name = ""; - this.aabb.clear(); - this.animationNames.length = 0; - this.sortedBones.length = 0; - this.sortedSlots.length = 0; - this.defaultActions.length = 0; - this.actions.length = 0; - // this.bones.clear(); - // this.slots.clear(); - // this.constraints.clear(); - // this.skins.clear(); - // this.animations.clear(); - this.defaultSkin = null; - this.defaultAnimation = null; - this.canvas = null; - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - ArmatureData.prototype.sortBones = function () { - var total = this.sortedBones.length; - if (total <= 0) { - return; - } - var sortHelper = this.sortedBones.concat(); - var index = 0; - var count = 0; - this.sortedBones.length = 0; - while (count < total) { - var bone = sortHelper[index++]; - if (index >= total) { - index = 0; - } - if (this.sortedBones.indexOf(bone) >= 0) { - continue; - } - var flag = false; - for (var k in this.constraints) { // Wait constraint. - var constraint = this.constraints[k]; - if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { - flag = true; - break; - } - } - if (flag) { - continue; - } - if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. - continue; - } - this.sortedBones.push(bone); - count++; - } - }; - /** - * @internal - */ - ArmatureData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0) { // TODO clear cache. - return; - } - this.cacheFrameRate = frameRate; - for (var k in this.animations) { - this.animations[k].cacheFrames(this.cacheFrameRate); - } - }; - /** - * @internal - */ - ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { - var dataArray = this.parent.cachedFrames; - var arrayOffset = dataArray.length; - dataArray.length += 10; - dataArray[arrayOffset] = globalTransformMatrix.a; - dataArray[arrayOffset + 1] = globalTransformMatrix.b; - dataArray[arrayOffset + 2] = globalTransformMatrix.c; - dataArray[arrayOffset + 3] = globalTransformMatrix.d; - dataArray[arrayOffset + 4] = globalTransformMatrix.tx; - dataArray[arrayOffset + 5] = globalTransformMatrix.ty; - dataArray[arrayOffset + 6] = transform.rotation; - dataArray[arrayOffset + 7] = transform.skew; - dataArray[arrayOffset + 8] = transform.scaleX; - dataArray[arrayOffset + 9] = transform.scaleY; - return arrayOffset; - }; - /** - * @internal - */ - ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { - var dataArray = this.parent.cachedFrames; - globalTransformMatrix.a = dataArray[arrayOffset]; - globalTransformMatrix.b = dataArray[arrayOffset + 1]; - globalTransformMatrix.c = dataArray[arrayOffset + 2]; - globalTransformMatrix.d = dataArray[arrayOffset + 3]; - globalTransformMatrix.tx = dataArray[arrayOffset + 4]; - globalTransformMatrix.ty = dataArray[arrayOffset + 5]; - transform.rotation = dataArray[arrayOffset + 6]; - transform.skew = dataArray[arrayOffset + 7]; - transform.scaleX = dataArray[arrayOffset + 8]; - transform.scaleY = dataArray[arrayOffset + 9]; - transform.x = globalTransformMatrix.tx; - transform.y = globalTransformMatrix.ty; - }; - /** - * @internal - */ - ArmatureData.prototype.addBone = function (value) { - if (value.name in this.bones) { - console.warn("Same bone: " + value.name); - return; - } - this.bones[value.name] = value; - this.sortedBones.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addSlot = function (value) { - if (value.name in this.slots) { - console.warn("Same slot: " + value.name); - return; - } - this.slots[value.name] = value; - this.sortedSlots.push(value); - }; - /** - * @internal - */ - ArmatureData.prototype.addConstraint = function (value) { - if (value.name in this.constraints) { - console.warn("Same constraint: " + value.name); - return; - } - this.constraints[value.name] = value; - }; - /** - * @internal - */ - ArmatureData.prototype.addSkin = function (value) { - if (value.name in this.skins) { - console.warn("Same skin: " + value.name); - return; - } - value.parent = this; - this.skins[value.name] = value; - if (this.defaultSkin === null) { - this.defaultSkin = value; - } - if (value.name === "default") { - this.defaultSkin = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAnimation = function (value) { - if (value.name in this.animations) { - console.warn("Same animation: " + value.name); - return; - } - value.parent = this; - this.animations[value.name] = value; - this.animationNames.push(value.name); - if (this.defaultAnimation === null) { - this.defaultAnimation = value; - } - }; - /** - * @internal - */ - ArmatureData.prototype.addAction = function (value, isDefault) { - if (isDefault) { - this.defaultActions.push(value); - } - else { - this.actions.push(value); - } - }; - /** - * - Get a specific done data. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼数据。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getBone = function (boneName) { - return boneName in this.bones ? this.bones[boneName] : null; - }; - /** - * - Get a specific slot data. - * @param slotName - The slot name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽数据。 - * @param slotName - 插槽名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSlot = function (slotName) { - return slotName in this.slots ? this.slots[slotName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getConstraint = function (constraintName) { - return constraintName in this.constraints ? this.constraints[constraintName] : null; - }; - /** - * - Get a specific skin data. - * @param skinName - The skin name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定皮肤数据。 - * @param skinName - 皮肤名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getSkin = function (skinName) { - return skinName in this.skins ? this.skins[skinName] : null; - }; - /** - * @private - */ - ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { - var skin = this.getSkin(skinName); - if (skin === null) { - return null; - } - return skin.getDisplay(slotName, meshName); - }; - /** - * - Get a specific animation data. - * @param animationName - The animation animationName. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的动画数据。 - * @param animationName - 动画名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - ArmatureData.prototype.getAnimation = function (animationName) { - return animationName in this.animations ? this.animations[animationName] : null; - }; - return ArmatureData; - }(dragonBones.BaseObject)); - dragonBones.ArmatureData = ArmatureData; - /** - * - The bone data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var BoneData = /** @class */ (function (_super) { - __extends(BoneData, _super); - function BoneData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.transform = new dragonBones.Transform(); - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - BoneData.toString = function () { - return "[class dragonBones.BoneData]"; - }; - BoneData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.inheritTranslation = false; - this.inheritRotation = false; - this.inheritScale = false; - this.inheritReflection = false; - this.type = 0 /* Bone */; - this.length = 0.0; - this.alpha = 1.0; - this.name = ""; - this.transform.identity(); - this.userData = null; - this.parent = null; - }; - return BoneData; - }(dragonBones.BaseObject)); - dragonBones.BoneData = BoneData; - /** - * @internal - */ - var SurfaceData = /** @class */ (function (_super) { - __extends(SurfaceData, _super); - function SurfaceData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new dragonBones.GeometryData(); - return _this; - } - SurfaceData.toString = function () { - return "[class dragonBones.SurfaceData]"; - }; - SurfaceData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Surface */; - this.segmentX = 0; - this.segmentY = 0; - this.geometry.clear(); - }; - return SurfaceData; - }(BoneData)); - dragonBones.SurfaceData = SurfaceData; - /** - * - The slot data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SlotData = /** @class */ (function (_super) { - __extends(SlotData, _super); - function SlotData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.color = null; // Initial value. - /** - * @private - */ - _this.userData = null; // Initial value. - return _this; - } - /** - * @internal - */ - SlotData.createColor = function () { - return new dragonBones.ColorTransform(); - }; - SlotData.toString = function () { - return "[class dragonBones.SlotData]"; - }; - SlotData.prototype._onClear = function () { - if (this.userData !== null) { - this.userData.returnToPool(); - } - this.blendMode = 0 /* Normal */; - this.displayIndex = 0; - this.zOrder = 0; - this.zIndex = 0; - this.alpha = 1.0; - this.name = ""; - this.color = null; // - this.userData = null; - this.parent = null; // - }; - /** - * @internal - */ - SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotData; - }(dragonBones.BaseObject)); - dragonBones.SlotData = SlotData; -})(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 CanvasData = /** @class */ (function (_super) { - __extends(CanvasData, _super); - function CanvasData() { - return _super !== null && _super.apply(this, arguments) || this; - } - CanvasData.toString = function () { - return "[class dragonBones.CanvasData]"; - }; - CanvasData.prototype._onClear = function () { - this.hasBackground = false; - this.color = 0x000000; - this.x = 0; - this.y = 0; - this.width = 0; - this.height = 0; - }; - return CanvasData; - }(dragonBones.BaseObject)); - dragonBones.CanvasData = CanvasData; -})(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 skin data, typically a armature data instance contains at least one skinData. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var SkinData = /** @class */ (function (_super) { - __extends(SkinData, _super); - function SkinData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.displays = {}; - return _this; - } - SkinData.toString = function () { - return "[class dragonBones.SkinData]"; - }; - SkinData.prototype._onClear = function () { - for (var k in this.displays) { - var slotDisplays = this.displays[k]; - for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { - var display = slotDisplays_1[_i]; - if (display !== null) { - display.returnToPool(); - } - } - delete this.displays[k]; - } - this.name = ""; - // this.displays.clear(); - this.parent = null; // - }; - /** - * @internal - */ - SkinData.prototype.addDisplay = function (slotName, value) { - if (!(slotName in this.displays)) { - this.displays[slotName] = []; - } - if (value !== null) { - value.parent = this; - } - var slotDisplays = this.displays[slotName]; // TODO clear prev - slotDisplays.push(value); - }; - /** - * @private - */ - SkinData.prototype.getDisplay = function (slotName, displayName) { - var slotDisplays = this.getDisplays(slotName); - if (slotDisplays !== null) { - for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { - var display = slotDisplays_2[_i]; - if (display !== null && display.name === displayName) { - return display; - } - } - } - return null; - }; - /** - * @private - */ - SkinData.prototype.getDisplays = function (slotName) { - if (!(slotName in this.displays)) { - return null; - } - return this.displays[slotName]; - }; - return SkinData; - }(dragonBones.BaseObject)); - dragonBones.SkinData = SkinData; -})(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 ConstraintData = /** @class */ (function (_super) { - __extends(ConstraintData, _super); - function ConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - ConstraintData.prototype._onClear = function () { - this.order = 0; - this.name = ""; - this.type = 0 /* IK */; - this.target = null; // - this.root = null; // - this.bone = null; - }; - return ConstraintData; - }(dragonBones.BaseObject)); - dragonBones.ConstraintData = ConstraintData; - /** - * @internal - */ - var IKConstraintData = /** @class */ (function (_super) { - __extends(IKConstraintData, _super); - function IKConstraintData() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintData.toString = function () { - return "[class dragonBones.IKConstraintData]"; - }; - IKConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.scaleEnabled = false; - this.bendPositive = false; - this.weight = 1.0; - }; - return IKConstraintData; - }(ConstraintData)); - dragonBones.IKConstraintData = IKConstraintData; - /** - * @internal - */ - var PathConstraintData = /** @class */ (function (_super) { - __extends(PathConstraintData, _super); - function PathConstraintData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - PathConstraintData.toString = function () { - return "[class dragonBones.PathConstraintData]"; - }; - PathConstraintData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.pathSlot = null; - this.pathDisplayData = null; - this.bones.length = 0; - this.positionMode = 0 /* Fixed */; - this.spacingMode = 1 /* Fixed */; - this.rotateMode = 1 /* Chain */; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 0.0; - this.translateMix = 0.0; - }; - PathConstraintData.prototype.AddBone = function (value) { - this.bones.push(value); - }; - return PathConstraintData; - }(ConstraintData)); - dragonBones.PathConstraintData = PathConstraintData; -})(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 GeometryData = /** @class */ (function () { - function GeometryData() { - this.weight = null; // Initial value. - } - GeometryData.prototype.clear = function () { - if (!this.isShared && this.weight !== null) { - this.weight.returnToPool(); - } - this.isShared = false; - this.inheritDeform = false; - this.offset = 0; - this.data = null; - this.weight = null; - }; - GeometryData.prototype.shareFrom = function (value) { - this.isShared = true; - this.offset = value.offset; - this.weight = value.weight; - }; - Object.defineProperty(GeometryData.prototype, "vertexCount", { - get: function () { - var intArray = this.data.intArray; - return intArray[this.offset + 0 /* GeometryVertexCount */]; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(GeometryData.prototype, "triangleCount", { - get: function () { - var intArray = this.data.intArray; - return intArray[this.offset + 1 /* GeometryTriangleCount */]; - }, - enumerable: true, - configurable: true - }); - return GeometryData; - }()); - dragonBones.GeometryData = GeometryData; - /** - * @private - */ - var DisplayData = /** @class */ (function (_super) { - __extends(DisplayData, _super); - function DisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.transform = new dragonBones.Transform(); - return _this; - } - DisplayData.prototype._onClear = function () { - this.name = ""; - this.path = ""; - this.transform.identity(); - this.parent = null; // - }; - return DisplayData; - }(dragonBones.BaseObject)); - dragonBones.DisplayData = DisplayData; - /** - * @private - */ - var ImageDisplayData = /** @class */ (function (_super) { - __extends(ImageDisplayData, _super); - function ImageDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.pivot = new dragonBones.Point(); - return _this; - } - ImageDisplayData.toString = function () { - return "[class dragonBones.ImageDisplayData]"; - }; - ImageDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Image */; - this.pivot.clear(); - this.texture = null; - }; - return ImageDisplayData; - }(DisplayData)); - dragonBones.ImageDisplayData = ImageDisplayData; - /** - * @private - */ - var ArmatureDisplayData = /** @class */ (function (_super) { - __extends(ArmatureDisplayData, _super); - function ArmatureDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.actions = []; - return _this; - } - ArmatureDisplayData.toString = function () { - return "[class dragonBones.ArmatureDisplayData]"; - }; - ArmatureDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { - var action = _a[_i]; - action.returnToPool(); - } - this.type = 1 /* Armature */; - this.inheritAnimation = false; - this.actions.length = 0; - this.armature = null; - }; - /** - * @private - */ - ArmatureDisplayData.prototype.addAction = function (value) { - this.actions.push(value); - }; - return ArmatureDisplayData; - }(DisplayData)); - dragonBones.ArmatureDisplayData = ArmatureDisplayData; - /** - * @private - */ - var MeshDisplayData = /** @class */ (function (_super) { - __extends(MeshDisplayData, _super); - function MeshDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new GeometryData(); - return _this; - } - MeshDisplayData.toString = function () { - return "[class dragonBones.MeshDisplayData]"; - }; - MeshDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Mesh */; - this.geometry.clear(); - this.texture = null; - }; - return MeshDisplayData; - }(DisplayData)); - dragonBones.MeshDisplayData = MeshDisplayData; - /** - * @private - */ - var BoundingBoxDisplayData = /** @class */ (function (_super) { - __extends(BoundingBoxDisplayData, _super); - function BoundingBoxDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.boundingBox = null; // Initial value. - return _this; - } - BoundingBoxDisplayData.toString = function () { - return "[class dragonBones.BoundingBoxDisplayData]"; - }; - BoundingBoxDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.boundingBox !== null) { - this.boundingBox.returnToPool(); - } - this.type = 3 /* BoundingBox */; - this.boundingBox = null; - }; - return BoundingBoxDisplayData; - }(DisplayData)); - dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; - /** - * @private - */ - var PathDisplayData = /** @class */ (function (_super) { - __extends(PathDisplayData, _super); - function PathDisplayData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.geometry = new GeometryData(); - _this.curveLengths = []; - return _this; - } - PathDisplayData.toString = function () { - return "[class dragonBones.PathDisplayData]"; - }; - PathDisplayData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 4 /* Path */; - this.closed = false; - this.constantSpeed = false; - this.geometry.clear(); - this.curveLengths.length = 0; - }; - return PathDisplayData; - }(DisplayData)); - dragonBones.PathDisplayData = PathDisplayData; - /** - * @private - */ - var WeightData = /** @class */ (function (_super) { - __extends(WeightData, _super); - function WeightData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.bones = []; - return _this; - } - WeightData.toString = function () { - return "[class dragonBones.WeightData]"; - }; - WeightData.prototype._onClear = function () { - this.count = 0; - this.offset = 0; - this.bones.length = 0; - }; - WeightData.prototype.addBone = function (value) { - this.bones.push(value); - }; - return WeightData; - }(dragonBones.BaseObject)); - dragonBones.WeightData = WeightData; -})(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 base class of bounding box data. - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 边界框数据基类。 - * @see dragonBones.RectangleData - * @see dragonBones.EllipseData - * @see dragonBones.PolygonData - * @version DragonBones 5.0 - * @language zh_CN - */ - var BoundingBoxData = /** @class */ (function (_super) { - __extends(BoundingBoxData, _super); - function BoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoundingBoxData.prototype._onClear = function () { - this.color = 0x000000; - this.width = 0.0; - this.height = 0.0; - }; - return BoundingBoxData; - }(dragonBones.BaseObject)); - dragonBones.BoundingBoxData = BoundingBoxData; - /** - * - The rectangle bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 矩形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var RectangleBoundingBoxData = /** @class */ (function (_super) { - __extends(RectangleBoundingBoxData, _super); - function RectangleBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - RectangleBoundingBoxData.toString = function () { - return "[class dragonBones.RectangleBoundingBoxData]"; - }; - /** - * - Compute the bit code for a point (x, y) using the clip rectangle - */ - RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { - var code = 0 /* InSide */; // initialised as being inside of [[clip window]] - if (x < xMin) { // to the left of clip window - code |= 1 /* Left */; - } - else if (x > xMax) { // to the right of clip window - code |= 2 /* Right */; - } - if (y < yMin) { // below the clip window - code |= 4 /* Top */; - } - else if (y > yMax) { // above the clip window - code |= 8 /* Bottom */; - } - return code; - }; - /** - * @private - */ - RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; - var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; - if (inSideA && inSideB) { - return -1; - } - var intersectionCount = 0; - var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - while (true) { - if ((outcode0 | outcode1) === 0) { // Bitwise OR is 0. Trivially accept and get out of loop - intersectionCount = 2; - break; - } - else if ((outcode0 & outcode1) !== 0) { // Bitwise AND is not 0. Trivially reject and get out of loop - break; - } - // failed both tests, so calculate the line segment to clip - // from an outside point to an intersection with clip edge - var x = 0.0; - var y = 0.0; - var normalRadian = 0.0; - // At least one endpoint is outside the clip rectangle; pick it. - var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; - // Now find the intersection point; - if ((outcodeOut & 4 /* Top */) !== 0) { // point is above the clip rectangle - x = xA + (xB - xA) * (yMin - yA) / (yB - yA); - y = yMin; - if (normalRadians !== null) { - normalRadian = -Math.PI * 0.5; - } - } - else if ((outcodeOut & 8 /* Bottom */) !== 0) { // point is below the clip rectangle - x = xA + (xB - xA) * (yMax - yA) / (yB - yA); - y = yMax; - if (normalRadians !== null) { - normalRadian = Math.PI * 0.5; - } - } - else if ((outcodeOut & 2 /* Right */) !== 0) { // point is to the right of clip rectangle - y = yA + (yB - yA) * (xMax - xA) / (xB - xA); - x = xMax; - if (normalRadians !== null) { - normalRadian = 0; - } - } - else if ((outcodeOut & 1 /* Left */) !== 0) { // point is to the left of clip rectangle - y = yA + (yB - yA) * (xMin - xA) / (xB - xA); - x = xMin; - if (normalRadians !== null) { - normalRadian = Math.PI; - } - } - // Now we move outside point to intersection point to clip - // and get ready for next pass. - if (outcodeOut === outcode0) { - xA = x; - yA = y; - outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.x = normalRadian; - } - } - else { - xB = x; - yB = y; - outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); - if (normalRadians !== null) { - normalRadians.y = normalRadian; - } - } - } - if (intersectionCount) { - if (inSideA) { - intersectionCount = 2; // 10 - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = xB; - } - if (normalRadians !== null) { - normalRadians.x = normalRadians.y + Math.PI; - } - } - else if (inSideB) { - intersectionCount = 1; // 01 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - } - } - return intersectionCount; - }; - RectangleBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 0 /* Rectangle */; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - return true; - } - } - return false; - }; - /** - * @inheritDoc - */ - RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var widthH = this.width * 0.5; - var heightH = this.height * 0.5; - var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return RectangleBoundingBoxData; - }(BoundingBoxData)); - dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; - /** - * - The ellipse bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 椭圆边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var EllipseBoundingBoxData = /** @class */ (function (_super) { - __extends(EllipseBoundingBoxData, _super); - function EllipseBoundingBoxData() { - return _super !== null && _super.apply(this, arguments) || this; - } - EllipseBoundingBoxData.toString = function () { - return "[class dragonBones.EllipseData]"; - }; - /** - * @private - */ - EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var d = widthH / heightH; - var dd = d * d; - yA *= d; - yB *= d; - var dX = xB - xA; - var dY = yB - yA; - var lAB = Math.sqrt(dX * dX + dY * dY); - var xD = dX / lAB; - var yD = dY / lAB; - var a = (xC - xA) * xD + (yC - yA) * yD; - var aa = a * a; - var ee = xA * xA + yA * yA; - var rr = widthH * widthH; - var dR = rr - ee + aa; - var intersectionCount = 0; - if (dR >= 0.0) { - var dT = Math.sqrt(dR); - var sA = a - dT; - var sB = a + dT; - var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); - var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); - var sideAB = inSideA * inSideB; - if (sideAB < 0) { - return -1; - } - else if (sideAB === 0) { - if (inSideA === -1) { - intersectionCount = 2; // 10 - xB = xA + sB * xD; - yB = (yA + sB * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xB; - intersectionPointA.y = yB; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xB; - intersectionPointB.y = yB; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (inSideB === 1) { - intersectionCount = 1; // 01 - xA = xA + sA * xD; - yA = (yA + sA * yD) / d; - if (intersectionPointA !== null) { - intersectionPointA.x = xA; - intersectionPointA.y = yA; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA; - intersectionPointB.y = yA; - } - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); - normalRadians.y = normalRadians.x + Math.PI; - } - } - else { - intersectionCount = 3; // 11 - if (intersectionPointA !== null) { - intersectionPointA.x = xA + sA * xD; - intersectionPointA.y = (yA + sA * yD) / d; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); - } - } - if (intersectionPointB !== null) { - intersectionPointB.x = xA + sB * xD; - intersectionPointB.y = (yA + sB * yD) / d; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); - } - } - } - } - } - return intersectionCount; - }; - EllipseBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 1 /* Ellipse */; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var widthH = this.width * 0.5; - if (pX >= -widthH && pX <= widthH) { - var heightH = this.height * 0.5; - if (pY >= -heightH && pY <= heightH) { - pY *= widthH / heightH; - return Math.sqrt(pX * pX + pY * pY) <= widthH; - } - } - return false; - }; - /** - * @inheritDoc - */ - EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); - return intersectionCount; - }; - return EllipseBoundingBoxData; - }(BoundingBoxData)); - dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; - /** - * - The polygon bounding box data. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形边界框数据。 - * @version DragonBones 5.1 - * @language zh_CN - */ - var PolygonBoundingBoxData = /** @class */ (function (_super) { - __extends(PolygonBoundingBoxData, _super); - function PolygonBoundingBoxData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - The polygon vertices. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 多边形顶点。 - * @version DragonBones 5.1 - * @language zh_CN - */ - _this.vertices = []; - return _this; - } - PolygonBoundingBoxData.toString = function () { - return "[class dragonBones.PolygonBoundingBoxData]"; - }; - /** - * @private - */ - PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (xA === xB) { - xA = xB + 0.000001; - } - if (yA === yB) { - yA = yB + 0.000001; - } - var count = vertices.length; - var dXAB = xA - xB; - var dYAB = yA - yB; - var llAB = xA * yB - yA * xB; - var intersectionCount = 0; - var xC = vertices[count - 2]; - var yC = vertices[count - 1]; - var dMin = 0.0; - var dMax = 0.0; - var xMin = 0.0; - var yMin = 0.0; - var xMax = 0.0; - var yMax = 0.0; - for (var i = 0; i < count; i += 2) { - var xD = vertices[i]; - var yD = vertices[i + 1]; - if (xC === xD) { - xC = xD + 0.0001; - } - if (yC === yD) { - yC = yD + 0.0001; - } - var dXCD = xC - xD; - var dYCD = yC - yD; - var llCD = xC * yD - yC * xD; - var ll = dXAB * dYCD - dYAB * dXCD; - var x = (llAB * dXCD - dXAB * llCD) / ll; - if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { - var y = (llAB * dYCD - dYAB * llCD) / ll; - if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { - if (intersectionPointB !== null) { - var d = x - xA; - if (d < 0.0) { - d = -d; - } - if (intersectionCount === 0) { - dMin = d; - dMax = d; - xMin = x; - yMin = y; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - } - else { - if (d < dMin) { - dMin = d; - xMin = x; - yMin = y; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - if (d > dMax) { - dMax = d; - xMax = x; - yMax = y; - if (normalRadians !== null) { - normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - } - } - } - intersectionCount++; - } - else { - xMin = x; - yMin = y; - xMax = x; - yMax = y; - intersectionCount++; - if (normalRadians !== null) { - normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; - normalRadians.y = normalRadians.x; - } - break; - } - } - } - xC = xD; - yC = yD; - } - if (intersectionCount === 1) { - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMin; - intersectionPointB.y = yMin; - } - if (normalRadians !== null) { - normalRadians.y = normalRadians.x + Math.PI; - } - } - else if (intersectionCount > 1) { - intersectionCount++; - if (intersectionPointA !== null) { - intersectionPointA.x = xMin; - intersectionPointA.y = yMin; - } - if (intersectionPointB !== null) { - intersectionPointB.x = xMax; - intersectionPointB.y = yMax; - } - } - return intersectionCount; - }; - PolygonBoundingBoxData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.type = 2 /* Polygon */; - this.x = 0.0; - this.y = 0.0; - this.vertices.length = 0; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { - var isInSide = false; - if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { - for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { - var yA = this.vertices[iP + 1]; - var yB = this.vertices[i + 1]; - if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { - var xA = this.vertices[iP]; - var xB = this.vertices[i]; - if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { - isInSide = !isInSide; - } - } - iP = i; - } - } - return isInSide; - }; - /** - * @inheritDoc - */ - PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var intersectionCount = 0; - if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { - intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); - } - return intersectionCount; - }; - return PolygonBoundingBoxData; - }(BoundingBoxData)); - dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; -})(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 animation data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationData = /** @class */ (function (_super) { - __extends(AnimationData, _super); - function AnimationData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.cachedFrames = []; - /** - * @private - */ - _this.boneTimelines = {}; - /** - * @private - */ - _this.slotTimelines = {}; - /** - * @private - */ - _this.constraintTimelines = {}; - /** - * @private - */ - _this.animationTimelines = {}; - /** - * @private - */ - _this.boneCachedFrameIndices = {}; - /** - * @private - */ - _this.slotCachedFrameIndices = {}; - /** - * @private - */ - _this.actionTimeline = null; // Initial value. - /** - * @private - */ - _this.zOrderTimeline = null; // Initial value. - return _this; - } - AnimationData.toString = function () { - return "[class dragonBones.AnimationData]"; - }; - AnimationData.prototype._onClear = function () { - for (var k in this.boneTimelines) { - for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - delete this.boneTimelines[k]; - } - for (var k in this.slotTimelines) { - for (var _b = 0, _c = this.slotTimelines[k]; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - delete this.slotTimelines[k]; - } - for (var k in this.constraintTimelines) { - for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - delete this.constraintTimelines[k]; - } - for (var k in this.animationTimelines) { - for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - delete this.animationTimelines[k]; - } - for (var k in this.boneCachedFrameIndices) { - delete this.boneCachedFrameIndices[k]; - } - for (var k in this.slotCachedFrameIndices) { - delete this.slotCachedFrameIndices[k]; - } - if (this.actionTimeline !== null) { - this.actionTimeline.returnToPool(); - } - if (this.zOrderTimeline !== null) { - this.zOrderTimeline.returnToPool(); - } - this.frameIntOffset = 0; - this.frameFloatOffset = 0; - this.frameOffset = 0; - this.blendType = 0 /* None */; - this.frameCount = 0; - this.playTimes = 0; - this.duration = 0.0; - this.scale = 1.0; - this.fadeInTime = 0.0; - this.cacheFrameRate = 0.0; - this.name = ""; - this.cachedFrames.length = 0; - // this.boneTimelines.clear(); - // this.slotTimelines.clear(); - // this.constraintTimelines.clear(); - // this.animationTimelines.clear(); - // this.boneCachedFrameIndices.clear(); - // this.slotCachedFrameIndices.clear(); - this.actionTimeline = null; - this.zOrderTimeline = null; - this.parent = null; // - }; - /** - * @internal - */ - AnimationData.prototype.cacheFrames = function (frameRate) { - if (this.cacheFrameRate > 0.0) { // TODO clear cache. - return; - } - this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); - var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. - this.cachedFrames.length = cacheFrameCount; - for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { - this.cachedFrames[i] = false; - } - for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { - var bone = _a[_i]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.boneCachedFrameIndices[bone.name] = indices; - } - for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { - var slot = _c[_b]; - var indices = new Array(cacheFrameCount); - for (var i = 0, l = indices.length; i < l; ++i) { - indices[i] = -1; - } - this.slotCachedFrameIndices[slot.name] = indices; - } - }; - /** - * @private - */ - AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : (this.constraintTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { - var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); - if (timelines.indexOf(timeline) < 0) { - timelines.push(timeline); - } - }; - /** - * @private - */ - AnimationData.prototype.getBoneTimelines = function (timelineName) { - return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotTimelines = function (timelineName) { - return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getConstraintTimelines = function (timelineName) { - return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getAnimationTimelines = function (timelineName) { - return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { - return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; - }; - /** - * @private - */ - AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { - return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; - }; - return AnimationData; - }(dragonBones.BaseObject)); - dragonBones.AnimationData = AnimationData; - /** - * @private - */ - var TimelineData = /** @class */ (function (_super) { - __extends(TimelineData, _super); - function TimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineData.toString = function () { - return "[class dragonBones.TimelineData]"; - }; - TimelineData.prototype._onClear = function () { - this.type = 10 /* BoneAll */; - this.offset = 0; - this.frameIndicesOffset = -1; - }; - return TimelineData; - }(dragonBones.BaseObject)); - dragonBones.TimelineData = TimelineData; - /** - * @internal - */ - var AnimationTimelineData = /** @class */ (function (_super) { - __extends(AnimationTimelineData, _super); - function AnimationTimelineData() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationTimelineData.toString = function () { - return "[class dragonBones.AnimationTimelineData]"; - }; - AnimationTimelineData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.x = 0.0; - this.y = 0.0; - }; - return AnimationTimelineData; - }(TimelineData)); - dragonBones.AnimationTimelineData = AnimationTimelineData; -})(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 animation config is used to describe all the information needed to play an animation state. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 动画配置用来描述播放一个动画状态所需要的全部信息。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @see dragonBones.AnimationState - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - var AnimationConfig = /** @class */ (function (_super) { - __extends(AnimationConfig, _super); - function AnimationConfig() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.boneMask = []; - return _this; - } - AnimationConfig.toString = function () { - return "[class dragonBones.AnimationConfig]"; - }; - AnimationConfig.prototype._onClear = function () { - this.pauseFadeOut = true; - this.fadeOutMode = 4 /* All */; - this.fadeOutTweenType = 1 /* Line */; - this.fadeOutTime = -1.0; - this.actionEnabled = true; - this.additive = false; - this.displayControl = true; - this.pauseFadeIn = true; - this.resetToPose = true; - this.fadeInTweenType = 1 /* Line */; - this.playTimes = -1; - this.layer = 0; - this.position = 0.0; - this.duration = -1.0; - this.timeScale = -100.0; - this.weight = 1.0; - this.fadeInTime = -1.0; - this.autoFadeOutTime = -1.0; - this.name = ""; - this.animation = ""; - this.group = ""; - this.boneMask.length = 0; - }; - /** - * @private - */ - AnimationConfig.prototype.clear = function () { - this._onClear(); - }; - /** - * @private - */ - AnimationConfig.prototype.copyFrom = function (value) { - this.pauseFadeOut = value.pauseFadeOut; - this.fadeOutMode = value.fadeOutMode; - this.autoFadeOutTime = value.autoFadeOutTime; - this.fadeOutTweenType = value.fadeOutTweenType; - this.actionEnabled = value.actionEnabled; - this.additive = value.additive; - this.displayControl = value.displayControl; - this.pauseFadeIn = value.pauseFadeIn; - this.resetToPose = value.resetToPose; - this.playTimes = value.playTimes; - this.layer = value.layer; - this.position = value.position; - this.duration = value.duration; - this.timeScale = value.timeScale; - this.fadeInTime = value.fadeInTime; - this.fadeOutTime = value.fadeOutTime; - this.fadeInTweenType = value.fadeInTweenType; - this.weight = value.weight; - this.name = value.name; - this.animation = value.animation; - this.group = value.group; - this.boneMask.length = value.boneMask.length; - for (var i = 0, l = this.boneMask.length; i < l; ++i) { - this.boneMask[i] = value.boneMask[i]; - } - }; - return AnimationConfig; - }(dragonBones.BaseObject)); - dragonBones.AnimationConfig = AnimationConfig; -})(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 texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var TextureAtlasData = /** @class */ (function (_super) { - __extends(TextureAtlasData, _super); - function TextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.textures = {}; - return _this; - } - TextureAtlasData.prototype._onClear = function () { - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - this.autoSearch = false; - this.width = 0; - this.height = 0; - this.scale = 1.0; - // this.textures.clear(); - this.name = ""; - this.imagePath = ""; - }; - /** - * @private - */ - TextureAtlasData.prototype.copyFrom = function (value) { - this.autoSearch = value.autoSearch; - this.scale = value.scale; - this.width = value.width; - this.height = value.height; - this.name = value.name; - this.imagePath = value.imagePath; - for (var k in this.textures) { - this.textures[k].returnToPool(); - delete this.textures[k]; - } - // this.textures.clear(); - for (var k in value.textures) { - var texture = this.createTexture(); - texture.copyFrom(value.textures[k]); - this.textures[k] = texture; - } - }; - /** - * @internal - */ - TextureAtlasData.prototype.addTexture = function (value) { - if (value.name in this.textures) { - console.warn("Same texture: " + value.name); - return; - } - value.parent = this; - this.textures[value.name] = value; - }; - /** - * @private - */ - TextureAtlasData.prototype.getTexture = function (textureName) { - return textureName in this.textures ? this.textures[textureName] : null; - }; - return TextureAtlasData; - }(dragonBones.BaseObject)); - dragonBones.TextureAtlasData = TextureAtlasData; - /** - * @private - */ - var TextureData = /** @class */ (function (_super) { - __extends(TextureData, _super); - function TextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.region = new dragonBones.Rectangle(); - _this.frame = null; // Initial value. - return _this; - } - TextureData.createRectangle = function () { - return new dragonBones.Rectangle(); - }; - TextureData.prototype._onClear = function () { - this.rotated = false; - this.name = ""; - this.region.clear(); - this.parent = null; // - this.frame = null; - }; - TextureData.prototype.copyFrom = function (value) { - this.rotated = value.rotated; - this.name = value.name; - this.region.copyFrom(value.region); - this.parent = value.parent; - if (this.frame === null && value.frame !== null) { - this.frame = TextureData.createRectangle(); - } - else if (this.frame !== null && value.frame === null) { - this.frame = null; - } - if (this.frame !== null && value.frame !== null) { - this.frame.copyFrom(value.frame); - } - }; - return TextureData; - }(dragonBones.BaseObject)); - dragonBones.TextureData = TextureData; -})(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_1) { - /** - * - Armature is the core of the skeleton animation system. - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架是骨骼动画系统的核心。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - var Armature = /** @class */ (function (_super) { - __extends(Armature, _super); - function Armature() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._slots = []; - /** - * @internal - */ - _this._constraints = []; - _this._actions = []; - _this._animation = null; // Initial value. - _this._proxy = null; // Initial value. - /** - * @internal - */ - _this._replaceTextureAtlasData = null; // Initial value. - _this._clock = null; // Initial value. - return _this; - } - Armature.toString = function () { - return "[class dragonBones.Armature]"; - }; - Armature._onSortSlots = function (a, b) { - return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; - }; - Armature.prototype._onClear = function () { - if (this._clock !== null) { // Remove clock first. - this._clock.remove(this); - } - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone.returnToPool(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot.returnToPool(); - } - for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { - var constraint = _e[_d]; - constraint.returnToPool(); - } - for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { - var action = _g[_f]; - action.returnToPool(); - } - if (this._animation !== null) { - this._animation.returnToPool(); - } - if (this._proxy !== null) { - this._proxy.dbClear(); - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - } - this.inheritAnimation = true; - this.userData = null; - this._lockUpdate = false; - this._slotsDirty = true; - this._zOrderDirty = false; - this._zIndexDirty = false; - this._alphaDirty = true; - this._flipX = false; - this._flipY = false; - this._cacheFrameIndex = -1; - this._alpha = 1.0; - this._globalAlpha = 1.0; - this._bones.length = 0; - this._slots.length = 0; - this._constraints.length = 0; - this._actions.length = 0; - this._armatureData = null; // - this._animation = null; // - this._proxy = null; // - this._display = null; - this._replaceTextureAtlasData = null; - this._replacedTexture = null; - this._dragonBones = null; // - this._clock = null; - this._parent = null; - }; - /** - * @internal - */ - Armature.prototype._sortZOrder = function (slotIndices, offset) { - var slotDatas = this._armatureData.sortedSlots; - var isOriginal = slotIndices === null; - if (this._zOrderDirty || !isOriginal) { - for (var i = 0, l = slotDatas.length; i < l; ++i) { - var slotIndex = isOriginal ? i : slotIndices[offset + i]; - if (slotIndex < 0 || slotIndex >= l) { - continue; - } - var slotData = slotDatas[slotIndex]; - var slot = this.getSlot(slotData.name); - if (slot !== null) { - slot._setZOrder(i); - } - } - this._slotsDirty = true; - this._zOrderDirty = !isOriginal; - } - }; - /** - * @internal - */ - Armature.prototype._addBone = function (value) { - if (this._bones.indexOf(value) < 0) { - this._bones.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addSlot = function (value) { - if (this._slots.indexOf(value) < 0) { - this._slots.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._addConstraint = function (value) { - if (this._constraints.indexOf(value) < 0) { - this._constraints.push(value); - } - }; - /** - * @internal - */ - Armature.prototype._bufferAction = function (action, append) { - if (this._actions.indexOf(action) < 0) { - if (append) { - this._actions.push(action); - } - else { - this._actions.unshift(action); - } - } - }; - /** - * - Dispose the armature. (Return to the object pool) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 释放骨架。 (回收到对象池) - * @example - *
-         *     removeChild(armature.display);
-         *     armature.dispose();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.dispose = function () { - if (this._armatureData !== null) { - this._lockUpdate = true; - this._dragonBones.bufferObject(this); - } - }; - /** - * @internal - */ - Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { - if (this._armatureData !== null) { - return; - } - this._armatureData = armatureData; - this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); - this._proxy = proxy; - this._display = display; - this._dragonBones = dragonBones; - this._proxy.dbInit(this); - this._animation.init(this); - this._animation.animations = this._armatureData.animations; - }; - /** - * @inheritDoc - */ - Armature.prototype.advanceTime = function (passedTime) { - if (this._lockUpdate) { - return; - } - this._lockUpdate = true; - if (this._armatureData === null) { - console.warn("The armature has been disposed."); - return; - } - else if (this._armatureData.parent === null) { - console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); - return; - } - var prevCacheFrameIndex = this._cacheFrameIndex; - // Update animation. - this._animation.advanceTime(passedTime); - // Sort slots. - if (this._slotsDirty || this._zIndexDirty) { - this._slots.sort(Armature._onSortSlots); - if (this._zIndexDirty) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i]._setZOrder(i); // - } - } - this._slotsDirty = false; - this._zIndexDirty = false; - } - // Update alpha. - if (this._alphaDirty) { - this._alphaDirty = false; - this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - bone._updateAlpha(); - } - for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { - var slot = _c[_b]; - slot._updateAlpha(); - } - } - // Update bones and slots. - if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { - var i = 0, l = 0; - for (i = 0, l = this._bones.length; i < l; ++i) { - this._bones[i].update(this._cacheFrameIndex); - } - for (i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].update(this._cacheFrameIndex); - } - } - // Do actions. - if (this._actions.length > 0) { - for (var _d = 0, _e = this._actions; _d < _e.length; _d++) { - var action = _e[_d]; - var actionData = action.actionData; - if (actionData !== null) { - if (actionData.type === 0 /* Play */) { - if (action.slot !== null) { - var childArmature = action.slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - else if (action.bone !== null) { - for (var _f = 0, _g = this.getSlots(); _f < _g.length; _f++) { - var slot = _g[_f]; - if (slot.parent === action.bone) { - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.animation.fadeIn(actionData.name); - } - } - } - } - else { - this._animation.fadeIn(actionData.name); - } - } - } - action.returnToPool(); - } - this._actions.length = 0; - } - this._lockUpdate = false; - this._proxy.dbUpdate(); - }; - /** - * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. - * @param boneName - The bone name. (If not set, all bones will be update) - * @param updateSlot - Whether to update the bone's slots. (Default: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 - * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) - * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) - * @see dragonBones.Bone#invalidUpdate() - * @see dragonBones.Slot#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.invalidUpdate = function (boneName, updateSlot) { - if (boneName === void 0) { boneName = null; } - if (updateSlot === void 0) { updateSlot = false; } - if (boneName !== null && boneName.length > 0) { - var bone = this.getBone(boneName); - if (bone !== null) { - bone.invalidUpdate(); - if (updateSlot) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === bone) { - slot.invalidUpdate(); - } - } - } - } - } - else { - for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { - var bone = _c[_b]; - bone.invalidUpdate(); - } - if (updateSlot) { - for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { - var slot = _e[_d]; - slot.invalidUpdate(); - } - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in a slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在某个插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.containsPoint = function (x, y) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.containsPoint(x, y)) { - return slot; - } - } - return null; - }; - /** - * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - var isV = xA === xB; - var dMin = 0.0; - var dMax = 0.0; - var intXA = 0.0; - var intYA = 0.0; - var intXB = 0.0; - var intYB = 0.0; - var intAN = 0.0; - var intBN = 0.0; - var intSlotA = null; - var intSlotB = null; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionPointA !== null || intersectionPointB !== null) { - if (intersectionPointA !== null) { - var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotA === null || d < dMin) { - dMin = d; - intXA = intersectionPointA.x; - intYA = intersectionPointA.y; - intSlotA = slot; - if (normalRadians) { - intAN = normalRadians.x; - } - } - } - if (intersectionPointB !== null) { - var d = intersectionPointB.x - xA; - if (d < 0.0) { - d = -d; - } - if (intSlotB === null || d > dMax) { - dMax = d; - intXB = intersectionPointB.x; - intYB = intersectionPointB.y; - intSlotB = slot; - if (normalRadians !== null) { - intBN = normalRadians.y; - } - } - } - } - else { - intSlotA = slot; - break; - } - } - } - if (intSlotA !== null && intersectionPointA !== null) { - intersectionPointA.x = intXA; - intersectionPointA.y = intYA; - if (normalRadians !== null) { - normalRadians.x = intAN; - } - } - if (intSlotB !== null && intersectionPointB !== null) { - intersectionPointB.x = intXB; - intersectionPointB.y = intYB; - if (normalRadians !== null) { - normalRadians.y = intBN; - } - } - return intSlotA; - }; - /** - * - Get a specific bone. - * @param name - The bone name. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的骨骼。 - * @param name - 骨骼名称。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBone = function (name) { - for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone.name === name) { - return bone; - } - } - return null; - }; - /** - * - Get a specific bone by the display. - * @param display - The display object. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的骨骼。 - * @param display - 显示对象。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBoneByDisplay = function (display) { - var slot = this.getSlotByDisplay(display); - return slot !== null ? slot.parent : null; - }; - /** - * - Get a specific slot. - * @param name - The slot name. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的插槽。 - * @param name - 插槽名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlot = function (name) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.name === name) { - return slot; - } - } - return null; - }; - /** - * - Get a specific slot by the display. - * @param display - The display object. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过显示对象获取特定的插槽。 - * @param display - 显示对象。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlotByDisplay = function (display) { - if (display !== null) { - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.display === display) { - return slot; - } - } - } - return null; - }; - /** - * - Get all bones. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getBones = function () { - return this._bones; - }; - /** - * - Get all slots. - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - Armature.prototype.getSlots = function () { - return this._slots; - }; - Object.defineProperty(Armature.prototype, "flipX", { - /** - * - Whether to flip the armature horizontally. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架水平翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipX; - }, - set: function (value) { - if (this._flipX === value) { - return; - } - this._flipX = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "flipY", { - /** - * - Whether to flip the armature vertically. - * @version DragonBones 5.5 - * @language en_US - */ - /** - * - 是否将骨架垂直翻转。 - * @version DragonBones 5.5 - * @language zh_CN - */ - get: function () { - return this._flipY; - }, - set: function (value) { - if (this._flipY === value) { - return; - } - this._flipY = value; - this.invalidUpdate(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "cacheFrameRate", { - /** - * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. - * There is a certain amount of memory overhead to improve performance by caching animation data in memory. - * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. - * When the animation cache is turned on, some features will fail, such as the offset property of bone. - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 - * @example - *
-             *     armature.cacheFrameRate = 24;
-             * 
- * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData.cacheFrameRate; - }, - set: function (value) { - if (this._armatureData.cacheFrameRate !== value) { - this._armatureData.cacheFrames(value); - // Set child armature frameRate. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.cacheFrameRate = value; - } - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "name", { - /** - * - The armature name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨架名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armatureData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "armatureData", { - /** - * - The armature data. - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._armatureData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "animation", { - /** - * - The animation player. - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "proxy", { - /** - * @pivate - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "eventDispatcher", { - /** - * - The EventDispatcher instance of the armature. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架的 EventDispatcher 实例。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._proxy; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "display", { - /** - * - The display container. - * The display of the slot is displayed as the parent. - * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 显示容器实例。 - * 插槽的显示对象都会以此显示容器为父级。 - * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "replacedTexture", { - /** - * @private - */ - get: function () { - return this._replacedTexture; - }, - set: function (value) { - if (this._replacedTexture === value) { - return; - } - if (this._replaceTextureAtlasData !== null) { - this._replaceTextureAtlasData.returnToPool(); - this._replaceTextureAtlasData = null; - } - this._replacedTexture = value; - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - slot.invalidUpdate(); - slot.update(-1); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock) { - this._clock.add(this); - } - // Update childArmature clock. - for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { - var slot = _a[_i]; - var childArmature = slot.childArmature; - if (childArmature !== null) { - childArmature.clock = this._clock; - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Armature.prototype, "parent", { - /** - * - Get the parent slot which the armature belongs to. - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 该骨架所属的父插槽。 - * @see dragonBones.Slot - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Armature.prototype.getDisplay = function () { - return this._display; - }; - return Armature; - }(dragonBones_1.BaseObject)); - dragonBones_1.Armature = Armature; -})(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 base class of the transform object. - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 变换对象的基类。 - * @see dragonBones.Transform - * @version DragonBones 4.5 - * @language zh_CN - */ - var TransformObject = /** @class */ (function (_super) { - __extends(TransformObject, _super); - function TransformObject() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * - A matrix relative to the armature coordinate system. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的矩阵。 - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.globalTransformMatrix = new dragonBones.Matrix(); - /** - * - A transform relative to the armature coordinate system. - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架坐标系的变换。 - * @see #updateGlobalTransform() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.global = new dragonBones.Transform(); - /** - * - The offset transform relative to the armature or the parent bone coordinate system. - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 相对于骨架或父骨骼坐标系的偏移变换。 - * @see #dragonBones.Bone#invalidUpdate() - * @version DragonBones 3.0 - * @language zh_CN - */ - _this.offset = new dragonBones.Transform(); - return _this; - } - /** - */ - TransformObject.prototype._onClear = function () { - this.globalTransformMatrix.identity(); - this.global.identity(); - this.offset.identity(); - this.origin = null; - this.userData = null; - this._globalDirty = false; - this._alpha = 1.0; - this._globalAlpha = 1.0; - this._armature = null; // - }; - /** - * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, - * some engines do not rely on these attributes to update rendering, such as Egret. - * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 - * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 - * @example - *
-         *     bone.updateGlobalTransform();
-         *     let rotation = bone.global.rotation;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - TransformObject.prototype.updateGlobalTransform = function () { - if (this._globalDirty) { - this._globalDirty = false; - this.global.fromMatrix(this.globalTransformMatrix); - } - }; - Object.defineProperty(TransformObject.prototype, "armature", { - /** - * - The armature to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的骨架。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - TransformObject._helpMatrix = new dragonBones.Matrix(); - TransformObject._helpTransform = new dragonBones.Transform(); - TransformObject._helpPoint = new dragonBones.Point(); - return TransformObject; - }(dragonBones.BaseObject)); - dragonBones.TransformObject = TransformObject; -})(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) { - /** - * - Bone is one of the most important logical units in the armature animation system, - * and is responsible for the realization of translate, rotation, scaling in the animations. - * A armature can contain multiple bones. - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 - * 一个骨架中可以包含多个骨骼。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot - * @version DragonBones 3.0 - * @language zh_CN - */ - var Bone = /** @class */ (function (_super) { - __extends(Bone, _super); - function Bone() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @internal - */ - _this.animationPose = new dragonBones.Transform(); - return _this; - } - Bone.toString = function () { - return "[class dragonBones.Bone]"; - }; - Bone.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.offsetMode = 1 /* Additive */; - this.animationPose.identity(); - this._transformDirty = false; - this._childrenTransformDirty = false; - this._localDirty = true; - this._hasConstraint = false; - this._visible = true; - this._cachedFrameIndex = -1; - this._boneData = null; // - this._parent = null; // - this._cachedFrameIndices = null; - }; - Bone.prototype._updateGlobalTransformMatrix = function (isCache) { - // For typescript. - var boneData = this._boneData; - var global = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - var origin = this.origin; - var offset = this.offset; - var animationPose = this.animationPose; - var parent = this._parent; // - var flipX = this._armature.flipX; - var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; - var inherit = parent !== null; - var rotation = 0.0; - if (this.offsetMode === 1 /* Additive */) { - if (origin !== null) { - // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); - global.x = origin.x + offset.x + animationPose.x; - global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; - global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; - if (dragonBones.DragonBones.yDown) { - global.y = origin.y + offset.y + animationPose.y; - global.skew = origin.skew + offset.skew + animationPose.skew; - global.rotation = origin.rotation + offset.rotation + animationPose.rotation; - } - else { - global.y = origin.y - offset.y + animationPose.y; - global.skew = origin.skew - offset.skew + animationPose.skew; - global.rotation = origin.rotation - offset.rotation + animationPose.rotation; - } - } - else { - global.copyFrom(offset); - if (!dragonBones.DragonBones.yDown) { - global.y = -global.y; - global.skew = -global.skew; - global.rotation = -global.rotation; - } - global.add(animationPose); - } - } - else if (this.offsetMode === 0 /* None */) { - if (origin !== null) { - global.copyFrom(origin).add(animationPose); - } - else { - global.copyFrom(animationPose); - } - } - else { - inherit = false; - global.copyFrom(offset); - if (!dragonBones.DragonBones.yDown) { - global.y = -global.y; - global.skew = -global.skew; - global.rotation = -global.rotation; - } - } - if (inherit) { - var isSurface = parent._boneData.type === 1 /* Surface */; - var surfaceBone = isSurface ? parent._bone : null; - var parentMatrix = isSurface ? parent._getGlobalTransformMatrix(global.x, global.y) : parent.globalTransformMatrix; - if (boneData.inheritScale && (!isSurface || surfaceBone !== null)) { - if (isSurface) { - if (boneData.inheritRotation) { - global.rotation += parent.global.rotation; - } - surfaceBone.updateGlobalTransform(); - global.scaleX *= surfaceBone.global.scaleX; - global.scaleY *= surfaceBone.global.scaleY; - parentMatrix.transformPoint(global.x, global.y, global); - global.toMatrix(globalTransformMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - } - else { - if (!boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (flipX && flipY) { - rotation = global.rotation - (parent.global.rotation + Math.PI); - } - else if (flipX) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else if (flipY) { - rotation = global.rotation + parent.global.rotation; - } - else { - rotation = global.rotation - parent.global.rotation; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - globalTransformMatrix.concat(parentMatrix); - if (boneData.inheritTranslation) { - global.x = globalTransformMatrix.tx; - global.y = globalTransformMatrix.ty; - } - else { - globalTransformMatrix.tx = global.x; - globalTransformMatrix.ty = global.y; - } - if (isCache) { - global.fromMatrix(globalTransformMatrix); - } - else { - this._globalDirty = true; - } - } - } - else { - if (boneData.inheritTranslation) { - var x = global.x; - var y = global.y; - global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - else { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - } - if (boneData.inheritRotation) { - parent.updateGlobalTransform(); - if (parent.global.scaleX < 0.0) { - rotation = global.rotation + parent.global.rotation + Math.PI; - } - else { - rotation = global.rotation + parent.global.rotation; - } - if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { - rotation -= global.rotation * 2.0; - if (flipX !== flipY || boneData.inheritReflection) { - global.skew += Math.PI; - } - if (!dragonBones.DragonBones.yDown) { - global.skew = -global.skew; - } - } - global.rotation = rotation; - } - else if (flipX || flipY) { - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - } - else { - if (flipX || flipY) { - if (flipX) { - global.x = -global.x; - } - if (flipY) { - global.y = -global.y; - } - if (flipX && flipY) { - rotation = global.rotation + Math.PI; - } - else { - if (flipX) { - rotation = Math.PI - global.rotation; - } - else { - rotation = -global.rotation; - } - global.skew += Math.PI; - } - global.rotation = rotation; - } - global.toMatrix(globalTransformMatrix); - } - }; - /** - * @internal - */ - Bone.prototype._updateAlpha = function () { - if (this._parent !== null) { - this._globalAlpha = this._alpha * this._parent._globalAlpha; - } - else { - this._globalAlpha = this._alpha * this._armature._globalAlpha; - } - }; - /** - * @internal - */ - Bone.prototype.init = function (boneData, armatureValue) { - if (this._boneData !== null) { - return; - } - this._boneData = boneData; - this._armature = armatureValue; - this._alpha = this._boneData.alpha; - if (this._boneData.parent !== null) { - this._parent = this._armature.getBone(this._boneData.parent.name); - } - this._armature._addBone(this); - // - this.origin = this._boneData.transform; - }; - /** - * @internal - */ - Bone.prototype.update = function (cacheFrameIndex) { - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { // Has been Cached. - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - /** - * @internal - */ - Bone.prototype.updateByConstraint = function () { - if (this._localDirty) { - this._localDirty = false; - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { - this._updateGlobalTransformMatrix(true); - } - this._transformDirty = true; - } - }; - /** - * - Forces the bone to update the transform in the next frame. - * When the bone is not animated or its animation state is finished, the bone will not continue to update, - * and when the skeleton must be updated for some reason, the method needs to be called explicitly. - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 强制骨骼在下一帧更新变换。 - * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 - * @example - *
-         *     let bone = armature.getBone("arm");
-         *     bone.offset.scaleX = 2.0;
-         *     bone.invalidUpdate();
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.invalidUpdate = function () { - this._transformDirty = true; - }; - /** - * - Check whether the bone contains a specific bone. - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查该骨骼是否包含特定的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - * @language zh_CN - */ - Bone.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.parent; - } - return ancestor === this; - }; - Object.defineProperty(Bone.prototype, "boneData", { - /** - * - The bone data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 骨骼数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._boneData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "visible", { - /** - * - The visible of all slots in the bone. - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 此骨骼所有插槽的可见。 - * @default true - * @see dragonBones.Slot#visible - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (slot.parent === this) { - slot._updateVisible(); - } - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "name", { - /** - * - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._boneData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Bone.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - return Bone; - }(dragonBones.TransformObject)); - dragonBones.Bone = Bone; -})(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) { - /** - * @internal - */ - var Surface = /** @class */ (function (_super) { - __extends(Surface, _super); - function Surface() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._vertices = []; - _this._deformVertices = []; - /** - * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y - */ - _this._hullCache = []; - /** - * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] - */ - _this._matrixCahce = []; - return _this; - } - Surface.toString = function () { - return "[class dragonBones.Surface]"; - }; - Surface.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._dX = 0.0; - this._dY = 0.0; - this._k = 0.0; - this._kX = 0.0; - this._kY = 0.0; - this._vertices.length = 0; - this._deformVertices.length = 0; - this._matrixCahce.length = 0; - this._hullCache.length = 0; - this._bone = null; - }; - Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { - var dabX = bX - aX; - var dabY = bY - aY; - var dacX = cX - aX; - var dacY = cY - aY; - transform.rotation = Math.atan2(dabY, dabX); - transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; - if (isDown) { - transform.rotation += Math.PI; - } - transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; - transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; - transform.toMatrix(matrix); - transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); - transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); - }; - Surface.prototype._updateVertices = function () { - var data = this._armature.armatureData.parent; - var geometry = this._boneData.geometry; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; - var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; - var vertices = this._vertices; - var animationVertices = this._deformVertices; - if (this._parent !== null) { - if (this._parent._boneData.type === 1 /* Surface */) { - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - var matrix = this._parent._getGlobalTransformMatrix(x, y); - // - vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; - vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty; - } - } - else { - var parentMatrix = this._parent.globalTransformMatrix; - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - var x = floatArray[verticesOffset + iD] + animationVertices[iD]; - var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - // - vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; - } - } - } - else { - for (var i = 0, l = vertexCount; i < l; ++i) { - var iD = i * 2; - vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; - vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; - } - } - }; - Surface.prototype._updateGlobalTransformMatrix = function (isCache) { - // tslint:disable-next-line:no-unused-expression - isCache; - var segmentXD = this._boneData.segmentX * 2; - var lastIndex = this._vertices.length - 2; - var lA = 200.0; - // - var raX = this._vertices[0]; - var raY = this._vertices[1]; - var rbX = this._vertices[segmentXD]; - var rbY = this._vertices[segmentXD + 1]; - var rcX = this._vertices[lastIndex]; - var rcY = this._vertices[lastIndex + 1]; - var rdX = this._vertices[lastIndex - segmentXD]; - var rdY = this._vertices[lastIndex - segmentXD + 1]; - // - var dacX = raX + (rcX - raX) * 0.5; - var dacY = raY + (rcY - raY) * 0.5; - var dbdX = rbX + (rdX - rbX) * 0.5; - var dbdY = rbY + (rdY - rbY) * 0.5; - var aX = dacX + (dbdX - dacX) * 0.5; - var aY = dacY + (dbdY - dacY) * 0.5; - var bX = rbX + (rcX - rbX) * 0.5; - var bY = rbY + (rcY - rbY) * 0.5; - var cX = rdX + (rcX - rdX) * 0.5; - var cY = rdY + (rcY - rdY) * 0.5; - // TODO interpolation - this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); - this._globalDirty = false; - }; - Surface.prototype._getGlobalTransformMatrix = function (x, y) { - var lA = 200.0; - var lB = 1000.0; - if (x < -lB || lB < x || y < -lB || lB < y) { - return this.globalTransformMatrix; - } - var isDown = false; - var surfaceData = this._boneData; - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var segmentXD = surfaceData.segmentX * 2; - var dX = this._dX; - var dY = this._dY; - var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 - var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 - var matrixIndex = 0; - var pX = indexX * dX - lA; - var pY = indexY * dY - lA; - // - var matrices = this._matrixCahce; - var helpMatrix = Surface._helpMatrix; - if (x < -lA) { - if (y < -lA || y >= lA) { // Out. - return this.globalTransformMatrix; - } - // Left. - isDown = y > this._kX * (x + lA) + pY; - matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexY * (segmentXD + 2); - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[2] - (segmentY - indexY) * ddX; - var sY = this._hullCache[3] - (segmentY - indexY) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (x >= lA) { - if (y < -lA || y >= lA) { // Out. - return this.globalTransformMatrix; - } - // Right. - isDown = y > this._kX * (x - lB) + pY; - matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; - var ddX = this._hullCache[4]; - var ddY = this._hullCache[5]; - var sX = this._hullCache[0] + indexY * ddX; - var sY = this._hullCache[1] + indexY * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y < -lA) { - if (x < -lA || x >= lA) { // Out. - return this.globalTransformMatrix; - } - // Up. - isDown = y > this._kY * (x - pX - dX) - lB; - matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[8] + indexX * ddX; - var sY = this._hullCache[9] + indexX * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else if (y >= lA) { - if (x < -lA || x >= lA) { // Out. - return this.globalTransformMatrix; - } - // Down - isDown = y > this._kY * (x - pX - dX) + lA; - matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; - var ddX = this._hullCache[10]; - var ddY = this._hullCache[11]; - var sX = this._hullCache[6] - (segmentX - indexX) * ddX; - var sY = this._hullCache[7] - (segmentX - indexX) * ddY; - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - else { // Center. - isDown = y > this._k * (x - pX - dX) + pY; - matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; - if (matrices[matrixIndex] > 0.0) { - helpMatrix.copyFromArray(matrices, matrixIndex + 1); - } - else { - var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); - var vertices = this._vertices; - if (isDown) { - this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); - } - else { - this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); - } - matrices[matrixIndex] = 1.0; - matrices[matrixIndex + 1] = helpMatrix.a; - matrices[matrixIndex + 2] = helpMatrix.b; - matrices[matrixIndex + 3] = helpMatrix.c; - matrices[matrixIndex + 4] = helpMatrix.d; - matrices[matrixIndex + 5] = helpMatrix.tx; - matrices[matrixIndex + 6] = helpMatrix.ty; - } - } - return helpMatrix; - }; - /** - * @internal - * @private - */ - Surface.prototype.init = function (surfaceData, armatureValue) { - if (this._boneData !== null) { - return; - } - _super.prototype.init.call(this, surfaceData, armatureValue); - var segmentX = surfaceData.segmentX; - var segmentY = surfaceData.segmentY; - var vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; - var lB = 1000.0; - var lA = 200.0; - // - this._dX = lA * 2.0 / segmentX; - this._dY = lA * 2.0 / segmentY; - this._k = -this._dY / this._dX; - this._kX = -this._dY / (lB - lA); - this._kY = -(lB - lA) / this._dX; - this._vertices.length = vertexCount * 2; - this._deformVertices.length = vertexCount * 2; - this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; - this._hullCache.length = 10; - for (var i = 0; i < vertexCount * 2; ++i) { - this._deformVertices[i] = 0.0; - } - if (this._parent !== null) { - if (this._parent.boneData.type === 0 /* Bone */) { - this._bone = this._parent; - } - else { - this._bone = this._parent._bone; - } - } - }; - /** - * @internal - */ - Surface.prototype.update = function (cacheFrameIndex) { - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { // Has been Cached. - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || - (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - } - else { - if (this._hasConstraint) { // Update constraints. - for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { - var constraint = _c[_b]; - if (constraint._root === this) { - constraint.update(); - } - } - } - if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - if (this._transformDirty) { - this._transformDirty = false; - this._childrenTransformDirty = true; - // - for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { - this._matrixCahce[i] = -1.0; - } - // - this._updateVertices(); - // - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - if (this._localDirty) { - this._updateGlobalTransformMatrix(isCache); - } - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - // Update hull vertices. - var lB = 1000.0; - var lA = 200.0; - var ddX = 2 * this.global.x; - var ddY = 2 * this.global.y; - // - var helpPoint = Surface._helpPoint; - this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); - this._hullCache[0] = helpPoint.x; - this._hullCache[1] = helpPoint.y; - this._hullCache[2] = ddX - helpPoint.x; - this._hullCache[3] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); - this._hullCache[4] = helpPoint.x; - this._hullCache[5] = helpPoint.y; - // - this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); - this._hullCache[6] = helpPoint.x; - this._hullCache[7] = helpPoint.y; - this._hullCache[8] = ddX - helpPoint.x; - this._hullCache[9] = ddY - helpPoint.y; - this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); - this._hullCache[10] = helpPoint.x; - this._hullCache[11] = helpPoint.y; - } - else if (this._childrenTransformDirty) { - this._childrenTransformDirty = false; - } - this._localDirty = true; - }; - return Surface; - }(dragonBones.Bone)); - dragonBones.Surface = Surface; -})(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 DisplayFrame = /** @class */ (function (_super) { - __extends(DisplayFrame, _super); - function DisplayFrame() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.deformVertices = []; - return _this; - } - DisplayFrame.toString = function () { - return "[class dragonBones.DisplayFrame]"; - }; - DisplayFrame.prototype._onClear = function () { - this.rawDisplayData = null; - this.displayData = null; - this.textureData = null; - this.display = null; - this.deformVertices.length = 0; - }; - DisplayFrame.prototype.updateDeformVertices = function () { - if (this.rawDisplayData === null || this.deformVertices.length !== 0) { - return; - } - var rawGeometryData; - if (this.rawDisplayData.type === 2 /* Mesh */) { - rawGeometryData = this.rawDisplayData.geometry; - } - else if (this.rawDisplayData.type === 4 /* Path */) { - rawGeometryData = this.rawDisplayData.geometry; - } - else { - return; - } - var vertexCount = 0; - if (rawGeometryData.weight !== null) { - vertexCount = rawGeometryData.weight.count * 2; - } - else { - vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; - } - this.deformVertices.length = vertexCount; - for (var i = 0, l = this.deformVertices.length; i < l; ++i) { - this.deformVertices[i] = 0.0; - } - }; - DisplayFrame.prototype.getGeometryData = function () { - if (this.displayData !== null) { - if (this.displayData.type === 2 /* Mesh */) { - return this.displayData.geometry; - } - if (this.displayData.type === 4 /* Path */) { - return this.displayData.geometry; - } - } - if (this.rawDisplayData !== null) { - if (this.rawDisplayData.type === 2 /* Mesh */) { - return this.rawDisplayData.geometry; - } - if (this.rawDisplayData.type === 4 /* Path */) { - return this.rawDisplayData.geometry; - } - } - return null; - }; - DisplayFrame.prototype.getBoundingBox = function () { - if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { - return this.displayData.boundingBox; - } - if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { - return this.rawDisplayData.boundingBox; - } - return null; - }; - DisplayFrame.prototype.getTextureData = function () { - if (this.displayData !== null) { - if (this.displayData.type === 0 /* Image */) { - return this.displayData.texture; - } - if (this.displayData.type === 2 /* Mesh */) { - return this.displayData.texture; - } - } - if (this.textureData !== null) { - return this.textureData; - } - if (this.rawDisplayData !== null) { - if (this.rawDisplayData.type === 0 /* Image */) { - return this.rawDisplayData.texture; - } - if (this.rawDisplayData.type === 2 /* Mesh */) { - return this.rawDisplayData.texture; - } - } - return null; - }; - return DisplayFrame; - }(dragonBones.BaseObject)); - dragonBones.DisplayFrame = DisplayFrame; - /** - * - The slot attached to the armature, controls the display status and properties of the display object. - * A bone can contain multiple slots. - * A slot can contain multiple display objects, displaying only one of the display objects at a time, - * but you can toggle the display object into frame animation while the animation is playing. - * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, - * and a custom other display object. - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData - * @version DragonBones 3.0 - * @language zh_CN - */ - var Slot = /** @class */ (function (_super) { - __extends(Slot, _super); - function Slot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._localMatrix = new dragonBones.Matrix(); - /** - * @internal - */ - _this._colorTransform = new dragonBones.ColorTransform(); - /** - * @internal - */ - _this._displayFrames = []; - /** - * @internal - */ - _this._geometryBones = []; - _this._rawDisplay = null; // Initial value. - _this._meshDisplay = null; // Initial value. - _this._display = null; - return _this; - } - Slot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - var disposeDisplayList = []; - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var dispayFrame = _a[_i]; - var display = dispayFrame.display; - if (display !== this._rawDisplay && display !== this._meshDisplay && - disposeDisplayList.indexOf(display) < 0) { - disposeDisplayList.push(display); - } - dispayFrame.returnToPool(); - } - for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { - var eachDisplay = disposeDisplayList_1[_b]; - if (eachDisplay instanceof dragonBones.Armature) { - eachDisplay.dispose(); - } - else { - this._disposeDisplay(eachDisplay, true); - } - } - if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. - this._disposeDisplay(this._meshDisplay, false); - } - if (this._rawDisplay !== null) { - this._disposeDisplay(this._rawDisplay, false); - } - this.displayController = null; - this._displayDataDirty = false; - this._displayDirty = false; - this._geometryDirty = false; - this._textureDirty = false; - this._visibleDirty = false; - this._blendModeDirty = false; - this._zOrderDirty = false; - this._colorDirty = false; - this._verticesDirty = false; - this._transformDirty = false; - this._visible = true; - this._blendMode = 0 /* Normal */; - this._displayIndex = -1; - this._animationDisplayIndex = -1; - this._zOrder = 0; - this._zIndex = 0; - this._cachedFrameIndex = -1; - this._pivotX = 0.0; - this._pivotY = 0.0; - this._localMatrix.identity(); - this._colorTransform.identity(); - this._displayFrames.length = 0; - this._geometryBones.length = 0; - this._slotData = null; // - this._displayFrame = null; - this._geometryData = null; - this._boundingBoxData = null; - this._textureData = null; - this._rawDisplay = null; - this._meshDisplay = null; - this._display = null; - this._childArmature = null; - this._parent = null; // - this._cachedFrameIndices = null; - }; - Slot.prototype._hasDisplay = function (display) { - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var displayFrame = _a[_i]; - if (displayFrame.display === display) { - return true; - } - } - return false; - }; - /** - * @internal - */ - Slot.prototype._isBonesUpdate = function () { - for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { - var bone = _a[_i]; - if (bone !== null && bone._childrenTransformDirty) { - return true; - } - } - return false; - }; - /** - * @internal - */ - Slot.prototype._updateAlpha = function () { - var globalAlpha = this._alpha * this._parent._globalAlpha; - if (this._globalAlpha !== globalAlpha) { - this._globalAlpha = globalAlpha; - this._colorDirty = true; - } - }; - Slot.prototype._updateDisplayData = function () { - var prevDisplayFrame = this._displayFrame; - var prevGeometryData = this._geometryData; - var prevTextureData = this._textureData; - var rawDisplayData = null; - var displayData = null; - this._displayFrame = null; - this._geometryData = null; - this._boundingBoxData = null; - this._textureData = null; - if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { - this._displayFrame = this._displayFrames[this._displayIndex]; - rawDisplayData = this._displayFrame.rawDisplayData; - displayData = this._displayFrame.displayData; - this._geometryData = this._displayFrame.getGeometryData(); - this._boundingBoxData = this._displayFrame.getBoundingBox(); - this._textureData = this._displayFrame.getTextureData(); - } - if (this._displayFrame !== prevDisplayFrame || - this._geometryData !== prevGeometryData || this._textureData !== prevTextureData) { - // Update pivot offset. - if (this._geometryData === null && this._textureData !== null) { - var imageDisplayData = ((displayData !== null && displayData.type === 0 /* Image */) ? displayData : rawDisplayData); // - var scale = this._textureData.parent.scale * this._armature._armatureData.scale; - var frame = this._textureData.frame; - this._pivotX = imageDisplayData.pivot.x; - this._pivotY = imageDisplayData.pivot.y; - var rect = frame !== null ? frame : this._textureData.region; - var width = rect.width; - var height = rect.height; - if (this._textureData.rotated && frame === null) { - width = rect.height; - height = rect.width; - } - this._pivotX *= width * scale; - this._pivotY *= height * scale; - if (frame !== null) { - this._pivotX += frame.x * scale; - this._pivotY += frame.y * scale; - } - // Update replace pivot. TODO - if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) { - rawDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX -= Slot._helpPoint.x; - this._pivotY -= Slot._helpPoint.y; - imageDisplayData.transform.toMatrix(Slot._helpMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); - this._pivotX += Slot._helpPoint.x; - this._pivotY += Slot._helpPoint.y; - } - if (!dragonBones.DragonBones.yDown) { - this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; - } - } - else { - this._pivotX = 0.0; - this._pivotY = 0.0; - } - // Update original transform. - if (rawDisplayData !== null) { // Compatible. - this.origin = rawDisplayData.transform; - } - else if (displayData !== null) { // Compatible. - this.origin = displayData.transform; - } - else { - this.origin = null; - } - // TODO remove slot offset. - if (this.origin !== null) { - this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); - } - else { - this.global.copyFrom(this.offset).toMatrix(this._localMatrix); - } - // Update geometry. - if (this._geometryData !== prevGeometryData) { - this._geometryDirty = true; - this._verticesDirty = true; - if (this._geometryData !== null) { - this._geometryBones.length = 0; - if (this._geometryData.weight !== null) { - for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { - var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); - this._geometryBones.push(bone); - } - } - } - else { - this._geometryBones.length = 0; - this._geometryData = null; - } - } - this._textureDirty = this._textureData !== prevTextureData; - this._transformDirty = true; - } - }; - Slot.prototype._updateDisplay = function () { - var prevDisplay = this._display !== null ? this._display : this._rawDisplay; - var prevChildArmature = this._childArmature; - // Update display and child armature. - if (this._displayFrame !== null) { - this._display = this._displayFrame.display; - if (this._display !== null && this._display instanceof dragonBones.Armature) { - this._childArmature = this._display; - this._display = this._childArmature.display; - } - else { - this._childArmature = null; - } - } - else { - this._display = null; - this._childArmature = null; - } - // Update display. - var currentDisplay = this._display !== null ? this._display : this._rawDisplay; - if (currentDisplay !== prevDisplay) { - this._textureDirty = true; - this._visibleDirty = true; - this._blendModeDirty = true; - // this._zOrderDirty = true; - this._colorDirty = true; - this._transformDirty = true; - this._onUpdateDisplay(); - this._replaceDisplay(prevDisplay); - } - // Update child armature. - if (this._childArmature !== prevChildArmature) { - if (prevChildArmature !== null) { - prevChildArmature._parent = null; // Update child armature parent. - prevChildArmature.clock = null; - if (prevChildArmature.inheritAnimation) { - prevChildArmature.animation.reset(); - } - } - if (this._childArmature !== null) { - this._childArmature._parent = this; // Update child armature parent. - this._childArmature.clock = this._armature.clock; - if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. - if (this._childArmature.cacheFrameRate === 0) { - var cacheFrameRate = this._armature.cacheFrameRate; - if (cacheFrameRate !== 0) { - this._childArmature.cacheFrameRate = cacheFrameRate; - } - } - // Child armature action. - if (this._displayFrame !== null) { - var actions = null; - var displayData = this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; - if (displayData !== null && displayData.type === 1 /* Armature */) { - actions = displayData.actions; - } - if (actions !== null && actions.length > 0) { - for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { - var action = actions_1[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - eventObject.slot = this; - this._armature._bufferAction(eventObject, false); - } - } - else { - this._childArmature.animation.play(); - } - } - } - } - } - }; - Slot.prototype._updateGlobalTransformMatrix = function (isCache) { - var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); - this.globalTransformMatrix.copyFrom(this._localMatrix); - this.globalTransformMatrix.concat(parentMatrix); - if (isCache) { - this.global.fromMatrix(this.globalTransformMatrix); - } - else { - this._globalDirty = true; - } - }; - /** - * @internal - */ - Slot.prototype._setDisplayIndex = function (value, isAnimation) { - if (isAnimation === void 0) { isAnimation = false; } - if (isAnimation) { - if (this._animationDisplayIndex === value) { - return; - } - this._animationDisplayIndex = value; - } - if (this._displayIndex === value) { - return; - } - this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; - this._displayDataDirty = true; - this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; - }; - /** - * @internal - */ - Slot.prototype._setZOrder = function (value) { - if (this._zOrder === value) { - // return false; - } - this._zOrder = value; - this._zOrderDirty = true; - return this._zOrderDirty; - }; - /** - * @internal - */ - Slot.prototype._setColor = function (value) { - this._colorTransform.copyFrom(value); - return this._colorDirty = true; - }; - /** - * @internal - */ - Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { - if (this._slotData !== null) { - return; - } - this._slotData = slotData; - this._colorDirty = true; // - this._blendModeDirty = true; // - this._blendMode = this._slotData.blendMode; - this._zOrder = this._slotData.zOrder; - this._zIndex = this._slotData.zIndex; - this._alpha = this._slotData.alpha; - this._colorTransform.copyFrom(this._slotData.color); - this._rawDisplay = rawDisplay; - this._meshDisplay = meshDisplay; - // - this._armature = armatureValue; - var slotParent = this._armature.getBone(this._slotData.parent.name); - if (slotParent !== null) { - this._parent = slotParent; - } - else { - // Never; - } - this._armature._addSlot(this); - // - this._initDisplay(this._rawDisplay, false); - if (this._rawDisplay !== this._meshDisplay) { - this._initDisplay(this._meshDisplay, false); - } - this._onUpdateDisplay(); - this._addDisplay(); - }; - /** - * @internal - */ - Slot.prototype.update = function (cacheFrameIndex) { - if (this._displayDataDirty) { - this._updateDisplayData(); - this._displayDataDirty = false; - } - if (this._displayDirty) { - this._updateDisplay(); - this._displayDirty = false; - } - if (this._geometryDirty || this._textureDirty) { - if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { - this._updateFrame(); - } - this._geometryDirty = false; - this._textureDirty = false; - } - if (this._display === null) { - return; - } - if (this._visibleDirty) { - this._updateVisible(); - this._visibleDirty = false; - } - if (this._blendModeDirty) { - this._updateBlendMode(); - this._blendModeDirty = false; - } - if (this._colorDirty) { - this._updateColor(); - this._colorDirty = false; - } - if (this._zOrderDirty) { - this._updateZOrder(); - this._zOrderDirty = false; - } - if (this._geometryData !== null && this._display === this._meshDisplay) { - var isSkinned = this._geometryData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (this._verticesDirty || - (isSkinned && this._isBonesUpdate()) || - (isSurface && this._parent._childrenTransformDirty)) { - this._verticesDirty = false; // Allow update mesh to reset the dirty value. - this._updateMesh(); - } - if (isSkinned || isSurface) { // Compatible. - return; - } - } - if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { - var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; - if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. - this._transformDirty = false; - } - else if (cachedFrameIndex >= 0) { // Has been Cached. - this._transformDirty = true; - this._cachedFrameIndex = cachedFrameIndex; - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. - this._transformDirty = false; - this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; - } - else { // Dirty. - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - } - else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. - cacheFrameIndex = -1; - this._transformDirty = true; - this._cachedFrameIndex = -1; - } - if (this._transformDirty) { - if (this._cachedFrameIndex < 0) { - var isCache = cacheFrameIndex >= 0; - this._updateGlobalTransformMatrix(isCache); - if (isCache && this._cachedFrameIndices !== null) { - this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); - } - } - else { - this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); - } - this._updateTransform(); - this._transformDirty = false; - } - }; - /** - * - Forces the slot to update the state of the display object in the next frame. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 强制插槽在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Slot.prototype.invalidUpdate = function () { - this._displayDataDirty = true; - this._displayDirty = true; - // - this._transformDirty = true; - }; - /** - * @private - */ - Slot.prototype.updateTransformAndMatrix = function () { - if (this._transformDirty) { - this._updateGlobalTransformMatrix(false); - this._transformDirty = false; - } - }; - /** - * @private - */ - Slot.prototype.replaceRawDisplayData = function (displayData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.rawDisplayData !== displayData) { - displayFrame.deformVertices.length = 0; - displayFrame.rawDisplayData = displayData; - if (displayFrame.rawDisplayData === null) { - var defaultSkin = this._armature._armatureData.defaultSkin; - if (defaultSkin !== null) { - var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); - if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { - displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; - } - } - } - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplayData = function (displayData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { - displayFrame.displayData = displayData; - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceTextureData = function (textureData, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.textureData !== textureData) { - displayFrame.textureData = textureData; - if (index === this._displayIndex) { - this._displayDataDirty = true; - } - } - }; - /** - * @private - */ - Slot.prototype.replaceDisplay = function (value, index) { - if (index === void 0) { index = -1; } - if (index < 0) { - index = this._displayIndex < 0 ? 0 : this._displayIndex; - } - else if (index >= this._displayFrames.length) { - return; - } - var displayFrame = this._displayFrames[index]; - if (displayFrame.display !== value) { - var prevDisplay = displayFrame.display; - displayFrame.display = value; - if (prevDisplay !== null && - prevDisplay !== this._rawDisplay && prevDisplay !== this._meshDisplay && - !this._hasDisplay(prevDisplay)) { - if (prevDisplay instanceof dragonBones.Armature) { - // (eachDisplay as Armature).dispose(); - } - else { - this._disposeDisplay(prevDisplay, true); - } - } - if (value !== null && - value !== this._rawDisplay && value !== this._meshDisplay && - !this._hasDisplay(prevDisplay) && - !(value instanceof dragonBones.Armature)) { - this._initDisplay(value, true); - } - if (index === this._displayIndex) { - this._displayDirty = true; - } - } - }; - /** - * - Check whether a specific point is inside a custom bounding box in the slot. - * The coordinate system of the point is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param x - The horizontal coordinate of the point. - * @param y - The vertical coordinate of the point. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定点是否在插槽的自定义边界框内。 - * 点的坐标系为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param x - 点的水平坐标。 - * @param y - 点的垂直坐标。 - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.containsPoint = function (x, y) { - if (this._boundingBoxData === null) { - return false; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); - return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); - }; - /** - * - Check whether a specific segment intersects a custom bounding box for the slot. - * The coordinate system of the segment and intersection is the inner coordinate system of the armature. - * Custom bounding boxes need to be customized in Dragonbones Pro. - * @param xA - The horizontal coordinate of the beginning of the segment. - * @param yA - The vertical coordinate of the beginning of the segment. - * @param xB - The horizontal coordinate of the end point of the segment. - * @param yB - The vertical coordinate of the end point of the segment. - * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) - * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) - * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) - * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 检查特定线段是否与插槽的自定义边界框相交。 - * 线段和交点的坐标系均为骨架内坐标系。 - * 自定义边界框需要在 DragonBones Pro 中自定义。 - * @param xA - 线段起点的水平坐标。 - * @param yA - 线段起点的垂直坐标。 - * @param xB - 线段终点的水平坐标。 - * @param yB - 线段终点的垂直坐标。 - * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) - * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) - * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] - * @version DragonBones 5.0 - * @language zh_CN - */ - Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { - if (intersectionPointA === void 0) { intersectionPointA = null; } - if (intersectionPointB === void 0) { intersectionPointB = null; } - if (normalRadians === void 0) { normalRadians = null; } - if (this._boundingBoxData === null) { - return 0; - } - this.updateTransformAndMatrix(); - Slot._helpMatrix.copyFrom(this.globalTransformMatrix); - Slot._helpMatrix.invert(); - Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); - xA = Slot._helpPoint.x; - yA = Slot._helpPoint.y; - Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); - xB = Slot._helpPoint.x; - yB = Slot._helpPoint.y; - var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); - if (intersectionCount > 0) { - if (intersectionCount === 1 || intersectionCount === 2) { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - if (intersectionPointB !== null) { - intersectionPointB.x = intersectionPointA.x; - intersectionPointB.y = intersectionPointA.y; - } - } - else if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - else { - if (intersectionPointA !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); - } - if (intersectionPointB !== null) { - this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); - } - } - if (normalRadians !== null) { - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); - normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); - normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); - } - } - return intersectionCount; - }; - /** - * @private - */ - Slot.prototype.getDisplayFrameAt = function (index) { - return this._displayFrames[index]; - }; - Object.defineProperty(Slot.prototype, "visible", { - /** - * - The visible of slot's display object. - * @default true - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 插槽的显示对象的可见。 - * @default true - * @version DragonBones 5.6 - * @language zh_CN - */ - get: function () { - return this._visible; - }, - set: function (value) { - if (this._visible === value) { - return; - } - this._visible = value; - this._updateVisible(); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayFrameCount", { - /** - * @private - */ - get: function () { - return this._displayFrames.length; - }, - set: function (value) { - var prevCount = this._displayFrames.length; - if (prevCount < value) { - this._displayFrames.length = value; - for (var i = prevCount; i < value; ++i) { - this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); - } - } - else if (prevCount > value) { - for (var i = prevCount - 1; i < value; --i) { - this.replaceDisplay(null, i); - this._displayFrames[i].returnToPool(); - } - this._displayFrames.length = value; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayIndex", { - /** - * - The index of the display object displayed in the display list. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 此时显示的显示对象在显示列表中的索引。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     slot.displayIndex = 3;
-             *     slot.displayController = "none";
-             * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._displayIndex; - }, - set: function (value) { - this._setDisplayIndex(value); - this.update(-1); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "name", { - /** - * - The slot name. - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽名称。 - * @see dragonBones.SlotData#name - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._slotData.name; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "displayList", { - /** - * - Contains a display list of display objects or child armatures. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - var displays = new Array(); - for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { - var displayFrame = _a[_i]; - displays.push(displayFrame.display); - } - return displays; - }, - set: function (value) { - this.displayFrameCount = value.length; - var index = 0; - for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { - var eachDisplay = value_1[_i]; - this.replaceDisplay(eachDisplay, index++); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "slotData", { - /** - * - The slot data. - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._slotData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "boundingBoxData", { - /** - * - The custom bounding box data for the slot at current time. - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 插槽此时的自定义包围盒数据。 - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - return this._boundingBoxData; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "rawDisplay", { - /** - * @private - */ - get: function () { - return this._rawDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "meshDisplay", { - /** - * @private - */ - get: function () { - return this._meshDisplay; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "display", { - /** - * - The display object that the slot displays at this time. - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的显示对象。 - * @example - *
-             *     let slot = armature.getSlot("text");
-             *     slot.display = new yourEngine.TextField();
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._display; - }, - set: function (value) { - if (this._display === value) { - return; - } - if (this._displayFrames.length === 0) { - this.displayFrameCount = 1; - this._displayIndex = 0; - } - this.replaceDisplay(value, this._displayIndex); - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "childArmature", { - /** - * - The child armature that the slot displayed at current time. - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     let prevChildArmature = slot.childArmature;
-             *     if (prevChildArmature) {
-             *         prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 插槽此时显示的子骨架。 - * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 - * @example - *
-             *     let slot = armature.getSlot("weapon");
-             *     let prevChildArmature = slot.childArmature;
-             *     if (prevChildArmature) {
-             *         prevChildArmature.dispose();
-             *     }
-             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
-             * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._childArmature; - }, - set: function (value) { - if (this._childArmature === value) { - return; - } - this.display = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Slot.prototype, "parent", { - /** - * - The parent bone to which it belongs. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 所属的父骨骼。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._parent; - }, - enumerable: true, - configurable: true - }); - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.getDisplay = function () { - return this._display; - }; - /** - * - Deprecated, please refer to {@link #display}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link #display}。 - * @deprecated - * @language zh_CN - */ - Slot.prototype.setDisplay = function (value) { - this.display = value; - }; - return Slot; - }(dragonBones.TransformObject)); - dragonBones.Slot = Slot; -})(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) { - /** - * @internal - */ - var Constraint = /** @class */ (function (_super) { - __extends(Constraint, _super); - function Constraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - Constraint.prototype._onClear = function () { - this._armature = null; // - this._target = null; // - this._root = null; // - this._bone = null; - }; - Object.defineProperty(Constraint.prototype, "name", { - get: function () { - return this._constraintData.name; - }, - enumerable: true, - configurable: true - }); - Constraint._helpMatrix = new dragonBones.Matrix(); - Constraint._helpTransform = new dragonBones.Transform(); - Constraint._helpPoint = new dragonBones.Point(); - return Constraint; - }(dragonBones.BaseObject)); - dragonBones.Constraint = Constraint; - /** - * @internal - */ - var IKConstraint = /** @class */ (function (_super) { - __extends(IKConstraint, _super); - function IKConstraint() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraint.toString = function () { - return "[class dragonBones.IKConstraint]"; - }; - IKConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._scaleEnabled = false; - this._bendPositive = false; - this._weight = 1.0; - this._constraintData = null; - }; - IKConstraint.prototype._computeA = function () { - var ikGlobal = this._target.global; - var global = this._root.global; - var globalTransformMatrix = this._root.globalTransformMatrix; - var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radian += Math.PI; - } - global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype._computeB = function () { - var boneLength = this._bone._boneData.length; - var parent = this._root; - var ikGlobal = this._target.global; - var parentGlobal = parent.global; - var global = this._bone.global; - var globalTransformMatrix = this._bone.globalTransformMatrix; - var x = globalTransformMatrix.a * boneLength; - var y = globalTransformMatrix.b * boneLength; - var lLL = x * x + y * y; - var lL = Math.sqrt(lLL); - var dX = global.x - parentGlobal.x; - var dY = global.y - parentGlobal.y; - var lPP = dX * dX + dY * dY; - var lP = Math.sqrt(lPP); - var rawRadian = global.rotation; - var rawParentRadian = parentGlobal.rotation; - var rawRadianA = Math.atan2(dY, dX); - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - var lTT = dX * dX + dY * dY; - var lT = Math.sqrt(lTT); - var radianA = 0.0; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); - if (lL + lP <= lT) { - } - else if (lP < lL) { - radianA += Math.PI; - } - } - else { - var h = (lPP - lLL + lTT) / (2.0 * lTT); - var r = Math.sqrt(lPP - h * h * lTT) / lT; - var hX = parentGlobal.x + (dX * h); - var hY = parentGlobal.y + (dY * h); - var rX = -dY * r; - var rY = dX * r; - var isPPR = false; - var parentParent = parent.parent; - if (parentParent !== null) { - var parentParentMatrix = parentParent.globalTransformMatrix; - isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; - } - if (isPPR !== this._bendPositive) { - global.x = hX - rX; - global.y = hY - rY; - } - else { - global.x = hX + rX; - global.y = hY + rY; - } - radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); - } - var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); - parentGlobal.rotation = rawParentRadian + dR * this._weight; - parentGlobal.toMatrix(parent.globalTransformMatrix); - // - var currentRadianA = rawRadianA + dR * this._weight; - global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; - global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; - // - var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); - if (global.scaleX < 0.0) { - radianB += Math.PI; - } - global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; - global.toMatrix(globalTransformMatrix); - }; - IKConstraint.prototype.init = function (constraintData, armature) { - if (this._constraintData !== null) { - return; - } - this._constraintData = constraintData; - this._armature = armature; - this._target = this._armature.getBone(this._constraintData.target.name); - this._root = this._armature.getBone(this._constraintData.root.name); - this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; - { - var ikConstraintData = this._constraintData; - this._scaleEnabled = ikConstraintData.scaleEnabled; - this._bendPositive = ikConstraintData.bendPositive; - this._weight = ikConstraintData.weight; - } - this._root._hasConstraint = true; - }; - IKConstraint.prototype.update = function () { - this._root.updateByConstraint(); - if (this._bone !== null) { - this._bone.updateByConstraint(); - this._computeB(); - } - else { - this._computeA(); - } - }; - IKConstraint.prototype.invalidUpdate = function () { - this._root.invalidUpdate(); - if (this._bone !== null) { - this._bone.invalidUpdate(); - } - }; - return IKConstraint; - }(Constraint)); - dragonBones.IKConstraint = IKConstraint; - /** - * @internal - */ - var PathConstraint = /** @class */ (function (_super) { - __extends(PathConstraint, _super); - function PathConstraint() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._bones = []; - _this._spaces = []; - _this._positions = []; - _this._curves = []; - _this._boneLengths = []; - _this._pathGlobalVertices = []; - _this._segments = [10]; - return _this; - } - PathConstraint.toString = function () { - return "[class dragonBones.PathConstraint]"; - }; - PathConstraint.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.dirty = false; - this.pathOffset = 0; - this.position = 0.0; - this.spacing = 0.0; - this.rotateOffset = 0.0; - this.rotateMix = 1.0; - this.translateMix = 1.0; - this._pathSlot = null; - this._bones.length = 0; - this._spaces.length = 0; - this._positions.length = 0; - this._curves.length = 0; - this._boneLengths.length = 0; - this._pathGlobalVertices.length = 0; - }; - PathConstraint.prototype._updatePathVertices = function (verticesData) { - //计算曲线的节点数据 - var armature = this._armature; - var dragonBonesData = armature.armatureData.parent; - var scale = armature.armatureData.scale; - var intArray = dragonBonesData.intArray; - var floatArray = dragonBonesData.floatArray; - var pathOffset = verticesData.offset; - var pathVertexCount = intArray[pathOffset + 0 /* GeometryVertexCount */]; - var pathVertexOffset = intArray[pathOffset + 2 /* GeometryFloatOffset */]; - this._pathGlobalVertices.length = pathVertexCount * 2; - var weightData = verticesData.weight; - //没有骨骼约束我,那节点只受自己的Bone控制 - if (weightData === null) { - var parentBone = this._pathSlot.parent; - parentBone.updateByConstraint(); - var matrix = parentBone.globalTransformMatrix; - for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { - var vx = floatArray[iV_1++] * scale; - var vy = floatArray[iV_1++] * scale; - var x = matrix.a * vx + matrix.c * vy + matrix.tx; - var y = matrix.b * vx + matrix.d * vy + matrix.ty; - // - this._pathGlobalVertices[i] = x; - this._pathGlobalVertices[i + 1] = y; - } - return; - } - //有骨骼约束我,那我的节点受骨骼权重控制 - var bones = this._pathSlot._geometryBones; - var weightBoneCount = weightData.bones.length; - var weightOffset = weightData.offset; - var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; - var iV = floatOffset; - var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; - for (var i = 0, iW = 0; i < pathVertexCount; i++) { - var vertexBoneCount = intArray[iB++]; // - var xG = 0.0, yG = 0.0; - for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone === null) { - continue; - } - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var vx = floatArray[iV++] * scale; - var vy = floatArray[iV++] * scale; - xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; - yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; - } - this._pathGlobalVertices[iW++] = xG; - this._pathGlobalVertices[iW++] = yG; - } - }; - PathConstraint.prototype._computeVertices = function (start, count, offset, out) { - //TODO优化 - for (var i = offset, iW = start; i < count; i += 2) { - out[i] = this._pathGlobalVertices[iW++]; - out[i + 1] = this._pathGlobalVertices[iW++]; - } - }; - PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { - //计算当前的骨骼在曲线上的位置 - var armature = this._armature; - var intArray = armature.armatureData.parent.intArray; - var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; - var positions = this._positions; - var spaces = this._spaces; - var isClosed = pathDisplayDta.closed; - var curveVertices = Array(); - var verticesLength = vertexCount * 2; - var curveCount = verticesLength / 6; - var preCurve = -1; - var position = this.position; - positions.length = spaceCount * 3 + 2; - var pathLength = 0.0; - //不需要匀速运动,效率高些 - if (!pathDisplayDta.constantSpeed) { - var lenghts = pathDisplayDta.curveLengths; - curveCount -= isClosed ? 1 : 2; - pathLength = lenghts[curveCount]; - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - curveVertices.length = 8; - for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - if (isClosed) { - position %= pathLength; - if (position < 0) { - position += pathLength; - } - curve = 0; - } - else if (position < 0) { - //TODO - continue; - } - else if (position > pathLength) { - //TODO - continue; - } - var percent = 0.0; - for (;; curve++) { - var len = lenghts[curve]; - if (position > len) { - continue; - } - if (curve === 0) { - percent = position / len; - } - else { - var preLen = lenghts[curve - 1]; - percent = (position - preLen) / (len - preLen); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - if (isClosed && curve === curveCount) { - //计算曲线 - this._computeVertices(verticesLength - 4, 4, 0, curveVertices); - this._computeVertices(0, 4, 4, curveVertices); - } - else { - this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); - } - } - // - this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); - } - return; - } - //匀速的 - if (isClosed) { - verticesLength += 2; - curveVertices.length = vertexCount; - this._computeVertices(2, verticesLength - 4, 0, curveVertices); - this._computeVertices(0, 2, verticesLength - 4, curveVertices); - curveVertices[verticesLength - 2] = curveVertices[0]; - curveVertices[verticesLength - 1] = curveVertices[1]; - } - else { - curveCount--; - verticesLength -= 4; - curveVertices.length = verticesLength; - this._computeVertices(2, verticesLength, 0, curveVertices); - } - // - var curves = new Array(curveCount); - pathLength = 0; - var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; - var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; - for (var i = 0, w = 2; i < curveCount; i++, w += 6) { - cx1 = curveVertices[w]; - cy1 = curveVertices[w + 1]; - cx2 = curveVertices[w + 2]; - cy2 = curveVertices[w + 3]; - x2 = curveVertices[w + 4]; - y2 = curveVertices[w + 5]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; - tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx; - dfy += ddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - pathLength += Math.sqrt(dfx * dfx + dfy * dfy); - curves[i] = pathLength; - x1 = x2; - y1 = y2; - } - if (percentPosition) { - position *= pathLength; - } - if (percentSpacing) { - for (var i = 0; i < spaceCount; i++) { - spaces[i] *= pathLength; - } - } - var segments = this._segments; - var curveLength = 0; - for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { - var space = spaces[i]; - position += space; - var p = position; - if (isClosed) { - p %= pathLength; - if (p < 0) - p += pathLength; - curve = 0; - } - else if (p < 0) { - continue; - } - else if (p > pathLength) { - continue; - } - // Determine curve containing position. - for (;; curve++) { - var length_1 = curves[curve]; - if (p > length_1) - continue; - if (curve === 0) - p /= length_1; - else { - var prev = curves[curve - 1]; - p = (p - prev) / (length_1 - prev); - } - break; - } - if (curve !== preCurve) { - preCurve = curve; - var ii = curve * 6; - x1 = curveVertices[ii]; - y1 = curveVertices[ii + 1]; - cx1 = curveVertices[ii + 2]; - cy1 = curveVertices[ii + 3]; - cx2 = curveVertices[ii + 4]; - cy2 = curveVertices[ii + 5]; - x2 = curveVertices[ii + 6]; - y2 = curveVertices[ii + 7]; - tmpx = (x1 - cx1 * 2 + cx2) * 0.03; - tmpy = (y1 - cy1 * 2 + cy2) * 0.03; - dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; - dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; - ddfx = tmpx * 2 + dddfx; - ddfy = tmpy * 2 + dddfy; - dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; - dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; - curveLength = Math.sqrt(dfx * dfx + dfy * dfy); - segments[0] = curveLength; - for (ii = 1; ii < 8; ii++) { - dfx += ddfx; - dfy += ddfy; - ddfx += dddfx; - ddfy += dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[ii] = curveLength; - } - dfx += ddfx; - dfy += ddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[8] = curveLength; - dfx += ddfx + dddfx; - dfy += ddfy + dddfy; - curveLength += Math.sqrt(dfx * dfx + dfy * dfy); - segments[9] = curveLength; - segment = 0; - } - // Weight by segment length. - p *= curveLength; - for (;; segment++) { - var length_2 = segments[segment]; - if (p > length_2) - continue; - if (segment === 0) - p /= length_2; - else { - var prev = segments[segment - 1]; - p = segment + (p - prev) / (length_2 - prev); - } - break; - } - this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); - } - }; - //Calculates a point on the curve, for a given t value between 0 and 1. - PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { - if (t === 0) { - out[offset] = x1; - out[offset + 1] = y1; - out[offset + 2] = 0; - return; - } - if (t === 1) { - out[offset] = x2; - out[offset + 1] = y2; - out[offset + 2] = 0; - return; - } - var mt = 1 - t; - var mt2 = mt * mt; - var t2 = t * t; - var a = mt2 * mt; - var b = mt2 * t * 3; - var c = mt * t2 * 3; - var d = t * t2; - var x = a * x1 + b * cx1 + c * cx2 + d * x2; - var y = a * y1 + b * cy1 + c * cy2 + d * y2; - out[offset] = x; - out[offset + 1] = y; - if (tangents) { - //Calculates the curve tangent at the specified t value - out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); - } - else { - out[offset + 2] = 0; - } - }; - PathConstraint.prototype.init = function (constraintData, armature) { - this._constraintData = constraintData; - this._armature = armature; - var data = constraintData; - this.pathOffset = data.pathDisplayData.geometry.offset; - // - this.position = data.position; - this.spacing = data.spacing; - this.rotateOffset = data.rotateOffset; - this.rotateMix = data.rotateMix; - this.translateMix = data.translateMix; - // - this._root = this._armature.getBone(data.root.name); - this._target = this._armature.getBone(data.target.name); - this._pathSlot = this._armature.getSlot(data.pathSlot.name); - for (var i = 0, l = data.bones.length; i < l; i++) { - var bone = this._armature.getBone(data.bones[i].name); - if (bone !== null) { - this._bones.push(bone); - } - } - if (data.rotateMode === 2 /* ChainScale */) { - this._boneLengths.length = this._bones.length; - } - this._root._hasConstraint = true; - }; - PathConstraint.prototype.update = function () { - var pathSlot = this._pathSlot; - if (pathSlot._geometryData === null || - pathSlot._geometryData.offset !== this.pathOffset) { - return; - } - var constraintData = this._constraintData; - // - //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 - var isPathVerticeDirty = false; - if (this._root._childrenTransformDirty) { - this._updatePathVertices(pathSlot._geometryData); - isPathVerticeDirty = true; - } - else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) { - this._updatePathVertices(pathSlot._geometryData); - pathSlot._verticesDirty = false; - isPathVerticeDirty = true; - } - if (!isPathVerticeDirty && !this.dirty) { - return; - } - // - var positionMode = constraintData.positionMode; - var spacingMode = constraintData.spacingMode; - var rotateMode = constraintData.rotateMode; - var bones = this._bones; - var isLengthMode = spacingMode === 0 /* Length */; - var isChainScaleMode = rotateMode === 2 /* ChainScale */; - var isTangentMode = rotateMode === 0 /* Tangent */; - var boneCount = bones.length; - var spacesCount = isTangentMode ? boneCount : boneCount + 1; - var spacing = this.spacing; - var spaces = this._spaces; - spaces.length = spacesCount; - //计曲线间隔和长度 - if (isChainScaleMode || isLengthMode) { - //Bone改变和spacing改变触发 - spaces[0] = 0; - for (var i = 0, l = spacesCount - 1; i < l; i++) { - var bone = bones[i]; - bone.updateByConstraint(); - var boneLength = bone._boneData.length; - var matrix = bone.globalTransformMatrix; - var x = boneLength * matrix.a; - var y = boneLength * matrix.b; - var len = Math.sqrt(x * x + y * y); - if (isChainScaleMode) { - this._boneLengths[i] = len; - } - spaces[i + 1] = (boneLength + spacing) * len / boneLength; - } - } - else { - for (var i = 0; i < spacesCount; i++) { - spaces[i] = spacing; - } - } - // - this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); - //根据新的节点数据重新采样 - var positions = this._positions; - var rotateOffset = this.rotateOffset; - var boneX = positions[0], boneY = positions[1]; - var tip; - if (rotateOffset === 0) { - tip = rotateMode === 1 /* Chain */; - } - else { - tip = false; - var bone = pathSlot.parent; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; - } - } - // - var rotateMix = this.rotateMix; - var translateMix = this.translateMix; - for (var i = 0, p = 3; i < boneCount; i++, p += 3) { - var bone = bones[i]; - bone.updateByConstraint(); - var matrix = bone.globalTransformMatrix; - matrix.tx += (boneX - matrix.tx) * translateMix; - matrix.ty += (boneY - matrix.ty) * translateMix; - var x = positions[p], y = positions[p + 1]; - var dx = x - boneX, dy = y - boneY; - if (isChainScaleMode) { - var lenght = this._boneLengths[i]; - var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; - matrix.a *= s; - matrix.b *= s; - } - boneX = x; - boneY = y; - if (rotateMix > 0) { - var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; - if (isTangentMode) { - r = positions[p - 1]; - } - else { - r = Math.atan2(dy, dx); - } - r -= Math.atan2(b, a); - if (tip) { - cos = Math.cos(r); - sin = Math.sin(r); - var length_3 = bone._boneData.length; - boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; - boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; - } - else { - r += rotateOffset; - } - if (r > dragonBones.Transform.PI) { - r -= dragonBones.Transform.PI_D; - } - else if (r < -dragonBones.Transform.PI) { - r += dragonBones.Transform.PI_D; - } - r *= rotateMix; - cos = Math.cos(r); - sin = Math.sin(r); - matrix.a = cos * a - sin * b; - matrix.b = sin * a + cos * b; - matrix.c = cos * c - sin * d; - matrix.d = sin * c + cos * d; - } - bone.global.fromMatrix(matrix); - } - this.dirty = false; - }; - PathConstraint.prototype.invalidUpdate = function () { - }; - return PathConstraint; - }(Constraint)); - dragonBones.PathConstraint = PathConstraint; -})(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) { - /** - * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimateble - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var WorldClock = /** @class */ (function () { - /** - * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. - * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 - * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 - * @version DragonBones 3.0 - * @language zh_CN - */ - function WorldClock(time) { - if (time === void 0) { time = 0.0; } - /** - * - Current time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - this.time = 0.0; - /** - * - The play speed, used to control animation speed-shift play. - * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] - * @default 1.0 - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放速度,用于控制动画变速播放。 - * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1.0 - * @version DragonBones 3.0 - * @language zh_CN - */ - this.timeScale = 1.0; - this._systemTime = 0.0; - this._animatebles = []; - this._clock = null; - this.time = time; - this._systemTime = new Date().getTime() * 0.001; - } - /** - * - Advance time for all IAnimatable instances. - * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 为所有的 IAnimatable 实例更新时间。 - * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.advanceTime = function (passedTime) { - if (passedTime !== passedTime) { - passedTime = 0.0; - } - var currentTime = Date.now() * 0.001; - if (passedTime < 0.0) { - passedTime = currentTime - this._systemTime; - } - this._systemTime = currentTime; - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - if (passedTime === 0.0) { - return; - } - if (passedTime < 0.0) { - this.time -= passedTime; - } - else { - this.time += passedTime; - } - var i = 0, r = 0, l = this._animatebles.length; - for (; i < l; ++i) { - var animatable = this._animatebles[i]; - if (animatable !== null) { - if (r > 0) { - this._animatebles[i - r] = animatable; - this._animatebles[i] = null; - } - animatable.advanceTime(passedTime); - } - else { - r++; - } - } - if (r > 0) { - l = this._animatebles.length; - for (; i < l; ++i) { - var animateble = this._animatebles[i]; - if (animateble !== null) { - this._animatebles[i - r] = animateble; - } - else { - r++; - } - } - this._animatebles.length -= r; - } - }; - /** - * - Check whether contains a specific instance of IAnimatable. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.contains = function (value) { - if (value === this) { - return false; - } - var ancestor = value; - while (ancestor !== this && ancestor !== null) { - ancestor = ancestor.clock; - } - return ancestor === this; - }; - /** - * - Add IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.add = function (value) { - if (this._animatebles.indexOf(value) < 0) { - this._animatebles.push(value); - value.clock = this; - } - }; - /** - * - Removes a specified IAnimatable instance. - * @param value - The IAnimatable instance. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除特定的 IAnimatable 实例。 - * @param value - IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.remove = function (value) { - var index = this._animatebles.indexOf(value); - if (index >= 0) { - this._animatebles[index] = null; - value.clock = null; - } - }; - /** - * - Clear all IAnimatable instances. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - * @language zh_CN - */ - WorldClock.prototype.clear = function () { - for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { - var animatable = _a[_i]; - if (animatable !== null) { - animatable.clock = null; - } - } - }; - Object.defineProperty(WorldClock.prototype, "clock", { - /** - * @inheritDoc - */ - get: function () { - return this._clock; - }, - set: function (value) { - if (this._clock === value) { - return; - } - if (this._clock !== null) { - this._clock.remove(this); - } - this._clock = value; - if (this._clock !== null) { - this._clock.add(this); - } - }, - enumerable: true, - configurable: true - }); - return WorldClock; - }()); - dragonBones.WorldClock = WorldClock; -})(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 animation player is used to play the animation data and manage the animation states. - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画播放器用来播放动画数据和管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - var Animation = /** @class */ (function (_super) { - __extends(Animation, _super); - function Animation() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._animationNames = []; - _this._animationStates = []; - _this._animations = {}; - _this._blendStates = {}; - _this._animationConfig = null; // Initial value. - return _this; - } - Animation.toString = function () { - return "[class dragonBones.Animation]"; - }; - Animation.prototype._onClear = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in this._blendStates) { - var blendStates = this._blendStates[k]; - for (var kB in blendStates) { - blendStates[kB].returnToPool(); - } - delete this._blendStates[k]; - } - if (this._animationConfig !== null) { - this._animationConfig.returnToPool(); - } - this.timeScale = 1.0; - this._animationDirty = false; - this._inheritTimeScale = 1.0; - this._animationNames.length = 0; - this._animationStates.length = 0; - //this._animations.clear(); - this._armature = null; // - this._animationConfig = null; // - this._lastAnimationState = null; - }; - Animation.prototype._fadeOut = function (animationConfig) { - switch (animationConfig.fadeOutMode) { - case 1 /* SameLayer */: - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 2 /* SameGroup */: - for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { - var animationState = _c[_b]; - if (animationState._parent !== null) { - continue; - } - if (animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 3 /* SameLayerAndGroup */: - for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { - var animationState = _e[_d]; - if (animationState._parent !== null) { - continue; - } - if (animationState.layer === animationConfig.layer && - animationState.group === animationConfig.group) { - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - } - break; - case 4 /* All */: - for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { - var animationState = _g[_f]; - if (animationState._parent !== null) { - continue; - } - animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); - } - break; - case 5 /* Single */: // TODO - default: - break; - } - }; - /** - * @internal - */ - Animation.prototype.init = function (armature) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); - }; - /** - * @internal - */ - Animation.prototype.advanceTime = function (passedTime) { - if (passedTime < 0.0) { // Only animationState can reverse play. - passedTime = -passedTime; - } - if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. - this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; - } - else { - this._inheritTimeScale = this.timeScale; - } - if (this._inheritTimeScale !== 1.0) { - passedTime *= this._inheritTimeScale; - } - for (var k in this._blendStates) { - var blendStates = this._blendStates[k]; - for (var kB in blendStates) { - blendStates[kB].reset(); - } - } - var animationStateCount = this._animationStates.length; - if (animationStateCount === 1) { - var animationState = this._animationStates[0]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - this._armature._dragonBones.bufferObject(animationState); - this._animationStates.length = 0; - this._lastAnimationState = null; - } - else { - var animationData = animationState.animationData; - var cacheFrameRate = animationData.cacheFrameRate; - if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. - this._animationDirty = false; - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { - var slot = _c[_b]; - if (slot.displayFrameCount > 0) { - var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; - if (rawDisplayData !== null && - rawDisplayData.parent === this._armature.armatureData.defaultSkin) { - slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); - continue; - } - } - slot._cachedFrameIndices = null; - } - } - animationState.advanceTime(passedTime, cacheFrameRate); - } - } - else if (animationStateCount > 1) { - for (var i = 0, r = 0; i < animationStateCount; ++i) { - var animationState = this._animationStates[i]; - if (animationState._fadeState > 0 && animationState._subFadeState > 0) { - r++; - this._armature._dragonBones.bufferObject(animationState); - this._animationDirty = true; - if (this._lastAnimationState === animationState) { // Update last animation state. - this._lastAnimationState = null; - } - } - else { - if (r > 0) { - this._animationStates[i - r] = animationState; - } - animationState.advanceTime(passedTime, 0.0); - } - if (i === animationStateCount - 1 && r > 0) { // Modify animation states size. - this._animationStates.length -= r; - if (this._lastAnimationState === null && this._animationStates.length > 0) { - this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; - } - } - } - this._armature._cacheFrameIndex = -1; - } - else { - this._armature._cacheFrameIndex = -1; - } - }; - /** - * - Clear all animations states. - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除所有的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.reset = function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.returnToPool(); - } - this._animationDirty = false; - this._animationConfig.clear(); - this._animationStates.length = 0; - this._lastAnimationState = null; - }; - /** - * - Pause a specific animation state. - * @param animationName - The name of animation state. (If not set, it will pause all animations) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停指定动画状态的播放。 - * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.stop = function (animationName) { - if (animationName === void 0) { animationName = null; } - if (animationName !== null) { - var animationState = this.getState(animationName); - if (animationState !== null) { - animationState.stop(); - } - } - else { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - animationState.stop(); - } - } - }; - /** - * - Play animation with a specific animation config. - * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. - * @param animationConfig - The animation config. - * @returns The playing animation state. - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 通过指定的动画配置来播放动画。 - * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 - * @param animationConfig - 动画配置。 - * @returns 播放的动画状态。 - * @see dragonBones.AnimationConfig - * @beta - * @version DragonBones 5.0 - * @language zh_CN - */ - Animation.prototype.playConfig = function (animationConfig) { - var animationName = animationConfig.animation; - if (!(animationName in this._animations)) { - console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); - return null; - } - var animationData = this._animations[animationName]; - if (animationConfig.fadeOutMode === 5 /* Single */) { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState_1 = _a[_i]; - if (animationState_1._fadeState < 1 && - animationState_1.layer === animationConfig.layer && - animationState_1.animationData === animationData) { - return animationState_1; - } - } - } - if (this._animationStates.length === 0) { - animationConfig.fadeInTime = 0.0; - } - else if (animationConfig.fadeInTime < 0.0) { - animationConfig.fadeInTime = animationData.fadeInTime; - } - if (animationConfig.fadeOutTime < 0.0) { - animationConfig.fadeOutTime = animationConfig.fadeInTime; - } - if (animationConfig.timeScale <= -100.0) { - animationConfig.timeScale = 1.0 / animationData.scale; - } - if (animationData.frameCount > 0) { - if (animationConfig.position < 0.0) { - animationConfig.position %= animationData.duration; - animationConfig.position = animationData.duration - animationConfig.position; - } - else if (animationConfig.position === animationData.duration) { - animationConfig.position -= 0.000001; // Play a little time before end. - } - else if (animationConfig.position > animationData.duration) { - animationConfig.position %= animationData.duration; - } - if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { - animationConfig.duration = animationData.duration - animationConfig.position; - } - if (animationConfig.playTimes < 0) { - animationConfig.playTimes = animationData.playTimes; - } - } - else { - animationConfig.playTimes = 1; - animationConfig.position = 0.0; - if (animationConfig.duration > 0.0) { - animationConfig.duration = 0.0; - } - } - if (animationConfig.duration === 0.0) { - animationConfig.duration = -1.0; - } - this._fadeOut(animationConfig); - // - var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); - animationState.init(this._armature, animationData, animationConfig); - this._animationDirty = true; - this._armature._cacheFrameIndex = -1; - if (this._animationStates.length > 0) { // Sort animation state. - var added = false; - for (var i = 0, l = this._animationStates.length; i < l; ++i) { - if (animationState.layer > this._animationStates[i].layer) { - added = true; - this._animationStates.splice(i, 0, animationState); - break; - } - else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { - added = true; - this._animationStates.splice(i + 1, 0, animationState); - break; - } - } - if (!added) { - this._animationStates.push(animationState); - } - } - else { - this._animationStates.push(animationState); - } - for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { // Child armature play same name animation. - var slot = _c[_b]; - var childArmature = slot.childArmature; - if (childArmature !== null && childArmature.inheritAnimation && - childArmature.animation.hasAnimation(animationName) && - childArmature.animation.getState(animationName) === null) { - childArmature.animation.fadeIn(animationName); // - } - } - for (var k in animationData.animationTimelines) { // Blend animation node. - var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); - if (childAnimationState === null) { - continue; - } - var timelines = animationData.animationTimelines[k]; - childAnimationState.actionEnabled = false; - childAnimationState.resetToPose = false; - childAnimationState.stop(); - animationState.addState(childAnimationState, timelines); - // - var index = this._animationStates.indexOf(animationState); - var childIndex = this._animationStates.indexOf(childAnimationState); - if (childIndex < index) { - this._animationStates.splice(index, 1); - this._animationStates.splice(childIndex, 0, animationState); - } - } - // if (!this._armature._lockUpdate && animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. - // this._armature.advanceTime(0.0); - // } - this._lastAnimationState = animationState; - return animationState; - }; - /** - * - Play a specific animation. - * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) - * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 播放指定动画。 - * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.play("walk");
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.play = function (animationName, playTimes) { - if (animationName === void 0) { animationName = null; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName !== null ? animationName : ""; - if (animationName !== null && animationName.length > 0) { - this.playConfig(this._animationConfig); - } - else if (this._lastAnimationState === null) { - var defaultAnimation = this._armature.armatureData.defaultAnimation; - if (defaultAnimation !== null) { - this._animationConfig.animation = defaultAnimation.name; - this.playConfig(this._animationConfig); - } - } - else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { - this._lastAnimationState.play(); - } - else { - this._animationConfig.animation = this._lastAnimationState.name; - this.playConfig(this._animationConfig); - } - return this._lastAnimationState; - }; - /** - * - Fade in a specific animation. - * @param animationName - The name of animation data. - * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) - * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) - * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) - * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) - * @returns The playing animation state. - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 淡入播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) - * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) - * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) - * @returns 播放的动画状态。 - * @example - *
-         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
-         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { - if (fadeInTime === void 0) { fadeInTime = -1.0; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - this._animationConfig.clear(); - this._animationConfig.fadeOutMode = fadeOutMode; - this._animationConfig.playTimes = playTimes; - this._animationConfig.layer = layer; - this._animationConfig.fadeInTime = fadeInTime; - this._animationConfig.animation = animationName; - this._animationConfig.group = group !== null ? group : ""; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific time. - * @param animationName - The name of animation data. - * @param time - The start time point of playing. (In seconds) - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定时间开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param time - 播放开始的时间。 (以秒为单位) - * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { - if (time === void 0) { time = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.position = time; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific frame. - * @param animationName - The name of animation data. - * @param frame - The start frame of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定帧开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param frame - 播放开始的帧数。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { - if (frame === void 0) { frame = 0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.frameCount > 0 ? animationData.duration * frame / animationData.frameCount : 0.0; - } - return this.playConfig(this._animationConfig); - }; - /** - * - Play a specific animation from the specific progress. - * @param animationName - The name of animation data. - * @param progress - The start progress value of playing. - * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 从指定进度开始播放指定的动画。 - * @param animationName - 动画数据名称。 - * @param progress - 开始播放的进度。 - * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { - if (progress === void 0) { progress = 0.0; } - if (playTimes === void 0) { playTimes = -1; } - this._animationConfig.clear(); - this._animationConfig.resetToPose = true; - this._animationConfig.playTimes = playTimes; - this._animationConfig.fadeInTime = 0.0; - this._animationConfig.animation = animationName; - var animationData = animationName in this._animations ? this._animations[animationName] : null; - if (animationData !== null) { - this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); - } - return this.playConfig(this._animationConfig); - }; - /** - * - Stop a specific animation at the specific time. - * @param animationName - The name of animation data. - * @param time - The stop time. (In seconds) - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定时间停止指定动画播放 - * @param animationName - 动画数据名称。 - * @param time - 停止的时间。 (以秒为单位) - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByTime = function (animationName, time) { - if (time === void 0) { time = 0.0; } - var animationState = this.gotoAndPlayByTime(animationName, time, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific frame. - * @param animationName - The name of animation data. - * @param frame - The stop frame. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定帧停止指定动画的播放 - * @param animationName - 动画数据名称。 - * @param frame - 停止的帧数。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { - if (frame === void 0) { frame = 0; } - var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * - Stop a specific animation at the specific progress. - * @param animationName - The name of animation data. - * @param progress - The stop progress value. - * @returns The played animation state. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 在指定的进度停止指定的动画播放。 - * @param animationName - 动画数据名称。 - * @param progress - 停止进度。 - * @returns 播放的动画状态。 - * @version DragonBones 4.5 - * @language zh_CN - */ - Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { - if (progress === void 0) { progress = 0.0; } - var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); - if (animationState !== null) { - animationState.stop(); - } - return animationState; - }; - /** - * @internal - */ - Animation.prototype.getBlendState = function (type, name, target) { - if (!(type in this._blendStates)) { - this._blendStates[type] = {}; - } - var blendStates = this._blendStates[type]; - if (!(name in blendStates)) { - var blendState = blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState); - blendState.target = target; - } - return blendStates[name]; - }; - /** - * - Get a specific animation state. - * @param animationName - The name of animation state. - * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取指定的动画状态。 - * @param animationName - 动画状态名称。 - * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) - * @example - *
-         *     armature.animation.play("walk");
-         *     let walkState = armature.animation.getState("walk");
-         *     walkState.timeScale = 0.5;
-         * 
- * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.getState = function (animationName, layer) { - if (layer === void 0) { layer = -1; } - var i = this._animationStates.length; - while (i--) { - var animationState = this._animationStates[i]; - if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { - return animationState; - } - } - return null; - }; - /** - * - Check whether a specific animation data is included. - * @param animationName - The name of animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含指定的动画数据 - * @param animationName - 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - Animation.prototype.hasAnimation = function (animationName) { - return animationName in this._animations; - }; - /** - * - Get all the animation states. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取所有的动画状态 - * @version DragonBones 5.1 - * @language zh_CN - */ - Animation.prototype.getStates = function () { - return this._animationStates; - }; - Object.defineProperty(Animation.prototype, "isPlaying", { - /** - * - Check whether there is an animation state is playing - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否有动画状态正在播放 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (animationState.isPlaying) { - return true; - } - } - return false; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "isCompleted", { - /** - * - Check whether all the animation states' playing were finished. - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否所有的动画状态均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { - var animationState = _a[_i]; - if (!animationState.isCompleted) { - return false; - } - } - return this._animationStates.length > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationName", { - /** - * - The name of the last playing animation state. - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态名称 - * @see #lastAnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationNames", { - /** - * - The name of all animation data - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有动画数据的名称 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animationNames; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animations", { - /** - * - All animation data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 所有的动画数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._animations; - }, - set: function (value) { - if (this._animations === value) { - return; - } - this._animationNames.length = 0; - for (var k in this._animations) { - delete this._animations[k]; - } - for (var k in value) { - this._animationNames.push(k); - this._animations[k] = value[k]; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "animationConfig", { - /** - * - An AnimationConfig instance that can be used quickly. - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 一个可以快速使用的动画配置实例。 - * @see dragonBones.AnimationConfig - * @version DragonBones 5.0 - * @language zh_CN - */ - get: function () { - this._animationConfig.clear(); - return this._animationConfig; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(Animation.prototype, "lastAnimationState", { - /** - * - The last playing animation state - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 上一个播放的动画状态 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._lastAnimationState; - }, - enumerable: true, - configurable: true - }); - return Animation; - }(dragonBones.BaseObject)); - dragonBones.Animation = Animation; -})(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 animation state is generated when the animation data is played. - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 动画状态由播放动画数据时产生。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - var AnimationState = /** @class */ (function (_super) { - __extends(AnimationState, _super); - function AnimationState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._boneMask = []; - _this._boneTimelines = []; - _this._boneBlendTimelines = []; - _this._slotTimelines = []; - _this._slotBlendTimelines = []; - _this._constraintTimelines = []; - _this._animationTimelines = []; - _this._poseTimelines = []; - /** - * @internal - */ - _this._actionTimeline = null; // Initial value. - _this._zOrderTimeline = null; // Initial value. - return _this; - } - AnimationState.toString = function () { - return "[class dragonBones.AnimationState]"; - }; - AnimationState.prototype._onClear = function () { - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.returnToPool(); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.returnToPool(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.returnToPool(); - } - for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.returnToPool(); - } - for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.returnToPool(); - } - for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { - var timeline = _l[_k]; - var animationState = timeline.target; - if (animationState._parent === this) { - animationState._fadeState = 1; - animationState._subFadeState = 1; - animationState._parent = null; - } - timeline.returnToPool(); - } - if (this._actionTimeline !== null) { - this._actionTimeline.returnToPool(); - } - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.returnToPool(); - } - this.actionEnabled = false; - this.additive = false; - this.displayControl = false; - this.resetToPose = false; - this.blendType = 0 /* None */; - this.playTimes = 1; - this.layer = 0; - this.timeScale = 1.0; - this._weight = 1.0; - this.parameterX = 0.0; - this.parameterY = 0.0; - this.positionX = 0.0; - this.positionY = 0.0; - this.autoFadeOutTime = 0.0; - this.fadeTotalTime = 0.0; - this.name = ""; - this.group = ""; - this._timelineDirty = 2; - this._playheadState = 0; - this._fadeState = -1; - this._subFadeState = -1; - this._position = 0.0; - this._duration = 0.0; - this._fadeTime = 0.0; - this._time = 0.0; - this._fadeProgress = 0.0; - this._weightResult = 0.0; - this._boneMask.length = 0; - this._boneTimelines.length = 0; - this._boneBlendTimelines.length = 0; - this._slotTimelines.length = 0; - this._slotBlendTimelines.length = 0; - this._constraintTimelines.length = 0; - this._animationTimelines.length = 0; - this._poseTimelines.length = 0; - // this._bonePoses.clear(); - this._animationData = null; // - this._armature = null; // - this._actionTimeline = null; // - this._zOrderTimeline = null; - this._activeChildA = null; - this._activeChildB = null; - this._parent = null; - }; - AnimationState.prototype._updateTimelines = function () { - { // Update constraint timelines. - for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { - var constraint = _a[_i]; - var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); - if (timelineDatas !== null) { - for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { - var timelineData = timelineDatas_1[_b]; - switch (timelineData.type) { - case 30 /* IKConstraint */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.target = constraint; - timeline.init(this._armature, this, timelineData); - this._constraintTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { // Pose timeline. - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); - timeline.target = constraint; - timeline.init(this._armature, this, null); - this._constraintTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - }; - AnimationState.prototype._updateBoneAndSlotTimelines = function () { - { // Update bone and surface timelines. - var boneTimelines = {}; - // Create bone timelines map. - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var timelineName = timeline.target.target.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - var timelineName = timeline.target.target.name; - if (!(timelineName in boneTimelines)) { - boneTimelines[timelineName] = []; - } - boneTimelines[timelineName].push(timeline); - } - // - for (var _d = 0, _e = this._armature.getBones(); _d < _e.length; _d++) { - var bone = _e[_d]; - var timelineName = bone.name; - if (!this.containsBoneMask(timelineName)) { - continue; - } - if (timelineName in boneTimelines) { // Remove bone timeline from map. - delete boneTimelines[timelineName]; - } - else { // Create new bone timeline. - var timelineDatas = this._animationData.getBoneTimelines(timelineName); - var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); - if (timelineDatas !== null) { - for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { - var timelineData = timelineDatas_2[_f]; - switch (timelineData.type) { - case 10 /* BoneAll */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 11 /* BoneTranslate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 12 /* BoneRotate */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 13 /* BoneScale */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, timelineData); - this._boneTimelines.push(timeline); - break; - } - case 60 /* BoneAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); - timeline.init(this._armature, this, timelineData); - this._boneBlendTimelines.push(timeline); - break; - } - case 50 /* Surface */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); - timeline.init(this._armature, this, timelineData); - this._boneBlendTimelines.push(timeline); - break; - } - default: - break; - } - } - } - else if (this.resetToPose) { // Pose timeline. - if (bone._boneData.type === 0 /* Bone */) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); - timeline.target = blendState; - timeline.init(this._armature, this, null); - this._boneTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - else { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); - timeline.init(this._armature, this, null); - this._boneBlendTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - for (var k in boneTimelines) { // Remove bone timelines. - for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { - var timeline = _h[_g]; - var index = this._boneTimelines.indexOf(timeline); - if (index >= 0) { - this._boneTimelines.splice(index, 1); - timeline.returnToPool(); - } - index = this._boneBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._boneBlendTimelines.splice(index, 1); - timeline.returnToPool(); - } - } - } - } - { // Update slot timelines. - var slotTimelines = {}; - var ffdFlags = []; - // Create slot timelines map. - for (var _j = 0, _k = this._slotTimelines; _j < _k.length; _j++) { - var timeline = _k[_j]; - var timelineName = timeline.target.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - for (var _l = 0, _m = this._slotBlendTimelines; _l < _m.length; _l++) { - var timeline = _m[_l]; - var timelineName = timeline.target.target.name; - if (!(timelineName in slotTimelines)) { - slotTimelines[timelineName] = []; - } - slotTimelines[timelineName].push(timeline); - } - // - for (var _o = 0, _p = this._armature.getSlots(); _o < _p.length; _o++) { - var slot = _p[_o]; - var boneName = slot.parent.name; - if (!this.containsBoneMask(boneName)) { - continue; - } - var timelineName = slot.name; - if (timelineName in slotTimelines) { // Remove slot timeline from map. - delete slotTimelines[timelineName]; - } - else { // Create new slot timeline. - var displayIndexFlag = false; - var colorFlag = false; - ffdFlags.length = 0; - var timelineDatas = this._animationData.getSlotTimelines(timelineName); - if (timelineDatas !== null) { - for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { - var timelineData = timelineDatas_3[_q]; - switch (timelineData.type) { - case 20 /* SlotDisplay */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - displayIndexFlag = true; - break; - } - case 23 /* SlotZIndex */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); - timeline.init(this._armature, this, timelineData); - this._slotBlendTimelines.push(timeline); - break; - } - case 21 /* SlotColor */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, timelineData); - this._slotTimelines.push(timeline); - colorFlag = true; - break; - } - case 22 /* SlotDeform */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); - timeline.init(this._armature, this, timelineData); - if (timeline.target !== null) { - this._slotBlendTimelines.push(timeline); - ffdFlags.push(timeline.geometryOffset); - } - else { - timeline.returnToPool(); - } - break; - } - case 24 /* SlotAlpha */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); - timeline.init(this._armature, this, timelineData); - this._slotBlendTimelines.push(timeline); - break; - } - default: - break; - } - } - } - if (this.resetToPose) { // Pose timeline. - if (!displayIndexFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - if (!colorFlag) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); - timeline.target = slot; - timeline.init(this._armature, this, null); - this._slotTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayFrame = slot.getDisplayFrameAt(i); - if (displayFrame.deformVertices.length === 0) { - continue; - } - var geometryData = displayFrame.getGeometryData(); - if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); - timeline.geometryOffset = geometryData.offset; // - timeline.displayFrame = displayFrame; // - timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); - timeline.init(this._armature, this, null); - this._slotBlendTimelines.push(timeline); - this._poseTimelines.push(timeline); - } - } - } - } - } - for (var k in slotTimelines) { // Remove slot timelines. - for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { - var timeline = _s[_r]; - var index = this._slotTimelines.indexOf(timeline); - if (index >= 0) { - this._slotTimelines.splice(index, 1); - timeline.returnToPool(); - } - index = this._slotBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._slotBlendTimelines.splice(index, 1); - timeline.returnToPool(); - } - } - } - } - }; - AnimationState.prototype._advanceFadeTime = function (passedTime) { - var isFadeOut = this._fadeState > 0; - if (this._subFadeState < 0) { // Fade start event. - this._subFadeState = 0; - var eventActive = this._parent === null && this.actionEnabled; - if (eventActive) { - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - if (passedTime < 0.0) { - passedTime = -passedTime; - } - this._fadeTime += passedTime; - if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. - this._subFadeState = 1; - this._fadeProgress = isFadeOut ? 0.0 : 1.0; - } - else if (this._fadeTime > 0.0) { // Fading. - this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); - } - else { // Before fade. - this._fadeProgress = isFadeOut ? 1.0 : 0.0; - } - if (this._subFadeState > 0) { // Fade complete event. - if (!isFadeOut) { - this._playheadState |= 1; // x1 - this._fadeState = 0; - } - var eventActive = this._parent === null && this.actionEnabled; - if (eventActive) { - var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; - if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = eventType; - eventObject.armature = this._armature; - eventObject.animationState = this; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - }; - /** - * @internal - */ - AnimationState.prototype.init = function (armature, animationData, animationConfig) { - if (this._armature !== null) { - return; - } - this._armature = armature; - this._animationData = animationData; - // - this.resetToPose = animationConfig.resetToPose; - this.additive = animationConfig.additive; - this.displayControl = animationConfig.displayControl; - this.actionEnabled = animationConfig.actionEnabled; - this.blendType = animationData.blendType; - this.layer = animationConfig.layer; - this.playTimes = animationConfig.playTimes; - this.timeScale = animationConfig.timeScale; - this.fadeTotalTime = animationConfig.fadeInTime; - this.autoFadeOutTime = animationConfig.autoFadeOutTime; - this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; - this.group = animationConfig.group; - // - this._weight = animationConfig.weight; - if (animationConfig.pauseFadeIn) { - this._playheadState = 2; // 10 - } - else { - this._playheadState = 3; // 11 - } - if (animationConfig.duration < 0.0) { - this._position = 0.0; - this._duration = this._animationData.duration; - if (animationConfig.position !== 0.0) { - if (this.timeScale >= 0.0) { - this._time = animationConfig.position; - } - else { - this._time = animationConfig.position - this._duration; - } - } - else { - this._time = 0.0; - } - } - else { - this._position = animationConfig.position; - this._duration = animationConfig.duration; - this._time = 0.0; - } - if (this.timeScale < 0.0 && this._time === 0.0) { - this._time = -0.000001; // Turn to end. - } - if (this.fadeTotalTime <= 0.0) { - this._fadeProgress = 0.999999; // Make different. - } - if (animationConfig.boneMask.length > 0) { - this._boneMask.length = animationConfig.boneMask.length; - for (var i = 0, l = this._boneMask.length; i < l; ++i) { - this._boneMask[i] = animationConfig.boneMask[i]; - } - } - this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); - this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); - this._actionTimeline.currentTime = this._time; - if (this._actionTimeline.currentTime < 0.0) { - this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; - } - if (this._animationData.zOrderTimeline !== null) { - this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); - this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); - } - }; - /** - * @internal - */ - AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { - // Update fade time. - if (this._fadeState !== 0 || this._subFadeState !== 0) { - this._advanceFadeTime(passedTime); - } - // Update time. - if (this._playheadState === 3) { // 11 - if (this.timeScale !== 1.0) { - passedTime *= this.timeScale; - } - this._time += passedTime; - } - // Update timeline. - if (this._timelineDirty !== 0) { - if (this._timelineDirty === 2) { - this._updateTimelines(); - } - this._timelineDirty = 0; - this._updateBoneAndSlotTimelines(); - } - var isBlendDirty = this._fadeState !== 0 || this._subFadeState === 0; - var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; - var isUpdateTimeline = true; - var isUpdateBoneTimeline = true; - var time = this._time; - this._weightResult = this._weight * this._fadeProgress; - if (this._parent !== null) { - this._weightResult *= this._parent._weightResult; - } - if (this._actionTimeline.playState <= 0) { // Update main timeline. - this._actionTimeline.update(time); - } - if (this._weight === 0.0) { - return; - } - if (isCacheEnabled) { // Cache time internval. - var internval = cacheFrameRate * 2.0; - this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; - } - if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { // Update zOrder timeline. - this._zOrderTimeline.update(time); - } - if (isCacheEnabled) { // Update cache. - var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint - if (this._armature._cacheFrameIndex === cacheFrameIndex) { // Same cache. - isUpdateTimeline = false; - isUpdateBoneTimeline = false; - } - else { - this._armature._cacheFrameIndex = cacheFrameIndex; - if (this._animationData.cachedFrames[cacheFrameIndex]) { // Cached. - isUpdateBoneTimeline = false; - } - else { // Cache. - this._animationData.cachedFrames[cacheFrameIndex] = true; - } - } - } - if (isUpdateTimeline) { - var isBlend = false; - var prevTarget = null; // - if (isUpdateBoneTimeline) { - for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { - var timeline = this._boneTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (timeline.target !== prevTarget) { - var blendState = timeline.target; - isBlend = blendState.update(this); - prevTarget = blendState; - if (blendState.dirty === 1) { - var pose = blendState.target.animationPose; - pose.x = 0.0; - pose.y = 0.0; - pose.rotation = 0.0; - pose.skew = 0.0; - pose.scaleX = 1.0; - pose.scaleY = 1.0; - } - } - if (isBlend) { - timeline.blend(isBlendDirty); - } - } - } - for (var i = 0, l = this._boneBlendTimelines.length; i < l; ++i) { - var timeline = this._boneBlendTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (timeline.target.update(this)) { - timeline.blend(isBlendDirty); - } - } - if (this.displayControl) { - for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { - var timeline = this._slotTimelines[i]; - if (timeline.playState <= 0) { - var slot = timeline.target; - var displayController = slot.displayController; - if (displayController === null || - displayController === this.name || - displayController === this.group) { - timeline.update(time); - } - } - } - } - for (var i = 0, l = this._slotBlendTimelines.length; i < l; ++i) { - var timeline = this._slotBlendTimelines[i]; - if (timeline.playState <= 0) { - var blendState = timeline.target; - timeline.update(time); - if (blendState.update(this)) { - timeline.blend(isBlendDirty); - } - } - } - for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { - var timeline = this._constraintTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - } - if (this._animationTimelines.length > 0) { - var dL = 100.0; - var dR = 100.0; - var leftState = null; - var rightState = null; - for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { - var timeline = this._animationTimelines[i]; - if (timeline.playState <= 0) { - timeline.update(time); - } - if (this.blendType === 1 /* E1D */) { // TODO - var animationState = timeline.target; - var d = this.parameterX - animationState.positionX; - if (d >= 0.0) { - if (d < dL) { - dL = d; - leftState = animationState; - } - } - else { - if (-d < dR) { - dR = -d; - rightState = animationState; - } - } - } - } - if (leftState !== null) { - if (this._activeChildA !== leftState) { - if (this._activeChildA !== null) { - this._activeChildA.weight = 0.0; - } - this._activeChildA = leftState; - this._activeChildA.activeTimeline(); - } - if (this._activeChildB !== rightState) { - if (this._activeChildB !== null) { - this._activeChildB.weight = 0.0; - } - this._activeChildB = rightState; - } - leftState.weight = dR / (dL + dR); - if (rightState) { - rightState.weight = 1.0 - leftState.weight; - } - } - } - } - if (this._fadeState === 0) { - if (this._subFadeState > 0) { - this._subFadeState = 0; - if (this._poseTimelines.length > 0) { // Remove pose timelines. - for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - var index = this._boneTimelines.indexOf(timeline); - if (index >= 0) { - this._boneTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._boneBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._boneBlendTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._slotTimelines.indexOf(timeline); - if (index >= 0) { - this._slotTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._slotBlendTimelines.indexOf(timeline); - if (index >= 0) { - this._slotBlendTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - index = this._constraintTimelines.indexOf(timeline); - if (index >= 0) { - this._constraintTimelines.splice(index, 1); - timeline.returnToPool(); - continue; - } - } - this._poseTimelines.length = 0; - } - } - if (this._actionTimeline.playState > 0) { - if (this.autoFadeOutTime >= 0.0) { // Auto fade out. - this.fadeOut(this.autoFadeOutTime); - } - } - } - }; - /** - * - Continue play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 继续播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.play = function () { - this._playheadState = 3; // 11 - }; - /** - * - Stop play. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.stop = function () { - this._playheadState &= 1; // 0x - }; - /** - * - Fade out the animation state. - * @param fadeOutTime - The fade out time. (In seconds) - * @param pausePlayhead - Whether to pause the animation playing when fade out. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 淡出动画状态。 - * @param fadeOutTime - 淡出时间。 (以秒为单位) - * @param pausePlayhead - 淡出时是否暂停播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { - if (pausePlayhead === void 0) { pausePlayhead = true; } - if (fadeOutTime < 0.0) { - fadeOutTime = 0.0; - } - if (pausePlayhead) { - this._playheadState &= 2; // x0 - } - if (this._fadeState > 0) { - if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { // If the animation is already in fade out, the new fade out will be ignored. - return; - } - } - else { - this._fadeState = 1; - this._subFadeState = -1; - if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { - this._fadeProgress = 0.000001; // Modify fade progress to different value. - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.fadeOut(); - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.fadeOut(); - } - for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.fadeOut(); - } - for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { - var timeline = _g[_f]; - timeline.fadeOut(); - } - for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { - var timeline = _j[_h]; - timeline.fadeOut(); - } - for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { - var timeline = _l[_k]; - timeline.fadeOut(); - // - var animaitonState = timeline.target; - animaitonState.fadeOut(999999.0, true); - } - } - this.displayControl = false; // - this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; - this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); - }; - /** - * - Check if a specific bone mask is included. - * @param boneName - The bone name. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 检查是否包含特定骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.containsBoneMask = function (boneName) { - return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; - }; - /** - * - Add a specific bone mask. - * @param boneName - The bone name. - * @param recursive - Whether or not to add a mask to the bone's sub-bone. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 添加特定的骨骼遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.addBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var currentBone = this._armature.getBone(boneName); - if (currentBone === null) { - return; - } - if (this._boneMask.indexOf(boneName) < 0) { // Add mixing - this._boneMask.push(boneName); - } - if (recursive) { // Add recursive mixing. - for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { - var bone = _a[_i]; - if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove the mask of a specific bone. - * @param boneName - The bone name. - * @param recursive - Whether to remove the bone's sub-bone mask. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除特定骨骼的遮罩。 - * @param boneName - 骨骼名称。 - * @param recursive - 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeBoneMask = function (boneName, recursive) { - if (recursive === void 0) { recursive = true; } - var index = this._boneMask.indexOf(boneName); - if (index >= 0) { // Remove mixing. - this._boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = this._armature.getBone(boneName); - if (currentBone !== null) { - var bones = this._armature.getBones(); - if (this._boneMask.length > 0) { // Remove recursive mixing. - for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { - var bone = bones_1[_i]; - var index_1 = this._boneMask.indexOf(bone.name); - if (index_1 >= 0 && currentBone.contains(bone)) { - this._boneMask.splice(index_1, 1); - } - } - } - else { // Add unrecursive mixing. - for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { - var bone = bones_2[_a]; - if (bone === currentBone) { - continue; - } - if (!currentBone.contains(bone)) { - this._boneMask.push(bone.name); - } - } - } - } - } - this._timelineDirty = 1; - }; - /** - * - Remove all bone masks. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - * @language zh_CN - */ - AnimationState.prototype.removeAllBoneMask = function () { - this._boneMask.length = 0; - this._timelineDirty = 1; - }; - /** - * @private - */ - AnimationState.prototype.addState = function (animationState, timelineDatas) { - if (timelineDatas === void 0) { timelineDatas = null; } - if (timelineDatas !== null) { - for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { - var timelineData = timelineDatas_4[_i]; - switch (timelineData.type) { - case 40 /* AnimationProgress */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - if (this.blendType !== 0 /* None */) { - var animaitonTimelineData = timelineData; - animationState.positionX = animaitonTimelineData.x; - animationState.positionY = animaitonTimelineData.y; - animationState.weight = 0.0; - } - animationState._parent = this; - this.resetToPose = false; - break; - } - case 41 /* AnimationWeight */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - case 42 /* AnimationParameter */: { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); - timeline.target = animationState; - timeline.init(this._armature, this, timelineData); - this._animationTimelines.push(timeline); - break; - } - default: - break; - } - } - } - if (animationState._parent === null) { - animationState._parent = this; - } - }; - /** - * @internal - */ - AnimationState.prototype.activeTimeline = function () { - for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.dirty = true; - timeline.currentTime = -1.0; - } - }; - Object.defineProperty(AnimationState.prototype, "isFadeIn", { - /** - * - Whether the animation state is fading in. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡入。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState < 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeOut", { - /** - * - Whether the animation state is fading out. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否正在淡出。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isFadeComplete", { - /** - * - Whether the animation state is fade completed. - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 是否淡入或淡出完毕。 - * @version DragonBones 5.1 - * @language zh_CN - */ - get: function () { - return this._fadeState === 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isPlaying", { - /** - * - Whether the animation state is playing. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否正在播放。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "isCompleted", { - /** - * - Whether the animation state is play completed. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 是否播放完毕。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.playState > 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { - /** - * - The times has been played. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 已经循环播放的次数。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentPlayTimes; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "totalTime", { - /** - * - The total time. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 总播放时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._duration; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "currentTime", { - /** - * - The time is currently playing. (In seconds) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 当前播放的时间。 (以秒为单位) - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._actionTimeline.currentTime; - }, - set: function (value) { - var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); - if (value < 0 || this._duration < value) { - value = (value % this._duration) + currentPlayTimes * this._duration; - if (value < 0) { - value += this._duration; - } - } - if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && - value === this._duration && this._parent === null) { - value = this._duration - 0.000001; // - } - if (this._time === value) { - return; - } - this._time = value; - this._actionTimeline.setCurrentTime(this._time); - if (this._zOrderTimeline !== null) { - this._zOrderTimeline.playState = -1; - } - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.playState = -1; - } - for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.playState = -1; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "weight", { - /** - * - The blend weight. - * @default 1.0 - * @version DragonBones 5.0 - * @language en_US - */ - /** - * - 混合权重。 - * @default 1.0 - * @version DragonBones 5.0 - * @language zh_CN - */ - /** - * - The animation data. - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language en_US - */ - get: function () { - return this._weight; - }, - set: function (value) { - if (this._weight === value) { - return; - } - this._weight = value; - for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { - var timeline = _a[_i]; - timeline.dirty = true; - } - for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { - var timeline = _c[_b]; - timeline.dirty = true; - } - for (var _d = 0, _e = this._slotBlendTimelines; _d < _e.length; _d++) { - var timeline = _e[_d]; - timeline.dirty = true; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AnimationState.prototype, "animationData", { - /** - * - 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._animationData; - }, - enumerable: true, - configurable: true - }); - return AnimationState; - }(dragonBones.BaseObject)); - dragonBones.AnimationState = AnimationState; - /** - * @internal - */ - var BlendState = /** @class */ (function (_super) { - __extends(BlendState, _super); - function BlendState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BlendState.toString = function () { - return "[class dragonBones.BlendState]"; - }; - BlendState.prototype._onClear = function () { - this.reset(); - this.target = null; - }; - BlendState.prototype.update = function (animationState) { - var animationLayer = animationState.layer; - var animationWeight = animationState._weightResult; - if (this.dirty > 0) { - if (this.leftWeight > 0.0) { - if (this.layer !== animationLayer) { - if (this.layerWeight >= this.leftWeight) { - this.dirty++; - this.layer = animationLayer; - this.leftWeight = 0.0; - this.blendWeight = 0.0; - return false; - } - this.layer = animationLayer; - this.leftWeight -= this.layerWeight; - this.layerWeight = 0.0; - } - animationWeight *= this.leftWeight; - this.dirty++; - this.blendWeight = animationWeight; - this.layerWeight += this.blendWeight; - return true; - } - return false; - } - this.dirty++; - this.layer = animationLayer; - this.leftWeight = 1.0; - this.blendWeight = animationWeight; - this.layerWeight = animationWeight; - return true; - }; - BlendState.prototype.reset = function () { - this.dirty = 0; - this.layer = 0; - this.leftWeight = 0.0; - this.layerWeight = 0.0; - this.blendWeight = 0.0; - }; - BlendState.BONE_TRANSFORM = "boneTransform"; - BlendState.BONE_ALPHA = "boneAlpha"; - BlendState.SURFACE = "surface"; - BlendState.SLOT_DEFORM = "slotDeform"; - BlendState.SLOT_ALPHA = "slotAlpha"; - BlendState.SLOT_Z_INDEX = "slotZIndex"; - return BlendState; - }(dragonBones.BaseObject)); - dragonBones.BlendState = BlendState; -})(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) { - /** - * @internal - */ - var TimelineState = /** @class */ (function (_super) { - __extends(TimelineState, _super); - function TimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TimelineState.prototype._onClear = function () { - this.dirty = false; - this.playState = -1; - this.currentPlayTimes = -1; - this.currentTime = -1.0; - this.target = null; - this._isTween = false; - this._valueOffset = 0; - this._frameValueOffset = 0; - this._frameOffset = 0; - this._frameRate = 0; - this._frameCount = 0; - this._frameIndex = -1; - this._frameRateR = 0.0; - this._position = 0.0; - this._duration = 0.0; - this._timeScale = 1.0; - this._timeOffset = 0.0; - this._animationData = null; // - this._timelineData = null; // - this._armature = null; // - this._animationState = null; // - this._actionTimeline = null; // - this._frameArray = null; // - this._valueArray = null; // - this._timelineArray = null; // - this._frameIndices = null; // - }; - TimelineState.prototype._setCurrentTime = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._actionTimeline !== null && this._frameCount <= 1) { // No frame or only one frame. - this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; - this.currentPlayTimes = 1; - this.currentTime = this._actionTimeline.currentTime; - } - else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { // Action timeline or has scale and offset. - var playTimes = this._animationState.playTimes; - var totalTime = playTimes * this._duration; - passedTime *= this._timeScale; - if (this._timeOffset !== 0.0) { - passedTime += this._timeOffset * this._animationData.duration; - } - if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { - if (this.playState <= 0 && this._animationState._playheadState === 3) { - this.playState = 1; - } - this.currentPlayTimes = playTimes; - if (passedTime < 0.0) { - this.currentTime = 0.0; - } - else { - this.currentTime = this.playState === 1 ? this._duration + 0.000001 : this._duration; // Precision problem - } - } - else { - if (this.playState !== 0 && this._animationState._playheadState === 3) { - this.playState = 0; - } - if (passedTime < 0.0) { - passedTime = -passedTime; - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = this._duration - (passedTime % this._duration); - } - else { - this.currentPlayTimes = Math.floor(passedTime / this._duration); - this.currentTime = passedTime % this._duration; - } - } - this.currentTime += this._position; - } - else { // Multi frames. - this.playState = this._actionTimeline.playState; - this.currentPlayTimes = this._actionTimeline.currentPlayTimes; - this.currentTime = this._actionTimeline.currentTime; - } - if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { - return false; - } - // Clear frame flag when timeline start or loopComplete. - if ((prevState < 0 && this.playState !== prevState) || - (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { - this._frameIndex = -1; - } - return true; - }; - TimelineState.prototype.init = function (armature, animationState, timelineData) { - this._armature = armature; - this._animationState = animationState; - this._timelineData = timelineData; - this._actionTimeline = this._animationState._actionTimeline; - if (this === this._actionTimeline) { - this._actionTimeline = null; // - } - this._animationData = this._animationState.animationData; - // - this._frameRate = this._animationData.parent.frameRate; - this._frameRateR = 1.0 / this._frameRate; - this._position = this._animationState._position; - this._duration = this._animationState._duration; - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. - this._frameArray = dragonBonesData.frameArray; - this._timelineArray = dragonBonesData.timelineArray; - this._frameIndices = dragonBonesData.frameIndices; - // - this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; - this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; - this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; - this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; - } - }; - TimelineState.prototype.fadeOut = function () { - this.dirty = false; - }; - TimelineState.prototype.update = function (passedTime) { - if (this._setCurrentTime(passedTime)) { - if (this._frameCount > 1) { - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { - this._frameIndex = frameIndex; - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - this._onArriveAtFrame(); - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { // May be pose timeline. - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - } - this._onArriveAtFrame(); - } - if (this._isTween || this.dirty) { - this._onUpdateFrame(); - } - } - }; - TimelineState.prototype.blend = function (_isDirty) { - }; - return TimelineState; - }(dragonBones.BaseObject)); - dragonBones.TimelineState = TimelineState; - /** - * @internal - */ - var TweenTimelineState = /** @class */ (function (_super) { - __extends(TweenTimelineState, _super); - function TweenTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { - var value = progress; - switch (tweenType) { - case 3 /* QuadIn */: - value = Math.pow(progress, 2.0); - break; - case 4 /* QuadOut */: - value = 1.0 - Math.pow(1.0 - progress, 2.0); - break; - case 5 /* QuadInOut */: - value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); - break; - } - return (value - progress) * easing + progress; - }; - TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { - if (progress <= 0.0) { - return 0.0; - } - else if (progress >= 1.0) { - return 1.0; - } - var isOmited = count > 0; - var segmentCount = count + 1; // + 2 - 1 - var valueIndex = Math.floor(progress * segmentCount); - var fromValue = 0.0; - var toValue = 0.0; - if (isOmited) { - fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; - toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; - } - else { - fromValue = samples[offset + valueIndex - 1]; - toValue = samples[offset + valueIndex]; - } - return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; - }; - TweenTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._tweenType = 0 /* None */; - this._curveCount = 0; - this._framePosition = 0.0; - this._frameDurationR = 0.0; - this._tweenEasing = 0.0; - this._tweenProgress = 0.0; - this._valueScale = 1.0; - }; - TweenTimelineState.prototype._onArriveAtFrame = function () { - if (this._frameCount > 1 && - (this._frameIndex !== this._frameCount - 1 || - this._animationState.playTimes === 0 || - this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { - this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; - this._isTween = this._tweenType !== 0 /* None */; - if (this._isTween) { - if (this._tweenType === 2 /* Curve */) { - this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; - } - else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { - this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; - } - } - else { - this.dirty = true; - } - this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; - if (this._frameIndex === this._frameCount - 1) { - this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); - } - else { - var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; - var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; - if (frameDuration > 0) { - this._frameDurationR = 1.0 / frameDuration; - } - else { - this._frameDurationR = 0.0; - } - } - } - else { - this.dirty = true; - this._isTween = false; - } - }; - TweenTimelineState.prototype._onUpdateFrame = function () { - if (this._isTween) { - this.dirty = true; - this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; - if (this._tweenType === 2 /* Curve */) { - this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); - } - else if (this._tweenType !== 1 /* Line */) { - this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); - } - } - }; - return TweenTimelineState; - }(TimelineState)); - dragonBones.TweenTimelineState = TweenTimelineState; - /** - * @internal - */ - var SingleValueTimelineState = /** @class */ (function (_super) { - __extends(SingleValueTimelineState, _super); - function SingleValueTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SingleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._current = 0.0; - this._difference = 0.0; - this._result = 0.0; - }; - SingleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + 1; - if (valueScale === 1.0) { - this._current = valueArray[valueOffset]; - this._difference = valueArray[nextValueOffset] - this._current; - } - else { - this._current = valueArray[valueOffset] * valueScale; - this._difference = valueArray[nextValueOffset] * valueScale - this._current; - } - } - else { - this._result = valueArray[valueOffset] * valueScale; - } - } - else { - this._result = 0.0; - } - }; - SingleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._result = this._current + this._difference * this._tweenProgress; - } - }; - return SingleValueTimelineState; - }(TweenTimelineState)); - dragonBones.SingleValueTimelineState = SingleValueTimelineState; - /** - * @internal - */ - var DoubleValueTimelineState = /** @class */ (function (_super) { - __extends(DoubleValueTimelineState, _super); - function DoubleValueTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - DoubleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._currentA = 0.0; - this._currentB = 0.0; - this._differenceA = 0.0; - this._differenceB = 0.0; - this._resultA = 0.0; - this._resultB = 0.0; - }; - DoubleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + 2; - if (valueScale === 1.0) { - this._currentA = valueArray[valueOffset]; - this._currentB = valueArray[valueOffset + 1]; - this._differenceA = valueArray[nextValueOffset] - this._currentA; - this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; - } - else { - this._currentA = valueArray[valueOffset] * valueScale; - this._currentB = valueArray[valueOffset + 1] * valueScale; - this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; - this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; - } - } - else { - this._resultA = valueArray[valueOffset] * valueScale; - this._resultB = valueArray[valueOffset + 1] * valueScale; - } - } - else { - this._resultA = 0.0; - this._resultB = 0.0; - } - }; - DoubleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._resultA = this._currentA + this._differenceA * this._tweenProgress; - this._resultB = this._currentB + this._differenceB * this._tweenProgress; - } - }; - return DoubleValueTimelineState; - }(TweenTimelineState)); - dragonBones.DoubleValueTimelineState = DoubleValueTimelineState; - /** - * @internal - */ - var MutilpleValueTimelineState = /** @class */ (function (_super) { - __extends(MutilpleValueTimelineState, _super); - function MutilpleValueTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rd = []; - return _this; - } - MutilpleValueTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._valueCount = 0; - this._rd.length = 0; - }; - MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - var valueCount = this._valueCount; - var rd = this._rd; - if (this._timelineData !== null) { - var valueScale = this._valueScale; - var valueArray = this._valueArray; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; - if (this._isTween) { - var nextValueOffset = this._frameIndex === this._frameCount - 1 ? - this._valueOffset + this._frameValueOffset : - valueOffset + valueCount; - if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; - } - } - } - else if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i]; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] * valueScale; - } - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = 0.0; - } - } - }; - MutilpleValueTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - var valueCount = this._valueCount; - var valueScale = this._valueScale; - var tweenProgress = this._tweenProgress; - var valueArray = this._valueArray; - var rd = this._rd; - // - var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; - if (valueScale === 1.0) { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; - } - } - else { - for (var i = 0; i < valueCount; ++i) { - rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; - } - } - } - }; - return MutilpleValueTimelineState; - }(TweenTimelineState)); - dragonBones.MutilpleValueTimelineState = MutilpleValueTimelineState; -})(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) { - /** - * @internal - */ - var ActionTimelineState = /** @class */ (function (_super) { - __extends(ActionTimelineState, _super); - function ActionTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ActionTimelineState.toString = function () { - return "[class dragonBones.ActionTimelineState]"; - }; - ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { - var eventDispatcher = this._armature.eventDispatcher; - if (this._animationState.actionEnabled) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; - var actionCount = this._frameArray[frameOffset + 1]; - var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. - for (var i = 0; i < actionCount; ++i) { - var actionIndex = this._frameArray[frameOffset + 2 + i]; - var action = actions[actionIndex]; - if (action.type === 0 /* Play */) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._bufferAction(eventObject, true); - } - else { - var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; - if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - eventObject.time = this._frameArray[frameOffset] / this._frameRate; - eventObject.animationState = this._animationState; - dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); - this._armature._dragonBones.bufferEvent(eventObject); - } - } - } - } - }; - ActionTimelineState.prototype._onArriveAtFrame = function () { }; - ActionTimelineState.prototype._onUpdateFrame = function () { }; - ActionTimelineState.prototype.update = function (passedTime) { - var prevState = this.playState; - var prevPlayTimes = this.currentPlayTimes; - var prevTime = this.currentTime; - if (this._setCurrentTime(passedTime)) { - var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; - var eventDispatcher = this._armature.eventDispatcher; - if (prevState < 0) { - if (this.playState !== prevState) { - if (this._animationState.displayControl && this._animationState.resetToPose) { // Reset zorder to pose. - this._armature._sortZOrder(null, 0); - } - prevPlayTimes = this.currentPlayTimes; - if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.type = dragonBones.EventObject.START; - eventObject.armature = this._armature; - eventObject.animationState = this._animationState; - this._armature._dragonBones.bufferEvent(eventObject); - } - } - else { - return; - } - } - var isReverse = this._animationState.timeScale < 0.0; - var loopCompleteEvent = null; - var completeEvent = null; - if (eventActive && this.currentPlayTimes !== prevPlayTimes) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { - loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; - loopCompleteEvent.armature = this._armature; - loopCompleteEvent.animationState = this._animationState; - } - if (this.playState > 0) { - if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { - completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - completeEvent.type = dragonBones.EventObject.COMPLETE; - completeEvent.armature = this._armature; - completeEvent.animationState = this._animationState; - } - } - } - if (this._frameCount > 1) { - var timelineData = this._timelineData; - var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint - var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; - if (this._frameIndex !== frameIndex) { // Arrive at frame. - var crossedFrameIndex = this._frameIndex; - this._frameIndex = frameIndex; - if (this._timelineArray !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; - if (isReverse) { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - if (this.currentPlayTimes === prevPlayTimes) { // Start. - if (crossedFrameIndex === frameIndex) { // Uncrossed. - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration) { // Support interval play. - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event after first frame. - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - else { - if (crossedFrameIndex < 0) { - var prevFrameIndex = Math.floor(prevTime * this._frameRate); - crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { // Start. - if (prevTime <= framePosition) { // Crossed. - if (crossedFrameIndex > 0) { - crossedFrameIndex--; - } - else { - crossedFrameIndex = this._frameCount - 1; - } - } - else if (crossedFrameIndex === frameIndex) { // Uncrossed. - crossedFrameIndex = -1; - } - } - } - while (crossedFrameIndex >= 0) { - if (crossedFrameIndex < this._frameCount - 1) { - crossedFrameIndex++; - } - else { - crossedFrameIndex = 0; - } - var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; - // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem - var framePosition = this._frameArray[frameOffset] / this._frameRate; - if (this._position <= framePosition && - framePosition <= this._position + this._duration // - ) { // Support interval play. - this._onCrossFrame(crossedFrameIndex); - } - if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event before first frame. - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - if (crossedFrameIndex === frameIndex) { - break; - } - } - } - } - } - } - else if (this._frameIndex < 0) { - this._frameIndex = 0; - if (this._timelineData !== null) { - this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; - // Arrive at frame. - var framePosition = this._frameArray[this._frameOffset] / this._frameRate; - if (this.currentPlayTimes === prevPlayTimes) { // Start. - if (prevTime <= framePosition) { - this._onCrossFrame(this._frameIndex); - } - } - else if (this._position <= framePosition) { // Loop complete. - if (!isReverse && loopCompleteEvent !== null) { // Add loop complete event before first frame. - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - loopCompleteEvent = null; - } - this._onCrossFrame(this._frameIndex); - } - } - } - if (loopCompleteEvent !== null) { - this._armature._dragonBones.bufferEvent(loopCompleteEvent); - } - if (completeEvent !== null) { - this._armature._dragonBones.bufferEvent(completeEvent); - } - } - }; - ActionTimelineState.prototype.setCurrentTime = function (value) { - this._setCurrentTime(value); - this._frameIndex = -1; - }; - return ActionTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ActionTimelineState = ActionTimelineState; - /** - * @internal - */ - var ZOrderTimelineState = /** @class */ (function (_super) { - __extends(ZOrderTimelineState, _super); - function ZOrderTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - ZOrderTimelineState.toString = function () { - return "[class dragonBones.ZOrderTimelineState]"; - }; - ZOrderTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var count = this._frameArray[this._frameOffset + 1]; - if (count > 0) { - this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); - } - else { - this._armature._sortZOrder(null, 0); - } - } - }; - ZOrderTimelineState.prototype._onUpdateFrame = function () { }; - return ZOrderTimelineState; - }(dragonBones.TimelineState)); - dragonBones.ZOrderTimelineState = ZOrderTimelineState; - /** - * @internal - */ - var BoneAllTimelineState = /** @class */ (function (_super) { - __extends(BoneAllTimelineState, _super); - function BoneAllTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneAllTimelineState.toString = function () { - return "[class dragonBones.BoneAllTimelineState]"; - }; - BoneAllTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); - this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); - } - if (this._timelineData === null) { // Pose. - this._rd[4] = 1.0; - this._rd[5] = 1.0; - } - }; - BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = 6; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneAllTimelineState.prototype.fadeOut = function () { - this.dirty = false; - this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); - this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); - }; - BoneAllTimelineState.prototype.blend = function (isDirty) { - var valueScale = this._armature.armatureData.scale; - var rd = this._rd; - // - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.x += rd[0] * blendWeight * valueScale; - result.y += rd[1] * blendWeight * valueScale; - result.rotation += rd[2] * blendWeight; - result.skew += rd[3] * blendWeight; - result.scaleX += (rd[4] - 1.0) * blendWeight; - result.scaleY += (rd[5] - 1.0) * blendWeight; - } - else { - result.x = rd[0] * blendWeight * valueScale; - result.y = rd[1] * blendWeight * valueScale; - result.rotation = rd[2] * blendWeight; - result.skew = rd[3] * blendWeight; - result.scaleX = (rd[4] - 1.0) * blendWeight + 1.0; // - result.scaleY = (rd[5] - 1.0) * blendWeight + 1.0; // - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneAllTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.BoneAllTimelineState = BoneAllTimelineState; - /** - * @internal - */ - var BoneTranslateTimelineState = /** @class */ (function (_super) { - __extends(BoneTranslateTimelineState, _super); - function BoneTranslateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneTranslateTimelineState.toString = function () { - return "[class dragonBones.BoneTranslateTimelineState]"; - }; - BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneTranslateTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.x += this._resultA * blendWeight; - result.y += this._resultB * blendWeight; - } - else if (blendWeight !== 1.0) { - result.x = this._resultA * blendWeight; - result.y = this._resultB * blendWeight; - } - else { - result.x = this._resultA; - result.y = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneTranslateTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; - /** - * @internal - */ - var BoneRotateTimelineState = /** @class */ (function (_super) { - __extends(BoneRotateTimelineState, _super); - function BoneRotateTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneRotateTimelineState.toString = function () { - return "[class dragonBones.BoneRotateTimelineState]"; - }; - BoneRotateTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._isTween && this._frameIndex === this._frameCount - 1) { - this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); - this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); - } - }; - BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneRotateTimelineState.prototype.fadeOut = function () { - this.dirty = false; - this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); - this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); - }; - BoneRotateTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.rotation += this._resultA * blendWeight; - result.skew += this._resultB * blendWeight; - } - else if (blendWeight !== 1.0) { - result.rotation = this._resultA * blendWeight; - result.skew = this._resultB * blendWeight; - } - else { - result.rotation = this._resultA; - result.skew = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneRotateTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; - /** - * @internal - */ - var BoneScaleTimelineState = /** @class */ (function (_super) { - __extends(BoneScaleTimelineState, _super); - function BoneScaleTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - BoneScaleTimelineState.toString = function () { - return "[class dragonBones.BoneScaleTimelineState]"; - }; - BoneScaleTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { // Pose. - this._resultA = 1.0; - this._resultB = 1.0; - } - }; - BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameFloatOffset; - this._valueArray = this._animationData.parent.parent.frameFloatArray; - }; - BoneScaleTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var bone = blendState.target; - var blendWeight = blendState.blendWeight; - var result = bone.animationPose; - if (blendState.dirty > 1) { - result.scaleX += (this._resultA - 1.0) * blendWeight; - result.scaleY += (this._resultB - 1.0) * blendWeight; - } - else if (blendWeight !== 1.0) { - result.scaleX = (this._resultA - 1.0) * blendWeight + 1.0; - result.scaleY = (this._resultB - 1.0) * blendWeight + 1.0; - } - else { - result.scaleX = this._resultA; - result.scaleY = this._resultB; - } - if (isDirty || this.dirty) { - this.dirty = false; - bone._transformDirty = true; - } - }; - return BoneScaleTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; - /** - * @internal - */ - var SurfaceTimelineState = /** @class */ (function (_super) { - __extends(SurfaceTimelineState, _super); - function SurfaceTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SurfaceTimelineState.toString = function () { - return "[class dragonBones.SurfaceTimelineState]"; - }; - SurfaceTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._deformCount = 0; - this._deformOffset = 0; - this._sameValueOffset = 0; - }; - SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; - var frameIntArray = dragonBonesData.frameIntArray; - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = dragonBonesData.frameFloatArray; - this._rd.length = this._valueCount * 2; - } - else { - this._deformCount = this.target.target._deformVertices.length; - } - }; - SurfaceTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var surface = blendState.target; - var blendWeight = blendState.blendWeight; - var result = surface._deformVertices; - var valueArray = this._valueArray; - if (valueArray !== null) { - var valueCount = this._valueCount; - var deformOffset = this._deformOffset; - var sameValueOffset = this._sameValueOffset; - var rd = this._rd; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < deformOffset) { - value = valueArray[sameValueOffset + i]; - } - else if (i < deformOffset + valueCount) { - value = rd[i - deformOffset]; - } - else { - value = valueArray[sameValueOffset + i - valueCount]; - } - if (blendState.dirty > 1) { - result[i] += value * blendWeight; - } - else { - result[i] = value * blendWeight; - } - } - } - else if (blendState.dirty === 1) { - for (var i = 0; i < this._deformCount; ++i) { - result[i] = 0.0; - } - } - if (isDirty || this.dirty) { - this.dirty = false; - surface._transformDirty = true; - } - }; - return SurfaceTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.SurfaceTimelineState = SurfaceTimelineState; - /** - * @internal - */ - var AlphaTimelineState = /** @class */ (function (_super) { - __extends(AlphaTimelineState, _super); - function AlphaTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AlphaTimelineState.toString = function () { - return "[class dragonBones.AlphaTimelineState]"; - }; - AlphaTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { // Pose. - this._result = 1.0; - } - }; - AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.01; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - AlphaTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var alphaTarget = blendState.target; - var blendWeight = blendState.blendWeight; - if (blendState.dirty > 1) { - alphaTarget._alpha += this._result * blendWeight; - if (alphaTarget._alpha > 1.0) { - alphaTarget._alpha = 1.0; - } - } - else { - alphaTarget._alpha = this._result * blendWeight; - } - if (isDirty || this.dirty) { - this.dirty = false; - this._armature._alphaDirty = true; - } - }; - return AlphaTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AlphaTimelineState = AlphaTimelineState; - /** - * @internal - */ - var SlotDisplayTimelineState = /** @class */ (function (_super) { - __extends(SlotDisplayTimelineState, _super); - function SlotDisplayTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotDisplayTimelineState.toString = function () { - return "[class dragonBones.SlotDisplayTimelineState]"; - }; - SlotDisplayTimelineState.prototype._onArriveAtFrame = function () { - if (this.playState >= 0) { - var slot = this.target; - var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; - if (slot.displayIndex !== displayIndex) { - slot._setDisplayIndex(displayIndex, true); - } - } - }; - SlotDisplayTimelineState.prototype._onUpdateFrame = function () { - }; - return SlotDisplayTimelineState; - }(dragonBones.TimelineState)); - dragonBones.SlotDisplayTimelineState = SlotDisplayTimelineState; - /** - * @internal - */ - var SlotColorTimelineState = /** @class */ (function (_super) { - __extends(SlotColorTimelineState, _super); - function SlotColorTimelineState() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._difference = [0, 0, 0, 0, 0, 0, 0, 0]; - _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; - return _this; - } - SlotColorTimelineState.toString = function () { - return "[class dragonBones.SlotColorTimelineState]"; - }; - SlotColorTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData !== null) { - var dragonBonesData = this._animationData.parent.parent; - var colorArray = dragonBonesData.colorArray; - var frameIntArray = dragonBonesData.frameIntArray; - var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; - var colorOffset = frameIntArray[valueOffset]; - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bounds bug. - } - if (this._isTween) { - this._current[0] = colorArray[colorOffset++]; - this._current[1] = colorArray[colorOffset++]; - this._current[2] = colorArray[colorOffset++]; - this._current[3] = colorArray[colorOffset++]; - this._current[4] = colorArray[colorOffset++]; - this._current[5] = colorArray[colorOffset++]; - this._current[6] = colorArray[colorOffset++]; - this._current[7] = colorArray[colorOffset++]; - if (this._frameIndex === this._frameCount - 1) { - colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; - } - else { - colorOffset = frameIntArray[valueOffset + 1]; - } - if (colorOffset < 0) { - colorOffset += 65536; // Fixed out of bounds bug. - } - this._difference[0] = colorArray[colorOffset++] - this._current[0]; - this._difference[1] = colorArray[colorOffset++] - this._current[1]; - this._difference[2] = colorArray[colorOffset++] - this._current[2]; - this._difference[3] = colorArray[colorOffset++] - this._current[3]; - this._difference[4] = colorArray[colorOffset++] - this._current[4]; - this._difference[5] = colorArray[colorOffset++] - this._current[5]; - this._difference[6] = colorArray[colorOffset++] - this._current[6]; - this._difference[7] = colorArray[colorOffset++] - this._current[7]; - } - else { - this._result[0] = colorArray[colorOffset++] * 0.01; - this._result[1] = colorArray[colorOffset++] * 0.01; - this._result[2] = colorArray[colorOffset++] * 0.01; - this._result[3] = colorArray[colorOffset++] * 0.01; - this._result[4] = colorArray[colorOffset++]; - this._result[5] = colorArray[colorOffset++]; - this._result[6] = colorArray[colorOffset++]; - this._result[7] = colorArray[colorOffset++]; - } - } - else { // Pose. - var slot = this.target; - var color = slot.slotData.color; - this._result[0] = color.alphaMultiplier; - this._result[1] = color.redMultiplier; - this._result[2] = color.greenMultiplier; - this._result[3] = color.blueMultiplier; - this._result[4] = color.alphaOffset; - this._result[5] = color.redOffset; - this._result[6] = color.greenOffset; - this._result[7] = color.blueOffset; - } - }; - SlotColorTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - if (this._isTween) { - this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; - this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; - this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; - this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; - this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; - this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; - this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; - this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; - } - }; - SlotColorTimelineState.prototype.fadeOut = function () { - this._isTween = false; - }; - SlotColorTimelineState.prototype.update = function (passedTime) { - _super.prototype.update.call(this, passedTime); - // Fade animation. - if (this._isTween || this.dirty) { - var slot = this.target; - var result = slot._colorTransform; - if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); - result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; - result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; - result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; - result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; - result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; - result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; - result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; - result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; - slot._colorDirty = true; - } - } - else if (this.dirty) { - this.dirty = false; - if (result.alphaMultiplier !== this._result[0] || - result.redMultiplier !== this._result[1] || - result.greenMultiplier !== this._result[2] || - result.blueMultiplier !== this._result[3] || - result.alphaOffset !== this._result[4] || - result.redOffset !== this._result[5] || - result.greenOffset !== this._result[6] || - result.blueOffset !== this._result[7]) { - result.alphaMultiplier = this._result[0]; - result.redMultiplier = this._result[1]; - result.greenMultiplier = this._result[2]; - result.blueMultiplier = this._result[3]; - result.alphaOffset = this._result[4]; - result.redOffset = this._result[5]; - result.greenOffset = this._result[6]; - result.blueOffset = this._result[7]; - slot._colorDirty = true; - } - } - } - }; - return SlotColorTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.SlotColorTimelineState = SlotColorTimelineState; - /** - * @internal - */ - var SlotZIndexTimelineState = /** @class */ (function (_super) { - __extends(SlotZIndexTimelineState, _super); - function SlotZIndexTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - SlotZIndexTimelineState.toString = function () { - return "[class dragonBones.SlotZIndexTimelineState]"; - }; - SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { - _super.prototype._onArriveAtFrame.call(this); - if (this._timelineData === null) { // Pose. - var blendState = this.target; - var slot = blendState.target; - this._result = slot.slotData.zIndex; - } - }; - SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - SlotZIndexTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var slot = blendState.target; - var blendWeight = blendState.blendWeight; - if (blendState.dirty > 1) { - slot._zIndex += this._result * blendWeight; - } - else { - slot._zIndex = this._result * blendWeight; - } - if (isDirty || this.dirty) { - this.dirty = false; - this._armature._zIndexDirty = true; - } - }; - return SlotZIndexTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.SlotZIndexTimelineState = SlotZIndexTimelineState; - /** - * @internal - */ - var DeformTimelineState = /** @class */ (function (_super) { - __extends(DeformTimelineState, _super); - function DeformTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - DeformTimelineState.toString = function () { - return "[class dragonBones.DeformTimelineState]"; - }; - DeformTimelineState.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this.geometryOffset = 0; - this.displayFrame = null; - this._deformCount = 0; - this._deformOffset = 0; - this._sameValueOffset = 0; - }; - DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - if (this._timelineData !== null) { - var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; - var dragonBonesData = this._animationData.parent.parent; - var frameIntArray = dragonBonesData.frameIntArray; - var slot = this.target.target; - this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; - if (this.geometryOffset < 0) { - this.geometryOffset += 65536; // Fixed out of bounds bug. - } - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayFrame = slot.getDisplayFrameAt(i); - var geometryData = displayFrame.getGeometryData(); - if (geometryData === null) { - continue; - } - if (geometryData.offset === this.geometryOffset) { - this.displayFrame = displayFrame; - this.displayFrame.updateDeformVertices(); - break; - } - } - if (this.displayFrame === null) { - this.returnToPool(); // - return; - } - this._valueOffset = this._animationData.frameFloatOffset; - this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; - this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; - this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; - this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; - this._valueScale = this._armature.armatureData.scale; - this._valueArray = dragonBonesData.frameFloatArray; - this._rd.length = this._valueCount * 2; - } - else { - this._deformCount = this.displayFrame.deformVertices.length; - } - }; - DeformTimelineState.prototype.blend = function (isDirty) { - var blendState = this.target; - var slot = blendState.target; - var blendWeight = blendState.blendWeight; - var result = this.displayFrame.deformVertices; - var valueArray = this._valueArray; - if (valueArray !== null) { - var valueCount = this._valueCount; - var deformOffset = this._deformOffset; - var sameValueOffset = this._sameValueOffset; - var rd = this._rd; - for (var i = 0; i < this._deformCount; ++i) { - var value = 0.0; - if (i < deformOffset) { - value = valueArray[sameValueOffset + i]; - } - else if (i < deformOffset + valueCount) { - value = rd[i - deformOffset]; - } - else { - value = valueArray[sameValueOffset + i - valueCount]; - } - if (blendState.dirty > 1) { - result[i] += value * blendWeight; - } - else { - result[i] = value * blendWeight; - } - } - } - else if (blendState.dirty === 1) { - for (var i = 0; i < this._deformCount; ++i) { - result[i] = 0.0; - } - } - if (isDirty || this.dirty) { - this.dirty = false; - if (slot._geometryData === this.displayFrame.getGeometryData()) { - slot._verticesDirty = true; - } - } - }; - return DeformTimelineState; - }(dragonBones.MutilpleValueTimelineState)); - dragonBones.DeformTimelineState = DeformTimelineState; - /** - * @internal - */ - var IKConstraintTimelineState = /** @class */ (function (_super) { - __extends(IKConstraintTimelineState, _super); - function IKConstraintTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - IKConstraintTimelineState.toString = function () { - return "[class dragonBones.IKConstraintTimelineState]"; - }; - IKConstraintTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var ikConstraint = this.target; - if (this._timelineData !== null) { - ikConstraint._bendPositive = this._currentA > 0.0; - ikConstraint._weight = this._currentB; - } - else { - var ikConstraintData = ikConstraint._constraintData; - ikConstraint._bendPositive = ikConstraintData.bendPositive; - ikConstraint._weight = ikConstraintData.weight; - } - ikConstraint.invalidUpdate(); - this.dirty = false; - }; - IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.01; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return IKConstraintTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; - /** - * @internal - */ - var AnimationProgressTimelineState = /** @class */ (function (_super) { - __extends(AnimationProgressTimelineState, _super); - function AnimationProgressTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationProgressTimelineState.toString = function () { - return "[class dragonBones.AnimationProgressTimelineState]"; - }; - AnimationProgressTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.currentTime = this._result * animationState.totalTime; - } - this.dirty = false; - }; - AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationProgressTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AnimationProgressTimelineState = AnimationProgressTimelineState; - /** - * @internal - */ - var AnimationWeightTimelineState = /** @class */ (function (_super) { - __extends(AnimationWeightTimelineState, _super); - function AnimationWeightTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationWeightTimelineState.toString = function () { - return "[class dragonBones.AnimationWeightTimelineState]"; - }; - AnimationWeightTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.weight = this._result; - } - this.dirty = false; - }; - AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationWeightTimelineState; - }(dragonBones.SingleValueTimelineState)); - dragonBones.AnimationWeightTimelineState = AnimationWeightTimelineState; - /** - * @internal - */ - var AnimationParametersTimelineState = /** @class */ (function (_super) { - __extends(AnimationParametersTimelineState, _super); - function AnimationParametersTimelineState() { - return _super !== null && _super.apply(this, arguments) || this; - } - AnimationParametersTimelineState.toString = function () { - return "[class dragonBones.AnimationParametersTimelineState]"; - }; - AnimationParametersTimelineState.prototype._onUpdateFrame = function () { - _super.prototype._onUpdateFrame.call(this); - var animationState = this.target; - if (animationState._parent !== null) { - animationState.parameterX = this._resultA; - animationState.parameterY = this._resultB; - } - this.dirty = false; - }; - AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { - _super.prototype.init.call(this, armature, animationState, timelineData); - this._valueOffset = this._animationData.frameIntOffset; - this._valueScale = 0.0001; - this._valueArray = this._animationData.parent.parent.frameIntArray; - }; - return AnimationParametersTimelineState; - }(dragonBones.DoubleValueTimelineState)); - dragonBones.AnimationParametersTimelineState = AnimationParametersTimelineState; -})(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 properties of the object carry basic information about an event, - * which are passed as parameter or parameter's parameter to event listeners when an event occurs. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 - * @version DragonBones 4.5 - * @language zh_CN - */ - var EventObject = /** @class */ (function (_super) { - __extends(EventObject, _super); - function EventObject() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @internal - * @private - */ - EventObject.actionDataToInstance = function (data, instance, armature) { - if (data.type === 0 /* Play */) { - instance.type = EventObject.FRAME_EVENT; - } - else { - instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; - } - instance.name = data.name; - instance.armature = armature; - instance.actionData = data; - instance.data = data.data; - if (data.bone !== null) { - instance.bone = armature.getBone(data.bone.name); - } - if (data.slot !== null) { - instance.slot = armature.getSlot(data.slot.name); - } - }; - EventObject.toString = function () { - return "[class dragonBones.EventObject]"; - }; - EventObject.prototype._onClear = function () { - this.time = 0.0; - this.type = ""; - this.name = ""; - this.armature = null; - this.bone = null; - this.slot = null; - this.animationState = null; - this.actionData = null; - this.data = null; - }; - /** - * - Animation start play. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画开始播放。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.START = "start"; - /** - * - Animation loop play complete once. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画循环播放完成一次。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.LOOP_COMPLETE = "loopComplete"; - /** - * - Animation play complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画播放完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.COMPLETE = "complete"; - /** - * - Animation fade in start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN = "fadeIn"; - /** - * - Animation fade in complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡入完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_IN_COMPLETE = "fadeInComplete"; - /** - * - Animation fade out start. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出开始。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT = "fadeOut"; - /** - * - Animation fade out complete. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画淡出完成。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; - /** - * - Animation frame event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.FRAME_EVENT = "frameEvent"; - /** - * - Animation frame sound event. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 动画帧声音事件。 - * @version DragonBones 4.5 - * @language zh_CN - */ - EventObject.SOUND_EVENT = "soundEvent"; - return EventObject; - }(dragonBones.BaseObject)); - dragonBones.EventObject = EventObject; -})(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 DataParser = /** @class */ (function () { - function DataParser() { - } - DataParser._getArmatureType = function (value) { - switch (value.toLowerCase()) { - case "stage": - return 2 /* Stage */; - case "armature": - return 0 /* Armature */; - case "movieclip": - return 1 /* MovieClip */; - default: - return 0 /* Armature */; - } - }; - DataParser._getBoneType = function (value) { - switch (value.toLowerCase()) { - case "bone": - return 0 /* Bone */; - case "surface": - return 1 /* Surface */; - default: - return 0 /* Bone */; - } - }; - DataParser._getPositionMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "percent": - return 1 /* Percent */; - case "fixed": - return 0 /* Fixed */; - default: - return 1 /* Percent */; - } - }; - DataParser._getSpacingMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "length": - return 0 /* Length */; - case "percent": - return 2 /* Percent */; - case "fixed": - return 1 /* Fixed */; - default: - return 0 /* Length */; - } - }; - DataParser._getRotateMode = function (value) { - switch (value.toLocaleLowerCase()) { - case "tangent": - return 0 /* Tangent */; - case "chain": - return 1 /* Chain */; - case "chainscale": - return 2 /* ChainScale */; - default: - return 0 /* Tangent */; - } - }; - DataParser._getDisplayType = function (value) { - switch (value.toLowerCase()) { - case "image": - return 0 /* Image */; - case "mesh": - return 2 /* Mesh */; - case "armature": - return 1 /* Armature */; - case "boundingbox": - return 3 /* BoundingBox */; - case "path": - return 4 /* Path */; - default: - return 0 /* Image */; - } - }; - DataParser._getBoundingBoxType = function (value) { - switch (value.toLowerCase()) { - case "rectangle": - return 0 /* Rectangle */; - case "ellipse": - return 1 /* Ellipse */; - case "polygon": - return 2 /* Polygon */; - default: - return 0 /* Rectangle */; - } - }; - DataParser._getBlendMode = function (value) { - switch (value.toLowerCase()) { - case "normal": - return 0 /* Normal */; - case "add": - return 1 /* Add */; - case "alpha": - return 2 /* Alpha */; - case "darken": - return 3 /* Darken */; - case "difference": - return 4 /* Difference */; - case "erase": - return 5 /* Erase */; - case "hardlight": - return 6 /* HardLight */; - case "invert": - return 7 /* Invert */; - case "layer": - return 8 /* Layer */; - case "lighten": - return 9 /* Lighten */; - case "multiply": - return 10 /* Multiply */; - case "overlay": - return 11 /* Overlay */; - case "screen": - return 12 /* Screen */; - case "subtract": - return 13 /* Subtract */; - default: - return 0 /* Normal */; - } - }; - DataParser._getAnimationBlendType = function (value) { - switch (value.toLowerCase()) { - case "none": - return 0 /* None */; - case "1d": - return 1 /* E1D */; - default: - return 0 /* None */; - } - }; - DataParser._getActionType = function (value) { - switch (value.toLowerCase()) { - case "play": - return 0 /* Play */; - case "frame": - return 10 /* Frame */; - case "sound": - return 11 /* Sound */; - default: - return 0 /* Play */; - } - }; - DataParser.DATA_VERSION_2_3 = "2.3"; - DataParser.DATA_VERSION_3_0 = "3.0"; - DataParser.DATA_VERSION_4_0 = "4.0"; - DataParser.DATA_VERSION_4_5 = "4.5"; - DataParser.DATA_VERSION_5_0 = "5.0"; - DataParser.DATA_VERSION_5_5 = "5.5"; - DataParser.DATA_VERSION_5_6 = "5.6"; - DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_6; - DataParser.DATA_VERSIONS = [ - DataParser.DATA_VERSION_4_0, - DataParser.DATA_VERSION_4_5, - DataParser.DATA_VERSION_5_0, - DataParser.DATA_VERSION_5_5, - DataParser.DATA_VERSION_5_6 - ]; - DataParser.TEXTURE_ATLAS = "textureAtlas"; - DataParser.SUB_TEXTURE = "SubTexture"; - DataParser.FORMAT = "format"; - DataParser.IMAGE_PATH = "imagePath"; - DataParser.WIDTH = "width"; - DataParser.HEIGHT = "height"; - DataParser.ROTATED = "rotated"; - DataParser.FRAME_X = "frameX"; - DataParser.FRAME_Y = "frameY"; - DataParser.FRAME_WIDTH = "frameWidth"; - DataParser.FRAME_HEIGHT = "frameHeight"; - DataParser.DRADON_BONES = "dragonBones"; - DataParser.USER_DATA = "userData"; - DataParser.ARMATURE = "armature"; - DataParser.CANVAS = "canvas"; - DataParser.BONE = "bone"; - DataParser.SURFACE = "surface"; - DataParser.SLOT = "slot"; - DataParser.CONSTRAINT = "constraint"; - DataParser.SKIN = "skin"; - DataParser.DISPLAY = "display"; - DataParser.FRAME = "frame"; - DataParser.IK = "ik"; - DataParser.PATH_CONSTRAINT = "path"; - DataParser.ANIMATION = "animation"; - DataParser.TIMELINE = "timeline"; - DataParser.FFD = "ffd"; - DataParser.TRANSLATE_FRAME = "translateFrame"; - DataParser.ROTATE_FRAME = "rotateFrame"; - DataParser.SCALE_FRAME = "scaleFrame"; - DataParser.DISPLAY_FRAME = "displayFrame"; - DataParser.COLOR_FRAME = "colorFrame"; - DataParser.DEFAULT_ACTIONS = "defaultActions"; - DataParser.ACTIONS = "actions"; - DataParser.EVENTS = "events"; - DataParser.INTS = "ints"; - DataParser.FLOATS = "floats"; - DataParser.STRINGS = "strings"; - DataParser.TRANSFORM = "transform"; - DataParser.PIVOT = "pivot"; - DataParser.AABB = "aabb"; - DataParser.COLOR = "color"; - DataParser.VERSION = "version"; - DataParser.COMPATIBLE_VERSION = "compatibleVersion"; - DataParser.FRAME_RATE = "frameRate"; - DataParser.TYPE = "type"; - DataParser.SUB_TYPE = "subType"; - DataParser.NAME = "name"; - DataParser.PARENT = "parent"; - DataParser.TARGET = "target"; - DataParser.STAGE = "stage"; - DataParser.SHARE = "share"; - DataParser.PATH = "path"; - DataParser.LENGTH = "length"; - DataParser.DISPLAY_INDEX = "displayIndex"; - DataParser.Z_ORDER = "zOrder"; - DataParser.Z_INDEX = "zIndex"; - DataParser.BLEND_MODE = "blendMode"; - DataParser.INHERIT_TRANSLATION = "inheritTranslation"; - DataParser.INHERIT_ROTATION = "inheritRotation"; - DataParser.INHERIT_SCALE = "inheritScale"; - DataParser.INHERIT_REFLECTION = "inheritReflection"; - DataParser.INHERIT_ANIMATION = "inheritAnimation"; - DataParser.INHERIT_DEFORM = "inheritDeform"; - DataParser.SEGMENT_X = "segmentX"; - DataParser.SEGMENT_Y = "segmentY"; - DataParser.BEND_POSITIVE = "bendPositive"; - DataParser.CHAIN = "chain"; - DataParser.WEIGHT = "weight"; - DataParser.BLEND_TYPE = "blendType"; - DataParser.FADE_IN_TIME = "fadeInTime"; - DataParser.PLAY_TIMES = "playTimes"; - DataParser.SCALE = "scale"; - DataParser.OFFSET = "offset"; - DataParser.POSITION = "position"; - DataParser.DURATION = "duration"; - DataParser.TWEEN_EASING = "tweenEasing"; - DataParser.TWEEN_ROTATE = "tweenRotate"; - DataParser.TWEEN_SCALE = "tweenScale"; - DataParser.CLOCK_WISE = "clockwise"; - DataParser.CURVE = "curve"; - DataParser.SOUND = "sound"; - DataParser.EVENT = "event"; - DataParser.ACTION = "action"; - DataParser.X = "x"; - DataParser.Y = "y"; - DataParser.SKEW_X = "skX"; - DataParser.SKEW_Y = "skY"; - DataParser.SCALE_X = "scX"; - DataParser.SCALE_Y = "scY"; - DataParser.VALUE = "value"; - DataParser.ROTATE = "rotate"; - DataParser.SKEW = "skew"; - DataParser.ALPHA = "alpha"; - DataParser.ALPHA_OFFSET = "aO"; - DataParser.RED_OFFSET = "rO"; - DataParser.GREEN_OFFSET = "gO"; - DataParser.BLUE_OFFSET = "bO"; - DataParser.ALPHA_MULTIPLIER = "aM"; - DataParser.RED_MULTIPLIER = "rM"; - DataParser.GREEN_MULTIPLIER = "gM"; - DataParser.BLUE_MULTIPLIER = "bM"; - DataParser.UVS = "uvs"; - DataParser.VERTICES = "vertices"; - DataParser.TRIANGLES = "triangles"; - DataParser.WEIGHTS = "weights"; - DataParser.SLOT_POSE = "slotPose"; - DataParser.BONE_POSE = "bonePose"; - DataParser.BONES = "bones"; - DataParser.POSITION_MODE = "positionMode"; - DataParser.SPACING_MODE = "spacingMode"; - DataParser.ROTATE_MODE = "rotateMode"; - DataParser.SPACING = "spacing"; - DataParser.ROTATE_OFFSET = "rotateOffset"; - DataParser.ROTATE_MIX = "rotateMix"; - DataParser.TRANSLATE_MIX = "translateMix"; - DataParser.TARGET_DISPLAY = "targetDisplay"; - DataParser.CLOSED = "closed"; - DataParser.CONSTANT_SPEED = "constantSpeed"; - DataParser.VERTEX_COUNT = "vertexCount"; - DataParser.LENGTHS = "lengths"; - DataParser.GOTO_AND_PLAY = "gotoAndPlay"; - DataParser.DEFAULT_NAME = "default"; - return DataParser; - }()); - dragonBones.DataParser = DataParser; -})(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 ObjectDataParser = /** @class */ (function (_super) { - __extends(ObjectDataParser, _super); - function ObjectDataParser() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._rawTextureAtlasIndex = 0; - _this._rawBones = []; - _this._data = null; // - _this._armature = null; // - _this._bone = null; // - _this._geometry = null; // - _this._slot = null; // - _this._skin = null; // - _this._mesh = null; // - _this._animation = null; // - _this._timeline = null; // - _this._rawTextureAtlases = null; - _this._frameValueType = 0 /* Step */; - _this._defaultColorOffset = -1; - _this._prevClockwise = 0; - _this._prevRotation = 0.0; - _this._frameDefaultValue = 0.0; - _this._frameValueScale = 1.0; - _this._helpMatrixA = new dragonBones.Matrix(); - _this._helpMatrixB = new dragonBones.Matrix(); - _this._helpTransform = new dragonBones.Transform(); - _this._helpColorTransform = new dragonBones.ColorTransform(); - _this._helpPoint = new dragonBones.Point(); - _this._helpArray = []; - _this._intArray = []; - _this._floatArray = []; - _this._frameIntArray = []; - _this._frameFloatArray = []; - _this._frameArray = []; - _this._timelineArray = []; - _this._colorArray = []; - _this._cacheRawMeshes = []; - _this._cacheMeshes = []; - _this._actionFrames = []; - _this._weightSlotPose = {}; - _this._weightBonePoses = {}; - _this._cacheBones = {}; - _this._slotChildActions = {}; - return _this; - } - ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "boolean") { - return value; - } - else if (type === "string") { - switch (value) { - case "0": - case "NaN": - case "": - case "false": - case "null": - case "undefined": - return false; - default: - return true; - } - } - else { - return !!value; - } - } - return defaultValue; - }; - ObjectDataParser._getNumber = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - if (value === null || value === "NaN") { - return defaultValue; - } - return +value || 0; - } - return defaultValue; - }; - ObjectDataParser._getString = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var type = typeof value; - if (type === "string") { - return value; - } - return String(value); - } - return defaultValue; - }; - ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { - var l_t = 1.0 - t; - var powA = l_t * l_t; - var powB = t * t; - var kA = l_t * powA; - var kB = 3.0 * t * powA; - var kC = 3.0 * l_t * powB; - var kD = t * powB; - result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; - result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; - }; - ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { - var curveCount = curve.length; - if (curveCount % 3 === 1) { - var stepIndex = -2; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 - stepIndex += 6; - } - var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; - var x1 = isInCurve ? curve[stepIndex] : 0.0; - var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; - var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - return true; - } - else { - var stepIndex = 0; - for (var i = 0, l = samples.length; i < l; ++i) { - var t = (i + 1) / (l + 1); // float - while (curve[stepIndex + 6] < t) { // stepIndex + 3 * 2 - stepIndex += 6; - } - var x1 = curve[stepIndex]; - var y1 = curve[stepIndex + 1]; - var x2 = curve[stepIndex + 2]; - var y2 = curve[stepIndex + 3]; - var x3 = curve[stepIndex + 4]; - var y3 = curve[stepIndex + 5]; - var x4 = curve[stepIndex + 6]; - var y4 = curve[stepIndex + 7]; - var lower = 0.0; - var higher = 1.0; - while (higher - lower > 0.0001) { - var percentage = (higher + lower) * 0.5; - this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); - if (t - this._helpPoint.x > 0.0) { - lower = percentage; - } - else { - higher = percentage; - } - } - samples[i] = this._helpPoint.y; - } - return false; - } - }; - ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { - if (dragonBones.DataParser.EVENT in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.SOUND in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); - } - if (dragonBones.DataParser.ACTION in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); - } - if (dragonBones.DataParser.EVENTS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); - } - }; - ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { - var actionOffset = this._armature.actions.length; - var actions = this._parseActionData(rawData, type, bone, slot); - var frameIndex = 0; - var frame = null; - for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { - var action = actions_2[_i]; - this._armature.addAction(action, false); - } - if (this._actionFrames.length === 0) { // First frame. - frame = new ActionFrame(); - frame.frameStart = 0; - this._actionFrames.push(frame); - frame = null; - } - for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { // Get same frame. - var eachFrame = _b[_a]; - if (eachFrame.frameStart === frameStart) { - frame = eachFrame; - break; - } - else if (eachFrame.frameStart > frameStart) { - break; - } - frameIndex++; - } - if (frame === null) { // Create and cache frame. - frame = new ActionFrame(); - frame.frameStart = frameStart; - this._actionFrames.splice(frameIndex, 0, frame); - } - for (var i = 0; i < actions.length; ++i) { // Cache action offsets. - frame.actions.push(actionOffset + i); - } - }; - ObjectDataParser.prototype._parseArmature = function (rawData, scale) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); - armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); - armature.scale = scale; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); - } - else { - armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); - } - if (armature.frameRate === 0) { // Data error. - armature.frameRate = 24; - } - this._armature = armature; - if (dragonBones.DataParser.CANVAS in rawData) { - var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; - var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); - if (dragonBones.DataParser.COLOR in rawCanvas) { - canvas.hasBackground = true; - } - else { - canvas.hasBackground = false; - } - canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); - canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; - canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; - canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; - canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; - armature.canvas = canvas; - } - if (dragonBones.DataParser.AABB in rawData) { - var rawAABB = rawData[dragonBones.DataParser.AABB]; - armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; - armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; - armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; - armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; - } - if (dragonBones.DataParser.BONE in rawData) { - var rawBones = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { - var rawBone = rawBones_1[_i]; - var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); - var bone = this._parseBone(rawBone); - if (parentName.length > 0) { // Get bone parent. - var parent_1 = armature.getBone(parentName); - if (parent_1 !== null) { - bone.parent = parent_1; - } - else { // Cache. - if (!(parentName in this._cacheBones)) { - this._cacheBones[parentName] = []; - } - this._cacheBones[parentName].push(bone); - } - } - if (bone.name in this._cacheBones) { - for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { - var child = _b[_a]; - child.parent = bone; - } - delete this._cacheBones[bone.name]; - } - armature.addBone(bone); - this._rawBones.push(bone); // Cache raw bones sort. - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawIKS = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { - var rawIK = rawIKS_1[_c]; - var constraint = this._parseIKConstraint(rawIK); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - armature.sortBones(); - if (dragonBones.DataParser.SLOT in rawData) { - var zOrder = 0; - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { - var rawSlot = rawSlots_1[_d]; - armature.addSlot(this._parseSlot(rawSlot, zOrder++)); - } - } - if (dragonBones.DataParser.SKIN in rawData) { - var rawSkins = rawData[dragonBones.DataParser.SKIN]; - for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { - var rawSkin = rawSkins_1[_e]; - armature.addSkin(this._parseSkin(rawSkin)); - } - } - if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { - var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; - for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { - var rawPath = rawPaths_1[_f]; - var constraint = this._parsePathConstraint(rawPath); - if (constraint) { - armature.addConstraint(constraint); - } - } - } - for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { // Link mesh. - var rawData_1 = this._cacheRawMeshes[i]; - var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); - if (shareName.length === 0) { - continue; - } - var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - if (skinName.length === 0) { // - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; - if (shareMesh === null) { - continue; // Error. - } - var mesh = this._cacheMeshes[i]; - mesh.geometry.shareFrom(shareMesh.geometry); - } - if (dragonBones.DataParser.ANIMATION in rawData) { - var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; - for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { - var rawAnimation = rawAnimations_1[_g]; - var animation = this._parseAnimation(rawAnimation); - armature.addAnimation(animation); - } - } - if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); - for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { - var action = actions_3[_h]; - armature.addAction(action, true); - if (action.type === 0 /* Play */) { // Set default animation from default action. - var animation = armature.getAnimation(action.name); - if (animation !== null) { - armature.defaultAnimation = animation; - } - } - } - } - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { - var action = actions_4[_j]; - armature.addAction(action, false); - } - } - // Clear helper. - this._rawBones.length = 0; - this._cacheRawMeshes.length = 0; - this._cacheMeshes.length = 0; - this._armature = null; - for (var k in this._weightSlotPose) { - delete this._weightSlotPose[k]; - } - for (var k in this._weightBonePoses) { - delete this._weightBonePoses[k]; - } - for (var k in this._cacheBones) { - delete this._cacheBones[k]; - } - for (var k in this._slotChildActions) { - delete this._slotChildActions[k]; - } - return armature; - }; - ObjectDataParser.prototype._parseBone = function (rawData) { - var type = 0 /* Bone */; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); - } - if (type === 0 /* Bone */) { - var scale = this._armature.scale; - var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); - bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); - bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); - bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); - bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); - bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; - bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); - } - return bone; - } - var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); - surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); - surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); - this._parseGeometry(rawData, surface.geometry); - return surface; - }; - ObjectDataParser.prototype._parseIKConstraint = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); - if (bone === null) { - return null; - } - var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); - constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); - constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); - constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 0 /* IK */; - constraint.target = target; - if (chain > 0 && bone.parent !== null) { - constraint.root = bone.parent; - constraint.bone = bone; - } - else { - constraint.root = bone; - constraint.bone = null; - } - return constraint; - }; - ObjectDataParser.prototype._parsePathConstraint = function (rawData) { - var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); - if (target === null) { - return null; - } - var defaultSkin = this._armature.defaultSkin; - if (defaultSkin === null) { - return null; - } - //TODO - var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); - if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { - return null; - } - var bones = rawData[dragonBones.DataParser.BONES]; - if (bones === null || bones.length === 0) { - return null; - } - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); - constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - constraint.type = 1 /* Path */; - constraint.pathSlot = target; - constraint.pathDisplayData = targetDisplay; - constraint.target = target.parent; - constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); - constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); - constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); - constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); - constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); - constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); - constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); - constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); - // - for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { - var boneName = bones_3[_i]; - var bone = this._armature.getBone(boneName); - if (bone !== null) { - constraint.AddBone(bone); - if (constraint.root === null) { - constraint.root = bone; - } - } - } - return constraint; - }; - ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - slot.zOrder = zOrder; - slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); - slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); - slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // - if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { - slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); - } - else { - slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); - } - if (dragonBones.DataParser.COLOR in rawData) { - slot.color = dragonBones.SlotData.createColor(); - this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - if (dragonBones.DataParser.ACTIONS in rawData) { - this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - } - return slot; - }; - ObjectDataParser.prototype._parseSkin = function (rawData) { - var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); - skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (skin.name.length === 0) { - skin.name = dragonBones.DataParser.DEFAULT_NAME; - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawSlots = rawData[dragonBones.DataParser.SLOT]; - this._skin = skin; - for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { - var rawSlot = rawSlots_2[_i]; - var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); - var slot = this._armature.getSlot(slotName); - if (slot !== null) { - this._slot = slot; - if (dragonBones.DataParser.DISPLAY in rawSlot) { - var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; - for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { - var rawDisplay = rawDisplays_1[_a]; - if (rawDisplay) { - skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); - } - else { - skin.addDisplay(slotName, null); - } - } - } - this._slot = null; // - } - } - this._skin = null; // - } - return skin; - }; - ObjectDataParser.prototype._parseDisplay = function (rawData) { - var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); - var type = 0 /* Image */; - var display = null; - if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { - type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); - } - switch (type) { - case 0 /* Image */: { - var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); - imageDisplay.name = name; - imageDisplay.path = path.length > 0 ? path : name; - this._parsePivot(rawData, imageDisplay); - break; - } - case 1 /* Armature */: { - var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); - armatureDisplay.name = name; - armatureDisplay.path = path.length > 0 ? path : name; - armatureDisplay.inheritAnimation = true; - if (dragonBones.DataParser.ACTIONS in rawData) { - var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); - for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { - var action = actions_5[_i]; - armatureDisplay.addAction(action); - } - } - else if (this._slot.name in this._slotChildActions) { - var displays = this._skin.getDisplays(this._slot.name); - if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { - for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { - var action = _b[_a]; - armatureDisplay.addAction(action); - } - delete this._slotChildActions[this._slot.name]; - } - } - break; - } - case 2 /* Mesh */: { - var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); - meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); - meshDisplay.name = name; - meshDisplay.path = path.length > 0 ? path : name; - if (dragonBones.DataParser.SHARE in rawData) { - meshDisplay.geometry.data = this._data; - this._cacheRawMeshes.push(rawData); - this._cacheMeshes.push(meshDisplay); - } - else { - this._parseMesh(rawData, meshDisplay); - } - break; - } - case 3 /* BoundingBox */: { - var boundingBox = this._parseBoundingBox(rawData); - if (boundingBox !== null) { - var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); - boundingBoxDisplay.name = name; - boundingBoxDisplay.path = path.length > 0 ? path : name; - boundingBoxDisplay.boundingBox = boundingBox; - } - break; - } - case 4 /* Path */: { - var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; - var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); - pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); - pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); - pathDisplay.name = name; - pathDisplay.path = path.length > 0 ? path : name; - pathDisplay.curveLengths.length = rawCurveLengths.length; - for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { - pathDisplay.curveLengths[i] = rawCurveLengths[i]; - } - this._parsePath(rawData, pathDisplay); - break; - } - } - if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); - } - return display; - }; - ObjectDataParser.prototype._parsePath = function (rawData, display) { - this._parseGeometry(rawData, display.geometry); - }; - ObjectDataParser.prototype._parsePivot = function (rawData, display) { - if (dragonBones.DataParser.PIVOT in rawData) { - var rawPivot = rawData[dragonBones.DataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); - display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); - } - else { - display.pivot.x = 0.5; - display.pivot.y = 0.5; - } - }; - ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { - this._parseGeometry(rawData, mesh.geometry); - if (dragonBones.DataParser.WEIGHTS in rawData) { // Cache pose data. - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; - this._weightSlotPose[meshName] = rawSlotPose; - this._weightBonePoses[meshName] = rawBonePoses; - } - }; - ObjectDataParser.prototype._parseBoundingBox = function (rawData) { - var boundingBox = null; - var type = 0 /* Rectangle */; - if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { - type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); - } - else { - type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); - } - switch (type) { - case 0 /* Rectangle */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); - break; - case 1 /* Ellipse */: - boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); - break; - case 2 /* Polygon */: - boundingBox = this._parsePolygonBoundingBox(rawData); - break; - } - if (boundingBox !== null) { - boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); - if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { - boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); - boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); - } - } - return boundingBox; - }; - ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { - var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); - if (dragonBones.DataParser.VERTICES in rawData) { - var scale = this._armature.scale; - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertices = polygonBoundingBox.vertices; - vertices.length = rawVertices.length; - for (var i = 0, l = rawVertices.length; i < l; i += 2) { - var x = rawVertices[i] * scale; - var y = rawVertices[i + 1] * scale; - vertices[i] = x; - vertices[i + 1] = y; - // AABB. - if (i === 0) { - polygonBoundingBox.x = x; - polygonBoundingBox.y = y; - polygonBoundingBox.width = x; - polygonBoundingBox.height = y; - } - else { - if (x < polygonBoundingBox.x) { - polygonBoundingBox.x = x; - } - else if (x > polygonBoundingBox.width) { - polygonBoundingBox.width = x; - } - if (y < polygonBoundingBox.y) { - polygonBoundingBox.y = y; - } - else if (y > polygonBoundingBox.height) { - polygonBoundingBox.height = y; - } - } - } - polygonBoundingBox.width -= polygonBoundingBox.x; - polygonBoundingBox.height -= polygonBoundingBox.y; - } - else { - console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); - } - return polygonBoundingBox; - }; - ObjectDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.blendType = dragonBones.DataParser._getAnimationBlendType(ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); - animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); - animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - animation.frameIntOffset = this._frameIntArray.length; - animation.frameFloatOffset = this._frameFloatArray.length; - animation.frameOffset = this._frameArray.length; - this._animation = animation; - if (dragonBones.DataParser.FRAME in rawData) { - var rawFrames = rawData[dragonBones.DataParser.FRAME]; - var keyFrameCount = rawFrames.length; - if (keyFrameCount > 0) { - for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { - var rawFrame = rawFrames[i]; - this._parseActionDataInFrame(rawFrame, frameStart, null, null); - frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, 0 /* Step */, 0, this._parseZOrderFrame); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.BONE]; - for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { - var rawTimeline = rawTimelines_1[_i]; - this._parseBoneTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.SLOT]; - for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { - var rawTimeline = rawTimelines_2[_a]; - this._parseSlotTimeline(rawTimeline); - } - } - if (dragonBones.DataParser.FFD in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.FFD]; - for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { - var rawTimeline = rawTimelines_3[_b]; - var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); - var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); - var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - if (skinName.length === 0) { // - skinName = dragonBones.DataParser.DEFAULT_NAME; - } - this._slot = this._armature.getSlot(slotName); - this._mesh = this._armature.getMesh(skinName, slotName, displayName); - if (this._slot === null || this._mesh === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, 2 /* Float */, 0, this._parseSlotDeformFrame); - if (timeline !== null) { - this._animation.addSlotTimeline(slotName, timeline); - } - this._slot = null; // - this._mesh = null; // - } - } - if (dragonBones.DataParser.IK in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.IK]; - for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { - var rawTimeline = rawTimelines_4[_c]; - var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var constraint = this._armature.getConstraint(constraintName); - if (constraint === null) { - continue; - } - var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, 1 /* Int */, 2, this._parseIKConstraintFrame); - if (timeline !== null) { - this._animation.addConstraintTimeline(constraintName, timeline); - } - } - } - if (this._actionFrames.length > 0) { - this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, 0 /* Step */, 0, this._parseActionFrame); - this._actionFrames.length = 0; - } - if (dragonBones.DataParser.TIMELINE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { - var rawTimeline = rawTimelines_5[_d]; - var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); - var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = null; - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 20 /* SlotDisplay */: // TODO - case 23 /* SlotZIndex */: - case 60 /* BoneAlpha */: - case 24 /* SlotAlpha */: - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - if (timelineType === 20 /* SlotDisplay */) { - this._frameValueType = 0 /* Step */; - this._frameValueScale = 1.0; - } - else { - this._frameValueType = 1 /* Int */; - if (timelineType === 23 /* SlotZIndex */) { - this._frameValueScale = 1.0; - } - else if (timelineType === 40 /* AnimationProgress */ || - timelineType === 41 /* AnimationWeight */) { - this._frameValueScale = 10000.0; - } - else { - this._frameValueScale = 100.0; - } - } - if (timelineType === 60 /* BoneAlpha */ || - timelineType === 24 /* SlotAlpha */ || - timelineType === 41 /* AnimationWeight */) { - this._frameDefaultValue = 1.0; - } - else { - this._frameDefaultValue = 0.0; - } - if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); - var animaitonTimeline = timeline; - animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); - animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 1, this._parseSingleValueFrame, timeline); - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 30 /* IKConstraint */: - case 42 /* AnimationParameter */: - if (timelineType === 30 /* IKConstraint */ || - timelineType === 42 /* AnimationParameter */) { - this._frameValueType = 1 /* Int */; - if (timelineType === 42 /* AnimationParameter */) { - this._frameValueScale = 10000.0; - } - else { - this._frameValueScale = 100.0; - } - } - else { - if (timelineType === 12 /* BoneRotate */) { - this._frameValueScale = dragonBones.Transform.DEG_RAD; - } - else { - this._frameValueScale = 1.0; - } - this._frameValueType = 2 /* Float */; - } - if (timelineType === 13 /* BoneScale */ || - timelineType === 30 /* IKConstraint */) { - this._frameDefaultValue = 1.0; - } - else { - this._frameDefaultValue = 0.0; - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 2, this._parseDoubleValueFrame); - break; - case 1 /* ZOrder */: - // TODO - break; - case 50 /* Surface */: { - var surface = this._armature.getBone(timelineName); - if (surface === null) { - continue; - } - this._geometry = surface.geometry; - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); - this._geometry = null; // - break; - } - case 22 /* SlotDeform */: { - this._geometry = null; // - for (var skinName in this._armature.skins) { - var skin = this._armature.skins[skinName]; - for (var slontName in skin.displays) { - var displays = skin.displays[slontName]; - for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { - var display = displays_1[_e]; - if (display !== null && display.name === timelineName) { - this._geometry = display.geometry; - break; - } - } - } - } - if (this._geometry === null) { - continue; - } - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); - this._geometry = null; // - break; - } - case 21 /* SlotColor */: - timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 1 /* Int */, 1, this._parseSlotColorFrame); - break; - } - if (timeline !== null) { - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 1 /* ZOrder */: - // TODO - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 50 /* Surface */: - case 60 /* BoneAlpha */: - this._animation.addBoneTimeline(timelineName, timeline); - break; - case 20 /* SlotDisplay */: - case 21 /* SlotColor */: - case 22 /* SlotDeform */: - case 23 /* SlotZIndex */: - case 24 /* SlotAlpha */: - this._animation.addSlotTimeline(timelineName, timeline); - break; - case 30 /* IKConstraint */: - this._animation.addConstraintTimeline(timelineName, timeline); - break; - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - case 42 /* AnimationParameter */: - this._animation.addAnimationTimeline(timelineName, timeline); - break; - } - } - } - } - this._animation = null; // - return animation; - }; - ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, timelineType, frameValueType, frameValueCount, frameParser, timeline) { - if (timeline === void 0) { timeline = null; } - if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { - rawFrames = rawData[framesKey]; - } - if (rawFrames === null) { - return null; - } - var keyFrameCount = rawFrames.length; - if (keyFrameCount === 0) { - return null; - } - var frameIntArrayLength = this._frameIntArray.length; - var frameFloatArrayLength = this._frameFloatArray.length; - var timelineOffset = this._timelineArray.length; - if (timeline === null) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - } - timeline.type = timelineType; - timeline.offset = timelineOffset; - this._frameValueType = frameValueType; - this._timeline = timeline; - this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; - if (rawData !== null) { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); - } - else { - this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; - this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; - } - this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; - this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; - switch (this._frameValueType) { - case 0 /* Step */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; - break; - case 1 /* Int */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; - break; - case 2 /* Float */: - this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; - break; - } - if (keyFrameCount === 1) { // Only one frame. - timeline.frameIndicesOffset = -1; - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; - } - else { - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - var frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - var rawFrame = rawFrames[iK]; - frameStart = i; // frame.frameStart; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - if (rawFrame instanceof ActionFrame) { - frameCount = this._actionFrames[iK + 1].frameStart - frameStart; - } - else { - frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); - } - } - this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; - iK++; - } - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - this._timeline = null; // - return timeline; - }; - ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (bone === null) { - return; - } - this._bone = bone; - this._slot = this._armature.getSlot(this._bone.name); - if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { - this._frameDefaultValue = 0.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, 2 /* Float */, 2, this._parseDoubleValueFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.ROTATE_FRAME in rawData) { - this._frameDefaultValue = 0.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, 2 /* Float */, 2, this._parseBoneRotateFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.SCALE_FRAME in rawData) { - this._frameDefaultValue = 1.0; - this._frameValueScale = 1.0; - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, 2 /* Float */, 2, this._parseBoneScaleFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - if (dragonBones.DataParser.FRAME in rawData) { - var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, 2 /* Float */, 6, this._parseBoneAllFrame); - if (timeline !== null) { - this._animation.addBoneTimeline(bone.name, timeline); - } - } - this._bone = null; // - this._slot = null; // - }; - ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { - var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); - if (slot === null) { - return; - } - var displayTimeline = null; - var colorTimeline = null; - this._slot = slot; - if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); - } - else { - displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); - } - if (dragonBones.DataParser.COLOR_FRAME in rawData) { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); - } - else { - colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); - } - if (displayTimeline !== null) { - this._animation.addSlotTimeline(slot.name, displayTimeline); - } - if (colorTimeline !== null) { - this._animation.addSlotTimeline(slot.name, colorTimeline); - } - this._slot = null; // - }; - ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - rawData; - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - this._frameArray.length += 1; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - return frameOffset; - }; - ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (frameCount > 0) { - if (dragonBones.DataParser.CURVE in rawData) { - var sampleCount = frameCount + 1; - this._helpArray.length = sampleCount; - var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); - this._frameArray.length += 1 + 1 + this._helpArray.length; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited ? sampleCount : -sampleCount; - for (var i = 0; i < sampleCount; ++i) { - this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); - } - } - else { - var noTween = -2.0; - var tweenEasing = noTween; - if (dragonBones.DataParser.TWEEN_EASING in rawData) { - tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); - } - if (tweenEasing === noTween) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - else if (tweenEasing === 0.0) { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; - } - else if (tweenEasing < 0.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); - } - else if (tweenEasing <= 1.0) { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); - } - else { - this._frameArray.length += 1 + 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; - this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); - } - } - } - else { - this._frameArray.length += 1; - this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { - var frameOffset = 0; - switch (this._frameValueType) { - case 0: { - frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue); - break; - } - case 1: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale); - break; - } - case 2: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 1; - this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale; - break; - } - } - return frameOffset; - }; - ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { - var frameOffset = 0; - switch (this._frameValueType) { - case 0: { - frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 2; - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue); - this._frameArray[frameOffset + 2] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue); - break; - } - case 1: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale); - this._frameIntArray[frameValueOffset + 1] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale); - break; - } - case 2: { - frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameValueOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale; - this._frameFloatArray[frameValueOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale; - break; - } - } - return frameOffset; - }; - ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { - // tslint:disable-next-line:no-unused-expression - frameCount; - var frameOffset = this._frameArray.length; - var actionCount = frame.actions.length; - this._frameArray.length += 1 + 1 + actionCount; - this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; - this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. - for (var i = 0; i < actionCount; ++i) { // Action offsets. - this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - if (dragonBones.DataParser.Z_ORDER in rawData) { - var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; - if (rawZOrder.length > 0) { - var slotCount = this._armature.sortedSlots.length; - var unchanged = new Array(slotCount - rawZOrder.length / 2); - var zOrders = new Array(slotCount); - for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { - unchanged[i_1] = 0; - } - for (var i_2 = 0; i_2 < slotCount; ++i_2) { - zOrders[i_2] = -1; - } - var originalIndex = 0; - var unchangedIndex = 0; - for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { - var slotIndex = rawZOrder[i_3]; - var zOrderOffset = rawZOrder[i_3 + 1]; - while (originalIndex !== slotIndex) { - unchanged[unchangedIndex++] = originalIndex++; - } - var index = originalIndex + zOrderOffset; - zOrders[index] = originalIndex++; - } - while (originalIndex < slotCount) { - unchanged[unchangedIndex++] = originalIndex++; - } - this._frameArray.length += 1 + slotCount; - this._frameArray[frameOffset + 1] = slotCount; - var i = slotCount; - while (i--) { - if (zOrders[i] === -1) { - this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; - } - else { - this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; - } - } - return frameOffset; - } - } - this._frameArray.length += 1; - this._frameArray[frameOffset + 1] = 0; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { - this._helpTransform.identity(); - if (dragonBones.DataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); - } - // Modify rotation. - var rotation = this._helpTransform.rotation; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 6; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; - this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; - this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { - // Modify rotation. - var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; - if (frameStart !== 0) { - if (this._prevClockwise === 0) { - rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); - } - else { - if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { - this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; - } - rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; - } - } - this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); - this._prevRotation = rotation; - // - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = rotation; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; - return frameOffset; - }; - ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameFloatOffset = this._frameFloatArray.length; - this._frameFloatArray.length += 2; - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); - this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseFrame(rawData, frameStart, frameCount); - this._frameArray.length += 1; - if (dragonBones.DataParser.VALUE in rawData) { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); - } - else { - this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); - } - this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var colorOffset = -1; - if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { - var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; - for (var k in rawColor) { // Detects the presence of color. - // tslint:disable-next-line:no-unused-expression - k; - this._parseColorTransform(rawColor, this._helpColorTransform); - colorOffset = this._colorArray.length; - this._colorArray.length += 8; - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); - this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); - colorOffset -= 8; - break; - } - } - if (colorOffset < 0) { - if (this._defaultColorOffset < 0) { - this._defaultColorOffset = colorOffset = this._colorArray.length; - this._colorArray.length += 8; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 100; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - this._colorArray[colorOffset++] = 0; - } - colorOffset = this._defaultColorOffset; - } - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1; - this._frameIntArray[frameIntOffset] = colorOffset; - return frameOffset; - }; - ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; - var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; - var weight = this._mesh.geometry.weight; - var x = 0.0; - var y = 0.0; - var iB = 0; - var iV = 0; - if (weight !== null) { - var rawSlotPose = this._weightSlotPose[meshName]; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - this._frameFloatArray.length += weight.count * 2; - iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; - } - else { - this._frameFloatArray.length += vertexCount * 2; - } - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices === null) { // Fill 0. - x = 0.0; - y = 0.0; - } - else { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - if (weight !== null) { // If mesh is skinned, transform point by bone bind pose. - var rawBonePoses = this._weightBonePoses[meshName]; - var vertexBoneCount = this._intArray[iB++]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var boneIndex = this._intArray[iB++]; - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; - this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; - } - } - else { - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 2; - this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; - this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); - return frameOffset; - }; - ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { - var actions = new Array(); - if (typeof rawData === "string") { - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - action.type = type; - action.name = rawData; - action.bone = bone; - action.slot = slot; - actions.push(action); - } - else if (rawData instanceof Array) { - for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { - var rawAction = rawData_2[_i]; - var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { - action.type = 0 /* Play */; - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); - } - else { - if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { - action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); - } - else { - action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); - } - action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); - } - if (dragonBones.DataParser.BONE in rawAction) { - var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); - action.bone = this._armature.getBone(boneName); - } - else { - action.bone = bone; - } - if (dragonBones.DataParser.SLOT in rawAction) { - var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); - action.slot = this._armature.getSlot(slotName); - } - else { - action.slot = slot; - } - var userData = null; - if (dragonBones.DataParser.INTS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawInts = rawAction[dragonBones.DataParser.INTS]; - for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { - var rawValue = rawInts_1[_a]; - userData.addInt(rawValue); - } - } - if (dragonBones.DataParser.FLOATS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; - for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { - var rawValue = rawFloats_1[_b]; - userData.addFloat(rawValue); - } - } - if (dragonBones.DataParser.STRINGS in rawAction) { - if (userData === null) { - userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); - } - var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; - for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { - var rawValue = rawStrings_1[_c]; - userData.addString(rawValue); - } - } - action.data = userData; - actions.push(action); - } - } - return actions; - }; - ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { - var frameFloatOffset = this._frameFloatArray.length; - var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); - var rawVertices = dragonBones.DataParser.VERTICES in rawData ? - rawData[dragonBones.DataParser.VERTICES] : - (dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null); - var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint - var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; - var weight = this._geometry.weight; - var x = 0.0; - var y = 0.0; - if (weight !== null) { - // TODO - } - else { - this._frameFloatArray.length += vertexCount * 2; - for (var i = 0; i < vertexCount * 2; i += 2) { - if (rawVertices !== null) { - if (i < offset || i - offset >= rawVertices.length) { - x = 0.0; - } - else { - x = rawVertices[i - offset]; - } - if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { - y = 0.0; - } - else { - y = rawVertices[i + 1 - offset]; - } - } - else { - x = 0.0; - y = 0.0; - } - this._frameFloatArray[frameFloatOffset + i] = x; - this._frameFloatArray[frameFloatOffset + i + 1] = y; - } - } - if (frameStart === 0) { - var frameIntOffset = this._frameIntArray.length; - this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; - this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; - this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; - this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; - this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; - this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; - } - return frameOffset; - }; - ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { - transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; - transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; - if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); - } - else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { - transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); - transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; - } - transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); - transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); - }; - ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { - color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; - color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; - color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; - color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); - color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); - color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); - color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); - }; - ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { - var rawVertices = rawData[dragonBones.DataParser.VERTICES]; - var vertexCount = Math.floor(rawVertices.length / 2); // uint - var triangleCount = 0; - var geometryOffset = this._intArray.length; - var verticesOffset = this._floatArray.length; - // - geometry.offset = geometryOffset; - geometry.data = this._data; - // - this._intArray.length += 1 + 1 + 1 + 1; - this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; - this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; - this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // - // - this._floatArray.length += vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[verticesOffset + i] = rawVertices[i]; - } - if (dragonBones.DataParser.TRIANGLES in rawData) { - var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; - triangleCount = Math.floor(rawTriangles.length / 3); // uint - // - this._intArray.length += triangleCount * 3; - for (var i = 0, l = triangleCount * 3; i < l; ++i) { - this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; - } - } - // Fill triangle count. - this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; - if (dragonBones.DataParser.UVS in rawData) { - var rawUVs = rawData[dragonBones.DataParser.UVS]; - var uvOffset = verticesOffset + vertexCount * 2; - this._floatArray.length += vertexCount * 2; - for (var i = 0, l = vertexCount * 2; i < l; ++i) { - this._floatArray[uvOffset + i] = rawUVs[i]; - } - } - if (dragonBones.DataParser.WEIGHTS in rawData) { - var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; - var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint - var weightOffset = this._intArray.length; - var floatOffset = this._floatArray.length; - var weightBoneCount = 0; - var sortedBones = this._armature.sortedBones; - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - weight.count = weightCount; - weight.offset = weightOffset; - this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; - this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; - if (dragonBones.DataParser.BONE_POSE in rawData) { - var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; - var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; - var weightBoneIndices = new Array(); - weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint - weightBoneIndices.length = weightBoneCount; - for (var i = 0; i < weightBoneCount; ++i) { - var rawBoneIndex = rawBonePoses[i * 7]; // uint - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - weightBoneIndices[i] = rawBoneIndex; - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - this._helpMatrixA.copyFromArray(rawSlotPose, 0); - for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { - var iD = i * 2; - var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint - var x = this._floatArray[verticesOffset + iD]; - var y = this._floatArray[verticesOffset + iD + 1]; - this._helpMatrixA.transformPoint(x, y, this._helpPoint); - x = this._helpPoint.x; - y = this._helpPoint.y; - for (var j = 0; j < vertexBoneCount; ++j) { - var rawBoneIndex = rawWeights[iW++]; // uint - var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); - this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); - this._helpMatrixB.invert(); - this._helpMatrixB.transformPoint(x, y, this._helpPoint); - this._intArray[iB++] = boneIndex; - this._floatArray[iV++] = rawWeights[iW++]; - this._floatArray[iV++] = this._helpPoint.x; - this._floatArray[iV++] = this._helpPoint.y; - } - } - } - else { - var rawBones = rawData[dragonBones.DataParser.BONES]; - weightBoneCount = rawBones.length; - for (var i = 0; i < weightBoneCount; i++) { - var rawBoneIndex = rawBones[i]; - var bone = this._rawBones[rawBoneIndex]; - weight.addBone(bone); - this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); - } - this._floatArray.length += weightCount * 3; - for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { - var vertexBoneCount = rawWeights[iW++]; - this._intArray[iB++] = vertexBoneCount; - for (var j = 0; j < vertexBoneCount; j++) { - var boneIndex = rawWeights[iW++]; - var boneWeight = rawWeights[iW++]; - var x = rawVertices[iV++]; - var y = rawVertices[iV++]; - this._intArray[iB++] = rawBones.indexOf(boneIndex); - this._floatArray[iF++] = boneWeight; - this._floatArray[iF++] = x; - this._floatArray[iF++] = y; - } - } - } - geometry.weight = weight; - } - }; - ObjectDataParser.prototype._parseArray = function (rawData) { - // tslint:disable-next-line:no-unused-expression - rawData; - this._intArray.length = 0; - this._floatArray.length = 0; - this._frameIntArray.length = 0; - this._frameFloatArray.length = 0; - this._frameArray.length = 0; - this._timelineArray.length = 0; - this._colorArray.length = 0; - }; - ObjectDataParser.prototype._modifyArray = function () { - // Align. - if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._intArray.push(0); - } - if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameIntArray.push(0); - } - if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._frameArray.push(0); - } - if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { - this._timelineArray.push(0); - } - if ((this._timelineArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { - this._colorArray.push(0); - } - var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; - var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; - var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; - var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; - var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; - var l7 = this._colorArray.length * Int16Array.BYTES_PER_ELEMENT; - var lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7; - // - var binary = new ArrayBuffer(lTotal); - var intArray = new Int16Array(binary, 0, this._intArray.length); - var floatArray = new Float32Array(binary, l1, this._floatArray.length); - var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); - var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); - var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); - var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); - var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); - for (var i = 0, l = this._intArray.length; i < l; ++i) { - intArray[i] = this._intArray[i]; - } - for (var i = 0, l = this._floatArray.length; i < l; ++i) { - floatArray[i] = this._floatArray[i]; - } - for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { - frameIntArray[i] = this._frameIntArray[i]; - } - for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { - frameFloatArray[i] = this._frameFloatArray[i]; - } - for (var i = 0, l = this._frameArray.length; i < l; ++i) { - frameArray[i] = this._frameArray[i]; - } - for (var i = 0, l = this._timelineArray.length; i < l; ++i) { - timelineArray[i] = this._timelineArray[i]; - } - for (var i = 0, l = this._colorArray.length; i < l; ++i) { - colorArray[i] = this._colorArray[i]; - } - this._data.binary = binary; - this._data.intArray = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = frameArray; - this._data.timelineArray = timelineArray; - this._data.colorArray = colorArray; - this._defaultColorOffset = -1; - }; - ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined, "Data error."); - var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); - var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); - if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || - dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { - var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); - data.version = version; - data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); - if (data.frameRate === 0) { // Data error. - data.frameRate = 24; - } - if (dragonBones.DataParser.ARMATURE in rawData) { - this._data = data; - this._parseArray(rawData); - var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; - for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { - var rawArmature = rawArmatures_1[_i]; - data.addArmature(this._parseArmature(rawArmature, scale)); - } - if (!this._data.binary) { // DragonBones.webAssembly ? 0 : null; - this._modifyArray(); - } - if (dragonBones.DataParser.STAGE in rawData) { - data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); - } - else if (data.armatureNames.length > 0) { - data.stage = data.getArmature(data.armatureNames[0]); - } - this._data = null; - } - if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { - this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; - } - return data; - } - else { - console.assert(false, "Nonsupport data version: " + version + "\n" + - "Please convert DragonBones data to support version.\n" + - "Read more: https://github.com/DragonBones/Tools/"); - } - return null; - }; - ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { - if (scale === void 0) { scale = 1.0; } - console.assert(rawData !== undefined); - if (rawData === null) { - if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { - return false; - } - var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; - this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); - if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { - this._rawTextureAtlasIndex = 0; - this._rawTextureAtlases = null; - } - return true; - } - // Texture format. - textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); - textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); - textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; - textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); - textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); - if (dragonBones.DataParser.SUB_TEXTURE in rawData) { - var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; - for (var i = 0, l = rawTextures.length; i < l; ++i) { - var rawTexture = rawTextures[i]; - var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); - var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); - var textureData = textureAtlasData.createTexture(); - textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); - textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); - textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); - textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); - textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); - textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); - if (frameWidth > 0.0 && frameHeight > 0.0) { - textureData.frame = dragonBones.TextureData.createRectangle(); - textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); - textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); - textureData.frame.width = frameWidth; - textureData.frame.height = frameHeight; - } - textureAtlasData.addTexture(textureData); - } - } - return true; - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - ObjectDataParser.getInstance = function () { - if (ObjectDataParser._objectDataParserInstance === null) { - ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); - } - return ObjectDataParser._objectDataParserInstance; - }; - ObjectDataParser._objectDataParserInstance = null; - return ObjectDataParser; - }(dragonBones.DataParser)); - dragonBones.ObjectDataParser = ObjectDataParser; - /** - * @private - */ - var ActionFrame = /** @class */ (function () { - function ActionFrame() { - this.frameStart = 0; - this.actions = []; - } - return ActionFrame; - }()); - dragonBones.ActionFrame = ActionFrame; -})(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 BinaryDataParser = /** @class */ (function (_super) { - __extends(BinaryDataParser, _super); - function BinaryDataParser() { - return _super !== null && _super.apply(this, arguments) || this; - } - BinaryDataParser.prototype._inRange = function (a, min, max) { - return min <= a && a <= max; - }; - BinaryDataParser.prototype._decodeUTF8 = function (data) { - var EOF_byte = -1; - var EOF_code_point = -1; - var FATAL_POINT = 0xFFFD; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte === EOF_byte) { - if (utf8_bytes_needed !== 0) { - code_point = FATAL_POINT; - } - else { - code_point = EOF_code_point; - } - } - else { - if (utf8_bytes_needed === 0) { - if (this._inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this._inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this._inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this._inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this._inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = _byte; - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = _byte; - } - } - } - } - //Decode string - if (code_point !== null && code_point !== EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; - }; - BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { - if (timelineData === void 0) { timelineData = null; } - var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); - timeline.type = type; - timeline.offset = offset; - this._timeline = timeline; - var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; - if (keyFrameCount === 1) { - timeline.frameIndicesOffset = -1; - } - else { - var frameIndicesOffset = 0; - var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. - var frameIndices = this._data.frameIndices; - frameIndicesOffset = frameIndices.length; - frameIndices.length += totalFrameCount; - timeline.frameIndicesOffset = frameIndicesOffset; - for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { - if (frameStart + frameCount <= i && iK < keyFrameCount) { - frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; - if (iK === keyFrameCount - 1) { - frameCount = this._animation.frameCount - frameStart; - } - else { - frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; - } - iK++; - } - frameIndices[frameIndicesOffset + i] = iK - 1; - } - } - this._timeline = null; // - return timeline; - }; - BinaryDataParser.prototype._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.blendType = dragonBones.DataParser._getAnimationBlendType(dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); - animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); - animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); - animation.duration = animation.frameCount / this._armature.frameRate; // float - animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); - animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); - animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); - if (animation.name.length === 0) { - animation.name = dragonBones.DataParser.DEFAULT_NAME; - } - // Offsets. - var offsets = rawData[dragonBones.DataParser.OFFSET]; - animation.frameIntOffset = offsets[0]; - animation.frameFloatOffset = offsets[1]; - animation.frameOffset = offsets[2]; - this._animation = animation; - if (dragonBones.DataParser.ACTION in rawData) { - animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); - } - if (dragonBones.DataParser.Z_ORDER in rawData) { - animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); - } - if (dragonBones.DataParser.BONE in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.BONE]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var bone = this._armature.getBone(k); - if (bone === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addBoneTimeline(bone.name, timeline); - } - } - } - if (dragonBones.DataParser.SLOT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var slot = this._armature.getSlot(k); - if (slot === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addSlotTimeline(slot.name, timeline); - } - } - } - if (dragonBones.DataParser.CONSTRAINT in rawData) { - var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; - for (var k in rawTimeliness) { - var rawTimelines = rawTimeliness[k]; - var constraint = this._armature.getConstraint(k); - if (constraint === null) { - continue; - } - for (var i = 0, l = rawTimelines.length; i < l; i += 2) { - var timelineType = rawTimelines[i]; - var timelineOffset = rawTimelines[i + 1]; - var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); - this._animation.addConstraintTimeline(constraint.name, timeline); - } - } - } - if (dragonBones.DataParser.TIMELINE in rawData) { - var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; - for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { - var rawTimeline = rawTimelines_6[_i]; - var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); - if (timelineOffset >= 0) { - var timelineType = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); - var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); - var timeline = null; - if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { - timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); - var animaitonTimeline = timeline; - animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); - animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); - } - timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); - switch (timelineType) { - case 0 /* Action */: - // TODO - break; - case 1 /* ZOrder */: - // TODO - break; - case 11 /* BoneTranslate */: - case 12 /* BoneRotate */: - case 13 /* BoneScale */: - case 50 /* Surface */: - case 60 /* BoneAlpha */: - this._animation.addBoneTimeline(timelineName, timeline); - break; - case 20 /* SlotDisplay */: - case 21 /* SlotColor */: - case 22 /* SlotDeform */: - case 23 /* SlotZIndex */: - case 24 /* SlotAlpha */: - this._animation.addSlotTimeline(timelineName, timeline); - break; - case 30 /* IKConstraint */: - this._animation.addConstraintTimeline(timelineName, timeline); - break; - case 40 /* AnimationProgress */: - case 41 /* AnimationWeight */: - case 42 /* AnimationParameter */: - this._animation.addAnimationTimeline(timelineName, timeline); - break; - } - } - } - } - this._animation = null; - return animation; - }; - BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { - geometry.offset = rawData[dragonBones.DataParser.OFFSET]; - geometry.data = this._data; - var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; - if (weightOffset >= 0) { - var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); - var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; - var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; - weight.offset = weightOffset; - for (var i = 0; i < boneCount; ++i) { - var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; - weight.addBone(this._rawBones[boneIndex]); - } - var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; - var weightCount = 0; - for (var i = 0, l = vertexCount; i < l; ++i) { - var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; - weightCount += vertexBoneCount; - boneIndicesOffset += vertexBoneCount; - } - weight.count = weightCount; - geometry.weight = weight; - } - }; - BinaryDataParser.prototype._parseArray = function (rawData) { - var offsets = rawData[dragonBones.DataParser.OFFSET]; - var l1 = offsets[1]; - var l2 = offsets[3]; - var l3 = offsets[5]; - var l4 = offsets[7]; - var l5 = offsets[9]; - var l6 = offsets[11]; - var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. - var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); - var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); - var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); - var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); - var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); - var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); - var colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. - this._data.binary = this._binary; - this._data.intArray = this._intArrayBuffer = intArray; - this._data.floatArray = floatArray; - this._data.frameIntArray = frameIntArray; - this._data.frameFloatArray = frameFloatArray; - this._data.frameArray = this._frameArrayBuffer = frameArray; - this._data.timelineArray = this._timelineArrayBuffer = timelineArray; - this._data.colorArray = colorArray; - }; - BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); - var tag = new Uint8Array(rawData, 0, 8); - if (tag[0] !== "D".charCodeAt(0) || - tag[1] !== "B".charCodeAt(0) || - tag[2] !== "D".charCodeAt(0) || - tag[3] !== "T".charCodeAt(0)) { - console.assert(false, "Nonsupport data."); - return null; - } - var headerLength = new Uint32Array(rawData, 8, 1)[0]; - var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); - var headerString = this._decodeUTF8(headerBytes); - var header = JSON.parse(headerString); - // - this._binaryOffset = 8 + 4 + headerLength; - this._binary = rawData; - return _super.prototype.parseDragonBonesData.call(this, header, scale); - }; - /** - * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. - * @deprecated - * @language en_US - */ - /** - * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 - * @deprecated - * @language zh_CN - */ - BinaryDataParser.getInstance = function () { - if (BinaryDataParser._binaryDataParserInstance === null) { - BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); - } - return BinaryDataParser._binaryDataParserInstance; - }; - BinaryDataParser._binaryDataParserInstance = null; - return BinaryDataParser; - }(dragonBones.ObjectDataParser)); - dragonBones.BinaryDataParser = BinaryDataParser; -})(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) { - /** - * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) - * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. - * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) - * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 - * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - * @language zh_CN - */ - var BaseFactory = /** @class */ (function () { - /** - * - Create a factory instance. (typically only one global factory instance is required) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) - * @version DragonBones 3.0 - * @language zh_CN - */ - function BaseFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - /** - * @private - */ - this.autoSearch = false; - this._dragonBonesDataMap = {}; - this._textureAtlasDataMap = {}; - this._dragonBones = null; - this._dataParser = null; - if (BaseFactory._objectParser === null) { - BaseFactory._objectParser = new dragonBones.ObjectDataParser(); - } - if (BaseFactory._binaryParser === null) { - BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); - } - this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; - } - BaseFactory.prototype._isSupportMesh = function () { - return true; - }; - BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { - if (textureAtlasName in this._textureAtlasDataMap) { - for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { - var textureAtlasData = _a[_i]; - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - if (this.autoSearch) { // Will be search all data, if the autoSearch is true. - for (var k in this._textureAtlasDataMap) { - for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { - var textureAtlasData = _c[_b]; - if (textureAtlasData.autoSearch) { - var textureData = textureAtlasData.getTexture(textureName); - if (textureData !== null) { - return textureData; - } - } - } - } - } - return null; - }; - BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { - var dragonBonesData = null; - var armatureData = null; - if (dragonBonesName.length > 0) { - if (dragonBonesName in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - armatureData = dragonBonesData.getArmature(armatureName); - } - } - if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { // Will be search all data, if do not give a data name or the autoSearch is true. - for (var k in this._dragonBonesDataMap) { - dragonBonesData = this._dragonBonesDataMap[k]; - if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { - armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData !== null) { - dragonBonesName = k; - break; - } - } - } - } - if (armatureData !== null) { - dataPackage.dataName = dragonBonesName; - dataPackage.textureAtlasName = textureAtlasName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = null; - if (skinName.length > 0) { - dataPackage.skin = armatureData.getSkin(skinName); - if (dataPackage.skin === null && this.autoSearch) { - for (var k in this._dragonBonesDataMap) { - var skinDragonBonesData = this._dragonBonesDataMap[k]; - var skinArmatureData = skinDragonBonesData.getArmature(skinName); - if (skinArmatureData !== null) { - dataPackage.skin = skinArmatureData.defaultSkin; - break; - } - } - } - } - if (dataPackage.skin === null) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - return false; - }; - BaseFactory.prototype._buildBones = function (dataPackage, armature) { - for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { - var boneData = _a[_i]; - var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); - bone.init(boneData, armature); - } - }; - /** - * @private - */ - BaseFactory.prototype._buildSlots = function (dataPackage, armature) { - var currentSkin = dataPackage.skin; - var defaultSkin = dataPackage.armature.defaultSkin; - if (currentSkin === null || defaultSkin === null) { - return; - } - var skinSlots = {}; - for (var k in defaultSkin.displays) { - var displays = defaultSkin.getDisplays(k); - skinSlots[k] = displays; - } - if (currentSkin !== defaultSkin) { - for (var k in currentSkin.displays) { - var displays = currentSkin.getDisplays(k); - skinSlots[k] = displays; - } - } - for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { - var slotData = _a[_i]; - var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; - var slot = this._buildSlot(dataPackage, slotData, armature); - if (displayDatas !== null) { - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - slot.replaceRawDisplayData(displayData, i); - if (displayData !== null) { - if (dataPackage.textureAtlasName.length > 0) { - var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); - slot.replaceTextureData(textureData, i); - } - var display = this._getSlotDisplay(dataPackage, displayData, slot); - slot.replaceDisplay(display, i); - } - else { - slot.replaceDisplay(null); - } - } - } - slot._setDisplayIndex(slotData.displayIndex, true); - } - }; - BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { - var constraints = dataPackage.armature.constraints; - for (var k in constraints) { - var constraintData = constraints[k]; - // TODO more constraint type. - switch (constraintData.type) { - case 0 /* IK */: - var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - ikConstraint.init(constraintData, armature); - armature._addConstraint(ikConstraint); - break; - case 1 /* Path */: - var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); - pathConstraint.init(constraintData, armature); - armature._addConstraint(pathConstraint); - break; - default: - var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); - constraint.init(constraintData, armature); - armature._addConstraint(constraint); - break; - } - } - }; - BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { - return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); - }; - BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { - var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; - var display = null; - switch (displayData.type) { - case 0 /* Image */: { - var imageDisplayData = displayData; - if (imageDisplayData.texture === null) { - imageDisplayData.texture = this._getTextureData(dataName, displayData.path); - } - display = slot.rawDisplay; - break; - } - case 2 /* Mesh */: { - var meshDisplayData = displayData; - if (meshDisplayData.texture === null) { - meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); - } - if (this._isSupportMesh()) { - display = slot.meshDisplay; - } - else { - display = slot.rawDisplay; - } - break; - } - case 1 /* Armature */: { - var armatureDisplayData = displayData; - var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); - if (childArmature !== null) { - childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; - if (!childArmature.inheritAnimation) { - var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; - if (actions.length > 0) { - for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { - var action = actions_6[_i]; - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); - eventObject.slot = slot; - slot.armature._bufferAction(eventObject, false); - } - } - else { - childArmature.animation.play(); - } - } - armatureDisplayData.armature = childArmature.armatureData; // - } - display = childArmature; - break; - } - case 3 /* BoundingBox */: - break; - default: - break; - } - return display; - }; - /** - * - Parse the raw data to a DragonBonesData instance and cache it to the factory. - * @param rawData - The raw data. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for all armatures. (Default: 1.0) - * @returns DragonBonesData instance - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 - * @param rawData - 原始数据。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) - * @returns DragonBonesData 实例 - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; - var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); - while (true) { - var textureAtlasData = this._buildTextureAtlasData(null, null); - if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { - this.addTextureAtlasData(textureAtlasData, name); - } - else { - textureAtlasData.returnToPool(); - break; - } - } - if (dragonBonesData !== null) { - this.addDragonBonesData(dragonBonesData, name); - } - return dragonBonesData; - }; - /** - * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. - * @param rawData - The raw texture atlas data. - * @param textureAtlas - The texture atlas object. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) - * @param scale - Specify a scaling value for the map set. (Default: 1.0) - * @returns TextureAtlasData instance - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 - * @param rawData - 原始贴图集数据。 - * @param textureAtlas - 贴图集对象。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) - * @returns TextureAtlasData 实例 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 1.0; } - var textureAtlasData = this._buildTextureAtlasData(null, null); - this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); - this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); - this.addTextureAtlasData(textureAtlasData, name); - return textureAtlasData; - }; - /** - * - Update texture atlases. - * @param textureAtlases - The texture atlas objects. - * @param name - The texture atlas name. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 更新贴图集对象。 - * @param textureAtlases - 多个贴图集对象。 - * @param name - 贴图集名称。 - * @version DragonBones 5.7 - * @language zh_CN - */ - BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { - var textureAtlasDatas = this.getTextureAtlasData(name); - if (textureAtlasDatas !== null) { - for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { - if (i < textureAtlases.length) { - this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); - } - } - } - }; - /** - * - Get a specific DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @returns DragonBonesData instance - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 DragonBonesData 实例。 - * @param name - DragonBonesData 实例的缓存名称。 - * @returns DragonBonesData 实例 - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getDragonBonesData = function (name) { - return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; - }; - /** - * - Cache a DragonBonesData instance to the factory. - * @param data - The DragonBonesData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 DragonBonesData 实例缓存到工厂中。 - * @param data - DragonBonesData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addDragonBonesData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - if (name in this._dragonBonesDataMap) { - if (this._dragonBonesDataMap[name] === data) { - return; - } - console.warn("Can not add same name data: " + name); - return; - } - this._dragonBonesDataMap[name] = data; - }; - /** - * - Remove a DragonBonesData instance. - * @param name - The DragonBonesData instance cache name. - * @param disposeData - Whether to dispose data. (Default: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 DragonBonesData 实例。 - * @param name - DragonBonesData 实例缓存名称。 - * @param disposeData - 是否释放数据。 (默认: true) - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); - } - delete this._dragonBonesDataMap[name]; - } - }; - /** - * - Get a list of specific TextureAtlasData instances. - * @param name - The TextureAtlasData cahce name. - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 获取特定的 TextureAtlasData 实例列表。 - * @param name - TextureAtlasData 实例缓存名称。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.getTextureAtlasData = function (name) { - return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; - }; - /** - * - Cache a TextureAtlasData instance to the factory. - * @param data - The TextureAtlasData instance. - * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 将 TextureAtlasData 实例缓存到工厂中。 - * @param data - TextureAtlasData 实例。 - * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.addTextureAtlasData = function (data, name) { - if (name === void 0) { name = null; } - name = name !== null ? name : data.name; - var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); - if (textureAtlasList.indexOf(data) < 0) { - textureAtlasList.push(data); - } - }; - /** - * - Remove a TextureAtlasData instance. - * @param name - The TextureAtlasData instance cache name. - * @param disposeData - Whether to dispose data. - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 移除 TextureAtlasData 实例。 - * @param name - TextureAtlasData 实例的缓存名称。 - * @param disposeData - 是否释放数据。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { - if (disposeData === void 0) { disposeData = true; } - if (name in this._textureAtlasDataMap) { - var textureAtlasDataList = this._textureAtlasDataMap[name]; - if (disposeData) { - for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { - var textureAtlasData = textureAtlasDataList_1[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[name]; - } - }; - /** - * - Get a specific armature data. - * @param name - The armature data name. - * @param dragonBonesName - The cached name for DragonbonesData instance. - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language en_US - */ - /** - * - 获取特定的骨架数据。 - * @param name - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 5.1 - * @language zh_CN - */ - BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { - return null; - } - return dataPackage.armature; - }; - /** - * - Clear all cached DragonBonesData instances and TextureAtlasData instances. - * @param disposeData - Whether to dispose data. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 - * @param disposeData - 是否释放数据。 - * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.clear = function (disposeData) { - if (disposeData === void 0) { disposeData = true; } - for (var k in this._dragonBonesDataMap) { - if (disposeData) { - this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); - } - delete this._dragonBonesDataMap[k]; - } - for (var k in this._textureAtlasDataMap) { - if (disposeData) { - var textureAtlasDataList = this._textureAtlasDataMap[k]; - for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { - var textureAtlasData = textureAtlasDataList_2[_i]; - this._dragonBones.bufferObject(textureAtlasData); - } - } - delete this._textureAtlasDataMap[k]; - } - }; - /** - * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. - * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature. - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 - * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架。 - * @example - *
-         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
-         *     armature.clock = factory.clock;
-         * 
- * @see dragonBones.DragonBonesData - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - * @language zh_CN - */ - BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - var dataPackage = new BuildArmaturePackage(); - if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { - console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); - return null; - } - var armature = this._buildArmature(dataPackage); - this._buildBones(dataPackage, armature); - this._buildSlots(dataPackage, armature); - this._buildConstraints(dataPackage, armature); - armature.invalidUpdate(null, true); - armature.advanceTime(0.0); // Update armature pose. - return armature; - }; - /** - * @private - */ - BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - if (displayIndex < 0) { - displayIndex = slot.displayIndex; - } - if (displayIndex < 0) { - displayIndex = 0; - } - slot.replaceDisplayData(displayData, displayIndex); - if (displayData !== null) { - var display = this._getSlotDisplay(null, displayData, slot); - if (displayData.type === 0 /* Image */) { - var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; - if (rawDisplayData !== null && - rawDisplayData.type === 2 /* Mesh */) { - display = slot.meshDisplay; - } - } - slot.replaceDisplay(display, displayIndex); - } - else { - slot.replaceDisplay(null, displayIndex); - } - }; - /** - * - Replaces the current display data for a particular slot with a specific display data. - * Specify display data with "dragonBonesName/armatureName/slotName/displayName". - * @param dragonBonesName - The DragonBonesData instance cache name. - * @param armatureName - The armature data name. - * @param slotName - The slot data name. - * @param displayName - The display data name. - * @param slot - The slot. - * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 - * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 - * @param armatureName - 骨架数据名称。 - * @param slotName - 插槽数据名称。 - * @param displayName - 显示对象数据名称。 - * @param slot - 插槽。 - * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) - * @example - *
-         *     let slot = armature.getSlot("weapon");
-         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
-         * 
- * @version DragonBones 4.5 - * @language zh_CN - */ - BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (armatureData === null || armatureData.defaultSkin === null) { - return false; - } - var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); - this.replaceDisplay(slot, displayData, displayIndex); - return true; - }; - /** - * @private - */ - BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { - var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); - if (!armatureData || !armatureData.defaultSkin) { - return false; - } - var displayDatas = armatureData.defaultSkin.getDisplays(slotName); - if (!displayDatas) { - return false; - } - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - this.replaceDisplay(slot, displayData, i); - } - return true; - }; - /** - * - Share specific skin data with specific armature. - * @param armature - The armature. - * @param skin - The skin data. - * @param isOverride - Whether it completely override the original skin. (Default: false) - * @param exclude - A list of slot names that do not need to be replace. - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 将特定的皮肤数据共享给特定的骨架使用。 - * @param armature - 骨架。 - * @param skin - 皮肤数据。 - * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) - * @param exclude - 不需要被替换的插槽名称列表。 - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB && armatureDataB.defaultSkin) {
-         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.SkinData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { - if (isOverride === void 0) { isOverride = false; } - if (exclude === void 0) { exclude = null; } - var success = false; - var defaultSkin = skin.parent.defaultSkin; - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - if (exclude !== null && exclude.indexOf(slot.name) >= 0) { - continue; - } - var displayDatas = skin.getDisplays(slot.name); - if (displayDatas === null) { - if (defaultSkin !== null && skin !== defaultSkin) { - displayDatas = defaultSkin.getDisplays(slot.name); - } - if (displayDatas === null) { - if (isOverride) { - slot.displayFrameCount = 0; - } - continue; - } - } - slot.displayFrameCount = displayDatas.length; - for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { - var displayData = displayDatas[i]; - slot.replaceRawDisplayData(displayData, i); - if (displayData !== null) { - slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); - } - else { - slot.replaceDisplay(null, i); - } - } - success = true; - } - return success; - }; - /** - * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. - * This enables you to make a armature template so that other armature without animations can share it's animations. - * @param armature - The armtaure. - * @param armatureData - The armature data. - * @param isOverride - Whether to completely overwrite the original animation. (Default: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language en_US - */ - /** - * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 - * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 - * @param armature - 骨架。 - * @param armatureData - 骨架数据。 - * @param isOverride - 是否完全覆盖原来的动画。(默认: false) - * @example - *
-         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
-         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
-         *     if (armatureDataB) {
-         *     factory.replaceAnimation(armatureA, armatureDataB);
-         *     }
-         * 
- * @see dragonBones.Armature - * @see dragonBones.ArmatureData - * @version DragonBones 5.6 - * @language zh_CN - */ - BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { - if (isOverride === void 0) { isOverride = true; } - var skinData = armatureData.defaultSkin; - if (skinData === null) { - return false; - } - if (isOverride) { - armature.animation.animations = armatureData.animations; - } - else { - var rawAnimations = armature.animation.animations; - var animations = {}; - for (var k in rawAnimations) { - animations[k] = rawAnimations[k]; - } - for (var k in armatureData.animations) { - animations[k] = armatureData.animations[k]; - } - armature.animation.animations = animations; - } - for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - var index = 0; - for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { - var display = _c[_b]; - if (display instanceof dragonBones.Armature) { - var displayDatas = skinData.getDisplays(slot.name); - if (displayDatas !== null && index < displayDatas.length) { - var displayData = displayDatas[index]; - if (displayData !== null && displayData.type === 1 /* Armature */) { - var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); - if (childArmatureData) { - this.replaceAnimation(display, childArmatureData, isOverride); - } - } - } - } - index++; - } - } - return true; - }; - /** - * @private - */ - BaseFactory.prototype.getAllDragonBonesData = function () { - return this._dragonBonesDataMap; - }; - /** - * @private - */ - BaseFactory.prototype.getAllTextureAtlasData = function () { - return this._textureAtlasDataMap; - }; - Object.defineProperty(BaseFactory.prototype, "clock", { - /** - * - An Worldclock instance updated by engine. - * @version DragonBones 5.7 - * @language en_US - */ - /** - * - 由引擎驱动的 WorldClock 实例。 - * @version DragonBones 5.7 - * @language zh_CN - */ - get: function () { - return this._dragonBones.clock; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(BaseFactory.prototype, "dragonBones", { - /** - * @private - */ - get: function () { - return this._dragonBones; - }, - enumerable: true, - configurable: true - }); - BaseFactory._objectParser = null; - BaseFactory._binaryParser = null; - return BaseFactory; - }()); - dragonBones.BaseFactory = BaseFactory; - /** - * @private - */ - var BuildArmaturePackage = /** @class */ (function () { - function BuildArmaturePackage() { - this.dataName = ""; - this.textureAtlasName = ""; - this.skin = null; - } - return BuildArmaturePackage; - }()); - dragonBones.BuildArmaturePackage = BuildArmaturePackage; -})(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. - */ -if (CC_EDITOR) { - _Scene.Sandbox._globalsVerifier_loadPluginScript.ignoreNames['dragonBones'] = true; -} -var dragonBones; -(function (dragonBones) { - var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; - var DragonBonesAsset = /** @class */ (function (_super) { - __extends(DragonBonesAsset, _super); - function DragonBonesAsset() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.dragonBonesData = ""; - _this.textureAtlases = []; - _this.textures = []; - return _this; - } - __decorate([ - property - ], DragonBonesAsset.prototype, "dragonBonesData", void 0); - __decorate([ - property([cc.String]) - ], DragonBonesAsset.prototype, "textureAtlases", void 0); - __decorate([ - property([cc.Texture2D]) - ], DragonBonesAsset.prototype, "textures", void 0); - DragonBonesAsset = __decorate([ - ccclass("DragonBones.DragonBonesAsset") - ], DragonBonesAsset); - return DragonBonesAsset; - }(cc.Asset)); - dragonBones.DragonBonesAsset = DragonBonesAsset; -})(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 Cocos texture atlas data. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图集数据。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosTextureAtlasData = /** @class */ (function (_super) { - __extends(CocosTextureAtlasData, _super); - function CocosTextureAtlasData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._renderTexture = null; // Initial value. - return _this; - } - CocosTextureAtlasData.toString = function () { - return "[class dragonBones.CocosTextureAtlasData]"; - }; - CocosTextureAtlasData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this._renderTexture !== null) { - // this._renderTexture.dispose(); - } - this._renderTexture = null; - }; - CocosTextureAtlasData.prototype.createTexture = function () { - return dragonBones.BaseObject.borrowObject(CocosTextureData); - }; - Object.defineProperty(CocosTextureAtlasData.prototype, "renderTexture", { - /** - * - The Cocos texture. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 贴图。 - * @version DragonBones 3.0 - * @language zh_CN - */ - get: function () { - return this._renderTexture; - }, - set: function (value) { - if (this._renderTexture === value) { - return; - } - this._renderTexture = value; - if (this._renderTexture !== null) { - for (var k in this.textures) { - var textureData = this.textures[k]; - if (textureData.renderTexture !== null) { - textureData.renderTexture.destroy(); - } - var reat = cc.rect(textureData.region.x, textureData.region.y, textureData.rotated ? textureData.region.height : textureData.region.width, textureData.rotated ? textureData.region.width : textureData.region.height); - var offset = cc.v2(); - var originSize = cc.size(reat.size.width, reat.size.height); - textureData.renderTexture = new cc.SpriteFrame(this._renderTexture, reat, textureData.rotated, offset, originSize); - } - } - else { - for (var k in this.textures) { - var textureData = this.textures[k]; - if (textureData.renderTexture !== null) { - textureData.renderTexture.destroy(); - } - textureData.renderTexture = null; - } - } - }, - enumerable: true, - configurable: true - }); - return CocosTextureAtlasData; - }(dragonBones.TextureAtlasData)); - dragonBones.CocosTextureAtlasData = CocosTextureAtlasData; - /** - * @internal - */ - var CocosTextureData = /** @class */ (function (_super) { - __extends(CocosTextureData, _super); - function CocosTextureData() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.renderTexture = null; // Initial value. - return _this; - } - CocosTextureData.toString = function () { - return "[class dragonBones.CocosTextureData]"; - }; - CocosTextureData.prototype._onClear = function () { - _super.prototype._onClear.call(this); - if (this.renderTexture !== null) { - this.renderTexture.destroy(); - } - this.renderTexture = null; - }; - return CocosTextureData; - }(dragonBones.TextureData)); - dragonBones.CocosTextureData = CocosTextureData; -})(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) { - // const _defaultItems = cc.Enum({ "None": -1 }); - // function _setItems(object: any, key: string, items: any) { - // (cc.Class as any).attr( // creator.d.ts error. - // object, - // key, - // { - // type: "Enum", - // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. - // } - // ); - // } - var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, executeInEditMode = _a.executeInEditMode, disallowMultiple = _a.disallowMultiple, playOnFocus = _a.playOnFocus, menu = _a.menu, help = _a.help; - /** - * @see dragonBones.IArmatureProxy - */ - var CocosArmatureComponent = /** @class */ (function (_super) { - __extends(CocosArmatureComponent, _super); - function CocosArmatureComponent() { - var _this = _super !== null && _super.apply(this, arguments) || this; - /** - * @private - */ - _this.debugDraw = false; - _this._debugDraw = false; - /** - * @internal - */ - _this._armature = null; - // Editor. - /** - * @internal - */ - _this._armatureName = ""; - _this.dragonBonesName = ''; - /** - * @internal - */ - _this._animationName = ""; - // Visibie. - /** - * @internal - */ - _this._dragonBonesAsset = null; - /** - * @internal - */ - _this._armatureNames = []; - /** - * @internal - */ - _this._animationNames = []; - /** - * @internal - */ - _this._playTimes = -1; - /** - * @internal - */ - _this._timeScale = 1.0; - return _this; - } - CocosArmatureComponent_1 = CocosArmatureComponent; - CocosArmatureComponent.prototype.dbInit = function (armature) { - this._armature = armature; - }; - CocosArmatureComponent.prototype.dbClear = function () { - this._armature = null; - _super.prototype.destroy.call(this); - }; - CocosArmatureComponent.prototype.dbUpdate = function () { - var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; - if (drawed || this._debugDraw) { - this._debugDraw = drawed; - } - }; - CocosArmatureComponent.prototype.dispose = function (_isposeProxy) { - if (_isposeProxy === void 0) { _isposeProxy = true; } - if (this._armature !== null) { - this._armature.dispose(); - this._armature = null; - } - }; - CocosArmatureComponent.prototype.destroy = function () { - this.dispose(); - if (false) { // `super.destroy()` will be called in `dbClear()`. - _super.prototype.destroy.call(this); - } - return true; - }; - /** - * @private - */ - CocosArmatureComponent.prototype.dispatchDBEvent = function (type, eventObject) { - var event = new cc.Event.EventCustom(type, false); - event.setUserData(eventObject); - this.node.dispatchEvent(event); - }; - CocosArmatureComponent.prototype.hasDBEventListener = function (type) { - return this.node.hasEventListener(type, false); // creator.d.ts error. - }; - CocosArmatureComponent.prototype.addDBEventListener = function (type, listener, target) { - this.node.on(type, listener, target); - }; - CocosArmatureComponent.prototype.removeDBEventListener = function (type, listener, target) { - this.node.off(type, listener, target); - }; - Object.defineProperty(CocosArmatureComponent.prototype, "armature", { - get: function () { - return this._armature; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CocosArmatureComponent.prototype, "animation", { - get: function () { - return this._armature.animation; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(CocosArmatureComponent.prototype, "dragonBonesAsset", { - get: function () { - return this._dragonBonesAsset || null; - }, - set: function (value) { - this._dragonBonesAsset = value; - this._loadAndDisplayDragonBones(); - }, - enumerable: true, - configurable: true - }); - CocosArmatureComponent.prototype._loadAndDisplayDragonBones = function () { - console.warn("\u5F00\u59CB\u521B\u5EFA DragonBones Armature"); - var notExistAsset = !this.dragonBonesAsset - || !this.dragonBonesAsset.dragonBonesData - || !this.dragonBonesAsset.textureAtlases - || !this.dragonBonesAsset.textures; - if (notExistAsset) { - console.error("dragonBonesAsset \u4E3A\u7A7A"); - return; - } - console.warn("\u521B\u5EFA DragonBones Armature"); - this._parseDragonAsset(); - this._parseDragonAtlasAsset(); - this.display(); - }; - CocosArmatureComponent.prototype._parseDragonAsset = function () { - var dragonBonesData; - if (typeof this.dragonBonesAsset.dragonBonesData === 'string') { - console.log("JSON.parse(this.dragonBonesAsset.dragonBonesData)"); - dragonBonesData = JSON.parse(this.dragonBonesAsset.dragonBonesData); - } - else { - dragonBonesData = this.dragonBonesAsset.dragonBonesData; - } - var data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); - if (data === null) { - console.warn("DragonBones Armature not exist"); - return; - } - this._armatureName = data.armatureNames[0]; - console.log("parseDragonBonesData", data); - }; - CocosArmatureComponent.prototype._parseDragonAtlasAsset = function () { - var _this = this; - var textureAtlases = this.dragonBonesAsset.textureAtlases; - if (typeof textureAtlases[0] === 'string') { - console.log('JSON.parse(this.dragonBonesAsset.textureAtlases)'); - textureAtlases = JSON.parse(textureAtlases); - } - else { - textureAtlases = this.dragonBonesAsset.textureAtlases; - } - var texture = Array.isArray(this.dragonBonesAsset.textures) ? this.dragonBonesAsset.textures[0] : this.dragonBonesAsset.textures; - if (typeof texture === 'string') { - cc.textureCache.addImage(texture, function (tex, error) { - if (error) { - console.error("error:" + error.message, error); - return; - } - var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); - console.log("parseTextureAtlasData", data); - console.log("dragonBonesAsset", _this.dragonBonesAsset); - console.log("textureAtlases", textureAtlases); - console.log("texture", tex); - }, this); - } - else { - var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); - console.log("string parseTextureAtlasData", data); - console.log("string dragonBonesAsset", this.dragonBonesAsset); - } - }; - CocosArmatureComponent.prototype.display = function () { - console.warn("Armature name:" + this._armatureName + ",dragonBonesName:" + this.dragonBonesName); - var armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); - if (!armatureComponent) { - console.log("armatureComponent is null"); - return; - } - armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); - armatureComponent.node.x = 0.0; - armatureComponent.node.y = 0; - this.node.addChild(armatureComponent.node); - this._dragonBonesNode = armatureComponent.node; - console.log("play animation default animation"); - }; - CocosArmatureComponent.prototype.onLoad = function () { - // this.display(); - if (!!this._dragonBonesNode) { - var component = this._dragonBonesNode.getComponent(CocosArmatureComponent_1); - var state = component.animation.play(component.animation.animationNames[0], 0); - if (!state) { - return; - } - console.warn("\u64AD\u653E\u52A8\u753B\uFF1A" + state.name, state); - } - else { - this._loadAndDisplayDragonBones(); - // this.onLoad(); - // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); - // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); - } - }; - var CocosArmatureComponent_1; - __decorate([ - property(cc.String) - ], CocosArmatureComponent.prototype, "_armatureName", void 0); - __decorate([ - property(cc.String) - ], CocosArmatureComponent.prototype, "_animationName", void 0); - __decorate([ - property({ - type: dragonBones.DragonBonesAsset, - }) - ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); - __decorate([ - property({ - type: dragonBones.DragonBonesAsset, - displayName: "DragonBones", - tooltip: "DragonBones Asset", - visible: true, - }) - ], CocosArmatureComponent.prototype, "dragonBonesAsset", null); - __decorate([ - property({ - type: [cc.String], - displayName: "Armature", - tooltip: "The armature name.", - visible: true, - editorOnly: true, - serializable: false, - }) - ], CocosArmatureComponent.prototype, "_armatureNames", void 0); - __decorate([ - property({ - type: [cc.String], - displayName: "Animation", - tooltip: "The animation name.", - visible: true, - editorOnly: true, - serializable: false, - }) - ], CocosArmatureComponent.prototype, "_animationNames", void 0); - __decorate([ - property({ - type: cc.Integer, - displayName: "Play times", - tooltip: "The animation play times.", - visible: true, - slide: true, - range: [-1, 99, 1], - }) - ], CocosArmatureComponent.prototype, "_playTimes", void 0); - __decorate([ - property({ - type: cc.Float, - displayName: "TimeScale", - tooltip: "The animation play speed.", - visible: true, - slide: true, - range: [-2, 2, 0.01], - }) - ], CocosArmatureComponent.prototype, "_timeScale", void 0); - CocosArmatureComponent = CocosArmatureComponent_1 = __decorate([ - ccclass("CocosArmatureComponent"), - executeInEditMode, - disallowMultiple, - playOnFocus, - menu("DragonBones/Armature"), - executeInEditMode, - help("https://github.com/DragonBones/") - ], CocosArmatureComponent); - return CocosArmatureComponent; - }(cc.Component)); - dragonBones.CocosArmatureComponent = CocosArmatureComponent; -})(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 Cocos slot. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 插槽。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosSlot = /** @class */ (function (_super) { - __extends(CocosSlot, _super); - function CocosSlot() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this._ccMeshDirty = false; - return _this; - } - CocosSlot.toString = function () { - return "[class dragonBones.CocosSlot]"; - }; - CocosSlot.prototype._onClear = function () { - _super.prototype._onClear.call(this); - this._textureScale = 1.0; - this._renderDisplay = null; - }; - CocosSlot.prototype._initDisplay = function (_value, _isRetain) { - }; - CocosSlot.prototype._disposeDisplay = function (value, isRelease) { - if (!isRelease) { - value.destroy(); - } - }; - CocosSlot.prototype._onUpdateDisplay = function () { - this._renderDisplay = (this._display ? this._display : this._rawDisplay); - }; - CocosSlot.prototype._addDisplay = function () { - var container = this._armature.display; - container.addChild(this._renderDisplay, this._zOrder); - }; - CocosSlot.prototype._replaceDisplay = function (value) { - var container = this._armature.display; - var prevDisplay = value; - if (this._renderDisplay.parent !== container) { - container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder()); - } - // container.removeChild(prevDisplay, false); - this._renderDisplay.active = true; - prevDisplay.active = false; - this._textureScale = 1.0; - }; - CocosSlot.prototype._removeDisplay = function () { - this._renderDisplay.parent.removeChild(this._renderDisplay, false); - }; - CocosSlot.prototype._updateZOrder = function () { - if (this._renderDisplay.getLocalZOrder() === this._zOrder) { - return; - } - this._renderDisplay.setLocalZOrder(this._zOrder); - }; - /** - * @internal - */ - CocosSlot.prototype._updateVisible = function () { - this._renderDisplay.active = this._parent.visible && this._visible; - }; - CocosSlot.prototype._updateBlendMode = function () { - var sprite = this._renderDisplay.getComponent(cc.Sprite); - if (sprite) { - switch (this._blendMode) { - case 0 /* Normal */: - break; - case 1 /* Add */: - var texture = sprite.spriteFrame.getTexture(); - var BlendFunc = cc.BlendFunc; // creator.d.ts error. - if (texture && texture.hasPremultipliedAlpha()) { - sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.ONE, BlendFunc.BlendFactor.ONE); // creator.d.ts error. - } - else { - sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.SRC_ALPHA, BlendFunc.BlendFactor.ONE); // creator.d.ts error. - } - break; - case 3 /* Darken */: - break; - case 4 /* Difference */: - break; - case 6 /* HardLight */: - break; - case 9 /* Lighten */: - break; - case 10 /* Multiply */: - break; - case 11 /* Overlay */: - break; - case 12 /* Screen */: - break; - default: - break; - } - } - else if (this._childArmature !== null) { - for (var _i = 0, _a = this._childArmature.getSlots(); _i < _a.length; _i++) { - var slot = _a[_i]; - slot._blendMode = this._blendMode; - slot._updateBlendMode(); - } - } - }; - CocosSlot.prototype._updateColor = function () { - var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha * 255; - var color = this._renderDisplay.color; - this._renderDisplay.opacity = alpha; - color.setR(this._colorTransform.redMultiplier * 0xFF); - color.setG(this._colorTransform.greenMultiplier * 0xFF); - color.setB(this._colorTransform.blueMultiplier * 0xFF); - this._renderDisplay.setColor(color); // creator.d.ts error. - }; - CocosSlot.prototype._updateFrame = function () { - var currentTextureData = this._textureData; - var sprite = this._renderDisplay.getComponent(cc.Sprite); - if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { - var currentTextureAtlasData = currentTextureData.parent; - if (this._armature.replacedTexture !== null) { // Update replaced texture atlas. - if (this._armature._replaceTextureAtlasData === null) { - currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); - currentTextureAtlasData.copyFrom(currentTextureData.parent); - currentTextureAtlasData.renderTexture = this._armature.replacedTexture; - this._armature._replaceTextureAtlasData = currentTextureAtlasData; - } - else { - currentTextureAtlasData = this._armature._replaceTextureAtlasData; - } - currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); - } - var renderTexture = currentTextureData.renderTexture; - if (renderTexture !== null) { - if (this._geometryData !== null) { // Mesh. - var data = this._geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; - var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; - var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - var uvOffset = vertexOffset + vertexCount * 2; - var scale = this._armature._armatureData.scale; - var textureAtlasSize = renderTexture.getTexture().getContentSizeInPixels(); - var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : textureAtlasSize.width; - var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : textureAtlasSize.height; - var region = currentTextureData.region; - var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); - var polygonInfo = { - triangles: { - verts: [], - indices: [] - }, - rect: boundsRect - }; - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var vertex = { - x: floatArray[vertexOffset + i] * scale, - y: -floatArray[vertexOffset + i + 1] * scale, - u: floatArray[uvOffset + i], - v: floatArray[uvOffset + i + 1] - }; - if (currentTextureData.rotated) { - var backU = vertex.u; - vertex.u = (region.x + (1.0 - vertex.v) * region.width) / textureAtlasWidth; - vertex.v = (region.y + backU * region.height) / textureAtlasHeight; - } - else { - vertex.u = (region.x + vertex.u * region.width) / textureAtlasWidth; - vertex.v = (region.y + vertex.v * region.height) / textureAtlasHeight; - } - polygonInfo.triangles.verts[i / 2] = vertex; - if (boundsRect.x > vertex.x) { - boundsRect.x = vertex.x; - } - if (boundsRect.width < vertex.x) { - boundsRect.width = vertex.x; - } - if (boundsRect.y > vertex.y) { - boundsRect.y = vertex.y; - } - if (boundsRect.height < vertex.y) { - boundsRect.height = vertex.y; - } - } - for (var i = 0; i < triangleCount * 3; ++i) { - polygonInfo.triangles.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; - } - this._textureScale = 1.0; - sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.MESH); // creator.d.ts error. - sprite.spriteFrame = renderTexture; - sprite._sgNode.setMeshPolygonInfo(polygonInfo); // creator.d.ts error. - sprite._sgNode.setContentSize(cc.size(boundsRect.width, boundsRect.height)); // creator.d.ts error. - var isSkinned = this._geometryData.weight !== null; - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - if (isSkinned || isSurface) { - this._identityTransform(); - } - // Delay to update cocos mesh. (some cocos bug.) - this._ccMeshDirty = true; - } - else { // Normal texture. - this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; - sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. - sprite.spriteFrame = renderTexture; - sprite._sgNode.setContentSize(renderTexture.getOriginalSize()); // creator.d.ts error. - } - this._visibleDirty = true; - // this._blendModeDirty = true; - // this._colorDirty = true; - return; - } - } - this._renderDisplay.active = false; - this._renderDisplay.setPosition(0.0, 0.0); - }; - CocosSlot.prototype._updateMesh = function () { - var scale = this._armature._armatureData.scale; - var deformVertices = this._displayFrame.deformVertices; - var bones = this._geometryBones; - var geometryData = this._geometryData; - var weightData = geometryData.weight; - var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform; - var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite; - var polygonInfo = meshDisplay.getMeshPolygonInfo(); - if (!polygonInfo) { - return; - } - var verticesAndUVs = polygonInfo.triangles.verts; - var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); - if (weightData !== null) { - var data = geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; - if (weightFloatOffset < 0) { - weightFloatOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { - var boneCount = intArray[iB++]; - var xG = 0.0, yG = 0.0; - for (var j = 0; j < boneCount; ++j) { - var boneIndex = intArray[iB++]; - var bone = bones[boneIndex]; - if (bone !== null) { - var matrix = bone.globalTransformMatrix; - var weight = floatArray[iV++]; - var xL = floatArray[iV++] * scale; - var yL = floatArray[iV++] * scale; - if (hasDeform) { - xL += deformVertices[iF++]; - yL += deformVertices[iF++]; - } - xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; - yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; - } - } - var vertex = verticesAndUVs[i]; - vertex.x = xG; - vertex.y = yG; - if (boundsRect.x > xG) { - boundsRect.x = xG; - } - if (boundsRect.width < xG) { - boundsRect.width = xG; - } - if (boundsRect.y > yG) { - boundsRect.y = yG; - } - if (boundsRect.height < yG) { - boundsRect.height = yG; - } - } - } - else { - var isSurface = this._parent._boneData.type !== 0 /* Bone */; - var data = geometryData.data; - var intArray = data.intArray; - var floatArray = data.floatArray; - var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; - var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; - if (vertexOffset < 0) { - vertexOffset += 65536; // Fixed out of bouds bug. - } - for (var i = 0, l = vertexCount * 2; i < l; i += 2) { - var iH = i / 2; // int. - var x = floatArray[vertexOffset + i] * scale; - var y = floatArray[vertexOffset + i + 1] * scale; - if (hasDeform) { - x += deformVertices[i]; - y += deformVertices[i + 1]; - } - var vertex = verticesAndUVs[iH]; - if (isSurface) { - var matrix = this._parent._getGlobalTransformMatrix(x, y); - vertex.x = matrix.a * x + matrix.c * y + matrix.tx; - vertex.y = matrix.b * x + matrix.d * y + matrix.ty; - // - x = vertex.x; - y = vertex.y; - } - else { - vertex.x = x; - y = vertex.y = -y; - } - if (boundsRect.x > x) { - boundsRect.x = x; - } - if (boundsRect.width < x) { - boundsRect.width = x; - } - if (boundsRect.y > y) { - boundsRect.y = y; - } - if (boundsRect.height < y) { - boundsRect.height = y; - } - } - } - boundsRect.width -= boundsRect.x; - boundsRect.height -= boundsRect.y; - polygonInfo.rect = boundsRect; - meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height)); - meshDisplay.setMeshPolygonInfo(polygonInfo); - if (weightData !== null) { - this._identityTransform(); - } - else { - var transform = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); - this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); - this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; - this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; - this._renderDisplay.scaleX = transform.scaleX * this._textureScale; - this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; - } - if (this._ccMeshDirty) { - this._ccMeshDirty = false; - this._verticesDirty = true; - } - }; - CocosSlot.prototype._updateTransform = function () { - // const globalTransformMatrix = this.globalTransformMatrix; - // const helpMatrix = TransformObject._helpMatrix; - // helpMatrix.a = globalTransformMatrix.a; - // helpMatrix.b = globalTransformMatrix.b; - // helpMatrix.c = -globalTransformMatrix.c; - // helpMatrix.d = -globalTransformMatrix.d; - // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { - // helpMatrix.tx = globalTransformMatrix.tx - (globalTransformMatrix.a * this._pivotX + globalTransformMatrix.c * this._pivotY); - // helpMatrix.ty = (globalTransformMatrix.ty - (globalTransformMatrix.b * this._pivotX + globalTransformMatrix.d * this._pivotY)); - // } - // else { - // helpMatrix.tx = globalTransformMatrix.tx; - // helpMatrix.ty = globalTransformMatrix.ty; - // } - // (this._renderDisplay as any)._sgNode._renderCmd.setNodeToParentTransform(helpMatrix); // creator.d.ts error. - this.updateGlobalTransform(); - var transform = this.global; - var globalTransformMatrix = this.globalTransformMatrix; - if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { - this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); - this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); - } - else { - this._renderDisplay.x = transform.x; - this._renderDisplay.y = transform.y; - } - this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; - this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; - this._renderDisplay.scaleX = transform.scaleX * this._textureScale; - this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; - }; - CocosSlot.prototype._identityTransform = function () { - // const helpMatrix = TransformObject._helpMatrix; - // helpMatrix.a = 1.0; - // helpMatrix.b = 0.0; - // helpMatrix.c = -0.0; - // helpMatrix.d = -1.0; - // helpMatrix.tx = 0.0; - // helpMatrix.ty = 0.0; - // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix); - this._renderDisplay.x = 0.0; - this._renderDisplay.y = 0.0; - this._renderDisplay.rotationX = 0.0; - this._renderDisplay.rotationY = 0.0; - this._renderDisplay.scaleX = 1.0; - this._renderDisplay.scaleY = 1.0; - }; - return CocosSlot; - }(dragonBones.Slot)); - dragonBones.CocosSlot = CocosSlot; -})(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) { - var ccclass = cc._decorator.ccclass; - var ClockHandler = /** @class */ (function (_super) { - __extends(ClockHandler, _super); - function ClockHandler() { - return _super !== null && _super.apply(this, arguments) || this; - } - ClockHandler.prototype.update = function (passedTime) { - CocosFactory.factory.dragonBones.advanceTime(passedTime); - }; - ClockHandler = __decorate([ - ccclass - ], ClockHandler); - return ClockHandler; - }(cc.Component)); - /** - * - The Cocos factory. - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - Cocos 工厂。 - * @version DragonBones 3.0 - * @language zh_CN - */ - var CocosFactory = /** @class */ (function (_super) { - __extends(CocosFactory, _super); - function CocosFactory(dataParser) { - if (dataParser === void 0) { dataParser = null; } - var _this = _super.call(this, dataParser) || this; - _this._node = null; - _this._armatureNode = null; - if (!CC_EDITOR) { // Is playing. - if (_this._node === null) { - var nodeName = "DragonBones Node"; - _this._node = cc.find(nodeName); - if (_this._node === null) { - _this._node = new cc.Node(nodeName); - cc.game.addPersistRootNode(_this._node); - } - } - if (!_this._node.getComponent(ClockHandler)) { - _this._node.addComponent(ClockHandler); - } - var eventManager = _this._node.getComponent(dragonBones.CocosArmatureComponent) || _this._node.addComponent(dragonBones.CocosArmatureComponent); - if (CocosFactory._dragonBonesInstance === null) { - CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); - // - dragonBones.DragonBones.yDown = false; - } - } - else { - if (CocosFactory._dragonBonesInstance === null) { - CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(null); - // - dragonBones.DragonBones.yDown = false; - } - } - _this._dragonBones = CocosFactory._dragonBonesInstance; - return _this; - } - Object.defineProperty(CocosFactory, "factory", { - /** - * - A global factory instance that can be used directly. - * @version DragonBones 4.7 - * @language en_US - */ - /** - * - 一个可以直接使用的全局工厂实例。 - * @version DragonBones 4.7 - * @language zh_CN - */ - get: function () { - if (this._factory === null) { - this._factory = new CocosFactory(); - } - return this._factory; - }, - enumerable: true, - configurable: true - }); - CocosFactory.prototype._isSupportMesh = function () { - if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { // creator.d.ts error. - console.warn("Only webgl mode can support mesh."); - return false; - } - return true; - }; - CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { - if (textureAtlasData !== null) { - textureAtlasData.renderTexture = textureAtlas; - } - else { - textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); - } - return textureAtlasData; - }; - CocosFactory.prototype._buildArmature = function (dataPackage) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); - var armatureDisplay = this._armatureNode === null ? new cc.Node(dataPackage.armature.name) : this._armatureNode; - var armatureComponent = armatureDisplay.getComponent(dragonBones.CocosArmatureComponent) || armatureDisplay.addComponent(dragonBones.CocosArmatureComponent); - armatureDisplay.setOpacityModifyRGB(false); - armatureDisplay.setCascadeOpacityEnabled(true); - armatureDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. - this._armatureNode = null; - armatureComponent._armature = armature; - armature.init(dataPackage.armature, armatureComponent, armatureDisplay, this._dragonBones); - return armature; - }; - CocosFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { - var childDisplayName = slot.slotData.name + " (" + displayData.path.replace("/", "_") + ")"; // - var proxy = slot.armature.proxy; - var childNode = cc.find(childDisplayName, proxy.node); - var childArmature = null; - if (!childNode) { - if (dataPackage !== null) { - childArmature = this.buildArmature(displayData.path, dataPackage.dataName); - } - else { - childArmature = this.buildArmature(displayData.path, displayData.parent.parent.parent.name); - } - } - else { - var childArmatureComponent = childNode.getComponent(dragonBones.CocosArmatureComponent) || null; - if (childArmatureComponent === null) { - if (dataPackage !== null) { - childArmatureComponent = this.buildArmatureComponent(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage.textureAtlasName, childNode); - } - else { - childArmatureComponent = this.buildArmatureComponent(displayData.path, "", "", "", childNode); - } - } - if (childArmatureComponent !== null) { - childArmature = childArmatureComponent.armature; - } - } - if (childArmature === null) { - return null; - } - var childArmatureDisplay = childArmature.display; - childArmatureDisplay.name = childDisplayName; - if (childArmatureDisplay.parent !== proxy.node) { - proxy.node.addChild(childArmatureDisplay, slot._zOrder); - } - childArmatureDisplay.active = false; - return childArmature; - }; - CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.CocosSlot); - var armatureDisplay = armature.display; - var rawSlotDisplay = cc.find(slotData.name, armatureDisplay) || new cc.Node(slotData.name); - rawSlotDisplay.addComponent(cc.Sprite); - rawSlotDisplay.setAnchorPoint(0.0, 0.0); - rawSlotDisplay.setOpacityModifyRGB(false); - rawSlotDisplay.setCascadeOpacityEnabled(true); - rawSlotDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. - slot.init(slotData, armature, rawSlotDisplay, rawSlotDisplay); - return slot; - }; - /** - * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. - * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. - * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. - * @param armatureName - The armature data name. - * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) - * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) - * @returns The armature component. - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language en_US - */ - /** - * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 - * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 - * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 - * @param armatureName - 骨架数据名称。 - * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) - * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) - * @returns 骨架组件。 - * @see dragonBones.IArmatureProxy - * @see dragonBones.BaseFactory#buildArmature - * @version DragonBones 4.5 - * @example - * - *
-         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
-         * 
- * @language zh_CN - */ - CocosFactory.prototype.buildArmatureComponent = function (armatureName, dragonBonesName, skinName, textureAtlasName, node) { - if (dragonBonesName === void 0) { dragonBonesName = ""; } - if (skinName === void 0) { skinName = ""; } - if (textureAtlasName === void 0) { textureAtlasName = ""; } - if (node === void 0) { node = null; } - this._armatureNode = node; - var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); - if (armature !== null) { - this._dragonBones.clock.add(armature); - return armature.proxy; - } - return null; - }; - /** - * - Create the display object with the specified texture. - * @param textureName - The texture data name. - * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) - * @version DragonBones 3.0 - * @language en_US - */ - /** - * - 创建带有指定贴图的显示对象。 - * @param textureName - 贴图数据名称。 - * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) - * @version DragonBones 3.0 - * @language zh_CN - */ - CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { - if (textureAtlasName === void 0) { textureAtlasName = null; } - var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); - if (textureData !== null && textureData.renderTexture !== null) { - var texture = textureData.renderTexture; - var sprite = new cc.Sprite(); - sprite.spriteFrame = texture; - return sprite; - } - return null; - }; - Object.defineProperty(CocosFactory.prototype, "soundEventManager", { - /** - * - A global sound event manager. - * Sound events can be listened to uniformly from the manager. - * @version DragonBones 4.5 - * @language en_US - */ - /** - * - 全局声音事件管理器。 - * 声音事件可以从该管理器统一侦听。 - * @version DragonBones 4.5 - * @language zh_CN - */ - get: function () { - return this._dragonBones.eventManager.node; - }, - enumerable: true, - configurable: true - }); - CocosFactory._dragonBonesInstance = null; - CocosFactory._factory = null; - return CocosFactory; - }(dragonBones.BaseFactory)); - dragonBones.CocosFactory = CocosFactory; -})(dragonBones || (dragonBones = {})); +"use strict"; +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 __decorate = (this && this.__decorate) || function (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; +}; +/** + * 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.
+ * 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) 确定)以及宽度和高度定义的区域。
+ * 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, 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 armature data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var ArmatureData = /** @class */ (function (_super) { + __extends(ArmatureData, _super); + function ArmatureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.aabb = new dragonBones.Rectangle(); + /** + * - The names of all the animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所有的动画数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * @private + */ + _this.bones = {}; + /** + * @private + */ + _this.slots = {}; + /** + * @private + */ + _this.constraints = {}; + /** + * @private + */ + _this.skins = {}; + /** + * @private + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + ArmatureData.prototype._onClear = function () { + for (var _i = 0, _a = this.defaultActions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + for (var _b = 0, _c = this.actions; _b < _c.length; _b++) { + var action = _c[_b]; + action.returnToPool(); + } + for (var k in this.bones) { + this.bones[k].returnToPool(); + delete this.bones[k]; + } + for (var k in this.slots) { + this.slots[k].returnToPool(); + delete this.slots[k]; + } + for (var k in this.constraints) { + this.constraints[k].returnToPool(); + delete this.constraints[k]; + } + for (var k in this.skins) { + this.skins[k].returnToPool(); + delete this.skins[k]; + } + for (var k in this.animations) { + this.animations[k].returnToPool(); + delete this.animations[k]; + } + if (this.canvas !== null) { + this.canvas.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.type = 0 /* Armature */; + this.frameRate = 0; + this.cacheFrameRate = 0; + this.scale = 1.0; + this.name = ""; + this.aabb.clear(); + this.animationNames.length = 0; + this.sortedBones.length = 0; + this.sortedSlots.length = 0; + this.defaultActions.length = 0; + this.actions.length = 0; + // this.bones.clear(); + // this.slots.clear(); + // this.constraints.clear(); + // this.skins.clear(); + // this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @internal + */ + ArmatureData.prototype.sortBones = function () { + var total = this.sortedBones.length; + if (total <= 0) { + return; + } + var sortHelper = this.sortedBones.concat(); + var index = 0; + var count = 0; + this.sortedBones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this.sortedBones.indexOf(bone) >= 0) { + continue; + } + var flag = false; + for (var k in this.constraints) { // Wait constraint. + var constraint = this.constraints[k]; + if (constraint.root === bone && this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @internal + */ + ArmatureData.prototype.cacheFrames = function (frameRate) { + if (this.cacheFrameRate > 0) { // TODO clear cache. + return; + } + this.cacheFrameRate = frameRate; + for (var k in this.animations) { + this.animations[k].cacheFrames(this.cacheFrameRate); + } + }; + /** + * @internal + */ + ArmatureData.prototype.setCacheFrame = function (globalTransformMatrix, transform) { + var dataArray = this.parent.cachedFrames; + var arrayOffset = dataArray.length; + dataArray.length += 10; + dataArray[arrayOffset] = globalTransformMatrix.a; + dataArray[arrayOffset + 1] = globalTransformMatrix.b; + dataArray[arrayOffset + 2] = globalTransformMatrix.c; + dataArray[arrayOffset + 3] = globalTransformMatrix.d; + dataArray[arrayOffset + 4] = globalTransformMatrix.tx; + dataArray[arrayOffset + 5] = globalTransformMatrix.ty; + dataArray[arrayOffset + 6] = transform.rotation; + dataArray[arrayOffset + 7] = transform.skew; + dataArray[arrayOffset + 8] = transform.scaleX; + dataArray[arrayOffset + 9] = transform.scaleY; + return arrayOffset; + }; + /** + * @internal + */ + ArmatureData.prototype.getCacheFrame = function (globalTransformMatrix, transform, arrayOffset) { + var dataArray = this.parent.cachedFrames; + globalTransformMatrix.a = dataArray[arrayOffset]; + globalTransformMatrix.b = dataArray[arrayOffset + 1]; + globalTransformMatrix.c = dataArray[arrayOffset + 2]; + globalTransformMatrix.d = dataArray[arrayOffset + 3]; + globalTransformMatrix.tx = dataArray[arrayOffset + 4]; + globalTransformMatrix.ty = dataArray[arrayOffset + 5]; + transform.rotation = dataArray[arrayOffset + 6]; + transform.skew = dataArray[arrayOffset + 7]; + transform.scaleX = dataArray[arrayOffset + 8]; + transform.scaleY = dataArray[arrayOffset + 9]; + transform.x = globalTransformMatrix.tx; + transform.y = globalTransformMatrix.ty; + }; + /** + * @internal + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Same bone: " + value.name); + return; + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @internal + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Same slot: " + value.name); + return; + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @internal + */ + ArmatureData.prototype.addConstraint = function (value) { + if (value.name in this.constraints) { + console.warn("Same constraint: " + value.name); + return; + } + this.constraints[value.name] = value; + }; + /** + * @internal + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Same skin: " + value.name); + return; + } + value.parent = this; + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + if (value.name === "default") { + this.defaultSkin = value; + } + }; + /** + * @internal + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Same animation: " + value.name); + return; + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * @internal + */ + ArmatureData.prototype.addAction = function (value, isDefault) { + if (isDefault) { + this.defaultActions.push(value); + } + else { + this.actions.push(value); + } + }; + /** + * - Get a specific done data. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼数据。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (boneName) { + return boneName in this.bones ? this.bones[boneName] : null; + }; + /** + * - Get a specific slot data. + * @param slotName - The slot name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽数据。 + * @param slotName - 插槽名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (slotName) { + return slotName in this.slots ? this.slots[slotName] : null; + }; + /** + * @private + */ + ArmatureData.prototype.getConstraint = function (constraintName) { + return constraintName in this.constraints ? this.constraints[constraintName] : null; + }; + /** + * - Get a specific skin data. + * @param skinName - The skin name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定皮肤数据。 + * @param skinName - 皮肤名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (skinName) { + return skinName in this.skins ? this.skins[skinName] : null; + }; + /** + * @private + */ + ArmatureData.prototype.getMesh = function (skinName, slotName, meshName) { + var skin = this.getSkin(skinName); + if (skin === null) { + return null; + } + return skin.getDisplay(slotName, meshName); + }; + /** + * - Get a specific animation data. + * @param animationName - The animation animationName. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的动画数据。 + * @param animationName - 动画名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (animationName) { + return animationName in this.animations ? this.animations[animationName] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * - The bone data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var BoneData = /** @class */ (function (_super) { + __extends(BoneData, _super); + function BoneData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.transform = new dragonBones.Transform(); + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + BoneData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.type = 0 /* Bone */; + this.length = 0.0; + this.alpha = 1.0; + this.name = ""; + this.transform.identity(); + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * @internal + */ + var SurfaceData = /** @class */ (function (_super) { + __extends(SurfaceData, _super); + function SurfaceData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new dragonBones.GeometryData(); + return _this; + } + SurfaceData.toString = function () { + return "[class dragonBones.SurfaceData]"; + }; + SurfaceData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Surface */; + this.segmentX = 0; + this.segmentY = 0; + this.geometry.clear(); + }; + return SurfaceData; + }(BoneData)); + dragonBones.SurfaceData = SurfaceData; + /** + * - The slot data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var SlotData = /** @class */ (function (_super) { + __extends(SlotData, _super); + function SlotData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.color = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @internal + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.zIndex = 0; + this.alpha = 1.0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @internal + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; +})(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 CanvasData = /** @class */ (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + CanvasData.prototype._onClear = function () { + this.hasBackground = false; + this.color = 0x000000; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + }; + return CanvasData; + }(dragonBones.BaseObject)); + dragonBones.CanvasData = CanvasData; +})(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 skin data, typically a armature data instance contains at least one skinData. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 皮肤数据,通常一个骨架数据至少包含一个皮肤数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var SkinData = /** @class */ (function (_super) { + __extends(SkinData, _super); + function SkinData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.displays = {}; + return _this; + } + SkinData.toString = function () { + return "[class dragonBones.SkinData]"; + }; + SkinData.prototype._onClear = function () { + for (var k in this.displays) { + var slotDisplays = this.displays[k]; + for (var _i = 0, slotDisplays_1 = slotDisplays; _i < slotDisplays_1.length; _i++) { + var display = slotDisplays_1[_i]; + if (display !== null) { + display.returnToPool(); + } + } + delete this.displays[k]; + } + this.name = ""; + // this.displays.clear(); + this.parent = null; // + }; + /** + * @internal + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + if (value !== null) { + value.parent = this; + } + var slotDisplays = this.displays[slotName]; // TODO clear prev + slotDisplays.push(value); + }; + /** + * @private + */ + SkinData.prototype.getDisplay = function (slotName, displayName) { + var slotDisplays = this.getDisplays(slotName); + if (slotDisplays !== null) { + for (var _i = 0, slotDisplays_2 = slotDisplays; _i < slotDisplays_2.length; _i++) { + var display = slotDisplays_2[_i]; + if (display !== null && display.name === displayName) { + return display; + } + } + } + return null; + }; + /** + * @private + */ + SkinData.prototype.getDisplays = function (slotName) { + if (!(slotName in this.displays)) { + return null; + } + return this.displays[slotName]; + }; + return SkinData; + }(dragonBones.BaseObject)); + dragonBones.SkinData = SkinData; +})(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 ConstraintData = /** @class */ (function (_super) { + __extends(ConstraintData, _super); + function ConstraintData() { + return _super !== null && _super.apply(this, arguments) || this; + } + ConstraintData.prototype._onClear = function () { + this.order = 0; + this.name = ""; + this.type = 0 /* IK */; + this.target = null; // + this.root = null; // + this.bone = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @internal + */ + var IKConstraintData = /** @class */ (function (_super) { + __extends(IKConstraintData, _super); + function IKConstraintData() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraintData.toString = function () { + return "[class dragonBones.IKConstraintData]"; + }; + IKConstraintData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.scaleEnabled = false; + this.bendPositive = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; + /** + * @internal + */ + var PathConstraintData = /** @class */ (function (_super) { + __extends(PathConstraintData, _super); + function PathConstraintData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + PathConstraintData.toString = function () { + return "[class dragonBones.PathConstraintData]"; + }; + PathConstraintData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.pathSlot = null; + this.pathDisplayData = null; + this.bones.length = 0; + this.positionMode = 0 /* Fixed */; + this.spacingMode = 1 /* Fixed */; + this.rotateMode = 1 /* Chain */; + this.position = 0.0; + this.spacing = 0.0; + this.rotateOffset = 0.0; + this.rotateMix = 0.0; + this.translateMix = 0.0; + }; + PathConstraintData.prototype.AddBone = function (value) { + this.bones.push(value); + }; + return PathConstraintData; + }(ConstraintData)); + dragonBones.PathConstraintData = PathConstraintData; +})(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 GeometryData = /** @class */ (function () { + function GeometryData() { + this.weight = null; // Initial value. + } + GeometryData.prototype.clear = function () { + if (!this.isShared && this.weight !== null) { + this.weight.returnToPool(); + } + this.isShared = false; + this.inheritDeform = false; + this.offset = 0; + this.data = null; + this.weight = null; + }; + GeometryData.prototype.shareFrom = function (value) { + this.isShared = true; + this.offset = value.offset; + this.weight = value.weight; + }; + Object.defineProperty(GeometryData.prototype, "vertexCount", { + get: function () { + var intArray = this.data.intArray; + return intArray[this.offset + 0 /* GeometryVertexCount */]; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(GeometryData.prototype, "triangleCount", { + get: function () { + var intArray = this.data.intArray; + return intArray[this.offset + 1 /* GeometryTriangleCount */]; + }, + enumerable: true, + configurable: true + }); + return GeometryData; + }()); + dragonBones.GeometryData = GeometryData; + /** + * @private + */ + var DisplayData = /** @class */ (function (_super) { + __extends(DisplayData, _super); + function DisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.transform = new dragonBones.Transform(); + return _this; + } + DisplayData.prototype._onClear = function () { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null; // + }; + return DisplayData; + }(dragonBones.BaseObject)); + dragonBones.DisplayData = DisplayData; + /** + * @private + */ + var ImageDisplayData = /** @class */ (function (_super) { + __extends(ImageDisplayData, _super); + function ImageDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.pivot = new dragonBones.Point(); + return _this; + } + ImageDisplayData.toString = function () { + return "[class dragonBones.ImageDisplayData]"; + }; + ImageDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Image */; + this.pivot.clear(); + this.texture = null; + }; + return ImageDisplayData; + }(DisplayData)); + dragonBones.ImageDisplayData = ImageDisplayData; + /** + * @private + */ + var ArmatureDisplayData = /** @class */ (function (_super) { + __extends(ArmatureDisplayData, _super); + function ArmatureDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.actions = []; + return _this; + } + ArmatureDisplayData.toString = function () { + return "[class dragonBones.ArmatureDisplayData]"; + }; + ArmatureDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.actions; _i < _a.length; _i++) { + var action = _a[_i]; + action.returnToPool(); + } + this.type = 1 /* Armature */; + this.inheritAnimation = false; + this.actions.length = 0; + this.armature = null; + }; + /** + * @private + */ + ArmatureDisplayData.prototype.addAction = function (value) { + this.actions.push(value); + }; + return ArmatureDisplayData; + }(DisplayData)); + dragonBones.ArmatureDisplayData = ArmatureDisplayData; + /** + * @private + */ + var MeshDisplayData = /** @class */ (function (_super) { + __extends(MeshDisplayData, _super); + function MeshDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new GeometryData(); + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 2 /* Mesh */; + this.geometry.clear(); + this.texture = null; + }; + return MeshDisplayData; + }(DisplayData)); + dragonBones.MeshDisplayData = MeshDisplayData; + /** + * @private + */ + var BoundingBoxDisplayData = /** @class */ (function (_super) { + __extends(BoundingBoxDisplayData, _super); + function BoundingBoxDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.boundingBox = null; // Initial value. + return _this; + } + BoundingBoxDisplayData.toString = function () { + return "[class dragonBones.BoundingBoxDisplayData]"; + }; + BoundingBoxDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.boundingBox !== null) { + this.boundingBox.returnToPool(); + } + this.type = 3 /* BoundingBox */; + this.boundingBox = null; + }; + return BoundingBoxDisplayData; + }(DisplayData)); + dragonBones.BoundingBoxDisplayData = BoundingBoxDisplayData; + /** + * @private + */ + var PathDisplayData = /** @class */ (function (_super) { + __extends(PathDisplayData, _super); + function PathDisplayData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.geometry = new GeometryData(); + _this.curveLengths = []; + return _this; + } + PathDisplayData.toString = function () { + return "[class dragonBones.PathDisplayData]"; + }; + PathDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 4 /* Path */; + this.closed = false; + this.constantSpeed = false; + this.geometry.clear(); + this.curveLengths.length = 0; + }; + return PathDisplayData; + }(DisplayData)); + dragonBones.PathDisplayData = PathDisplayData; + /** + * @private + */ + var WeightData = /** @class */ (function (_super) { + __extends(WeightData, _super); + function WeightData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.bones = []; + return _this; + } + WeightData.toString = function () { + return "[class dragonBones.WeightData]"; + }; + WeightData.prototype._onClear = function () { + this.count = 0; + this.offset = 0; + this.bones.length = 0; + }; + WeightData.prototype.addBone = function (value) { + this.bones.push(value); + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(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 base class of bounding box data. + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + var BoundingBoxData = /** @class */ (function (_super) { + __extends(BoundingBoxData, _super); + function BoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * - The rectangle bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 矩形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = /** @class */ (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + RectangleBoundingBoxData.toString = function () { + return "[class dragonBones.RectangleBoundingBoxData]"; + }; + /** + * - Compute the bit code for a point (x, y) using the clip rectangle + */ + RectangleBoundingBoxData._computeOutCode = function (x, y, xMin, yMin, xMax, yMax) { + var code = 0 /* InSide */; // initialised as being inside of [[clip window]] + if (x < xMin) { // to the left of clip window + code |= 1 /* Left */; + } + else if (x > xMax) { // to the right of clip window + code |= 2 /* Right */; + } + if (y < yMin) { // below the clip window + code |= 4 /* Top */; + } + else if (y > yMax) { // above the clip window + code |= 8 /* Bottom */; + } + return code; + }; + /** + * @private + */ + RectangleBoundingBoxData.rectangleIntersectsSegment = function (xA, yA, xB, yB, xMin, yMin, xMax, yMax, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; + var inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; + if (inSideA && inSideB) { + return -1; + } + var intersectionCount = 0; + var outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + var outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + while (true) { + if ((outcode0 | outcode1) === 0) { // Bitwise OR is 0. Trivially accept and get out of loop + intersectionCount = 2; + break; + } + else if ((outcode0 & outcode1) !== 0) { // Bitwise AND is not 0. Trivially reject and get out of loop + break; + } + // failed both tests, so calculate the line segment to clip + // from an outside point to an intersection with clip edge + var x = 0.0; + var y = 0.0; + var normalRadian = 0.0; + // At least one endpoint is outside the clip rectangle; pick it. + var outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; + // Now find the intersection point; + if ((outcodeOut & 4 /* Top */) !== 0) { // point is above the clip rectangle + x = xA + (xB - xA) * (yMin - yA) / (yB - yA); + y = yMin; + if (normalRadians !== null) { + normalRadian = -Math.PI * 0.5; + } + } + else if ((outcodeOut & 8 /* Bottom */) !== 0) { // point is below the clip rectangle + x = xA + (xB - xA) * (yMax - yA) / (yB - yA); + y = yMax; + if (normalRadians !== null) { + normalRadian = Math.PI * 0.5; + } + } + else if ((outcodeOut & 2 /* Right */) !== 0) { // point is to the right of clip rectangle + y = yA + (yB - yA) * (xMax - xA) / (xB - xA); + x = xMax; + if (normalRadians !== null) { + normalRadian = 0; + } + } + else if ((outcodeOut & 1 /* Left */) !== 0) { // point is to the left of clip rectangle + y = yA + (yB - yA) * (xMin - xA) / (xB - xA); + x = xMin; + if (normalRadians !== null) { + normalRadian = Math.PI; + } + } + // Now we move outside point to intersection point to clip + // and get ready for next pass. + if (outcodeOut === outcode0) { + xA = x; + yA = y; + outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + if (normalRadians !== null) { + normalRadians.x = normalRadian; + } + } + else { + xB = x; + yB = y; + outcode1 = RectangleBoundingBoxData._computeOutCode(xB, yB, xMin, yMin, xMax, yMax); + if (normalRadians !== null) { + normalRadians.y = normalRadian; + } + } + } + if (intersectionCount) { + if (inSideA) { + intersectionCount = 2; // 10 + if (intersectionPointA !== null) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = xB; + } + if (normalRadians !== null) { + normalRadians.x = normalRadians.y + Math.PI; + } + } + else if (inSideB) { + intersectionCount = 1; // 01 + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (normalRadians !== null) { + normalRadians.y = normalRadians.x + Math.PI; + } + } + else { + intersectionCount = 3; // 11 + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + } + } + return intersectionCount; + }; + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inheritDoc + */ + RectangleBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + var heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + return true; + } + } + return false; + }; + /** + * @inheritDoc + */ + RectangleBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var widthH = this.width * 0.5; + var heightH = this.height * 0.5; + var intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, -widthH, -heightH, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return RectangleBoundingBoxData; + }(BoundingBoxData)); + dragonBones.RectangleBoundingBoxData = RectangleBoundingBoxData; + /** + * - The ellipse bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 椭圆边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = /** @class */ (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + EllipseBoundingBoxData.toString = function () { + return "[class dragonBones.EllipseData]"; + }; + /** + * @private + */ + EllipseBoundingBoxData.ellipseIntersectsSegment = function (xA, yA, xB, yB, xC, yC, widthH, heightH, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var d = widthH / heightH; + var dd = d * d; + yA *= d; + yB *= d; + var dX = xB - xA; + var dY = yB - yA; + var lAB = Math.sqrt(dX * dX + dY * dY); + var xD = dX / lAB; + var yD = dY / lAB; + var a = (xC - xA) * xD + (yC - yA) * yD; + var aa = a * a; + var ee = xA * xA + yA * yA; + var rr = widthH * widthH; + var dR = rr - ee + aa; + var intersectionCount = 0; + if (dR >= 0.0) { + var dT = Math.sqrt(dR); + var sA = a - dT; + var sB = a + dT; + var inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); + var inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); + var sideAB = inSideA * inSideB; + if (sideAB < 0) { + return -1; + } + else if (sideAB === 0) { + if (inSideA === -1) { + intersectionCount = 2; // 10 + xB = xA + sB * xD; + yB = (yA + sB * yD) / d; + if (intersectionPointA !== null) { + intersectionPointA.x = xB; + intersectionPointA.y = yB; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xB; + intersectionPointB.y = yB; + } + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yB / rr * dd, xB / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } + else if (inSideB === 1) { + intersectionCount = 1; // 01 + xA = xA + sA * xD; + yA = (yA + sA * yD) / d; + if (intersectionPointA !== null) { + intersectionPointA.x = xA; + intersectionPointA.y = yA; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA; + intersectionPointB.y = yA; + } + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yA / rr * dd, xA / rr); + normalRadians.y = normalRadians.x + Math.PI; + } + } + else { + intersectionCount = 3; // 11 + if (intersectionPointA !== null) { + intersectionPointA.x = xA + sA * xD; + intersectionPointA.y = (yA + sA * yD) / d; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(intersectionPointA.y / rr * dd, intersectionPointA.x / rr); + } + } + if (intersectionPointB !== null) { + intersectionPointB.x = xA + sB * xD; + intersectionPointB.y = (yA + sB * yD) / d; + if (normalRadians !== null) { + normalRadians.y = Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); + } + } + } + } + } + return intersectionCount; + }; + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inheritDoc + */ + EllipseBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + var heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + pY *= widthH / heightH; + return Math.sqrt(pX * pX + pY * pY) <= widthH; + } + } + return false; + }; + /** + * @inheritDoc + */ + EllipseBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment(xA, yA, xB, yB, 0.0, 0.0, this.width * 0.5, this.height * 0.5, intersectionPointA, intersectionPointB, normalRadians); + return intersectionCount; + }; + return EllipseBoundingBoxData; + }(BoundingBoxData)); + dragonBones.EllipseBoundingBoxData = EllipseBoundingBoxData; + /** + * - The polygon bounding box data. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形边界框数据。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var PolygonBoundingBoxData = /** @class */ (function (_super) { + __extends(PolygonBoundingBoxData, _super); + function PolygonBoundingBoxData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * - The polygon vertices. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + _this.vertices = []; + return _this; + } + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + if (xA === xB) { + xA = xB + 0.000001; + } + if (yA === yB) { + yA = yB + 0.000001; + } + var count = vertices.length; + var dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[count - 2]; + var yC = vertices[count - 1]; + var dMin = 0.0; + var dMax = 0.0; + var xMin = 0.0; + var yMin = 0.0; + var xMax = 0.0; + var yMax = 0.0; + for (var i = 0; i < count; i += 2) { + var xD = vertices[i]; + var yD = vertices[i + 1]; + if (xC === xD) { + xC = xD + 0.0001; + } + if (yC === yD) { + yC = yD + 0.0001; + } + var dXCD = xC - xD; + var dYCD = yC - yD; + var llCD = xC * yD - yC * xD; + var ll = dXAB * dYCD - dYAB * dXCD; + var x = (llAB * dXCD - dXAB * llCD) / ll; + if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB === 0.0 || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { + var y = (llAB * dYCD - dYAB * llCD) / ll; + if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB === 0.0 || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { + if (intersectionPointB !== null) { + var d = x - xA; + if (d < 0.0) { + d = -d; + } + if (intersectionCount === 0) { + dMin = d; + dMax = d; + xMin = x; + yMin = y; + xMax = x; + yMax = y; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = normalRadians.x; + } + } + else { + if (d < dMin) { + dMin = d; + xMin = x; + yMin = y; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + } + } + if (d > dMax) { + dMax = d; + xMax = x; + yMax = y; + if (normalRadians !== null) { + normalRadians.y = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + } + } + } + intersectionCount++; + } + else { + xMin = x; + yMin = y; + xMax = x; + yMax = y; + intersectionCount++; + if (normalRadians !== null) { + normalRadians.x = Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5; + normalRadians.y = normalRadians.x; + } + break; + } + } + } + xC = xD; + yC = yD; + } + if (intersectionCount === 1) { + if (intersectionPointA !== null) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xMin; + intersectionPointB.y = yMin; + } + if (normalRadians !== null) { + normalRadians.y = normalRadians.x + Math.PI; + } + } + else if (intersectionCount > 1) { + intersectionCount++; + if (intersectionPointA !== null) { + intersectionPointA.x = xMin; + intersectionPointA.y = yMin; + } + if (intersectionPointB !== null) { + intersectionPointB.x = xMax; + intersectionPointB.y = yMax; + } + } + return intersectionCount; + }; + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 2 /* Polygon */; + this.x = 0.0; + this.y = 0.0; + this.vertices.length = 0; + }; + /** + * @inheritDoc + */ + PolygonBoundingBoxData.prototype.containsPoint = function (pX, pY) { + var isInSide = false; + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { + for (var i = 0, l = this.vertices.length, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[iP + 1]; + var yB = this.vertices[i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[iP]; + var xB = this.vertices[i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inheritDoc + */ + PolygonBoundingBoxData.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var intersectionCount = 0; + if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.x + this.width, this.y + this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(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 animation data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var AnimationData = /** @class */ (function (_super) { + __extends(AnimationData, _super); + function AnimationData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.cachedFrames = []; + /** + * @private + */ + _this.boneTimelines = {}; + /** + * @private + */ + _this.slotTimelines = {}; + /** + * @private + */ + _this.constraintTimelines = {}; + /** + * @private + */ + _this.animationTimelines = {}; + /** + * @private + */ + _this.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var _i = 0, _a = this.boneTimelines[k]; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var _b = 0, _c = this.slotTimelines[k]; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + delete this.slotTimelines[k]; + } + for (var k in this.constraintTimelines) { + for (var _d = 0, _e = this.constraintTimelines[k]; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + delete this.constraintTimelines[k]; + } + for (var k in this.animationTimelines) { + for (var _f = 0, _g = this.animationTimelines[k]; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + delete this.animationTimelines[k]; + } + for (var k in this.boneCachedFrameIndices) { + delete this.boneCachedFrameIndices[k]; + } + for (var k in this.slotCachedFrameIndices) { + delete this.slotCachedFrameIndices[k]; + } + if (this.actionTimeline !== null) { + this.actionTimeline.returnToPool(); + } + if (this.zOrderTimeline !== null) { + this.zOrderTimeline.returnToPool(); + } + this.frameIntOffset = 0; + this.frameFloatOffset = 0; + this.frameOffset = 0; + this.blendType = 0 /* None */; + this.frameCount = 0; + this.playTimes = 0; + this.duration = 0.0; + this.scale = 1.0; + this.fadeInTime = 0.0; + this.cacheFrameRate = 0.0; + this.name = ""; + this.cachedFrames.length = 0; + // this.boneTimelines.clear(); + // this.slotTimelines.clear(); + // this.constraintTimelines.clear(); + // this.animationTimelines.clear(); + // this.boneCachedFrameIndices.clear(); + // this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @internal + */ + AnimationData.prototype.cacheFrames = function (frameRate) { + if (this.cacheFrameRate > 0.0) { // TODO clear cache. + return; + } + this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); + var cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. + this.cachedFrames.length = cacheFrameCount; + for (var i = 0, l = this.cacheFrames.length; i < l; ++i) { + this.cachedFrames[i] = false; + } + for (var _i = 0, _a = this.parent.sortedBones; _i < _a.length; _i++) { + var bone = _a[_i]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + this.boneCachedFrameIndices[bone.name] = indices; + } + for (var _b = 0, _c = this.parent.sortedSlots; _b < _c.length; _b++) { + var slot = _c[_b]; + var indices = new Array(cacheFrameCount); + for (var i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + this.slotCachedFrameIndices[slot.name] = indices; + } + }; + /** + * @private + */ + AnimationData.prototype.addBoneTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : (this.boneTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : (this.slotTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addConstraintTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : (this.constraintTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addAnimationTimeline = function (timelineName, timeline) { + var timelines = timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : (this.animationTimelines[timelineName] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (timelineName) { + return timelineName in this.boneTimelines ? this.boneTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimelines = function (timelineName) { + return timelineName in this.slotTimelines ? this.slotTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getConstraintTimelines = function (timelineName) { + return timelineName in this.constraintTimelines ? this.constraintTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getAnimationTimelines = function (timelineName) { + return timelineName in this.animationTimelines ? this.animationTimelines[timelineName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (boneName) { + return boneName in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[boneName] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (slotName) { + return slotName in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[slotName] : null; + }; + return AnimationData; + }(dragonBones.BaseObject)); + dragonBones.AnimationData = AnimationData; + /** + * @private + */ + var TimelineData = /** @class */ (function (_super) { + __extends(TimelineData, _super); + function TimelineData() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineData.toString = function () { + return "[class dragonBones.TimelineData]"; + }; + TimelineData.prototype._onClear = function () { + this.type = 10 /* BoneAll */; + this.offset = 0; + this.frameIndicesOffset = -1; + }; + return TimelineData; + }(dragonBones.BaseObject)); + dragonBones.TimelineData = TimelineData; + /** + * @internal + */ + var AnimationTimelineData = /** @class */ (function (_super) { + __extends(AnimationTimelineData, _super); + function AnimationTimelineData() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationTimelineData.toString = function () { + return "[class dragonBones.AnimationTimelineData]"; + }; + AnimationTimelineData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.x = 0.0; + this.y = 0.0; + }; + return AnimationTimelineData; + }(TimelineData)); + dragonBones.AnimationTimelineData = AnimationTimelineData; +})(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 animation config is used to describe all the information needed to play an animation state. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 动画配置用来描述播放一个动画状态所需要的全部信息。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @see dragonBones.AnimationState + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + var AnimationConfig = /** @class */ (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additive = false; + this.displayControl = true; + this.pauseFadeIn = true; + this.resetToPose = true; + this.fadeInTweenType = 1 /* Line */; + this.playTimes = -1; + this.layer = 0; + this.position = 0.0; + this.duration = -1.0; + this.timeScale = -100.0; + this.weight = 1.0; + this.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + /** + * @private + */ + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + /** + * @private + */ + AnimationConfig.prototype.copyFrom = function (value) { + this.pauseFadeOut = value.pauseFadeOut; + this.fadeOutMode = value.fadeOutMode; + this.autoFadeOutTime = value.autoFadeOutTime; + this.fadeOutTweenType = value.fadeOutTweenType; + this.actionEnabled = value.actionEnabled; + this.additive = value.additive; + this.displayControl = value.displayControl; + this.pauseFadeIn = value.pauseFadeIn; + this.resetToPose = value.resetToPose; + this.playTimes = value.playTimes; + this.layer = value.layer; + this.position = value.position; + this.duration = value.duration; + this.timeScale = value.timeScale; + this.fadeInTime = value.fadeInTime; + this.fadeOutTime = value.fadeOutTime; + this.fadeInTweenType = value.fadeInTweenType; + this.weight = value.weight; + this.name = value.name; + this.animation = value.animation; + this.group = value.group; + this.boneMask.length = value.boneMask.length; + for (var i = 0, l = this.boneMask.length; i < l; ++i) { + this.boneMask[i] = value.boneMask[i]; + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(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 texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var TextureAtlasData = /** @class */ (function (_super) { + __extends(TextureAtlasData, _super); + function TextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.textures = {}; + return _this; + } + TextureAtlasData.prototype._onClear = function () { + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + this.autoSearch = false; + this.width = 0; + this.height = 0; + this.scale = 1.0; + // this.textures.clear(); + this.name = ""; + this.imagePath = ""; + }; + /** + * @private + */ + TextureAtlasData.prototype.copyFrom = function (value) { + this.autoSearch = value.autoSearch; + this.scale = value.scale; + this.width = value.width; + this.height = value.height; + this.name = value.name; + this.imagePath = value.imagePath; + for (var k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + // this.textures.clear(); + for (var k in value.textures) { + var texture = this.createTexture(); + texture.copyFrom(value.textures[k]); + this.textures[k] = texture; + } + }; + /** + * @internal + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Same texture: " + value.name); + return; + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (textureName) { + return textureName in this.textures ? this.textures[textureName] : null; + }; + return TextureAtlasData; + }(dragonBones.BaseObject)); + dragonBones.TextureAtlasData = TextureAtlasData; + /** + * @private + */ + var TextureData = /** @class */ (function (_super) { + __extends(TextureData, _super); + function TextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.region = new dragonBones.Rectangle(); + _this.frame = null; // Initial value. + return _this; + } + TextureData.createRectangle = function () { + return new dragonBones.Rectangle(); + }; + TextureData.prototype._onClear = function () { + this.rotated = false; + this.name = ""; + this.region.clear(); + this.parent = null; // + this.frame = null; + }; + TextureData.prototype.copyFrom = function (value) { + this.rotated = value.rotated; + this.name = value.name; + this.region.copyFrom(value.region); + this.parent = value.parent; + if (this.frame === null && value.frame !== null) { + this.frame = TextureData.createRectangle(); + } + else if (this.frame !== null && value.frame === null) { + this.frame = null; + } + if (this.frame !== null && value.frame !== null) { + this.frame.copyFrom(value.frame); + } + }; + return TextureData; + }(dragonBones.BaseObject)); + dragonBones.TextureData = TextureData; +})(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_1) { + /** + * - Armature is the core of the skeleton animation system. + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架是骨骼动画系统的核心。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + var Armature = /** @class */ (function (_super) { + __extends(Armature, _super); + function Armature() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._bones = []; + _this._slots = []; + /** + * @internal + */ + _this._constraints = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @internal + */ + _this._replaceTextureAtlasData = null; // Initial value. + _this._clock = null; // Initial value. + return _this; + } + Armature.toString = function () { + return "[class dragonBones.Armature]"; + }; + Armature._onSortSlots = function (a, b) { + return a._zIndex * 1000 + a._zOrder > b._zIndex * 1000 + b._zOrder ? 1 : -1; + }; + Armature.prototype._onClear = function () { + if (this._clock !== null) { // Remove clock first. + this._clock.remove(this); + } + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone.returnToPool(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot.returnToPool(); + } + for (var _d = 0, _e = this._constraints; _d < _e.length; _d++) { + var constraint = _e[_d]; + constraint.returnToPool(); + } + for (var _f = 0, _g = this._actions; _f < _g.length; _f++) { + var action = _g[_f]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.dbClear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.userData = null; + this._lockUpdate = false; + this._slotsDirty = true; + this._zOrderDirty = false; + this._zIndexDirty = false; + this._alphaDirty = true; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._alpha = 1.0; + this._globalAlpha = 1.0; + this._bones.length = 0; + this._slots.length = 0; + this._constraints.length = 0; + this._actions.length = 0; + this._armatureData = null; // + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + /** + * @internal + */ + Armature.prototype._sortZOrder = function (slotIndices, offset) { + var slotDatas = this._armatureData.sortedSlots; + var isOriginal = slotIndices === null; + if (this._zOrderDirty || !isOriginal) { + for (var i = 0, l = slotDatas.length; i < l; ++i) { + var slotIndex = isOriginal ? i : slotIndices[offset + i]; + if (slotIndex < 0 || slotIndex >= l) { + continue; + } + var slotData = slotDatas[slotIndex]; + var slot = this.getSlot(slotData.name); + if (slot !== null) { + slot._setZOrder(i); + } + } + this._slotsDirty = true; + this._zOrderDirty = !isOriginal; + } + }; + /** + * @internal + */ + Armature.prototype._addBone = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bones.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._addSlot = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slots.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._addConstraint = function (value) { + if (this._constraints.indexOf(value) < 0) { + this._constraints.push(value); + } + }; + /** + * @internal + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * - Dispose the armature. (Return to the object pool) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 释放骨架。 (回收到对象池) + * @example + *
+         *     removeChild(armature.display);
+         *     armature.dispose();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this._armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @internal + */ + Armature.prototype.init = function (armatureData, proxy, display, dragonBones) { + if (this._armatureData !== null) { + return; + } + this._armatureData = armatureData; + this._animation = dragonBones_1.BaseObject.borrowObject(dragonBones_1.Animation); + this._proxy = proxy; + this._display = display; + this._dragonBones = dragonBones; + this._proxy.dbInit(this); + this._animation.init(this); + this._animation.animations = this._armatureData.animations; + }; + /** + * @inheritDoc + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + this._lockUpdate = true; + if (this._armatureData === null) { + console.warn("The armature has been disposed."); + return; + } + else if (this._armatureData.parent === null) { + console.warn("The armature data has been disposed.\nPlease make sure dispose armature before call factory.clear()."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update animation. + this._animation.advanceTime(passedTime); + // Sort slots. + if (this._slotsDirty || this._zIndexDirty) { + this._slots.sort(Armature._onSortSlots); + if (this._zIndexDirty) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i]._setZOrder(i); // + } + } + this._slotsDirty = false; + this._zIndexDirty = false; + } + // Update alpha. + if (this._alphaDirty) { + this._alphaDirty = false; + this._globalAlpha = this._alpha * (this._parent !== null ? this._parent._globalAlpha : 1.0); + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + bone._updateAlpha(); + } + for (var _b = 0, _c = this._slots; _b < _c.length; _b++) { + var slot = _c[_b]; + slot._updateAlpha(); + } + } + // Update bones and slots. + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { + var i = 0, l = 0; + for (i = 0, l = this._bones.length; i < l; ++i) { + this._bones[i].update(this._cacheFrameIndex); + } + for (i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].update(this._cacheFrameIndex); + } + } + // Do actions. + if (this._actions.length > 0) { + for (var _d = 0, _e = this._actions; _d < _e.length; _d++) { + var action = _e[_d]; + var actionData = action.actionData; + if (actionData !== null) { + if (actionData.type === 0 /* Play */) { + if (action.slot !== null) { + var childArmature = action.slot.childArmature; + if (childArmature !== null) { + childArmature.animation.fadeIn(actionData.name); + } + } + else if (action.bone !== null) { + for (var _f = 0, _g = this.getSlots(); _f < _g.length; _f++) { + var slot = _g[_f]; + if (slot.parent === action.bone) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.animation.fadeIn(actionData.name); + } + } + } + } + else { + this._animation.fadeIn(actionData.name); + } + } + } + action.returnToPool(); + } + this._actions.length = 0; + } + this._lockUpdate = false; + this._proxy.dbUpdate(); + }; + /** + * - Forces a specific bone or its owning slot to update the transform or display property in the next frame. + * @param boneName - The bone name. (If not set, all bones will be update) + * @param updateSlot - Whether to update the bone's slots. (Default: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制特定骨骼或其拥有的插槽在下一帧更新变换或显示属性。 + * @param boneName - 骨骼名称。 (如果未设置,将更新所有骨骼) + * @param updateSlot - 是否更新骨骼的插槽。 (默认: false) + * @see dragonBones.Bone#invalidUpdate() + * @see dragonBones.Slot#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlot) { + if (boneName === void 0) { boneName = null; } + if (updateSlot === void 0) { updateSlot = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlot) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === bone) { + slot.invalidUpdate(); + } + } + } + } + } + else { + for (var _b = 0, _c = this._bones; _b < _c.length; _b++) { + var bone = _c[_b]; + bone.invalidUpdate(); + } + if (updateSlot) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * - Check whether a specific point is inside a custom bounding box in a slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在某个插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Armature.prototype.containsPoint = function (x, y) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.containsPoint(x, y)) { + return slot; + } + } + return null; + }; + /** + * - Check whether a specific segment intersects a custom bounding box for a slot in the armature. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns The slot of the first custom bounding box where the segment intersects from the start point to the end point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与骨架的某个插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 线段从起点到终点相交的第一个自定义边界框的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Armature.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + var isV = xA === xB; + var dMin = 0.0; + var dMax = 0.0; + var intXA = 0.0; + var intYA = 0.0; + var intXB = 0.0; + var intYB = 0.0; + var intAN = 0.0; + var intBN = 0.0; + var intSlotA = null; + var intSlotB = null; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionPointA !== null || intersectionPointB !== null) { + if (intersectionPointA !== null) { + var d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; + if (d < 0.0) { + d = -d; + } + if (intSlotA === null || d < dMin) { + dMin = d; + intXA = intersectionPointA.x; + intYA = intersectionPointA.y; + intSlotA = slot; + if (normalRadians) { + intAN = normalRadians.x; + } + } + } + if (intersectionPointB !== null) { + var d = intersectionPointB.x - xA; + if (d < 0.0) { + d = -d; + } + if (intSlotB === null || d > dMax) { + dMax = d; + intXB = intersectionPointB.x; + intYB = intersectionPointB.y; + intSlotB = slot; + if (normalRadians !== null) { + intBN = normalRadians.y; + } + } + } + } + else { + intSlotA = slot; + break; + } + } + } + if (intSlotA !== null && intersectionPointA !== null) { + intersectionPointA.x = intXA; + intersectionPointA.y = intYA; + if (normalRadians !== null) { + normalRadians.x = intAN; + } + } + if (intSlotB !== null && intersectionPointB !== null) { + intersectionPointB.x = intXB; + intersectionPointB.y = intYB; + if (normalRadians !== null) { + normalRadians.y = intBN; + } + } + return intSlotA; + }; + /** + * - Get a specific bone. + * @param name - The bone name. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的骨骼。 + * @param name - 骨骼名称。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBone = function (name) { + for (var _i = 0, _a = this._bones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.name === name) { + return bone; + } + } + return null; + }; + /** + * - Get a specific bone by the display. + * @param display - The display object. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的骨骼。 + * @param display - 显示对象。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBoneByDisplay = function (display) { + var slot = this.getSlotByDisplay(display); + return slot !== null ? slot.parent : null; + }; + /** + * - Get a specific slot. + * @param name - The slot name. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的插槽。 + * @param name - 插槽名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlot = function (name) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.name === name) { + return slot; + } + } + return null; + }; + /** + * - Get a specific slot by the display. + * @param display - The display object. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过显示对象获取特定的插槽。 + * @param display - 显示对象。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlotByDisplay = function (display) { + if (display !== null) { + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.display === display) { + return slot; + } + } + } + return null; + }; + /** + * - Get all bones. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * - Get all slots. + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + /** + * - Whether to flip the armature horizontally. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架水平翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + get: function () { + return this._flipX; + }, + set: function (value) { + if (this._flipX === value) { + return; + } + this._flipX = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "flipY", { + /** + * - Whether to flip the armature vertically. + * @version DragonBones 5.5 + * @language en_US + */ + /** + * - 是否将骨架垂直翻转。 + * @version DragonBones 5.5 + * @language zh_CN + */ + get: function () { + return this._flipY; + }, + set: function (value) { + if (this._flipY === value) { + return; + } + this._flipY = value; + this.invalidUpdate(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "cacheFrameRate", { + /** + * - The animation cache frame rate, which turns on the animation cache when the set value is greater than 0. + * There is a certain amount of memory overhead to improve performance by caching animation data in memory. + * The frame rate should not be set too high, usually with the frame rate of the animation is similar and lower than the program running frame rate. + * When the animation cache is turned on, some features will fail, such as the offset property of bone. + * @example + *
+             *     armature.cacheFrameRate = 24;
+             * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如骨骼的 offset 属性等。 + * @example + *
+             *     armature.cacheFrameRate = 24;
+             * 
+ * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._armatureData.cacheFrameRate; + }, + set: function (value) { + if (this._armatureData.cacheFrameRate !== value) { + this._armatureData.cacheFrames(value); + // Set child armature frameRate. + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.cacheFrameRate = value; + } + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "name", { + /** + * - The armature name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨架名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "armatureData", { + /** + * - The armature data. + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._armatureData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * - The animation player. + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "proxy", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "eventDispatcher", { + /** + * - The EventDispatcher instance of the armature. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架的 EventDispatcher 实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * - The display container. + * The display of the slot is displayed as the parent. + * Depending on the rendering engine, the type will be different, usually the DisplayObjectContainer type. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 显示容器实例。 + * 插槽的显示对象都会以此显示容器为父级。 + * 根据渲染引擎的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @private + */ + get: function () { + return this._replacedTexture; + }, + set: function (value) { + if (this._replacedTexture === value) { + return; + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + this._replacedTexture = value; + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + slot.invalidUpdate(); + slot.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + if (this._clock !== null) { + this._clock.remove(this); + } + this._clock = value; + if (this._clock) { + this._clock.add(this); + } + // Update childArmature clock. + for (var _i = 0, _a = this._slots; _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.clock = this._clock; + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "parent", { + /** + * - Get the parent slot which the armature belongs to. + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 该骨架所属的父插槽。 + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(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 base class of the transform object. + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 变换对象的基类。 + * @see dragonBones.Transform + * @version DragonBones 4.5 + * @language zh_CN + */ + var TransformObject = /** @class */ (function (_super) { + __extends(TransformObject, _super); + function TransformObject() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * - A matrix relative to the armature coordinate system. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * - A transform relative to the armature coordinate system. + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架坐标系的变换。 + * @see #updateGlobalTransform() + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * - The offset transform relative to the armature or the parent bone coordinate system. + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 相对于骨架或父骨骼坐标系的偏移变换。 + * @see #dragonBones.Bone#invalidUpdate() + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + */ + TransformObject.prototype._onClear = function () { + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; + this.userData = null; + this._globalDirty = false; + this._alpha = 1.0; + this._globalAlpha = 1.0; + this._armature = null; // + }; + /** + * - For performance considerations, rotation or scale in the {@link #global} attribute of the bone or slot is not always properly accessible, + * some engines do not rely on these attributes to update rendering, such as Egret. + * The use of this method ensures that the access to the {@link #global} property is correctly rotation or scale. + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 出于性能的考虑,骨骼或插槽的 {@link #global} 属性中的旋转或缩放并不总是正确可访问的,有些引擎并不依赖这些属性更新渲染,比如 Egret。 + * 使用此方法可以保证访问到 {@link #global} 属性中正确的旋转或缩放。 + * @example + *
+         *     bone.updateGlobalTransform();
+         *     let rotation = bone.global.rotation;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * - The armature to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的骨架。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + TransformObject._helpMatrix = new dragonBones.Matrix(); + TransformObject._helpTransform = new dragonBones.Transform(); + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(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) { + /** + * - Bone is one of the most important logical units in the armature animation system, + * and is responsible for the realization of translate, rotation, scaling in the animations. + * A armature can contain multiple bones. + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移、旋转、缩放的实现。 + * 一个骨架中可以包含多个骨骼。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + var Bone = /** @class */ (function (_super) { + __extends(Bone, _super); + function Bone() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @internal + */ + _this.animationPose = new dragonBones.Transform(); + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this._transformDirty = false; + this._childrenTransformDirty = false; + this._localDirty = true; + this._hasConstraint = false; + this._visible = true; + this._cachedFrameIndex = -1; + this._boneData = null; // + this._parent = null; // + this._cachedFrameIndices = null; + }; + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + // For typescript. + var boneData = this._boneData; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var origin = this.origin; + var offset = this.offset; + var animationPose = this.animationPose; + var parent = this._parent; // + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var inherit = parent !== null; + var rotation = 0.0; + if (this.offsetMode === 1 /* Additive */) { + if (origin !== null) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = origin.x + offset.x + animationPose.x; + global.scaleX = origin.scaleX * offset.scaleX * animationPose.scaleX; + global.scaleY = origin.scaleY * offset.scaleY * animationPose.scaleY; + if (dragonBones.DragonBones.yDown) { + global.y = origin.y + offset.y + animationPose.y; + global.skew = origin.skew + offset.skew + animationPose.skew; + global.rotation = origin.rotation + offset.rotation + animationPose.rotation; + } + else { + global.y = origin.y - offset.y + animationPose.y; + global.skew = origin.skew - offset.skew + animationPose.skew; + global.rotation = origin.rotation - offset.rotation + animationPose.rotation; + } + } + else { + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + global.add(animationPose); + } + } + else if (this.offsetMode === 0 /* None */) { + if (origin !== null) { + global.copyFrom(origin).add(animationPose); + } + else { + global.copyFrom(animationPose); + } + } + else { + inherit = false; + global.copyFrom(offset); + if (!dragonBones.DragonBones.yDown) { + global.y = -global.y; + global.skew = -global.skew; + global.rotation = -global.rotation; + } + } + if (inherit) { + var isSurface = parent._boneData.type === 1 /* Surface */; + var surfaceBone = isSurface ? parent._bone : null; + var parentMatrix = isSurface ? parent._getGlobalTransformMatrix(global.x, global.y) : parent.globalTransformMatrix; + if (boneData.inheritScale && (!isSurface || surfaceBone !== null)) { + if (isSurface) { + if (boneData.inheritRotation) { + global.rotation += parent.global.rotation; + } + surfaceBone.updateGlobalTransform(); + global.scaleX *= surfaceBone.global.scaleX; + global.scaleY *= surfaceBone.global.scaleY; + parentMatrix.transformPoint(global.x, global.y, global); + global.toMatrix(globalTransformMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } + else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + } + else { + if (!boneData.inheritRotation) { + parent.updateGlobalTransform(); + if (flipX && flipY) { + rotation = global.rotation - (parent.global.rotation + Math.PI); + } + else if (flipX) { + rotation = global.rotation + parent.global.rotation + Math.PI; + } + else if (flipY) { + rotation = global.rotation + parent.global.rotation; + } + else { + rotation = global.rotation - parent.global.rotation; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (boneData.inheritTranslation) { + global.x = globalTransformMatrix.tx; + global.y = globalTransformMatrix.ty; + } + else { + globalTransformMatrix.tx = global.x; + globalTransformMatrix.ty = global.y; + } + if (isCache) { + global.fromMatrix(globalTransformMatrix); + } + else { + this._globalDirty = true; + } + } + } + else { + if (boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (boneData.inheritRotation) { + parent.updateGlobalTransform(); + if (parent.global.scaleX < 0.0) { + rotation = global.rotation + parent.global.rotation + Math.PI; + } + else { + rotation = global.rotation + parent.global.rotation; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + rotation -= global.rotation * 2.0; + if (flipX !== flipY || boneData.inheritReflection) { + global.skew += Math.PI; + } + if (!dragonBones.DragonBones.yDown) { + global.skew = -global.skew; + } + } + global.rotation = rotation; + } + else if (flipX || flipY) { + if (flipX && flipY) { + rotation = global.rotation + Math.PI; + } + else { + if (flipX) { + rotation = Math.PI - global.rotation; + } + else { + rotation = -global.rotation; + } + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + rotation = global.rotation + Math.PI; + } + else { + if (flipX) { + rotation = Math.PI - global.rotation; + } + else { + rotation = -global.rotation; + } + global.skew += Math.PI; + } + global.rotation = rotation; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + */ + Bone.prototype._updateAlpha = function () { + if (this._parent !== null) { + this._globalAlpha = this._alpha * this._parent._globalAlpha; + } + else { + this._globalAlpha = this._alpha * this._armature._globalAlpha; + } + }; + /** + * @internal + */ + Bone.prototype.init = function (boneData, armatureValue) { + if (this._boneData !== null) { + return; + } + this._boneData = boneData; + this._armature = armatureValue; + this._alpha = this._boneData.alpha; + if (this._boneData.parent !== null) { + this._parent = this._armature.getBone(this._boneData.parent.name); + } + this._armature._addBone(this); + // + this.origin = this._boneData.transform; + }; + /** + * @internal + */ + Bone.prototype.update = function (cacheFrameIndex) { + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + // + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + // + } + else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + this._localDirty = true; + }; + /** + * @internal + */ + Bone.prototype.updateByConstraint = function () { + if (this._localDirty) { + this._localDirty = false; + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { + this._updateGlobalTransformMatrix(true); + } + this._transformDirty = true; + } + }; + /** + * - Forces the bone to update the transform in the next frame. + * When the bone is not animated or its animation state is finished, the bone will not continue to update, + * and when the skeleton must be updated for some reason, the method needs to be called explicitly. + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 强制骨骼在下一帧更新变换。 + * 当该骨骼没有动画状态或其动画状态播放完成时,骨骼将不在继续更新,而此时由于某些原因必须更新骨骼时,则需要显式调用该方法。 + * @example + *
+         *     let bone = armature.getBone("arm");
+         *     bone.offset.scaleX = 2.0;
+         *     bone.invalidUpdate();
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * - Check whether the bone contains a specific bone. + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查该骨骼是否包含特定的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (value) { + if (value === this) { + return false; + } + var ancestor = value; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + Object.defineProperty(Bone.prototype, "boneData", { + /** + * - The bone data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 骨骼数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._boneData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "visible", { + /** + * - The visible of all slots in the bone. + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot#visible + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible === value) { + return; + } + this._visible = value; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + slot._updateVisible(); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "name", { + /** + * - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._boneData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "parent", { + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(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) { + /** + * @internal + */ + var Surface = /** @class */ (function (_super) { + __extends(Surface, _super); + function Surface() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._vertices = []; + _this._deformVertices = []; + /** + * - x1, y1, x2, y2, x3, y3, x4, y4, d1X, d1Y, d2X, d2Y + */ + _this._hullCache = []; + /** + * - Inside [flag, a, b, c, d, tx, ty], Outside [flag, a, b, c, d, tx, ty] + */ + _this._matrixCahce = []; + return _this; + } + Surface.toString = function () { + return "[class dragonBones.Surface]"; + }; + Surface.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._dX = 0.0; + this._dY = 0.0; + this._k = 0.0; + this._kX = 0.0; + this._kY = 0.0; + this._vertices.length = 0; + this._deformVertices.length = 0; + this._matrixCahce.length = 0; + this._hullCache.length = 0; + this._bone = null; + }; + Surface.prototype._getAffineTransform = function (x, y, lX, lY, aX, aY, bX, bY, cX, cY, transform, matrix, isDown) { + var dabX = bX - aX; + var dabY = bY - aY; + var dacX = cX - aX; + var dacY = cY - aY; + transform.rotation = Math.atan2(dabY, dabX); + transform.skew = Math.atan2(dacY, dacX) - Math.PI * 0.5 - transform.rotation; + if (isDown) { + transform.rotation += Math.PI; + } + transform.scaleX = Math.sqrt(dabX * dabX + dabY * dabY) / lX; + transform.scaleY = Math.sqrt(dacX * dacX + dacY * dacY) / lY; + transform.toMatrix(matrix); + transform.x = matrix.tx = aX - (matrix.a * x + matrix.c * y); + transform.y = matrix.ty = aY - (matrix.b * x + matrix.d * y); + }; + Surface.prototype._updateVertices = function () { + var data = this._armature.armatureData.parent; + var geometry = this._boneData.geometry; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometry.offset + 0 /* GeometryVertexCount */]; + var verticesOffset = intArray[geometry.offset + 2 /* GeometryFloatOffset */]; + var vertices = this._vertices; + var animationVertices = this._deformVertices; + if (this._parent !== null) { + if (this._parent._boneData.type === 1 /* Surface */) { + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + var x = floatArray[verticesOffset + iD] + animationVertices[iD]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + var matrix = this._parent._getGlobalTransformMatrix(x, y); + // + vertices[iD] = matrix.a * x + matrix.c * y + matrix.tx; + vertices[iD + 1] = matrix.b * x + matrix.d * y + matrix.ty; + } + } + else { + var parentMatrix = this._parent.globalTransformMatrix; + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + var x = floatArray[verticesOffset + iD] + animationVertices[iD]; + var y = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + // + vertices[iD] = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + vertices[iD + 1] = parentMatrix.b * x + parentMatrix.d * y + parentMatrix.ty; + } + } + } + else { + for (var i = 0, l = vertexCount; i < l; ++i) { + var iD = i * 2; + vertices[iD] = floatArray[verticesOffset + iD] + animationVertices[iD]; + vertices[iD + 1] = floatArray[verticesOffset + iD + 1] + animationVertices[iD + 1]; + } + } + }; + Surface.prototype._updateGlobalTransformMatrix = function (isCache) { + // tslint:disable-next-line:no-unused-expression + isCache; + var segmentXD = this._boneData.segmentX * 2; + var lastIndex = this._vertices.length - 2; + var lA = 200.0; + // + var raX = this._vertices[0]; + var raY = this._vertices[1]; + var rbX = this._vertices[segmentXD]; + var rbY = this._vertices[segmentXD + 1]; + var rcX = this._vertices[lastIndex]; + var rcY = this._vertices[lastIndex + 1]; + var rdX = this._vertices[lastIndex - segmentXD]; + var rdY = this._vertices[lastIndex - segmentXD + 1]; + // + var dacX = raX + (rcX - raX) * 0.5; + var dacY = raY + (rcY - raY) * 0.5; + var dbdX = rbX + (rdX - rbX) * 0.5; + var dbdY = rbY + (rdY - rbY) * 0.5; + var aX = dacX + (dbdX - dacX) * 0.5; + var aY = dacY + (dbdY - dacY) * 0.5; + var bX = rbX + (rcX - rbX) * 0.5; + var bY = rbY + (rcY - rbY) * 0.5; + var cX = rdX + (rcX - rdX) * 0.5; + var cY = rdY + (rcY - rdY) * 0.5; + // TODO interpolation + this._getAffineTransform(0.0, 0.0, lA, lA, aX, aY, bX, bY, cX, cY, this.global, this.globalTransformMatrix, false); + this._globalDirty = false; + }; + Surface.prototype._getGlobalTransformMatrix = function (x, y) { + var lA = 200.0; + var lB = 1000.0; + if (x < -lB || lB < x || y < -lB || lB < y) { + return this.globalTransformMatrix; + } + var isDown = false; + var surfaceData = this._boneData; + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var segmentXD = surfaceData.segmentX * 2; + var dX = this._dX; + var dY = this._dY; + var indexX = Math.floor((x + lA) / dX); // -1 ~ segmentX - 1 + var indexY = Math.floor((y + lA) / dY); // -1 ~ segmentY - 1 + var matrixIndex = 0; + var pX = indexX * dX - lA; + var pY = indexY * dY - lA; + // + var matrices = this._matrixCahce; + var helpMatrix = Surface._helpMatrix; + if (x < -lA) { + if (y < -lA || y >= lA) { // Out. + return this.globalTransformMatrix; + } + // Left. + isDown = y > this._kX * (x + lA) + pY; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + segmentY + indexY) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexY * (segmentXD + 2); + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[2] - (segmentY - indexY) * ddX; + var sY = this._hullCache[3] - (segmentY - indexY) * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(-lA, pY + dY, lB - lA, dY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(-lB, pY, lB - lA, dY, sX, sY, vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (x >= lA) { + if (y < -lA || y >= lA) { // Out. + return this.globalTransformMatrix; + } + // Right. + isDown = y > this._kX * (x - lB) + pY; + matrixIndex = ((segmentX * segmentY + segmentX + indexY) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = (indexY + 1) * (segmentXD + 2) - 2; + var ddX = this._hullCache[4]; + var ddY = this._hullCache[5]; + var sX = this._hullCache[0] + indexY * ddX; + var sY = this._hullCache[1] + indexY * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(lB, pY + dY, lB - lA, dY, sX + ddX, sY + ddY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], sX, sY, Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(lA, pY, lB - lA, dY, vertices[vertexIndex], vertices[vertexIndex + 1], sX, sY, vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (y < -lA) { + if (x < -lA || x >= lA) { // Out. + return this.globalTransformMatrix; + } + // Up. + isDown = y > this._kY * (x - pX - dX) - lB; + matrixIndex = ((segmentX * segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexX * 2; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[8] + indexX * ddX; + var sY = this._hullCache[9] + indexX * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, -lA, dX, lB - lA, vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex], vertices[vertexIndex + 1], sX + ddX, sY + ddY, Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, -lB, dX, lB - lA, sX, sY, sX + ddX, sY + ddY, vertices[vertexIndex], vertices[vertexIndex + 1], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else if (y >= lA) { + if (x < -lA || x >= lA) { // Out. + return this.globalTransformMatrix; + } + // Down + isDown = y > this._kY * (x - pX - dX) + lA; + matrixIndex = ((segmentX * segmentY + segmentX + segmentY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = segmentY * (segmentXD + 2) + indexX * 2; + var ddX = this._hullCache[10]; + var ddY = this._hullCache[11]; + var sX = this._hullCache[6] - (segmentX - indexX) * ddX; + var sY = this._hullCache[7] - (segmentX - indexX) * ddY; + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, lB, dX, lB - lA, sX + ddX, sY + ddY, sX, sY, vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, lA, dX, lB - lA, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], sX, sY, Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + else { // Center. + isDown = y > this._k * (x - pX - dX) + pY; + matrixIndex = ((segmentX * indexY + indexX) * 2 + (isDown ? 1 : 0)) * 7; + if (matrices[matrixIndex] > 0.0) { + helpMatrix.copyFromArray(matrices, matrixIndex + 1); + } + else { + var vertexIndex = indexX * 2 + indexY * (segmentXD + 2); + var vertices = this._vertices; + if (isDown) { + this._getAffineTransform(pX + dX, pY + dY, dX, dY, vertices[vertexIndex + segmentXD + 4], vertices[vertexIndex + segmentXD + 5], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], vertices[vertexIndex + 2], vertices[vertexIndex + 3], Surface._helpTransform, helpMatrix, true); + } + else { + this._getAffineTransform(pX, pY, dX, dY, vertices[vertexIndex], vertices[vertexIndex + 1], vertices[vertexIndex + 2], vertices[vertexIndex + 3], vertices[vertexIndex + segmentXD + 2], vertices[vertexIndex + segmentXD + 3], Surface._helpTransform, helpMatrix, false); + } + matrices[matrixIndex] = 1.0; + matrices[matrixIndex + 1] = helpMatrix.a; + matrices[matrixIndex + 2] = helpMatrix.b; + matrices[matrixIndex + 3] = helpMatrix.c; + matrices[matrixIndex + 4] = helpMatrix.d; + matrices[matrixIndex + 5] = helpMatrix.tx; + matrices[matrixIndex + 6] = helpMatrix.ty; + } + } + return helpMatrix; + }; + /** + * @internal + * @private + */ + Surface.prototype.init = function (surfaceData, armatureValue) { + if (this._boneData !== null) { + return; + } + _super.prototype.init.call(this, surfaceData, armatureValue); + var segmentX = surfaceData.segmentX; + var segmentY = surfaceData.segmentY; + var vertexCount = this._armature.armatureData.parent.intArray[surfaceData.geometry.offset + 0 /* GeometryVertexCount */]; + var lB = 1000.0; + var lA = 200.0; + // + this._dX = lA * 2.0 / segmentX; + this._dY = lA * 2.0 / segmentY; + this._k = -this._dY / this._dX; + this._kX = -this._dY / (lB - lA); + this._kY = -(lB - lA) / this._dX; + this._vertices.length = vertexCount * 2; + this._deformVertices.length = vertexCount * 2; + this._matrixCahce.length = (segmentX * segmentY + segmentX * 2 + segmentY * 2) * 2 * 7; + this._hullCache.length = 10; + for (var i = 0; i < vertexCount * 2; ++i) { + this._deformVertices[i] = 0.0; + } + if (this._parent !== null) { + if (this._parent.boneData.type === 0 /* Bone */) { + this._bone = this._parent; + } + else { + this._bone = this._parent._bone; + } + } + }; + /** + * @internal + */ + Surface.prototype.update = function (cacheFrameIndex) { + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || + (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } + else { + if (this._hasConstraint) { // Update constraints. + for (var _b = 0, _c = this._armature._constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + if (constraint._root === this) { + constraint.update(); + } + } + } + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + if (this._transformDirty) { + this._transformDirty = false; + this._childrenTransformDirty = true; + // + for (var i = 0, l = this._matrixCahce.length; i < l; i += 7) { + this._matrixCahce[i] = -1.0; + } + // + this._updateVertices(); + // + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + // Update hull vertices. + var lB = 1000.0; + var lA = 200.0; + var ddX = 2 * this.global.x; + var ddY = 2 * this.global.y; + // + var helpPoint = Surface._helpPoint; + this.globalTransformMatrix.transformPoint(lB, -lA, helpPoint); + this._hullCache[0] = helpPoint.x; + this._hullCache[1] = helpPoint.y; + this._hullCache[2] = ddX - helpPoint.x; + this._hullCache[3] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(0.0, this._dY, helpPoint, true); + this._hullCache[4] = helpPoint.x; + this._hullCache[5] = helpPoint.y; + // + this.globalTransformMatrix.transformPoint(lA, lB, helpPoint); + this._hullCache[6] = helpPoint.x; + this._hullCache[7] = helpPoint.y; + this._hullCache[8] = ddX - helpPoint.x; + this._hullCache[9] = ddY - helpPoint.y; + this.globalTransformMatrix.transformPoint(this._dX, 0.0, helpPoint, true); + this._hullCache[10] = helpPoint.x; + this._hullCache[11] = helpPoint.y; + } + else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + this._localDirty = true; + }; + return Surface; + }(dragonBones.Bone)); + dragonBones.Surface = Surface; +})(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 DisplayFrame = /** @class */ (function (_super) { + __extends(DisplayFrame, _super); + function DisplayFrame() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.deformVertices = []; + return _this; + } + DisplayFrame.toString = function () { + return "[class dragonBones.DisplayFrame]"; + }; + DisplayFrame.prototype._onClear = function () { + this.rawDisplayData = null; + this.displayData = null; + this.textureData = null; + this.display = null; + this.deformVertices.length = 0; + }; + DisplayFrame.prototype.updateDeformVertices = function () { + if (this.rawDisplayData === null || this.deformVertices.length !== 0) { + return; + } + var rawGeometryData; + if (this.rawDisplayData.type === 2 /* Mesh */) { + rawGeometryData = this.rawDisplayData.geometry; + } + else if (this.rawDisplayData.type === 4 /* Path */) { + rawGeometryData = this.rawDisplayData.geometry; + } + else { + return; + } + var vertexCount = 0; + if (rawGeometryData.weight !== null) { + vertexCount = rawGeometryData.weight.count * 2; + } + else { + vertexCount = rawGeometryData.data.intArray[rawGeometryData.offset + 0 /* GeometryVertexCount */] * 2; + } + this.deformVertices.length = vertexCount; + for (var i = 0, l = this.deformVertices.length; i < l; ++i) { + this.deformVertices[i] = 0.0; + } + }; + DisplayFrame.prototype.getGeometryData = function () { + if (this.displayData !== null) { + if (this.displayData.type === 2 /* Mesh */) { + return this.displayData.geometry; + } + if (this.displayData.type === 4 /* Path */) { + return this.displayData.geometry; + } + } + if (this.rawDisplayData !== null) { + if (this.rawDisplayData.type === 2 /* Mesh */) { + return this.rawDisplayData.geometry; + } + if (this.rawDisplayData.type === 4 /* Path */) { + return this.rawDisplayData.geometry; + } + } + return null; + }; + DisplayFrame.prototype.getBoundingBox = function () { + if (this.displayData !== null && this.displayData.type === 3 /* BoundingBox */) { + return this.displayData.boundingBox; + } + if (this.rawDisplayData !== null && this.rawDisplayData.type === 3 /* BoundingBox */) { + return this.rawDisplayData.boundingBox; + } + return null; + }; + DisplayFrame.prototype.getTextureData = function () { + if (this.displayData !== null) { + if (this.displayData.type === 0 /* Image */) { + return this.displayData.texture; + } + if (this.displayData.type === 2 /* Mesh */) { + return this.displayData.texture; + } + } + if (this.textureData !== null) { + return this.textureData; + } + if (this.rawDisplayData !== null) { + if (this.rawDisplayData.type === 0 /* Image */) { + return this.rawDisplayData.texture; + } + if (this.rawDisplayData.type === 2 /* Mesh */) { + return this.rawDisplayData.texture; + } + } + return null; + }; + return DisplayFrame; + }(dragonBones.BaseObject)); + dragonBones.DisplayFrame = DisplayFrame; + /** + * - The slot attached to the armature, controls the display status and properties of the display object. + * A bone can contain multiple slots. + * A slot can contain multiple display objects, displaying only one of the display objects at a time, + * but you can toggle the display object into frame animation while the animation is playing. + * The display object can be a normal texture, or it can be a display of a child armature, a grid display object, + * and a custom other display object. + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + var Slot = /** @class */ (function (_super) { + __extends(Slot, _super); + function Slot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._localMatrix = new dragonBones.Matrix(); + /** + * @internal + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @internal + */ + _this._displayFrames = []; + /** + * @internal + */ + _this._geometryBones = []; + _this._rawDisplay = null; // Initial value. + _this._meshDisplay = null; // Initial value. + _this._display = null; + return _this; + } + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var dispayFrame = _a[_i]; + var display = dispayFrame.display; + if (display !== this._rawDisplay && display !== this._meshDisplay && + disposeDisplayList.indexOf(display) < 0) { + disposeDisplayList.push(display); + } + dispayFrame.returnToPool(); + } + for (var _b = 0, disposeDisplayList_1 = disposeDisplayList; _b < disposeDisplayList_1.length; _b++) { + var eachDisplay = disposeDisplayList_1[_b]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay, true); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. + this._disposeDisplay(this._meshDisplay, false); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay, false); + } + this.displayController = null; + this._displayDataDirty = false; + this._displayDirty = false; + this._geometryDirty = false; + this._textureDirty = false; + this._visibleDirty = false; + this._blendModeDirty = false; + this._zOrderDirty = false; + this._colorDirty = false; + this._verticesDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._zIndex = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._displayFrames.length = 0; + this._geometryBones.length = 0; + this._slotData = null; // + this._displayFrame = null; + this._geometryData = null; + this._boundingBoxData = null; + this._textureData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._parent = null; // + this._cachedFrameIndices = null; + }; + Slot.prototype._hasDisplay = function (display) { + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var displayFrame = _a[_i]; + if (displayFrame.display === display) { + return true; + } + } + return false; + }; + /** + * @internal + */ + Slot.prototype._isBonesUpdate = function () { + for (var _i = 0, _a = this._geometryBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + */ + Slot.prototype._updateAlpha = function () { + var globalAlpha = this._alpha * this._parent._globalAlpha; + if (this._globalAlpha !== globalAlpha) { + this._globalAlpha = globalAlpha; + this._colorDirty = true; + } + }; + Slot.prototype._updateDisplayData = function () { + var prevDisplayFrame = this._displayFrame; + var prevGeometryData = this._geometryData; + var prevTextureData = this._textureData; + var rawDisplayData = null; + var displayData = null; + this._displayFrame = null; + this._geometryData = null; + this._boundingBoxData = null; + this._textureData = null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayFrames.length) { + this._displayFrame = this._displayFrames[this._displayIndex]; + rawDisplayData = this._displayFrame.rawDisplayData; + displayData = this._displayFrame.displayData; + this._geometryData = this._displayFrame.getGeometryData(); + this._boundingBoxData = this._displayFrame.getBoundingBox(); + this._textureData = this._displayFrame.getTextureData(); + } + if (this._displayFrame !== prevDisplayFrame || + this._geometryData !== prevGeometryData || this._textureData !== prevTextureData) { + // Update pivot offset. + if (this._geometryData === null && this._textureData !== null) { + var imageDisplayData = ((displayData !== null && displayData.type === 0 /* Image */) ? displayData : rawDisplayData); // + var scale = this._textureData.parent.scale * this._armature._armatureData.scale; + var frame = this._textureData.frame; + this._pivotX = imageDisplayData.pivot.x; + this._pivotY = imageDisplayData.pivot.y; + var rect = frame !== null ? frame : this._textureData.region; + var width = rect.width; + var height = rect.height; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width * scale; + this._pivotY *= height * scale; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + // Update replace pivot. TODO + if (rawDisplayData !== null && imageDisplayData !== rawDisplayData) { + rawDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); + this._pivotX -= Slot._helpPoint.x; + this._pivotY -= Slot._helpPoint.y; + imageDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0.0, 0.0, Slot._helpPoint); + this._pivotX += Slot._helpPoint.x; + this._pivotY += Slot._helpPoint.y; + } + if (!dragonBones.DragonBones.yDown) { + this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update original transform. + if (rawDisplayData !== null) { // Compatible. + this.origin = rawDisplayData.transform; + } + else if (displayData !== null) { // Compatible. + this.origin = displayData.transform; + } + else { + this.origin = null; + } + // TODO remove slot offset. + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + // Update geometry. + if (this._geometryData !== prevGeometryData) { + this._geometryDirty = true; + this._verticesDirty = true; + if (this._geometryData !== null) { + this._geometryBones.length = 0; + if (this._geometryData.weight !== null) { + for (var i = 0, l = this._geometryData.weight.bones.length; i < l; ++i) { + var bone = this._armature.getBone(this._geometryData.weight.bones[i].name); + this._geometryBones.push(bone); + } + } + } + else { + this._geometryBones.length = 0; + this._geometryData = null; + } + } + this._textureDirty = this._textureData !== prevTextureData; + this._transformDirty = true; + } + }; + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayFrame !== null) { + this._display = this._displayFrame.display; + if (this._display !== null && this._display instanceof dragonBones.Armature) { + this._childArmature = this._display; + this._display = this._childArmature.display; + } + else { + this._childArmature = null; + } + } + else { + this._display = null; + this._childArmature = null; + } + // Update display. + var currentDisplay = this._display !== null ? this._display : this._rawDisplay; + if (currentDisplay !== prevDisplay) { + this._textureDirty = true; + this._visibleDirty = true; + this._blendModeDirty = true; + // this._zOrderDirty = true; + this._colorDirty = true; + this._transformDirty = true; + this._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + } + // Update child armature. + if (this._childArmature !== prevChildArmature) { + if (prevChildArmature !== null) { + prevChildArmature._parent = null; // Update child armature parent. + prevChildArmature.clock = null; + if (prevChildArmature.inheritAnimation) { + prevChildArmature.animation.reset(); + } + } + if (this._childArmature !== null) { + this._childArmature._parent = this; // Update child armature parent. + this._childArmature.clock = this._armature.clock; + if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. + if (this._childArmature.cacheFrameRate === 0) { + var cacheFrameRate = this._armature.cacheFrameRate; + if (cacheFrameRate !== 0) { + this._childArmature.cacheFrameRate = cacheFrameRate; + } + } + // Child armature action. + if (this._displayFrame !== null) { + var actions = null; + var displayData = this._displayFrame.displayData !== null ? this._displayFrame.displayData : this._displayFrame.rawDisplayData; + if (displayData !== null && displayData.type === 1 /* Armature */) { + actions = displayData.actions; + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + eventObject.slot = this; + this._armature._bufferAction(eventObject, false); + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + } + }; + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + var parentMatrix = this._parent._boneData.type === 0 /* Bone */ ? this._parent.globalTransformMatrix : this._parent._getGlobalTransformMatrix(this.global.x, this.global.y); + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(parentMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @internal + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return; + } + this._displayIndex = value < this._displayFrames.length ? value : this._displayFrames.length - 1; + this._displayDataDirty = true; + this._displayDirty = this._displayIndex < 0 || this._display !== this._displayFrames[this._displayIndex].display; + }; + /** + * @internal + */ + Slot.prototype._setZOrder = function (value) { + if (this._zOrder === value) { + // return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + return this._colorDirty = true; + }; + /** + * @internal + */ + Slot.prototype.init = function (slotData, armatureValue, rawDisplay, meshDisplay) { + if (this._slotData !== null) { + return; + } + this._slotData = slotData; + this._colorDirty = true; // + this._blendModeDirty = true; // + this._blendMode = this._slotData.blendMode; + this._zOrder = this._slotData.zOrder; + this._zIndex = this._slotData.zIndex; + this._alpha = this._slotData.alpha; + this._colorTransform.copyFrom(this._slotData.color); + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + // + this._armature = armatureValue; + var slotParent = this._armature.getBone(this._slotData.parent.name); + if (slotParent !== null) { + this._parent = slotParent; + } + else { + // Never; + } + this._armature._addSlot(this); + // + this._initDisplay(this._rawDisplay, false); + if (this._rawDisplay !== this._meshDisplay) { + this._initDisplay(this._meshDisplay, false); + } + this._onUpdateDisplay(); + this._addDisplay(); + }; + /** + * @internal + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDataDirty) { + this._updateDisplayData(); + this._displayDataDirty = false; + } + if (this._displayDirty) { + this._updateDisplay(); + this._displayDirty = false; + } + if (this._geometryDirty || this._textureDirty) { + if (this._display === null || this._display === this._rawDisplay || this._display === this._meshDisplay) { + this._updateFrame(); + } + this._geometryDirty = false; + this._textureDirty = false; + } + if (this._display === null) { + return; + } + if (this._visibleDirty) { + this._updateVisible(); + this._visibleDirty = false; + } + if (this._blendModeDirty) { + this._updateBlendMode(); + this._blendModeDirty = false; + } + if (this._colorDirty) { + this._updateColor(); + this._colorDirty = false; + } + if (this._zOrderDirty) { + this._updateZOrder(); + this._zOrderDirty = false; + } + if (this._geometryData !== null && this._display === this._meshDisplay) { + var isSkinned = this._geometryData.weight !== null; + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + if (this._verticesDirty || + (isSkinned && this._isBonesUpdate()) || + (isSurface && this._parent._childrenTransformDirty)) { + this._verticesDirty = false; // Allow update mesh to reset the dirty value. + this._updateMesh(); + } + if (isSkinned || isSurface) { // Compatible. + return; + } + } + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + var cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex]; + if (cachedFrameIndex >= 0 && this._cachedFrameIndex === cachedFrameIndex) { // Same cache. + this._transformDirty = false; + } + else if (cachedFrameIndex >= 0) { // Has been Cached. + this._transformDirty = true; + this._cachedFrameIndex = cachedFrameIndex; + } + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + else if (this._cachedFrameIndex >= 0) { // Same cache, but not set index yet. + this._transformDirty = false; + this._cachedFrameIndices[cacheFrameIndex] = this._cachedFrameIndex; + } + else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + else if (this._transformDirty || this._parent._childrenTransformDirty) { // Dirty. + cacheFrameIndex = -1; + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + if (this._transformDirty) { + if (this._cachedFrameIndex < 0) { + var isCache = cacheFrameIndex >= 0; + this._updateGlobalTransformMatrix(isCache); + if (isCache && this._cachedFrameIndices !== null) { + this._cachedFrameIndex = this._cachedFrameIndices[cacheFrameIndex] = this._armature._armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + } + } + else { + this._armature._armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + this._updateTransform(); + this._transformDirty = false; + } + }; + /** + * - Forces the slot to update the state of the display object in the next frame. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 强制插槽在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDataDirty = true; + this._displayDirty = true; + // + this._transformDirty = true; + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._updateGlobalTransformMatrix(false); + this._transformDirty = false; + } + }; + /** + * @private + */ + Slot.prototype.replaceRawDisplayData = function (displayData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.rawDisplayData !== displayData) { + displayFrame.deformVertices.length = 0; + displayFrame.rawDisplayData = displayData; + if (displayFrame.rawDisplayData === null) { + var defaultSkin = this._armature._armatureData.defaultSkin; + if (defaultSkin !== null) { + var defaultRawDisplayDatas = defaultSkin.getDisplays(this._slotData.name); + if (defaultRawDisplayDatas !== null && index < defaultRawDisplayDatas.length) { + displayFrame.rawDisplayData = defaultRawDisplayDatas[index]; + } + } + } + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceDisplayData = function (displayData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.displayData !== displayData && displayFrame.rawDisplayData !== displayData) { + displayFrame.displayData = displayData; + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceTextureData = function (textureData, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.textureData !== textureData) { + displayFrame.textureData = textureData; + if (index === this._displayIndex) { + this._displayDataDirty = true; + } + } + }; + /** + * @private + */ + Slot.prototype.replaceDisplay = function (value, index) { + if (index === void 0) { index = -1; } + if (index < 0) { + index = this._displayIndex < 0 ? 0 : this._displayIndex; + } + else if (index >= this._displayFrames.length) { + return; + } + var displayFrame = this._displayFrames[index]; + if (displayFrame.display !== value) { + var prevDisplay = displayFrame.display; + displayFrame.display = value; + if (prevDisplay !== null && + prevDisplay !== this._rawDisplay && prevDisplay !== this._meshDisplay && + !this._hasDisplay(prevDisplay)) { + if (prevDisplay instanceof dragonBones.Armature) { + // (eachDisplay as Armature).dispose(); + } + else { + this._disposeDisplay(prevDisplay, true); + } + } + if (value !== null && + value !== this._rawDisplay && value !== this._meshDisplay && + !this._hasDisplay(prevDisplay) && + !(value instanceof dragonBones.Armature)) { + this._initDisplay(value, true); + } + if (index === this._displayIndex) { + this._displayDirty = true; + } + } + }; + /** + * - Check whether a specific point is inside a custom bounding box in the slot. + * The coordinate system of the point is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param x - The horizontal coordinate of the point. + * @param y - The vertical coordinate of the point. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定点是否在插槽的自定义边界框内。 + * 点的坐标系为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param x - 点的水平坐标。 + * @param y - 点的垂直坐标。 + * @version DragonBones 5.0 + * @language zh_CN + */ + Slot.prototype.containsPoint = function (x, y) { + if (this._boundingBoxData === null) { + return false; + } + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(x, y, Slot._helpPoint); + return this._boundingBoxData.containsPoint(Slot._helpPoint.x, Slot._helpPoint.y); + }; + /** + * - Check whether a specific segment intersects a custom bounding box for the slot. + * The coordinate system of the segment and intersection is the inner coordinate system of the armature. + * Custom bounding boxes need to be customized in Dragonbones Pro. + * @param xA - The horizontal coordinate of the beginning of the segment. + * @param yA - The vertical coordinate of the beginning of the segment. + * @param xB - The horizontal coordinate of the end point of the segment. + * @param yB - The vertical coordinate of the end point of the segment. + * @param intersectionPointA - The first intersection at which a line segment intersects the bounding box from the beginning to the end. (If not set, the intersection point will not calculated) + * @param intersectionPointB - The first intersection at which a line segment intersects the bounding box from the end to the beginning. (If not set, the intersection point will not calculated) + * @param normalRadians - The normal radians of the tangent of the intersection boundary box. [x: Normal radian of the first intersection tangent, y: Normal radian of the second intersection tangent] (If not set, the normal will not calculated) + * @returns Intersection situation. [1: Disjoint and segments within the bounding box, 0: Disjoint, 1: Intersecting and having a nodal point and ending in the bounding box, 2: Intersecting and having a nodal point and starting at the bounding box, 3: Intersecting and having two intersections, N: Intersecting and having N intersections] + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 检查特定线段是否与插槽的自定义边界框相交。 + * 线段和交点的坐标系均为骨架内坐标系。 + * 自定义边界框需要在 DragonBones Pro 中自定义。 + * @param xA - 线段起点的水平坐标。 + * @param yA - 线段起点的垂直坐标。 + * @param xB - 线段终点的水平坐标。 + * @param yB - 线段终点的垂直坐标。 + * @param intersectionPointA - 线段从起点到终点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param intersectionPointB - 线段从终点到起点与边界框相交的第一个交点。 (如果未设置,则不计算交点) + * @param normalRadians - 交点边界框切线的法线弧度。 [x: 第一个交点切线的法线弧度, y: 第二个交点切线的法线弧度] (如果未设置,则不计算法线) + * @returns 相交的情况。 [-1: 不相交且线段在包围盒内, 0: 不相交, 1: 相交且有一个交点且终点在包围盒内, 2: 相交且有一个交点且起点在包围盒内, 3: 相交且有两个交点, N: 相交且有 N 个交点] + * @version DragonBones 5.0 + * @language zh_CN + */ + Slot.prototype.intersectsSegment = function (xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians) { + if (intersectionPointA === void 0) { intersectionPointA = null; } + if (intersectionPointB === void 0) { intersectionPointB = null; } + if (normalRadians === void 0) { normalRadians = null; } + if (this._boundingBoxData === null) { + return 0; + } + this.updateTransformAndMatrix(); + Slot._helpMatrix.copyFrom(this.globalTransformMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(xA, yA, Slot._helpPoint); + xA = Slot._helpPoint.x; + yA = Slot._helpPoint.y; + Slot._helpMatrix.transformPoint(xB, yB, Slot._helpPoint); + xB = Slot._helpPoint.x; + yB = Slot._helpPoint.y; + var intersectionCount = this._boundingBoxData.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionCount === 1 || intersectionCount === 2) { + if (intersectionPointA !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + if (intersectionPointB !== null) { + intersectionPointB.x = intersectionPointA.x; + intersectionPointB.y = intersectionPointA.y; + } + } + else if (intersectionPointB !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + } + else { + if (intersectionPointA !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointA.x, intersectionPointA.y, intersectionPointA); + } + if (intersectionPointB !== null) { + this.globalTransformMatrix.transformPoint(intersectionPointB.x, intersectionPointB.y, intersectionPointB); + } + } + if (normalRadians !== null) { + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.x), Math.sin(normalRadians.x), Slot._helpPoint, true); + normalRadians.x = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + this.globalTransformMatrix.transformPoint(Math.cos(normalRadians.y), Math.sin(normalRadians.y), Slot._helpPoint, true); + normalRadians.y = Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + } + } + return intersectionCount; + }; + /** + * @private + */ + Slot.prototype.getDisplayFrameAt = function (index) { + return this._displayFrames[index]; + }; + Object.defineProperty(Slot.prototype, "visible", { + /** + * - The visible of slot's display object. + * @default true + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 插槽的显示对象的可见。 + * @default true + * @version DragonBones 5.6 + * @language zh_CN + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible === value) { + return; + } + this._visible = value; + this._updateVisible(); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayFrameCount", { + /** + * @private + */ + get: function () { + return this._displayFrames.length; + }, + set: function (value) { + var prevCount = this._displayFrames.length; + if (prevCount < value) { + this._displayFrames.length = value; + for (var i = prevCount; i < value; ++i) { + this._displayFrames[i] = dragonBones.BaseObject.borrowObject(DisplayFrame); + } + } + else if (prevCount > value) { + for (var i = prevCount - 1; i < value; --i) { + this.replaceDisplay(null, i); + this._displayFrames[i].returnToPool(); + } + this._displayFrames.length = value; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * - The index of the display object displayed in the display list. + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     slot.displayIndex = 3;
+             *     slot.displayController = "none";
+             * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 此时显示的显示对象在显示列表中的索引。 + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     slot.displayIndex = 3;
+             *     slot.displayController = "none";
+             * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + this._setDisplayIndex(value); + this.update(-1); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "name", { + /** + * - The slot name. + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽名称。 + * @see dragonBones.SlotData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._slotData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * - Contains a display list of display objects or child armatures. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + var displays = new Array(); + for (var _i = 0, _a = this._displayFrames; _i < _a.length; _i++) { + var displayFrame = _a[_i]; + displays.push(displayFrame.display); + } + return displays; + }, + set: function (value) { + this.displayFrameCount = value.length; + var index = 0; + for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { + var eachDisplay = value_1[_i]; + this.replaceDisplay(eachDisplay, index++); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "slotData", { + /** + * - The slot data. + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._slotData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * - The custom bounding box data for the slot at current time. + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 插槽此时的自定义包围盒数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return this._boundingBoxData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "rawDisplay", { + /** + * @private + */ + get: function () { + return this._rawDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "meshDisplay", { + /** + * @private + */ + get: function () { + return this._meshDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "display", { + /** + * - The display object that the slot displays at this time. + * @example + *
+             *     let slot = armature.getSlot("text");
+             *     slot.display = new yourEngine.TextField();
+             * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的显示对象。 + * @example + *
+             *     let slot = armature.getSlot("text");
+             *     slot.display = new yourEngine.TextField();
+             * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + if (this._displayFrames.length === 0) { + this.displayFrameCount = 1; + this._displayIndex = 0; + } + this.replaceDisplay(value, this._displayIndex); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * - The child armature that the slot displayed at current time. + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     let prevChildArmature = slot.childArmature;
+             *     if (prevChildArmature) {
+             *         prevChildArmature.dispose();
+             *     }
+             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+             * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 插槽此时显示的子骨架。 + * 注意,被替换的对象或子骨架并不会被回收,根据语言和引擎的不同,需要额外处理。 + * @example + *
+             *     let slot = armature.getSlot("weapon");
+             *     let prevChildArmature = slot.childArmature;
+             *     if (prevChildArmature) {
+             *         prevChildArmature.dispose();
+             *     }
+             *     slot.childArmature = factory.buildArmature("weapon_blabla", "weapon_blabla_project");
+             * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._childArmature; + }, + set: function (value) { + if (this._childArmature === value) { + return; + } + this.display = value; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "parent", { + /** + * - The parent bone to which it belongs. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 所属的父骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * - Deprecated, please refer to {@link #display}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link #display}。 + * @deprecated + * @language zh_CN + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(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) { + /** + * @internal + */ + var Constraint = /** @class */ (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this._armature = null; // + this._target = null; // + this._root = null; // + this._bone = null; + }; + Object.defineProperty(Constraint.prototype, "name", { + get: function () { + return this._constraintData.name; + }, + enumerable: true, + configurable: true + }); + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @internal + */ + var IKConstraint = /** @class */ (function (_super) { + __extends(IKConstraint, _super); + function IKConstraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraint.toString = function () { + return "[class dragonBones.IKConstraint]"; + }; + IKConstraint.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._scaleEnabled = false; + this._bendPositive = false; + this._weight = 1.0; + this._constraintData = null; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this._target.global; + var global = this._root.global; + var globalTransformMatrix = this._root.globalTransformMatrix; + var radian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + radian += Math.PI; + } + global.rotation += dragonBones.Transform.normalizeRadian(radian - global.rotation) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype._computeB = function () { + var boneLength = this._bone._boneData.length; + var parent = this._root; + var ikGlobal = this._target.global; + var parentGlobal = parent.global; + var global = this._bone.global; + var globalTransformMatrix = this._bone.globalTransformMatrix; + var x = globalTransformMatrix.a * boneLength; + var y = globalTransformMatrix.b * boneLength; + var lLL = x * x + y * y; + var lL = Math.sqrt(lLL); + var dX = global.x - parentGlobal.x; + var dY = global.y - parentGlobal.y; + var lPP = dX * dX + dY * dY; + var lP = Math.sqrt(lPP); + var rawRadian = global.rotation; + var rawParentRadian = parentGlobal.rotation; + var rawRadianA = Math.atan2(dY, dX); + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + var lTT = dX * dX + dY * dY; + var lT = Math.sqrt(lTT); + var radianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + radianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + radianA += Math.PI; + } + } + else { + var h = (lPP - lLL + lTT) / (2.0 * lTT); + var r = Math.sqrt(lPP - h * h * lTT) / lT; + var hX = parentGlobal.x + (dX * h); + var hY = parentGlobal.y + (dY * h); + var rX = -dY * r; + var rY = dX * r; + var isPPR = false; + var parentParent = parent.parent; + if (parentParent !== null) { + var parentParentMatrix = parentParent.globalTransformMatrix; + isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0.0; + } + if (isPPR !== this._bendPositive) { + global.x = hX - rX; + global.y = hY - rY; + } + else { + global.x = hX + rX; + global.y = hY + rY; + } + radianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = dragonBones.Transform.normalizeRadian(radianA - rawRadianA); + parentGlobal.rotation = rawParentRadian + dR * this._weight; + parentGlobal.toMatrix(parent.globalTransformMatrix); + // + var currentRadianA = rawRadianA + dR * this._weight; + global.x = parentGlobal.x + Math.cos(currentRadianA) * lP; + global.y = parentGlobal.y + Math.sin(currentRadianA) * lP; + // + var radianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + radianB += Math.PI; + } + global.rotation = parentGlobal.rotation + rawRadian - rawParentRadian + dragonBones.Transform.normalizeRadian(radianB - dR - rawRadian) * this._weight; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.init = function (constraintData, armature) { + if (this._constraintData !== null) { + return; + } + this._constraintData = constraintData; + this._armature = armature; + this._target = this._armature.getBone(this._constraintData.target.name); + this._root = this._armature.getBone(this._constraintData.root.name); + this._bone = this._constraintData.bone !== null ? this._armature.getBone(this._constraintData.bone.name) : null; + { + var ikConstraintData = this._constraintData; + this._scaleEnabled = ikConstraintData.scaleEnabled; + this._bendPositive = ikConstraintData.bendPositive; + this._weight = ikConstraintData.weight; + } + this._root._hasConstraint = true; + }; + IKConstraint.prototype.update = function () { + this._root.updateByConstraint(); + if (this._bone !== null) { + this._bone.updateByConstraint(); + this._computeB(); + } + else { + this._computeA(); + } + }; + IKConstraint.prototype.invalidUpdate = function () { + this._root.invalidUpdate(); + if (this._bone !== null) { + this._bone.invalidUpdate(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; + /** + * @internal + */ + var PathConstraint = /** @class */ (function (_super) { + __extends(PathConstraint, _super); + function PathConstraint() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._bones = []; + _this._spaces = []; + _this._positions = []; + _this._curves = []; + _this._boneLengths = []; + _this._pathGlobalVertices = []; + _this._segments = [10]; + return _this; + } + PathConstraint.toString = function () { + return "[class dragonBones.PathConstraint]"; + }; + PathConstraint.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.dirty = false; + this.pathOffset = 0; + this.position = 0.0; + this.spacing = 0.0; + this.rotateOffset = 0.0; + this.rotateMix = 1.0; + this.translateMix = 1.0; + this._pathSlot = null; + this._bones.length = 0; + this._spaces.length = 0; + this._positions.length = 0; + this._curves.length = 0; + this._boneLengths.length = 0; + this._pathGlobalVertices.length = 0; + }; + PathConstraint.prototype._updatePathVertices = function (verticesData) { + //计算曲线的节点数据 + var armature = this._armature; + var dragonBonesData = armature.armatureData.parent; + var scale = armature.armatureData.scale; + var intArray = dragonBonesData.intArray; + var floatArray = dragonBonesData.floatArray; + var pathOffset = verticesData.offset; + var pathVertexCount = intArray[pathOffset + 0 /* GeometryVertexCount */]; + var pathVertexOffset = intArray[pathOffset + 2 /* GeometryFloatOffset */]; + this._pathGlobalVertices.length = pathVertexCount * 2; + var weightData = verticesData.weight; + //没有骨骼约束我,那节点只受自己的Bone控制 + if (weightData === null) { + var parentBone = this._pathSlot.parent; + parentBone.updateByConstraint(); + var matrix = parentBone.globalTransformMatrix; + for (var i = 0, iV_1 = pathVertexOffset; i < pathVertexCount; i += 2) { + var vx = floatArray[iV_1++] * scale; + var vy = floatArray[iV_1++] * scale; + var x = matrix.a * vx + matrix.c * vy + matrix.tx; + var y = matrix.b * vx + matrix.d * vy + matrix.ty; + // + this._pathGlobalVertices[i] = x; + this._pathGlobalVertices[i + 1] = y; + } + return; + } + //有骨骼约束我,那我的节点受骨骼权重控制 + var bones = this._pathSlot._geometryBones; + var weightBoneCount = weightData.bones.length; + var weightOffset = weightData.offset; + var floatOffset = intArray[weightOffset + 1 /* WeigthFloatOffset */]; + var iV = floatOffset; + var iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount; + for (var i = 0, iW = 0; i < pathVertexCount; i++) { + var vertexBoneCount = intArray[iB++]; // + var xG = 0.0, yG = 0.0; + for (var ii = 0, ll = vertexBoneCount; ii < ll; ii++) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (bone === null) { + continue; + } + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var vx = floatArray[iV++] * scale; + var vy = floatArray[iV++] * scale; + xG += (matrix.a * vx + matrix.c * vy + matrix.tx) * weight; + yG += (matrix.b * vx + matrix.d * vy + matrix.ty) * weight; + } + this._pathGlobalVertices[iW++] = xG; + this._pathGlobalVertices[iW++] = yG; + } + }; + PathConstraint.prototype._computeVertices = function (start, count, offset, out) { + //TODO优化 + for (var i = offset, iW = start; i < count; i += 2) { + out[i] = this._pathGlobalVertices[iW++]; + out[i + 1] = this._pathGlobalVertices[iW++]; + } + }; + PathConstraint.prototype._computeBezierCurve = function (pathDisplayDta, spaceCount, tangents, percentPosition, percentSpacing) { + //计算当前的骨骼在曲线上的位置 + var armature = this._armature; + var intArray = armature.armatureData.parent.intArray; + var vertexCount = intArray[pathDisplayDta.geometry.offset + 0 /* GeometryVertexCount */]; + var positions = this._positions; + var spaces = this._spaces; + var isClosed = pathDisplayDta.closed; + var curveVertices = Array(); + var verticesLength = vertexCount * 2; + var curveCount = verticesLength / 6; + var preCurve = -1; + var position = this.position; + positions.length = spaceCount * 3 + 2; + var pathLength = 0.0; + //不需要匀速运动,效率高些 + if (!pathDisplayDta.constantSpeed) { + var lenghts = pathDisplayDta.curveLengths; + curveCount -= isClosed ? 1 : 2; + pathLength = lenghts[curveCount]; + if (percentPosition) { + position *= pathLength; + } + if (percentSpacing) { + for (var i = 0; i < spaceCount; i++) { + spaces[i] *= pathLength; + } + } + curveVertices.length = 8; + for (var i = 0, o = 0, curve = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + if (isClosed) { + position %= pathLength; + if (position < 0) { + position += pathLength; + } + curve = 0; + } + else if (position < 0) { + //TODO + continue; + } + else if (position > pathLength) { + //TODO + continue; + } + var percent = 0.0; + for (;; curve++) { + var len = lenghts[curve]; + if (position > len) { + continue; + } + if (curve === 0) { + percent = position / len; + } + else { + var preLen = lenghts[curve - 1]; + percent = (position - preLen) / (len - preLen); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + if (isClosed && curve === curveCount) { + //计算曲线 + this._computeVertices(verticesLength - 4, 4, 0, curveVertices); + this._computeVertices(0, 4, 4, curveVertices); + } + else { + this._computeVertices(curve * 6 + 2, 8, 0, curveVertices); + } + } + // + this.addCurvePosition(percent, curveVertices[0], curveVertices[1], curveVertices[2], curveVertices[3], curveVertices[4], curveVertices[5], curveVertices[6], curveVertices[7], positions, o, tangents); + } + return; + } + //匀速的 + if (isClosed) { + verticesLength += 2; + curveVertices.length = vertexCount; + this._computeVertices(2, verticesLength - 4, 0, curveVertices); + this._computeVertices(0, 2, verticesLength - 4, curveVertices); + curveVertices[verticesLength - 2] = curveVertices[0]; + curveVertices[verticesLength - 1] = curveVertices[1]; + } + else { + curveCount--; + verticesLength -= 4; + curveVertices.length = verticesLength; + this._computeVertices(2, verticesLength, 0, curveVertices); + } + // + var curves = new Array(curveCount); + pathLength = 0; + var x1 = curveVertices[0], y1 = curveVertices[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0; + var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy; + for (var i = 0, w = 2; i < curveCount; i++, w += 6) { + cx1 = curveVertices[w]; + cy1 = curveVertices[w + 1]; + cx2 = curveVertices[w + 2]; + cy2 = curveVertices[w + 3]; + x2 = curveVertices[w + 4]; + y2 = curveVertices[w + 5]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.1875; + tmpy = (y1 - cy1 * 2 + cy2) * 0.1875; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx; + dfy += ddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + pathLength += Math.sqrt(dfx * dfx + dfy * dfy); + curves[i] = pathLength; + x1 = x2; + y1 = y2; + } + if (percentPosition) { + position *= pathLength; + } + if (percentSpacing) { + for (var i = 0; i < spaceCount; i++) { + spaces[i] *= pathLength; + } + } + var segments = this._segments; + var curveLength = 0; + for (var i = 0, o = 0, curve = 0, segment = 0; i < spaceCount; i++, o += 3) { + var space = spaces[i]; + position += space; + var p = position; + if (isClosed) { + p %= pathLength; + if (p < 0) + p += pathLength; + curve = 0; + } + else if (p < 0) { + continue; + } + else if (p > pathLength) { + continue; + } + // Determine curve containing position. + for (;; curve++) { + var length_1 = curves[curve]; + if (p > length_1) + continue; + if (curve === 0) + p /= length_1; + else { + var prev = curves[curve - 1]; + p = (p - prev) / (length_1 - prev); + } + break; + } + if (curve !== preCurve) { + preCurve = curve; + var ii = curve * 6; + x1 = curveVertices[ii]; + y1 = curveVertices[ii + 1]; + cx1 = curveVertices[ii + 2]; + cy1 = curveVertices[ii + 3]; + cx2 = curveVertices[ii + 4]; + cy2 = curveVertices[ii + 5]; + x2 = curveVertices[ii + 6]; + y2 = curveVertices[ii + 7]; + tmpx = (x1 - cx1 * 2 + cx2) * 0.03; + tmpy = (y1 - cy1 * 2 + cy2) * 0.03; + dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006; + dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006; + ddfx = tmpx * 2 + dddfx; + ddfy = tmpy * 2 + dddfy; + dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667; + dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667; + curveLength = Math.sqrt(dfx * dfx + dfy * dfy); + segments[0] = curveLength; + for (ii = 1; ii < 8; ii++) { + dfx += ddfx; + dfy += ddfy; + ddfx += dddfx; + ddfy += dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[ii] = curveLength; + } + dfx += ddfx; + dfy += ddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[8] = curveLength; + dfx += ddfx + dddfx; + dfy += ddfy + dddfy; + curveLength += Math.sqrt(dfx * dfx + dfy * dfy); + segments[9] = curveLength; + segment = 0; + } + // Weight by segment length. + p *= curveLength; + for (;; segment++) { + var length_2 = segments[segment]; + if (p > length_2) + continue; + if (segment === 0) + p /= length_2; + else { + var prev = segments[segment - 1]; + p = segment + (p - prev) / (length_2 - prev); + } + break; + } + this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, positions, o, tangents); + } + }; + //Calculates a point on the curve, for a given t value between 0 and 1. + PathConstraint.prototype.addCurvePosition = function (t, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, offset, tangents) { + if (t === 0) { + out[offset] = x1; + out[offset + 1] = y1; + out[offset + 2] = 0; + return; + } + if (t === 1) { + out[offset] = x2; + out[offset + 1] = y2; + out[offset + 2] = 0; + return; + } + var mt = 1 - t; + var mt2 = mt * mt; + var t2 = t * t; + var a = mt2 * mt; + var b = mt2 * t * 3; + var c = mt * t2 * 3; + var d = t * t2; + var x = a * x1 + b * cx1 + c * cx2 + d * x2; + var y = a * y1 + b * cy1 + c * cy2 + d * y2; + out[offset] = x; + out[offset + 1] = y; + if (tangents) { + //Calculates the curve tangent at the specified t value + out[offset + 2] = Math.atan2(y - (a * y1 + b * cy1 + c * cy2), x - (a * x1 + b * cx1 + c * cx2)); + } + else { + out[offset + 2] = 0; + } + }; + PathConstraint.prototype.init = function (constraintData, armature) { + this._constraintData = constraintData; + this._armature = armature; + var data = constraintData; + this.pathOffset = data.pathDisplayData.geometry.offset; + // + this.position = data.position; + this.spacing = data.spacing; + this.rotateOffset = data.rotateOffset; + this.rotateMix = data.rotateMix; + this.translateMix = data.translateMix; + // + this._root = this._armature.getBone(data.root.name); + this._target = this._armature.getBone(data.target.name); + this._pathSlot = this._armature.getSlot(data.pathSlot.name); + for (var i = 0, l = data.bones.length; i < l; i++) { + var bone = this._armature.getBone(data.bones[i].name); + if (bone !== null) { + this._bones.push(bone); + } + } + if (data.rotateMode === 2 /* ChainScale */) { + this._boneLengths.length = this._bones.length; + } + this._root._hasConstraint = true; + }; + PathConstraint.prototype.update = function () { + var pathSlot = this._pathSlot; + if (pathSlot._geometryData === null || + pathSlot._geometryData.offset !== this.pathOffset) { + return; + } + var constraintData = this._constraintData; + // + //曲线节点数据改变:父亲bone改变,权重bones改变,变形顶点改变 + var isPathVerticeDirty = false; + if (this._root._childrenTransformDirty) { + this._updatePathVertices(pathSlot._geometryData); + isPathVerticeDirty = true; + } + else if (pathSlot._verticesDirty || pathSlot._isBonesUpdate()) { + this._updatePathVertices(pathSlot._geometryData); + pathSlot._verticesDirty = false; + isPathVerticeDirty = true; + } + if (!isPathVerticeDirty && !this.dirty) { + return; + } + // + var positionMode = constraintData.positionMode; + var spacingMode = constraintData.spacingMode; + var rotateMode = constraintData.rotateMode; + var bones = this._bones; + var isLengthMode = spacingMode === 0 /* Length */; + var isChainScaleMode = rotateMode === 2 /* ChainScale */; + var isTangentMode = rotateMode === 0 /* Tangent */; + var boneCount = bones.length; + var spacesCount = isTangentMode ? boneCount : boneCount + 1; + var spacing = this.spacing; + var spaces = this._spaces; + spaces.length = spacesCount; + //计曲线间隔和长度 + if (isChainScaleMode || isLengthMode) { + //Bone改变和spacing改变触发 + spaces[0] = 0; + for (var i = 0, l = spacesCount - 1; i < l; i++) { + var bone = bones[i]; + bone.updateByConstraint(); + var boneLength = bone._boneData.length; + var matrix = bone.globalTransformMatrix; + var x = boneLength * matrix.a; + var y = boneLength * matrix.b; + var len = Math.sqrt(x * x + y * y); + if (isChainScaleMode) { + this._boneLengths[i] = len; + } + spaces[i + 1] = (boneLength + spacing) * len / boneLength; + } + } + else { + for (var i = 0; i < spacesCount; i++) { + spaces[i] = spacing; + } + } + // + this._computeBezierCurve(pathSlot._displayFrame.rawDisplayData, spacesCount, isTangentMode, positionMode === 1 /* Percent */, spacingMode === 2 /* Percent */); + //根据新的节点数据重新采样 + var positions = this._positions; + var rotateOffset = this.rotateOffset; + var boneX = positions[0], boneY = positions[1]; + var tip; + if (rotateOffset === 0) { + tip = rotateMode === 1 /* Chain */; + } + else { + tip = false; + var bone = pathSlot.parent; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + rotateOffset *= matrix.a * matrix.d - matrix.b * matrix.c > 0 ? dragonBones.Transform.DEG_RAD : -dragonBones.Transform.DEG_RAD; + } + } + // + var rotateMix = this.rotateMix; + var translateMix = this.translateMix; + for (var i = 0, p = 3; i < boneCount; i++, p += 3) { + var bone = bones[i]; + bone.updateByConstraint(); + var matrix = bone.globalTransformMatrix; + matrix.tx += (boneX - matrix.tx) * translateMix; + matrix.ty += (boneY - matrix.ty) * translateMix; + var x = positions[p], y = positions[p + 1]; + var dx = x - boneX, dy = y - boneY; + if (isChainScaleMode) { + var lenght = this._boneLengths[i]; + var s = (Math.sqrt(dx * dx + dy * dy) / lenght - 1) * rotateMix + 1; + matrix.a *= s; + matrix.b *= s; + } + boneX = x; + boneY = y; + if (rotateMix > 0) { + var a = matrix.a, b = matrix.b, c = matrix.c, d = matrix.d, r = void 0, cos = void 0, sin = void 0; + if (isTangentMode) { + r = positions[p - 1]; + } + else { + r = Math.atan2(dy, dx); + } + r -= Math.atan2(b, a); + if (tip) { + cos = Math.cos(r); + sin = Math.sin(r); + var length_3 = bone._boneData.length; + boneX += (length_3 * (cos * a - sin * b) - dx) * rotateMix; + boneY += (length_3 * (sin * a + cos * b) - dy) * rotateMix; + } + else { + r += rotateOffset; + } + if (r > dragonBones.Transform.PI) { + r -= dragonBones.Transform.PI_D; + } + else if (r < -dragonBones.Transform.PI) { + r += dragonBones.Transform.PI_D; + } + r *= rotateMix; + cos = Math.cos(r); + sin = Math.sin(r); + matrix.a = cos * a - sin * b; + matrix.b = sin * a + cos * b; + matrix.c = cos * c - sin * d; + matrix.d = sin * c + cos * d; + } + bone.global.fromMatrix(matrix); + } + this.dirty = false; + }; + PathConstraint.prototype.invalidUpdate = function () { + }; + return PathConstraint; + }(Constraint)); + dragonBones.PathConstraint = PathConstraint; +})(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) { + /** + * - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance. + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - WorldClock 对动画提供时钟支持,为每个加入到该实例的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = /** @class */ (function () { + /** + * - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance. + * When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个 WorldClock 实例。通常并不需要创建 WorldClock 实例。 + * 当多个 WorldClock 实例使用不同的速度运行时,可以实现一些特殊的动画效果,比如子弹时间等。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = 0.0; } + /** + * - Current time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * - The play speed, used to control animation speed-shift play. + * [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play] + * @default 1.0 + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放速度,用于控制动画变速播放。 + * [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._systemTime = 0.0; + this._animatebles = []; + this._clock = null; + this.time = time; + this._systemTime = new Date().getTime() * 0.001; + } + /** + * - Advance time for all IAnimatable instances. + * @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 为所有的 IAnimatable 实例更新时间。 + * @param passedTime - 前进的时间。 [-1: 自动计算当前帧与上一帧的时间差, [0~N): 前进的时间] (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + var currentTime = Date.now() * 0.001; + if (passedTime < 0.0) { + passedTime = currentTime - this._systemTime; + } + this._systemTime = currentTime; + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime === 0.0) { + return; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + var i = 0, r = 0, l = this._animatebles.length; + for (; i < l; ++i) { + var animatable = this._animatebles[i]; + if (animatable !== null) { + if (r > 0) { + this._animatebles[i - r] = animatable; + this._animatebles[i] = null; + } + animatable.advanceTime(passedTime); + } + else { + r++; + } + } + if (r > 0) { + l = this._animatebles.length; + for (; i < l; ++i) { + var animateble = this._animatebles[i]; + if (animateble !== null) { + this._animatebles[i - r] = animateble; + } + else { + r++; + } + } + this._animatebles.length -= r; + } + }; + /** + * - Check whether contains a specific instance of IAnimatable. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + if (value === this) { + return false; + } + var ancestor = value; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.clock; + } + return ancestor === this; + }; + /** + * - Add IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.add = function (value) { + if (this._animatebles.indexOf(value) < 0) { + this._animatebles.push(value); + value.clock = this; + } + }; + /** + * - Removes a specified IAnimatable instance. + * @param value - The IAnimatable instance. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除特定的 IAnimatable 实例。 + * @param value - IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.remove = function (value) { + var index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles[index] = null; + value.clock = null; + } + }; + /** + * - Clear all IAnimatable instances. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.clear = function () { + for (var _i = 0, _a = this._animatebles; _i < _a.length; _i++) { + var animatable = _a[_i]; + if (animatable !== null) { + animatable.clock = null; + } + } + }; + Object.defineProperty(WorldClock.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + if (this._clock !== null) { + this._clock.remove(this); + } + this._clock = value; + if (this._clock !== null) { + this._clock.add(this); + } + }, + enumerable: true, + configurable: true + }); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(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 animation player is used to play the animation data and manage the animation states. + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画播放器用来播放动画数据和管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + var Animation = /** @class */ (function (_super) { + __extends(Animation, _super); + function Animation() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._animationNames = []; + _this._animationStates = []; + _this._animations = {}; + _this._blendStates = {}; + _this._animationConfig = null; // Initial value. + return _this; + } + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + Animation.prototype._onClear = function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + for (var k in this._animations) { + delete this._animations[k]; + } + for (var k in this._blendStates) { + var blendStates = this._blendStates[k]; + for (var kB in blendStates) { + blendStates[kB].returnToPool(); + } + delete this._blendStates[k]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._inheritTimeScale = 1.0; + this._animationNames.length = 0; + this._animationStates.length = 0; + //this._animations.clear(); + this._armature = null; // + this._animationConfig = null; // + this._lastAnimationState = null; + }; + Animation.prototype._fadeOut = function (animationConfig) { + switch (animationConfig.fadeOutMode) { + case 1 /* SameLayer */: + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState._parent !== null) { + continue; + } + if (animationState.layer === animationConfig.layer) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 2 /* SameGroup */: + for (var _b = 0, _c = this._animationStates; _b < _c.length; _b++) { + var animationState = _c[_b]; + if (animationState._parent !== null) { + continue; + } + if (animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 3 /* SameLayerAndGroup */: + for (var _d = 0, _e = this._animationStates; _d < _e.length; _d++) { + var animationState = _e[_d]; + if (animationState._parent !== null) { + continue; + } + if (animationState.layer === animationConfig.layer && + animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + case 4 /* All */: + for (var _f = 0, _g = this._animationStates; _f < _g.length; _f++) { + var animationState = _g[_f]; + if (animationState._parent !== null) { + continue; + } + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 5 /* Single */: // TODO + default: + break; + } + }; + /** + * @internal + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { // Only animationState can reverse play. + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. + this._inheritTimeScale = this._armature._parent._armature.animation._inheritTimeScale * this.timeScale; + } + else { + this._inheritTimeScale = this.timeScale; + } + if (this._inheritTimeScale !== 1.0) { + passedTime *= this._inheritTimeScale; + } + for (var k in this._blendStates) { + var blendStates = this._blendStates[k]; + for (var kB in blendStates) { + blendStates[kB].reset(); + } + } + var animationStateCount = this._animationStates.length; + if (animationStateCount === 1) { + var animationState = this._animationStates[0]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + this._armature._dragonBones.bufferObject(animationState); + this._animationStates.length = 0; + this._lastAnimationState = null; + } + else { + var animationData = animationState.animationData; + var cacheFrameRate = animationData.cacheFrameRate; + if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. + this._animationDirty = false; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + if (slot.displayFrameCount > 0) { + var rawDisplayData = slot.getDisplayFrameAt(0).rawDisplayData; + if (rawDisplayData !== null && + rawDisplayData.parent === this._armature.armatureData.defaultSkin) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + continue; + } + } + slot._cachedFrameIndices = null; + } + } + animationState.advanceTime(passedTime, cacheFrameRate); + } + } + else if (animationStateCount > 1) { + for (var i = 0, r = 0; i < animationStateCount; ++i) { + var animationState = this._animationStates[i]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + r++; + this._armature._dragonBones.bufferObject(animationState); + this._animationDirty = true; + if (this._lastAnimationState === animationState) { // Update last animation state. + this._lastAnimationState = null; + } + } + else { + if (r > 0) { + this._animationStates[i - r] = animationState; + } + animationState.advanceTime(passedTime, 0.0); + } + if (i === animationStateCount - 1 && r > 0) { // Modify animation states size. + this._animationStates.length -= r; + if (this._lastAnimationState === null && this._animationStates.length > 0) { + this._lastAnimationState = this._animationStates[this._animationStates.length - 1]; + } + } + } + this._armature._cacheFrameIndex = -1; + } + else { + this._armature._cacheFrameIndex = -1; + } + }; + /** + * - Clear all animations states. + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.reset = function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.returnToPool(); + } + this._animationDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * - Pause a specific animation state. + * @param animationName - The name of animation state. (If not set, it will pause all animations) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停指定动画状态的播放。 + * @param animationName - 动画状态名称。 (如果未设置,则暂停所有动画) + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.stop = function (animationName) { + if (animationName === void 0) { animationName = null; } + if (animationName !== null) { + var animationState = this.getState(animationName); + if (animationState !== null) { + animationState.stop(); + } + } + else { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + animationState.stop(); + } + } + }; + /** + * - Play animation with a specific animation config. + * The API is still in the experimental phase and may encounter bugs or stability or compatibility issues when used. + * @param animationConfig - The animation config. + * @returns The playing animation state. + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 通过指定的动画配置来播放动画。 + * 该 API 仍在实验阶段,使用时可能遭遇 bug 或稳定性或兼容性问题。 + * @param animationConfig - 动画配置。 + * @returns 播放的动画状态。 + * @see dragonBones.AnimationConfig + * @beta + * @version DragonBones 5.0 + * @language zh_CN + */ + Animation.prototype.playConfig = function (animationConfig) { + var animationName = animationConfig.animation; + if (!(animationName in this._animations)) { + console.warn("Non-existent animation.\n", "DragonBones name: " + this._armature.armatureData.parent.name, "Armature name: " + this._armature.name, "Animation name: " + animationName); + return null; + } + var animationData = this._animations[animationName]; + if (animationConfig.fadeOutMode === 5 /* Single */) { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState_1 = _a[_i]; + if (animationState_1._fadeState < 1 && + animationState_1.layer === animationConfig.layer && + animationState_1.animationData === animationData) { + return animationState_1; + } + } + } + if (this._animationStates.length === 0) { + animationConfig.fadeInTime = 0.0; + } + else if (animationConfig.fadeInTime < 0.0) { + animationConfig.fadeInTime = animationData.fadeInTime; + } + if (animationConfig.fadeOutTime < 0.0) { + animationConfig.fadeOutTime = animationConfig.fadeInTime; + } + if (animationConfig.timeScale <= -100.0) { + animationConfig.timeScale = 1.0 / animationData.scale; + } + if (animationData.frameCount > 0) { + if (animationConfig.position < 0.0) { + animationConfig.position %= animationData.duration; + animationConfig.position = animationData.duration - animationConfig.position; + } + else if (animationConfig.position === animationData.duration) { + animationConfig.position -= 0.000001; // Play a little time before end. + } + else if (animationConfig.position > animationData.duration) { + animationConfig.position %= animationData.duration; + } + if (animationConfig.duration > 0.0 && animationConfig.position + animationConfig.duration > animationData.duration) { + animationConfig.duration = animationData.duration - animationConfig.position; + } + if (animationConfig.playTimes < 0) { + animationConfig.playTimes = animationData.playTimes; + } + } + else { + animationConfig.playTimes = 1; + animationConfig.position = 0.0; + if (animationConfig.duration > 0.0) { + animationConfig.duration = 0.0; + } + } + if (animationConfig.duration === 0.0) { + animationConfig.duration = -1.0; + } + this._fadeOut(animationConfig); + // + var animationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); + animationState.init(this._armature, animationData, animationConfig); + this._animationDirty = true; + this._armature._cacheFrameIndex = -1; + if (this._animationStates.length > 0) { // Sort animation state. + var added = false; + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + if (animationState.layer > this._animationStates[i].layer) { + added = true; + this._animationStates.splice(i, 0, animationState); + break; + } + else if (i !== l - 1 && animationState.layer > this._animationStates[i + 1].layer) { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { // Child armature play same name animation. + var slot = _c[_b]; + var childArmature = slot.childArmature; + if (childArmature !== null && childArmature.inheritAnimation && + childArmature.animation.hasAnimation(animationName) && + childArmature.animation.getState(animationName) === null) { + childArmature.animation.fadeIn(animationName); // + } + } + for (var k in animationData.animationTimelines) { // Blend animation node. + var childAnimationState = this.fadeIn(k, 0.0, 1, animationState.layer, "", 5 /* Single */); + if (childAnimationState === null) { + continue; + } + var timelines = animationData.animationTimelines[k]; + childAnimationState.actionEnabled = false; + childAnimationState.resetToPose = false; + childAnimationState.stop(); + animationState.addState(childAnimationState, timelines); + // + var index = this._animationStates.indexOf(animationState); + var childIndex = this._animationStates.indexOf(childAnimationState); + if (childIndex < index) { + this._animationStates.splice(index, 1); + this._animationStates.splice(childIndex, 0, animationState); + } + } + // if (!this._armature._lockUpdate && animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. + // this._armature.advanceTime(0.0); + // } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * - Play a specific animation. + * @param animationName - The name of animation data. (If not set, The default animation will be played, or resume the animation playing from pause status, or replay the last playing animation) + * @param playTimes - Playing repeat times. [-1: Use default value of the animation data, 0: No end loop playing, [1~N]: Repeat N times] (default: -1) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 播放指定动画。 + * @param animationName - 动画数据名称。 (如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放之前播放的动画) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.play("walk");
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.play = function (animationName, playTimes) { + if (animationName === void 0) { animationName = null; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName !== null ? animationName : ""; + if (animationName !== null && animationName.length > 0) { + this.playConfig(this._animationConfig); + } + else if (this._lastAnimationState === null) { + var defaultAnimation = this._armature.armatureData.defaultAnimation; + if (defaultAnimation !== null) { + this._animationConfig.animation = defaultAnimation.name; + this.playConfig(this._animationConfig); + } + } + else if (!this._lastAnimationState.isPlaying && !this._lastAnimationState.isCompleted) { + this._lastAnimationState.play(); + } + else { + this._animationConfig.animation = this._lastAnimationState.name; + this.playConfig(this._animationConfig); + } + return this._lastAnimationState; + }; + /** + * - Fade in a specific animation. + * @param animationName - The name of animation data. + * @param fadeInTime - The fade in time. [-1: Use the default value of animation data, [0~N]: The fade in time (In seconds)] (Default: -1) + * @param playTimes - playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @param layer - The blending layer, the animation states in high level layer will get the blending weights with high priority, when the total blending weights are more than 1.0, there will be no more weights can be allocated to the other animation states. (Default: 0) + * @param group - The blending group name, it is typically used to specify the substitution of multiple animation states blending. (Default: null) + * @param fadeOutMode - The fade out mode, which is typically used to specify alternate mode of multiple animation states blending. (Default: AnimationFadeOutMode.SameLayerAndGroup) + * @returns The playing animation state. + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 淡入播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param fadeInTime - 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间 (以秒为单位)] (默认: -1) + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @param layer - 混合图层,图层高的动画状态会优先获取混合权重,当混合权重分配总和超过 1.0 时,剩余的动画状态将不能再获得权重分配。 (默认: 0) + * @param group - 混合组名称,该属性通常用来指定多个动画状态混合时的相互替换关系。 (默认: null) + * @param fadeOutMode - 淡出模式,该属性通常用来指定多个动画状态混合时的相互替换模式。 (默认: AnimationFadeOutMode.SameLayerAndGroup) + * @returns 播放的动画状态。 + * @example + *
+         *     armature.animation.fadeIn("walk", 0.3, 0, 0, "normalGroup").resetToPose = false;
+         *     armature.animation.fadeIn("attack", 0.3, 1, 0, "attackGroup").resetToPose = false;
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode) { + if (fadeInTime === void 0) { fadeInTime = -1.0; } + if (playTimes === void 0) { playTimes = -1; } + if (layer === void 0) { layer = 0; } + if (group === void 0) { group = null; } + if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } + this._animationConfig.clear(); + this._animationConfig.fadeOutMode = fadeOutMode; + this._animationConfig.playTimes = playTimes; + this._animationConfig.layer = layer; + this._animationConfig.fadeInTime = fadeInTime; + this._animationConfig.animation = animationName; + this._animationConfig.group = group !== null ? group : ""; + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific time. + * @param animationName - The name of animation data. + * @param time - The start time point of playing. (In seconds) + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定时间开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param time - 播放开始的时间。 (以秒为单位) + * @param playTimes - 循环播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { + if (time === void 0) { time = 0.0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.position = time; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific frame. + * @param animationName - The name of animation data. + * @param frame - The start frame of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定帧开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param frame - 播放开始的帧数。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { + if (frame === void 0) { frame = 0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.frameCount > 0 ? animationData.duration * frame / animationData.frameCount : 0.0; + } + return this.playConfig(this._animationConfig); + }; + /** + * - Play a specific animation from the specific progress. + * @param animationName - The name of animation data. + * @param progress - The start progress value of playing. + * @param playTimes - Playing repeat times. [-1: Use the default value of animation data, 0: No end loop playing, [1~N]: Repeat N times] (Default: -1) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 从指定进度开始播放指定的动画。 + * @param animationName - 动画数据名称。 + * @param progress - 开始播放的进度。 + * @param playTimes - 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] (默认: -1) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { + if (progress === void 0) { progress = 0.0; } + if (playTimes === void 0) { playTimes = -1; } + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + var animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.duration * (progress > 0.0 ? progress : 0.0); + } + return this.playConfig(this._animationConfig); + }; + /** + * - Stop a specific animation at the specific time. + * @param animationName - The name of animation data. + * @param time - The stop time. (In seconds) + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定时间停止指定动画播放 + * @param animationName - 动画数据名称。 + * @param time - 停止的时间。 (以秒为单位) + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByTime = function (animationName, time) { + if (time === void 0) { time = 0.0; } + var animationState = this.gotoAndPlayByTime(animationName, time, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * - Stop a specific animation at the specific frame. + * @param animationName - The name of animation data. + * @param frame - The stop frame. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定帧停止指定动画的播放 + * @param animationName - 动画数据名称。 + * @param frame - 停止的帧数。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { + if (frame === void 0) { frame = 0; } + var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * - Stop a specific animation at the specific progress. + * @param animationName - The name of animation data. + * @param progress - The stop progress value. + * @returns The played animation state. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 在指定的进度停止指定的动画播放。 + * @param animationName - 动画数据名称。 + * @param progress - 停止进度。 + * @returns 播放的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { + if (progress === void 0) { progress = 0.0; } + var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + if (animationState !== null) { + animationState.stop(); + } + return animationState; + }; + /** + * @internal + */ + Animation.prototype.getBlendState = function (type, name, target) { + if (!(type in this._blendStates)) { + this._blendStates[type] = {}; + } + var blendStates = this._blendStates[type]; + if (!(name in blendStates)) { + var blendState = blendStates[name] = dragonBones.BaseObject.borrowObject(dragonBones.BlendState); + blendState.target = target; + } + return blendStates[name]; + }; + /** + * - Get a specific animation state. + * @param animationName - The name of animation state. + * @param layer - The layer of find animation states. [-1: Find all layers, [0~N]: Specified layer] (default: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取指定的动画状态。 + * @param animationName - 动画状态名称。 + * @param layer - 查找动画状态的层级。 [-1: 查找所有层级, [0~N]: 指定层级] (默认: -1) + * @example + *
+         *     armature.animation.play("walk");
+         *     let walkState = armature.animation.getState("walk");
+         *     walkState.timeScale = 0.5;
+         * 
+ * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName, layer) { + if (layer === void 0) { layer = -1; } + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName && (layer < 0 || animationState.layer === layer)) { + return animationState; + } + } + return null; + }; + /** + * - Check whether a specific animation data is included. + * @param animationName - The name of animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含指定的动画数据 + * @param animationName - 动画数据名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * - Get all the animation states. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取所有的动画状态 + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * - Check whether there is an animation state is playing + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否有动画状态正在播放 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (animationState.isPlaying) { + return true; + } + } + return false; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "isCompleted", { + /** + * - Check whether all the animation states' playing were finished. + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否所有的动画状态均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + for (var _i = 0, _a = this._animationStates; _i < _a.length; _i++) { + var animationState = _a[_i]; + if (!animationState.isCompleted) { + return false; + } + } + return this._animationStates.length > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationName", { + /** + * - The name of the last playing animation state. + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态名称 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationNames", { + /** + * - The name of all animation data + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有动画数据的名称 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * - All animation data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 所有的动画数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animations; + }, + set: function (value) { + if (this._animations === value) { + return; + } + this._animationNames.length = 0; + for (var k in this._animations) { + delete this._animations[k]; + } + for (var k in value) { + this._animationNames.push(k); + this._animations[k] = value[k]; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * - An AnimationConfig instance that can be used quickly. + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + this._animationConfig.clear(); + return this._animationConfig; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationState", { + /** + * - The last playing animation state + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 上一个播放的动画状态 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(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 animation state is generated when the animation data is played. + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 动画状态由播放动画数据时产生。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + var AnimationState = /** @class */ (function (_super) { + __extends(AnimationState, _super); + function AnimationState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._boneMask = []; + _this._boneTimelines = []; + _this._boneBlendTimelines = []; + _this._slotTimelines = []; + _this._slotBlendTimelines = []; + _this._constraintTimelines = []; + _this._animationTimelines = []; + _this._poseTimelines = []; + /** + * @internal + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + AnimationState.prototype._onClear = function () { + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.returnToPool(); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.returnToPool(); + } + for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.returnToPool(); + } + for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.returnToPool(); + } + for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { + var timeline = _l[_k]; + var animationState = timeline.target; + if (animationState._parent === this) { + animationState._fadeState = 1; + animationState._subFadeState = 1; + animationState._parent = null; + } + timeline.returnToPool(); + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.actionEnabled = false; + this.additive = false; + this.displayControl = false; + this.resetToPose = false; + this.blendType = 0 /* None */; + this.playTimes = 1; + this.layer = 0; + this.timeScale = 1.0; + this._weight = 1.0; + this.parameterX = 0.0; + this.parameterY = 0.0; + this.positionX = 0.0; + this.positionY = 0.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this._timelineDirty = 2; + this._playheadState = 0; + this._fadeState = -1; + this._subFadeState = -1; + this._position = 0.0; + this._duration = 0.0; + this._fadeTime = 0.0; + this._time = 0.0; + this._fadeProgress = 0.0; + this._weightResult = 0.0; + this._boneMask.length = 0; + this._boneTimelines.length = 0; + this._boneBlendTimelines.length = 0; + this._slotTimelines.length = 0; + this._slotBlendTimelines.length = 0; + this._constraintTimelines.length = 0; + this._animationTimelines.length = 0; + this._poseTimelines.length = 0; + // this._bonePoses.clear(); + this._animationData = null; // + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + this._activeChildA = null; + this._activeChildB = null; + this._parent = null; + }; + AnimationState.prototype._updateTimelines = function () { + { // Update constraint timelines. + for (var _i = 0, _a = this._armature._constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + var timelineDatas = this._animationData.getConstraintTimelines(constraint.name); + if (timelineDatas !== null) { + for (var _b = 0, timelineDatas_1 = timelineDatas; _b < timelineDatas_1.length; _b++) { + var timelineData = timelineDatas_1[_b]; + switch (timelineData.type) { + case 30 /* IKConstraint */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.target = constraint; + timeline.init(this._armature, this, timelineData); + this._constraintTimelines.push(timeline); + break; + } + default: + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintTimelineState); + timeline.target = constraint; + timeline.init(this._armature, this, null); + this._constraintTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + }; + AnimationState.prototype._updateBoneAndSlotTimelines = function () { + { // Update bone and surface timelines. + var boneTimelines = {}; + // Create bone timelines map. + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.target.target.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + var timelineName = timeline.target.target.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + // + for (var _d = 0, _e = this._armature.getBones(); _d < _e.length; _d++) { + var bone = _e[_d]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + if (timelineName in boneTimelines) { // Remove bone timeline from map. + delete boneTimelines[timelineName]; + } + else { // Create new bone timeline. + var timelineDatas = this._animationData.getBoneTimelines(timelineName); + var blendState = this._armature.animation.getBlendState(BlendState.BONE_TRANSFORM, bone.name, bone); + if (timelineDatas !== null) { + for (var _f = 0, timelineDatas_2 = timelineDatas; _f < timelineDatas_2.length; _f++) { + var timelineData = timelineDatas_2[_f]; + switch (timelineData.type) { + case 10 /* BoneAll */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 11 /* BoneTranslate */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTranslateTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 12 /* BoneRotate */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneRotateTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 13 /* BoneScale */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneScaleTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + } + case 60 /* BoneAlpha */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.BONE_ALPHA, bone.name, bone); + timeline.init(this._armature, this, timelineData); + this._boneBlendTimelines.push(timeline); + break; + } + case 50 /* Surface */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); + timeline.init(this._armature, this, timelineData); + this._boneBlendTimelines.push(timeline); + break; + } + default: + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + if (bone._boneData.type === 0 /* Bone */) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.target = blendState; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + else { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SURFACE, bone.name, bone); + timeline.init(this._armature, this, null); + this._boneBlendTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + for (var k in boneTimelines) { // Remove bone timelines. + for (var _g = 0, _h = boneTimelines[k]; _g < _h.length; _g++) { + var timeline = _h[_g]; + var index = this._boneTimelines.indexOf(timeline); + if (index >= 0) { + this._boneTimelines.splice(index, 1); + timeline.returnToPool(); + } + index = this._boneBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._boneBlendTimelines.splice(index, 1); + timeline.returnToPool(); + } + } + } + } + { // Update slot timelines. + var slotTimelines = {}; + var ffdFlags = []; + // Create slot timelines map. + for (var _j = 0, _k = this._slotTimelines; _j < _k.length; _j++) { + var timeline = _k[_j]; + var timelineName = timeline.target.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _l = 0, _m = this._slotBlendTimelines; _l < _m.length; _l++) { + var timeline = _m[_l]; + var timelineName = timeline.target.target.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + // + for (var _o = 0, _p = this._armature.getSlots(); _o < _p.length; _o++) { + var slot = _p[_o]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + if (timelineName in slotTimelines) { // Remove slot timeline from map. + delete slotTimelines[timelineName]; + } + else { // Create new slot timeline. + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + var timelineDatas = this._animationData.getSlotTimelines(timelineName); + if (timelineDatas !== null) { + for (var _q = 0, timelineDatas_3 = timelineDatas; _q < timelineDatas_3.length; _q++) { + var timelineData = timelineDatas_3[_q]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 23 /* SlotZIndex */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotZIndexTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_Z_INDEX, slot.name, slot); + timeline.init(this._armature, this, timelineData); + this._slotBlendTimelines.push(timeline); + break; + } + case 21 /* SlotColor */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotDeform */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); + timeline.init(this._armature, this, timelineData); + if (timeline.target !== null) { + this._slotBlendTimelines.push(timeline); + ffdFlags.push(timeline.geometryOffset); + } + else { + timeline.returnToPool(); + } + break; + } + case 24 /* SlotAlpha */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AlphaTimelineState); + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_ALPHA, slot.name, slot); + timeline.init(this._armature, this, timelineData); + this._slotBlendTimelines.push(timeline); + break; + } + default: + break; + } + } + } + if (this.resetToPose) { // Pose timeline. + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.target = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayFrame = slot.getDisplayFrameAt(i); + if (displayFrame.deformVertices.length === 0) { + continue; + } + var geometryData = displayFrame.getGeometryData(); + if (geometryData !== null && ffdFlags.indexOf(geometryData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.DeformTimelineState); + timeline.geometryOffset = geometryData.offset; // + timeline.displayFrame = displayFrame; // + timeline.target = this._armature.animation.getBlendState(BlendState.SLOT_DEFORM, slot.name, slot); + timeline.init(this._armature, this, null); + this._slotBlendTimelines.push(timeline); + this._poseTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { // Remove slot timelines. + for (var _r = 0, _s = slotTimelines[k]; _r < _s.length; _r++) { + var timeline = _s[_r]; + var index = this._slotTimelines.indexOf(timeline); + if (index >= 0) { + this._slotTimelines.splice(index, 1); + timeline.returnToPool(); + } + index = this._slotBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._slotBlendTimelines.splice(index, 1); + timeline.returnToPool(); + } + } + } + } + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { // Fade start event. + this._subFadeState = 0; + var eventActive = this._parent === null && this.actionEnabled; + if (eventActive) { + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + if (passedTime < 0.0) { + passedTime = -passedTime; + } + this._fadeTime += passedTime; + if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. + this._subFadeState = 1; + this._fadeProgress = isFadeOut ? 0.0 : 1.0; + } + else if (this._fadeTime > 0.0) { // Fading. + this._fadeProgress = isFadeOut ? (1.0 - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); + } + else { // Before fade. + this._fadeProgress = isFadeOut ? 1.0 : 0.0; + } + if (this._subFadeState > 0) { // Fade complete event. + if (!isFadeOut) { + this._playheadState |= 1; // x1 + this._fadeState = 0; + } + var eventActive = this._parent === null && this.actionEnabled; + if (eventActive) { + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + }; + /** + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationData = animationData; + // + this.resetToPose = animationConfig.resetToPose; + this.additive = animationConfig.additive; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.blendType = animationData.blendType; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + // + this._weight = animationConfig.weight; + if (animationConfig.pauseFadeIn) { + this._playheadState = 2; // 10 + } + else { + this._playheadState = 3; // 11 + } + if (animationConfig.duration < 0.0) { + this._position = 0.0; + this._duration = this._animationData.duration; + if (animationConfig.position !== 0.0) { + if (this.timeScale >= 0.0) { + this._time = animationConfig.position; + } + else { + this._time = animationConfig.position - this._duration; + } + } + else { + this._time = 0.0; + } + } + else { + this._position = animationConfig.position; + this._duration = animationConfig.duration; + this._time = 0.0; + } + if (this.timeScale < 0.0 && this._time === 0.0) { + this._time = -0.000001; // Turn to end. + } + if (this.fadeTotalTime <= 0.0) { + this._fadeProgress = 0.999999; // Make different. + } + if (animationConfig.boneMask.length > 0) { + this._boneMask.length = animationConfig.boneMask.length; + for (var i = 0, l = this._boneMask.length; i < l; ++i) { + this._boneMask[i] = animationConfig.boneMask[i]; + } + } + this._actionTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ActionTimelineState); + this._actionTimeline.init(this._armature, this, this._animationData.actionTimeline); + this._actionTimeline.currentTime = this._time; + if (this._actionTimeline.currentTime < 0.0) { + this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; + } + if (this._animationData.zOrderTimeline !== null) { + this._zOrderTimeline = dragonBones.BaseObject.borrowObject(dragonBones.ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this._animationData.zOrderTimeline); + } + }; + /** + * @internal + */ + AnimationState.prototype.advanceTime = function (passedTime, cacheFrameRate) { + // Update fade time. + if (this._fadeState !== 0 || this._subFadeState !== 0) { + this._advanceFadeTime(passedTime); + } + // Update time. + if (this._playheadState === 3) { // 11 + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + this._time += passedTime; + } + // Update timeline. + if (this._timelineDirty !== 0) { + if (this._timelineDirty === 2) { + this._updateTimelines(); + } + this._timelineDirty = 0; + this._updateBoneAndSlotTimelines(); + } + var isBlendDirty = this._fadeState !== 0 || this._subFadeState === 0; + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this._weight * this._fadeProgress; + if (this._parent !== null) { + this._weightResult *= this._parent._weightResult; + } + if (this._actionTimeline.playState <= 0) { // Update main timeline. + this._actionTimeline.update(time); + } + if (this._weight === 0.0) { + return; + } + if (isCacheEnabled) { // Cache time internval. + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null && this._zOrderTimeline.playState <= 0) { // Update zOrder timeline. + this._zOrderTimeline.update(time); + } + if (isCacheEnabled) { // Update cache. + var cacheFrameIndex = Math.floor(this._actionTimeline.currentTime * cacheFrameRate); // uint + if (this._armature._cacheFrameIndex === cacheFrameIndex) { // Same cache. + isUpdateTimeline = false; + isUpdateBoneTimeline = false; + } + else { + this._armature._cacheFrameIndex = cacheFrameIndex; + if (this._animationData.cachedFrames[cacheFrameIndex]) { // Cached. + isUpdateBoneTimeline = false; + } + else { // Cache. + this._animationData.cachedFrames[cacheFrameIndex] = true; + } + } + } + if (isUpdateTimeline) { + var isBlend = false; + var prevTarget = null; // + if (isUpdateBoneTimeline) { + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (timeline.target !== prevTarget) { + var blendState = timeline.target; + isBlend = blendState.update(this); + prevTarget = blendState; + if (blendState.dirty === 1) { + var pose = blendState.target.animationPose; + pose.x = 0.0; + pose.y = 0.0; + pose.rotation = 0.0; + pose.skew = 0.0; + pose.scaleX = 1.0; + pose.scaleY = 1.0; + } + } + if (isBlend) { + timeline.blend(isBlendDirty); + } + } + } + for (var i = 0, l = this._boneBlendTimelines.length; i < l; ++i) { + var timeline = this._boneBlendTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (timeline.target.update(this)) { + timeline.blend(isBlendDirty); + } + } + if (this.displayControl) { + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (timeline.playState <= 0) { + var slot = timeline.target; + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + timeline.update(time); + } + } + } + } + for (var i = 0, l = this._slotBlendTimelines.length; i < l; ++i) { + var timeline = this._slotBlendTimelines[i]; + if (timeline.playState <= 0) { + var blendState = timeline.target; + timeline.update(time); + if (blendState.update(this)) { + timeline.blend(isBlendDirty); + } + } + } + for (var i = 0, l = this._constraintTimelines.length; i < l; ++i) { + var timeline = this._constraintTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + } + if (this._animationTimelines.length > 0) { + var dL = 100.0; + var dR = 100.0; + var leftState = null; + var rightState = null; + for (var i = 0, l = this._animationTimelines.length; i < l; ++i) { + var timeline = this._animationTimelines[i]; + if (timeline.playState <= 0) { + timeline.update(time); + } + if (this.blendType === 1 /* E1D */) { // TODO + var animationState = timeline.target; + var d = this.parameterX - animationState.positionX; + if (d >= 0.0) { + if (d < dL) { + dL = d; + leftState = animationState; + } + } + else { + if (-d < dR) { + dR = -d; + rightState = animationState; + } + } + } + } + if (leftState !== null) { + if (this._activeChildA !== leftState) { + if (this._activeChildA !== null) { + this._activeChildA.weight = 0.0; + } + this._activeChildA = leftState; + this._activeChildA.activeTimeline(); + } + if (this._activeChildB !== rightState) { + if (this._activeChildB !== null) { + this._activeChildB.weight = 0.0; + } + this._activeChildB = rightState; + } + leftState.weight = dR / (dL + dR); + if (rightState) { + rightState.weight = 1.0 - leftState.weight; + } + } + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + if (this._poseTimelines.length > 0) { // Remove pose timelines. + for (var _i = 0, _a = this._poseTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var index = this._boneTimelines.indexOf(timeline); + if (index >= 0) { + this._boneTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._boneBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._boneBlendTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._slotTimelines.indexOf(timeline); + if (index >= 0) { + this._slotTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._slotBlendTimelines.indexOf(timeline); + if (index >= 0) { + this._slotBlendTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + index = this._constraintTimelines.indexOf(timeline); + if (index >= 0) { + this._constraintTimelines.splice(index, 1); + timeline.returnToPool(); + continue; + } + } + this._poseTimelines.length = 0; + } + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { // Auto fade out. + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * - Continue play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * - Stop play. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * - Fade out the animation state. + * @param fadeOutTime - The fade out time. (In seconds) + * @param pausePlayhead - Whether to pause the animation playing when fade out. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 淡出动画状态。 + * @param fadeOutTime - 淡出时间。 (以秒为单位) + * @param pausePlayhead - 淡出时是否暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { + if (pausePlayhead === void 0) { pausePlayhead = true; } + if (fadeOutTime < 0.0) { + fadeOutTime = 0.0; + } + if (pausePlayhead) { + this._playheadState &= 2; // x0 + } + if (this._fadeState > 0) { + if (fadeOutTime > this.fadeTotalTime - this._fadeTime) { // If the animation is already in fade out, the new fade out will be ignored. + return; + } + } + else { + this._fadeState = 1; + this._subFadeState = -1; + if (fadeOutTime <= 0.0 || this._fadeProgress <= 0.0) { + this._fadeProgress = 0.000001; // Modify fade progress to different value. + } + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.fadeOut(); + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + for (var _d = 0, _e = this._slotTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.fadeOut(); + } + for (var _f = 0, _g = this._slotBlendTimelines; _f < _g.length; _f++) { + var timeline = _g[_f]; + timeline.fadeOut(); + } + for (var _h = 0, _j = this._constraintTimelines; _h < _j.length; _h++) { + var timeline = _j[_h]; + timeline.fadeOut(); + } + for (var _k = 0, _l = this._animationTimelines; _k < _l.length; _k++) { + var timeline = _l[_k]; + timeline.fadeOut(); + // + var animaitonState = timeline.target; + animaitonState.fadeOut(999999.0, true); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * - Check if a specific bone mask is included. + * @param boneName - The bone name. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 检查是否包含特定骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (boneName) { + return this._boneMask.length === 0 || this._boneMask.indexOf(boneName) >= 0; + }; + /** + * - Add a specific bone mask. + * @param boneName - The bone name. + * @param recursive - Whether or not to add a mask to the bone's sub-bone. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 添加特定的骨骼遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (boneName, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(boneName); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(boneName) < 0) { // Add mixing + this._boneMask.push(boneName); + } + if (recursive) { // Add recursive mixing. + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + this._timelineDirty = 1; + }; + /** + * - Remove the mask of a specific bone. + * @param boneName - The bone name. + * @param recursive - Whether to remove the bone's sub-bone mask. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除特定骨骼的遮罩。 + * @param boneName - 骨骼名称。 + * @param recursive - 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (boneName, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(boneName); + if (index >= 0) { // Remove mixing. + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(boneName); + if (currentBone !== null) { + var bones = this._armature.getBones(); + if (this._boneMask.length > 0) { // Remove recursive mixing. + for (var _i = 0, bones_1 = bones; _i < bones_1.length; _i++) { + var bone = bones_1[_i]; + var index_1 = this._boneMask.indexOf(bone.name); + if (index_1 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_1, 1); + } + } + } + else { // Add unrecursive mixing. + for (var _a = 0, bones_2 = bones; _a < bones_2.length; _a++) { + var bone = bones_2[_a]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + } + } + this._timelineDirty = 1; + }; + /** + * - Remove all bone masks. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = 1; + }; + /** + * @private + */ + AnimationState.prototype.addState = function (animationState, timelineDatas) { + if (timelineDatas === void 0) { timelineDatas = null; } + if (timelineDatas !== null) { + for (var _i = 0, timelineDatas_4 = timelineDatas; _i < timelineDatas_4.length; _i++) { + var timelineData = timelineDatas_4[_i]; + switch (timelineData.type) { + case 40 /* AnimationProgress */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationProgressTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + if (this.blendType !== 0 /* None */) { + var animaitonTimelineData = timelineData; + animationState.positionX = animaitonTimelineData.x; + animationState.positionY = animaitonTimelineData.y; + animationState.weight = 0.0; + } + animationState._parent = this; + this.resetToPose = false; + break; + } + case 41 /* AnimationWeight */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationWeightTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + break; + } + case 42 /* AnimationParameter */: { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationParametersTimelineState); + timeline.target = animationState; + timeline.init(this._armature, this, timelineData); + this._animationTimelines.push(timeline); + break; + } + default: + break; + } + } + } + if (animationState._parent === null) { + animationState._parent = this; + } + }; + /** + * @internal + */ + AnimationState.prototype.activeTimeline = function () { + for (var _i = 0, _a = this._slotTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.dirty = true; + timeline.currentTime = -1.0; + } + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * - Whether the animation state is fading in. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * - Whether the animation state is fading out. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * - Whether the animation state is fade completed. + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 是否淡入或淡出完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * - Whether the animation state is playing. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isCompleted", { + /** + * - Whether the animation state is play completed. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * - The times has been played. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 已经循环播放的次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * - The total time. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 总播放时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * - The time is currently playing. (In seconds) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentTime; + }, + set: function (value) { + var currentPlayTimes = this._actionTimeline.currentPlayTimes - (this._actionTimeline.playState > 0 ? 1 : 0); + if (value < 0 || this._duration < value) { + value = (value % this._duration) + currentPlayTimes * this._duration; + if (value < 0) { + value += this._duration; + } + } + if (this.playTimes > 0 && currentPlayTimes === this.playTimes - 1 && + value === this._duration && this._parent === null) { + value = this._duration - 0.000001; // + } + if (this._time === value) { + return; + } + this._time = value; + this._actionTimeline.setCurrentTime(this._time); + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.playState = -1; + } + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.playState = -1; + } + for (var _b = 0, _c = this._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.playState = -1; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "weight", { + /** + * - The blend weight. + * @default 1.0 + * @version DragonBones 5.0 + * @language en_US + */ + /** + * - 混合权重。 + * @default 1.0 + * @version DragonBones 5.0 + * @language zh_CN + */ + /** + * - The animation data. + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language en_US + */ + get: function () { + return this._weight; + }, + set: function (value) { + if (this._weight === value) { + return; + } + this._weight = value; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + timeline.dirty = true; + } + for (var _b = 0, _c = this._boneBlendTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.dirty = true; + } + for (var _d = 0, _e = this._slotBlendTimelines; _d < _e.length; _d++) { + var timeline = _e[_d]; + timeline.dirty = true; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "animationData", { + /** + * - 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; + /** + * @internal + */ + var BlendState = /** @class */ (function (_super) { + __extends(BlendState, _super); + function BlendState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BlendState.toString = function () { + return "[class dragonBones.BlendState]"; + }; + BlendState.prototype._onClear = function () { + this.reset(); + this.target = null; + }; + BlendState.prototype.update = function (animationState) { + var animationLayer = animationState.layer; + var animationWeight = animationState._weightResult; + if (this.dirty > 0) { + if (this.leftWeight > 0.0) { + if (this.layer !== animationLayer) { + if (this.layerWeight >= this.leftWeight) { + this.dirty++; + this.layer = animationLayer; + this.leftWeight = 0.0; + this.blendWeight = 0.0; + return false; + } + this.layer = animationLayer; + this.leftWeight -= this.layerWeight; + this.layerWeight = 0.0; + } + animationWeight *= this.leftWeight; + this.dirty++; + this.blendWeight = animationWeight; + this.layerWeight += this.blendWeight; + return true; + } + return false; + } + this.dirty++; + this.layer = animationLayer; + this.leftWeight = 1.0; + this.blendWeight = animationWeight; + this.layerWeight = animationWeight; + return true; + }; + BlendState.prototype.reset = function () { + this.dirty = 0; + this.layer = 0; + this.leftWeight = 0.0; + this.layerWeight = 0.0; + this.blendWeight = 0.0; + }; + BlendState.BONE_TRANSFORM = "boneTransform"; + BlendState.BONE_ALPHA = "boneAlpha"; + BlendState.SURFACE = "surface"; + BlendState.SLOT_DEFORM = "slotDeform"; + BlendState.SLOT_ALPHA = "slotAlpha"; + BlendState.SLOT_Z_INDEX = "slotZIndex"; + return BlendState; + }(dragonBones.BaseObject)); + dragonBones.BlendState = BlendState; +})(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) { + /** + * @internal + */ + var TimelineState = /** @class */ (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.dirty = false; + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this.target = null; + this._isTween = false; + this._valueOffset = 0; + this._frameValueOffset = 0; + this._frameOffset = 0; + this._frameRate = 0; + this._frameCount = 0; + this._frameIndex = -1; + this._frameRateR = 0.0; + this._position = 0.0; + this._duration = 0.0; + this._timeScale = 1.0; + this._timeOffset = 0.0; + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._valueArray = null; // + this._timelineArray = null; // + this._frameIndices = null; // + }; + TimelineState.prototype._setCurrentTime = function (passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._actionTimeline !== null && this._frameCount <= 1) { // No frame or only one frame. + this.playState = this._actionTimeline.playState >= 0 ? 1 : -1; + this.currentPlayTimes = 1; + this.currentTime = this._actionTimeline.currentTime; + } + else if (this._actionTimeline === null || this._timeScale !== 1.0 || this._timeOffset !== 0.0) { // Action timeline or has scale and offset. + var playTimes = this._animationState.playTimes; + var totalTime = playTimes * this._duration; + passedTime *= this._timeScale; + if (this._timeOffset !== 0.0) { + passedTime += this._timeOffset * this._animationData.duration; + } + if (playTimes > 0 && (passedTime >= totalTime || passedTime <= -totalTime)) { + if (this.playState <= 0 && this._animationState._playheadState === 3) { + this.playState = 1; + } + this.currentPlayTimes = playTimes; + if (passedTime < 0.0) { + this.currentTime = 0.0; + } + else { + this.currentTime = this.playState === 1 ? this._duration + 0.000001 : this._duration; // Precision problem + } + } + else { + if (this.playState !== 0 && this._animationState._playheadState === 3) { + this.playState = 0; + } + if (passedTime < 0.0) { + passedTime = -passedTime; + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = this._duration - (passedTime % this._duration); + } + else { + this.currentPlayTimes = Math.floor(passedTime / this._duration); + this.currentTime = passedTime % this._duration; + } + } + this.currentTime += this._position; + } + else { // Multi frames. + this.playState = this._actionTimeline.playState; + this.currentPlayTimes = this._actionTimeline.currentPlayTimes; + this.currentTime = this._actionTimeline.currentTime; + } + if (this.currentPlayTimes === prevPlayTimes && this.currentTime === prevTime) { + return false; + } + // Clear frame flag when timeline start or loopComplete. + if ((prevState < 0 && this.playState !== prevState) || + (this.playState <= 0 && this.currentPlayTimes !== prevPlayTimes)) { + this._frameIndex = -1; + } + return true; + }; + TimelineState.prototype.init = function (armature, animationState, timelineData) { + this._armature = armature; + this._animationState = animationState; + this._timelineData = timelineData; + this._actionTimeline = this._animationState._actionTimeline; + if (this === this._actionTimeline) { + this._actionTimeline = null; // + } + this._animationData = this._animationState.animationData; + // + this._frameRate = this._animationData.parent.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; // May by the animation data is not belone to this armature data. + this._frameArray = dragonBonesData.frameArray; + this._timelineArray = dragonBonesData.timelineArray; + this._frameIndices = dragonBonesData.frameIndices; + // + this._frameCount = this._timelineArray[this._timelineData.offset + 2 /* TimelineKeyFrameCount */]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + 4 /* TimelineFrameValueOffset */]; + this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + 0 /* TimelineScale */]; + this._timeOffset = this._timelineArray[this._timelineData.offset + 1 /* TimelineOffset */] * 0.01; + } + }; + TimelineState.prototype.fadeOut = function () { + this.dirty = false; + }; + TimelineState.prototype.update = function (passedTime) { + if (this._setCurrentTime(passedTime)) { + if (this._frameCount > 1) { + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[this._timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { + this._frameIndex = frameIndex; + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; + this._onArriveAtFrame(); + } + } + else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (this._timelineData !== null) { // May be pose timeline. + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; + } + this._onArriveAtFrame(); + } + if (this._isTween || this.dirty) { + this._onUpdateFrame(); + } + } + }; + TimelineState.prototype.blend = function (_isDirty) { + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + */ + var TweenTimelineState = /** @class */ (function (_super) { + __extends(TweenTimelineState, _super); + function TweenTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TweenTimelineState._getEasingValue = function (tweenType, progress, easing) { + var value = progress; + switch (tweenType) { + case 3 /* QuadIn */: + value = Math.pow(progress, 2.0); + break; + case 4 /* QuadOut */: + value = 1.0 - Math.pow(1.0 - progress, 2.0); + break; + case 5 /* QuadInOut */: + value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); + break; + } + return (value - progress) * easing + progress; + }; + TweenTimelineState._getEasingCurveValue = function (progress, samples, count, offset) { + if (progress <= 0.0) { + return 0.0; + } + else if (progress >= 1.0) { + return 1.0; + } + var isOmited = count > 0; + var segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = 0.0; + var toValue = 0.0; + if (isOmited) { + fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; + } + else { + fromValue = samples[offset + valueIndex - 1]; + toValue = samples[offset + valueIndex]; + } + return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; + }; + TweenTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._tweenType = 0 /* None */; + this._curveCount = 0; + this._framePosition = 0.0; + this._frameDurationR = 0.0; + this._tweenEasing = 0.0; + this._tweenProgress = 0.0; + this._valueScale = 1.0; + }; + TweenTimelineState.prototype._onArriveAtFrame = function () { + if (this._frameCount > 1 && + (this._frameIndex !== this._frameCount - 1 || + this._animationState.playTimes === 0 || + this._animationState.currentPlayTimes < this._animationState.playTimes - 1)) { + this._tweenType = this._frameArray[this._frameOffset + 1 /* FrameTweenType */]; + this._isTween = this._tweenType !== 0 /* None */; + if (this._isTween) { + if (this._tweenType === 2 /* Curve */) { + this._curveCount = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */]; + } + else if (this._tweenType !== 0 /* None */ && this._tweenType !== 1 /* Line */) { + this._tweenEasing = this._frameArray[this._frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] * 0.01; + } + } + else { + this.dirty = true; + } + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; + if (this._frameIndex === this._frameCount - 1) { + this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); + } + else { + var nextFrameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex + 1]; + var frameDuration = this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition; + if (frameDuration > 0) { + this._frameDurationR = 1.0 / frameDuration; + } + else { + this._frameDurationR = 0.0; + } + } + } + else { + this.dirty = true; + this._isTween = false; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._isTween) { + this.dirty = true; + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + if (this._tweenType === 2 /* Curve */) { + this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + 3 /* FrameCurveSamples */); + } + else if (this._tweenType !== 1 /* Line */) { + this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); + } + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + */ + var SingleValueTimelineState = /** @class */ (function (_super) { + __extends(SingleValueTimelineState, _super); + function SingleValueTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SingleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._current = 0.0; + this._difference = 0.0; + this._result = 0.0; + }; + SingleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + 1; + if (valueScale === 1.0) { + this._current = valueArray[valueOffset]; + this._difference = valueArray[nextValueOffset] - this._current; + } + else { + this._current = valueArray[valueOffset] * valueScale; + this._difference = valueArray[nextValueOffset] * valueScale - this._current; + } + } + else { + this._result = valueArray[valueOffset] * valueScale; + } + } + else { + this._result = 0.0; + } + }; + SingleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._result = this._current + this._difference * this._tweenProgress; + } + }; + return SingleValueTimelineState; + }(TweenTimelineState)); + dragonBones.SingleValueTimelineState = SingleValueTimelineState; + /** + * @internal + */ + var DoubleValueTimelineState = /** @class */ (function (_super) { + __extends(DoubleValueTimelineState, _super); + function DoubleValueTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + DoubleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._currentA = 0.0; + this._currentB = 0.0; + this._differenceA = 0.0; + this._differenceB = 0.0; + this._resultA = 0.0; + this._resultB = 0.0; + }; + DoubleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * 2; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + 2; + if (valueScale === 1.0) { + this._currentA = valueArray[valueOffset]; + this._currentB = valueArray[valueOffset + 1]; + this._differenceA = valueArray[nextValueOffset] - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] - this._currentB; + } + else { + this._currentA = valueArray[valueOffset] * valueScale; + this._currentB = valueArray[valueOffset + 1] * valueScale; + this._differenceA = valueArray[nextValueOffset] * valueScale - this._currentA; + this._differenceB = valueArray[nextValueOffset + 1] * valueScale - this._currentB; + } + } + else { + this._resultA = valueArray[valueOffset] * valueScale; + this._resultB = valueArray[valueOffset + 1] * valueScale; + } + } + else { + this._resultA = 0.0; + this._resultB = 0.0; + } + }; + DoubleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._resultA = this._currentA + this._differenceA * this._tweenProgress; + this._resultB = this._currentB + this._differenceB * this._tweenProgress; + } + }; + return DoubleValueTimelineState; + }(TweenTimelineState)); + dragonBones.DoubleValueTimelineState = DoubleValueTimelineState; + /** + * @internal + */ + var MutilpleValueTimelineState = /** @class */ (function (_super) { + __extends(MutilpleValueTimelineState, _super); + function MutilpleValueTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._rd = []; + return _this; + } + MutilpleValueTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._valueCount = 0; + this._rd.length = 0; + }; + MutilpleValueTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + var valueCount = this._valueCount; + var rd = this._rd; + if (this._timelineData !== null) { + var valueScale = this._valueScale; + var valueArray = this._valueArray; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; + if (this._isTween) { + var nextValueOffset = this._frameIndex === this._frameCount - 1 ? + this._valueOffset + this._frameValueOffset : + valueOffset + valueCount; + if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[valueCount + i] = valueArray[nextValueOffset + i] - valueArray[valueOffset + i]; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[valueCount + i] = (valueArray[nextValueOffset + i] - valueArray[valueOffset + i]) * valueScale; + } + } + } + else if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i]; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] * valueScale; + } + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = 0.0; + } + } + }; + MutilpleValueTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + var valueCount = this._valueCount; + var valueScale = this._valueScale; + var tweenProgress = this._tweenProgress; + var valueArray = this._valueArray; + var rd = this._rd; + // + var valueOffset = this._valueOffset + this._frameValueOffset + this._frameIndex * valueCount; + if (valueScale === 1.0) { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] + rd[valueCount + i] * tweenProgress; + } + } + else { + for (var i = 0; i < valueCount; ++i) { + rd[i] = valueArray[valueOffset + i] * valueScale + rd[valueCount + i] * tweenProgress; + } + } + } + }; + return MutilpleValueTimelineState; + }(TweenTimelineState)); + dragonBones.MutilpleValueTimelineState = MutilpleValueTimelineState; +})(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) { + /** + * @internal + */ + var ActionTimelineState = /** @class */ (function (_super) { + __extends(ActionTimelineState, _super); + function ActionTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + ActionTimelineState.toString = function () { + return "[class dragonBones.ActionTimelineState]"; + }; + ActionTimelineState.prototype._onCrossFrame = function (frameIndex) { + var eventDispatcher = this._armature.eventDispatcher; + if (this._animationState.actionEnabled) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */ + frameIndex]; + var actionCount = this._frameArray[frameOffset + 1]; + var actions = this._animationData.parent.actions; // May be the animaton data not belong to this armature data. + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._bufferAction(eventObject, true); + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasDBEventListener(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.animationState = this._animationState; + dragonBones.EventObject.actionDataToInstance(action, eventObject, this._armature); + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + } + }; + ActionTimelineState.prototype._onArriveAtFrame = function () { }; + ActionTimelineState.prototype._onUpdateFrame = function () { }; + ActionTimelineState.prototype.update = function (passedTime) { + var prevState = this.playState; + var prevPlayTimes = this.currentPlayTimes; + var prevTime = this.currentTime; + if (this._setCurrentTime(passedTime)) { + var eventActive = this._animationState._parent === null && this._animationState.actionEnabled; + var eventDispatcher = this._armature.eventDispatcher; + if (prevState < 0) { + if (this.playState !== prevState) { + if (this._animationState.displayControl && this._animationState.resetToPose) { // Reset zorder to pose. + this._armature._sortZOrder(null, 0); + } + prevPlayTimes = this.currentPlayTimes; + if (eventActive && eventDispatcher.hasDBEventListener(dragonBones.EventObject.START)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = dragonBones.EventObject.START; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + else { + return; + } + } + var isReverse = this._animationState.timeScale < 0.0; + var loopCompleteEvent = null; + var completeEvent = null; + if (eventActive && this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + loopCompleteEvent.type = dragonBones.EventObject.LOOP_COMPLETE; + loopCompleteEvent.armature = this._armature; + loopCompleteEvent.animationState = this._animationState; + } + if (this.playState > 0) { + if (eventDispatcher.hasDBEventListener(dragonBones.EventObject.COMPLETE)) { + completeEvent = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + completeEvent.type = dragonBones.EventObject.COMPLETE; + completeEvent.armature = this._armature; + completeEvent.animationState = this._animationState; + } + } + } + if (this._frameCount > 1) { + var timelineData = this._timelineData; + var timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + var frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { // Arrive at frame. + var crossedFrameIndex = this._frameIndex; + this._frameIndex = frameIndex; + if (this._timelineArray !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + this._frameIndex]; + if (isReverse) { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (crossedFrameIndex === frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + while (crossedFrameIndex >= 0) { + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && + framePosition <= this._position + this._duration) { // Support interval play. + this._onCrossFrame(crossedFrameIndex); + } + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event after first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex > 0) { + crossedFrameIndex--; + } + else { + crossedFrameIndex = this._frameCount - 1; + } + if (crossedFrameIndex === frameIndex) { + break; + } + } + } + else { + if (crossedFrameIndex < 0) { + var prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { // Crossed. + if (crossedFrameIndex > 0) { + crossedFrameIndex--; + } + else { + crossedFrameIndex = this._frameCount - 1; + } + } + else if (crossedFrameIndex === frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + while (crossedFrameIndex >= 0) { + if (crossedFrameIndex < this._frameCount - 1) { + crossedFrameIndex++; + } + else { + crossedFrameIndex = 0; + } + var frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + 5 /* TimelineFrameOffset */ + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + var framePosition = this._frameArray[frameOffset] / this._frameRate; + if (this._position <= framePosition && + framePosition <= this._position + this._duration // + ) { // Support interval play. + this._onCrossFrame(crossedFrameIndex); + } + if (loopCompleteEvent !== null && crossedFrameIndex === 0) { // Add loop complete event before first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + if (crossedFrameIndex === frameIndex) { + break; + } + } + } + } + } + } + else if (this._frameIndex < 0) { + this._frameIndex = 0; + if (this._timelineData !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[this._timelineData.offset + 5 /* TimelineFrameOffset */]; + // Arrive at frame. + var framePosition = this._frameArray[this._frameOffset] / this._frameRate; + if (this.currentPlayTimes === prevPlayTimes) { // Start. + if (prevTime <= framePosition) { + this._onCrossFrame(this._frameIndex); + } + } + else if (this._position <= framePosition) { // Loop complete. + if (!isReverse && loopCompleteEvent !== null) { // Add loop complete event before first frame. + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + loopCompleteEvent = null; + } + this._onCrossFrame(this._frameIndex); + } + } + } + if (loopCompleteEvent !== null) { + this._armature._dragonBones.bufferEvent(loopCompleteEvent); + } + if (completeEvent !== null) { + this._armature._dragonBones.bufferEvent(completeEvent); + } + } + }; + ActionTimelineState.prototype.setCurrentTime = function (value) { + this._setCurrentTime(value); + this._frameIndex = -1; + }; + return ActionTimelineState; + }(dragonBones.TimelineState)); + dragonBones.ActionTimelineState = ActionTimelineState; + /** + * @internal + */ + var ZOrderTimelineState = /** @class */ (function (_super) { + __extends(ZOrderTimelineState, _super); + function ZOrderTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + ZOrderTimelineState.toString = function () { + return "[class dragonBones.ZOrderTimelineState]"; + }; + ZOrderTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var count = this._frameArray[this._frameOffset + 1]; + if (count > 0) { + this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); + } + else { + this._armature._sortZOrder(null, 0); + } + } + }; + ZOrderTimelineState.prototype._onUpdateFrame = function () { }; + return ZOrderTimelineState; + }(dragonBones.TimelineState)); + dragonBones.ZOrderTimelineState = ZOrderTimelineState; + /** + * @internal + */ + var BoneAllTimelineState = /** @class */ (function (_super) { + __extends(BoneAllTimelineState, _super); + function BoneAllTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneAllTimelineState.toString = function () { + return "[class dragonBones.BoneAllTimelineState]"; + }; + BoneAllTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._isTween && this._frameIndex === this._frameCount - 1) { + this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); + this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); + } + if (this._timelineData === null) { // Pose. + this._rd[4] = 1.0; + this._rd[5] = 1.0; + } + }; + BoneAllTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = 6; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + this.dirty = false; + this._rd[2] = dragonBones.Transform.normalizeRadian(this._rd[2]); + this._rd[3] = dragonBones.Transform.normalizeRadian(this._rd[3]); + }; + BoneAllTimelineState.prototype.blend = function (isDirty) { + var valueScale = this._armature.armatureData.scale; + var rd = this._rd; + // + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.x += rd[0] * blendWeight * valueScale; + result.y += rd[1] * blendWeight * valueScale; + result.rotation += rd[2] * blendWeight; + result.skew += rd[3] * blendWeight; + result.scaleX += (rd[4] - 1.0) * blendWeight; + result.scaleY += (rd[5] - 1.0) * blendWeight; + } + else { + result.x = rd[0] * blendWeight * valueScale; + result.y = rd[1] * blendWeight * valueScale; + result.rotation = rd[2] * blendWeight; + result.skew = rd[3] * blendWeight; + result.scaleX = (rd[4] - 1.0) * blendWeight + 1.0; // + result.scaleY = (rd[5] - 1.0) * blendWeight + 1.0; // + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneAllTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + */ + var BoneTranslateTimelineState = /** @class */ (function (_super) { + __extends(BoneTranslateTimelineState, _super); + function BoneTranslateTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTranslateTimelineState.toString = function () { + return "[class dragonBones.BoneTranslateTimelineState]"; + }; + BoneTranslateTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneTranslateTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.x += this._resultA * blendWeight; + result.y += this._resultB * blendWeight; + } + else if (blendWeight !== 1.0) { + result.x = this._resultA * blendWeight; + result.y = this._resultB * blendWeight; + } + else { + result.x = this._resultA; + result.y = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneTranslateTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneTranslateTimelineState = BoneTranslateTimelineState; + /** + * @internal + */ + var BoneRotateTimelineState = /** @class */ (function (_super) { + __extends(BoneRotateTimelineState, _super); + function BoneRotateTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneRotateTimelineState.toString = function () { + return "[class dragonBones.BoneRotateTimelineState]"; + }; + BoneRotateTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._isTween && this._frameIndex === this._frameCount - 1) { + this._differenceA = dragonBones.Transform.normalizeRadian(this._differenceA); + this._differenceB = dragonBones.Transform.normalizeRadian(this._differenceB); + } + }; + BoneRotateTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneRotateTimelineState.prototype.fadeOut = function () { + this.dirty = false; + this._resultA = dragonBones.Transform.normalizeRadian(this._resultA); + this._resultB = dragonBones.Transform.normalizeRadian(this._resultB); + }; + BoneRotateTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.rotation += this._resultA * blendWeight; + result.skew += this._resultB * blendWeight; + } + else if (blendWeight !== 1.0) { + result.rotation = this._resultA * blendWeight; + result.skew = this._resultB * blendWeight; + } + else { + result.rotation = this._resultA; + result.skew = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneRotateTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneRotateTimelineState = BoneRotateTimelineState; + /** + * @internal + */ + var BoneScaleTimelineState = /** @class */ (function (_super) { + __extends(BoneScaleTimelineState, _super); + function BoneScaleTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneScaleTimelineState.toString = function () { + return "[class dragonBones.BoneScaleTimelineState]"; + }; + BoneScaleTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + this._resultA = 1.0; + this._resultB = 1.0; + } + }; + BoneScaleTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameFloatOffset; + this._valueArray = this._animationData.parent.parent.frameFloatArray; + }; + BoneScaleTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var bone = blendState.target; + var blendWeight = blendState.blendWeight; + var result = bone.animationPose; + if (blendState.dirty > 1) { + result.scaleX += (this._resultA - 1.0) * blendWeight; + result.scaleY += (this._resultB - 1.0) * blendWeight; + } + else if (blendWeight !== 1.0) { + result.scaleX = (this._resultA - 1.0) * blendWeight + 1.0; + result.scaleY = (this._resultB - 1.0) * blendWeight + 1.0; + } + else { + result.scaleX = this._resultA; + result.scaleY = this._resultB; + } + if (isDirty || this.dirty) { + this.dirty = false; + bone._transformDirty = true; + } + }; + return BoneScaleTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.BoneScaleTimelineState = BoneScaleTimelineState; + /** + * @internal + */ + var SurfaceTimelineState = /** @class */ (function (_super) { + __extends(SurfaceTimelineState, _super); + function SurfaceTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SurfaceTimelineState.toString = function () { + return "[class dragonBones.SurfaceTimelineState]"; + }; + SurfaceTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._deformCount = 0; + this._deformOffset = 0; + this._sameValueOffset = 0; + }; + SurfaceTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; + var frameIntArray = dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = dragonBonesData.frameFloatArray; + this._rd.length = this._valueCount * 2; + } + else { + this._deformCount = this.target.target._deformVertices.length; + } + }; + SurfaceTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var surface = blendState.target; + var blendWeight = blendState.blendWeight; + var result = surface._deformVertices; + var valueArray = this._valueArray; + if (valueArray !== null) { + var valueCount = this._valueCount; + var deformOffset = this._deformOffset; + var sameValueOffset = this._sameValueOffset; + var rd = this._rd; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0.0; + if (i < deformOffset) { + value = valueArray[sameValueOffset + i]; + } + else if (i < deformOffset + valueCount) { + value = rd[i - deformOffset]; + } + else { + value = valueArray[sameValueOffset + i - valueCount]; + } + if (blendState.dirty > 1) { + result[i] += value * blendWeight; + } + else { + result[i] = value * blendWeight; + } + } + } + else if (blendState.dirty === 1) { + for (var i = 0; i < this._deformCount; ++i) { + result[i] = 0.0; + } + } + if (isDirty || this.dirty) { + this.dirty = false; + surface._transformDirty = true; + } + }; + return SurfaceTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.SurfaceTimelineState = SurfaceTimelineState; + /** + * @internal + */ + var AlphaTimelineState = /** @class */ (function (_super) { + __extends(AlphaTimelineState, _super); + function AlphaTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AlphaTimelineState.toString = function () { + return "[class dragonBones.AlphaTimelineState]"; + }; + AlphaTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + this._result = 1.0; + } + }; + AlphaTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.01; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + AlphaTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var alphaTarget = blendState.target; + var blendWeight = blendState.blendWeight; + if (blendState.dirty > 1) { + alphaTarget._alpha += this._result * blendWeight; + if (alphaTarget._alpha > 1.0) { + alphaTarget._alpha = 1.0; + } + } + else { + alphaTarget._alpha = this._result * blendWeight; + } + if (isDirty || this.dirty) { + this.dirty = false; + this._armature._alphaDirty = true; + } + }; + return AlphaTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AlphaTimelineState = AlphaTimelineState; + /** + * @internal + */ + var SlotDisplayTimelineState = /** @class */ (function (_super) { + __extends(SlotDisplayTimelineState, _super); + function SlotDisplayTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDisplayTimelineState.toString = function () { + return "[class dragonBones.SlotDisplayTimelineState]"; + }; + SlotDisplayTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var slot = this.target; + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : slot._slotData.displayIndex; + if (slot.displayIndex !== displayIndex) { + slot._setDisplayIndex(displayIndex, true); + } + } + }; + SlotDisplayTimelineState.prototype._onUpdateFrame = function () { + }; + return SlotDisplayTimelineState; + }(dragonBones.TimelineState)); + dragonBones.SlotDisplayTimelineState = SlotDisplayTimelineState; + /** + * @internal + */ + var SlotColorTimelineState = /** @class */ (function (_super) { + __extends(SlotColorTimelineState, _super); + function SlotColorTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = [0, 0, 0, 0, 0, 0, 0, 0]; + _this._difference = [0, 0, 0, 0, 0, 0, 0, 0]; + _this._result = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; + return _this; + } + SlotColorTimelineState.toString = function () { + return "[class dragonBones.SlotColorTimelineState]"; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var dragonBonesData = this._animationData.parent.parent; + var colorArray = dragonBonesData.colorArray; + var frameIntArray = dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex; + var colorOffset = frameIntArray[valueOffset]; + if (colorOffset < 0) { + colorOffset += 65536; // Fixed out of bounds bug. + } + if (this._isTween) { + this._current[0] = colorArray[colorOffset++]; + this._current[1] = colorArray[colorOffset++]; + this._current[2] = colorArray[colorOffset++]; + this._current[3] = colorArray[colorOffset++]; + this._current[4] = colorArray[colorOffset++]; + this._current[5] = colorArray[colorOffset++]; + this._current[6] = colorArray[colorOffset++]; + this._current[7] = colorArray[colorOffset++]; + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1]; + } + if (colorOffset < 0) { + colorOffset += 65536; // Fixed out of bounds bug. + } + this._difference[0] = colorArray[colorOffset++] - this._current[0]; + this._difference[1] = colorArray[colorOffset++] - this._current[1]; + this._difference[2] = colorArray[colorOffset++] - this._current[2]; + this._difference[3] = colorArray[colorOffset++] - this._current[3]; + this._difference[4] = colorArray[colorOffset++] - this._current[4]; + this._difference[5] = colorArray[colorOffset++] - this._current[5]; + this._difference[6] = colorArray[colorOffset++] - this._current[6]; + this._difference[7] = colorArray[colorOffset++] - this._current[7]; + } + else { + this._result[0] = colorArray[colorOffset++] * 0.01; + this._result[1] = colorArray[colorOffset++] * 0.01; + this._result[2] = colorArray[colorOffset++] * 0.01; + this._result[3] = colorArray[colorOffset++] * 0.01; + this._result[4] = colorArray[colorOffset++]; + this._result[5] = colorArray[colorOffset++]; + this._result[6] = colorArray[colorOffset++]; + this._result[7] = colorArray[colorOffset++]; + } + } + else { // Pose. + var slot = this.target; + var color = slot.slotData.color; + this._result[0] = color.alphaMultiplier; + this._result[1] = color.redMultiplier; + this._result[2] = color.greenMultiplier; + this._result[3] = color.blueMultiplier; + this._result[4] = color.alphaOffset; + this._result[5] = color.redOffset; + this._result[6] = color.greenOffset; + this._result[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + if (this._isTween) { + this._result[0] = (this._current[0] + this._difference[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._difference[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._difference[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._difference[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._difference[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._difference[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._difference[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._difference[7] * this._tweenProgress; + } + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._isTween = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._isTween || this.dirty) { + var slot = this.target; + var result = slot._colorTransform; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + if (result.alphaMultiplier !== this._result[0] || + result.redMultiplier !== this._result[1] || + result.greenMultiplier !== this._result[2] || + result.blueMultiplier !== this._result[3] || + result.alphaOffset !== this._result[4] || + result.redOffset !== this._result[5] || + result.greenOffset !== this._result[6] || + result.blueOffset !== this._result[7]) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 4); + result.alphaMultiplier += (this._result[0] - result.alphaMultiplier) * fadeProgress; + result.redMultiplier += (this._result[1] - result.redMultiplier) * fadeProgress; + result.greenMultiplier += (this._result[2] - result.greenMultiplier) * fadeProgress; + result.blueMultiplier += (this._result[3] - result.blueMultiplier) * fadeProgress; + result.alphaOffset += (this._result[4] - result.alphaOffset) * fadeProgress; + result.redOffset += (this._result[5] - result.redOffset) * fadeProgress; + result.greenOffset += (this._result[6] - result.greenOffset) * fadeProgress; + result.blueOffset += (this._result[7] - result.blueOffset) * fadeProgress; + slot._colorDirty = true; + } + } + else if (this.dirty) { + this.dirty = false; + if (result.alphaMultiplier !== this._result[0] || + result.redMultiplier !== this._result[1] || + result.greenMultiplier !== this._result[2] || + result.blueMultiplier !== this._result[3] || + result.alphaOffset !== this._result[4] || + result.redOffset !== this._result[5] || + result.greenOffset !== this._result[6] || + result.blueOffset !== this._result[7]) { + result.alphaMultiplier = this._result[0]; + result.redMultiplier = this._result[1]; + result.greenMultiplier = this._result[2]; + result.blueMultiplier = this._result[3]; + result.alphaOffset = this._result[4]; + result.redOffset = this._result[5]; + result.greenOffset = this._result[6]; + result.blueOffset = this._result[7]; + slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.TweenTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + */ + var SlotZIndexTimelineState = /** @class */ (function (_super) { + __extends(SlotZIndexTimelineState, _super); + function SlotZIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotZIndexTimelineState.toString = function () { + return "[class dragonBones.SlotZIndexTimelineState]"; + }; + SlotZIndexTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData === null) { // Pose. + var blendState = this.target; + var slot = blendState.target; + this._result = slot.slotData.zIndex; + } + }; + SlotZIndexTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + SlotZIndexTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var slot = blendState.target; + var blendWeight = blendState.blendWeight; + if (blendState.dirty > 1) { + slot._zIndex += this._result * blendWeight; + } + else { + slot._zIndex = this._result * blendWeight; + } + if (isDirty || this.dirty) { + this.dirty = false; + this._armature._zIndexDirty = true; + } + }; + return SlotZIndexTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.SlotZIndexTimelineState = SlotZIndexTimelineState; + /** + * @internal + */ + var DeformTimelineState = /** @class */ (function (_super) { + __extends(DeformTimelineState, _super); + function DeformTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + DeformTimelineState.toString = function () { + return "[class dragonBones.DeformTimelineState]"; + }; + DeformTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.geometryOffset = 0; + this.displayFrame = null; + this._deformCount = 0; + this._deformOffset = 0; + this._sameValueOffset = 0; + }; + DeformTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + var dragonBonesData = this._animationData.parent.parent; + var frameIntArray = dragonBonesData.frameIntArray; + var slot = this.target.target; + this.geometryOffset = frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */]; + if (this.geometryOffset < 0) { + this.geometryOffset += 65536; // Fixed out of bounds bug. + } + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayFrame = slot.getDisplayFrameAt(i); + var geometryData = displayFrame.getGeometryData(); + if (geometryData === null) { + continue; + } + if (geometryData.offset === this.geometryOffset) { + this.displayFrame = displayFrame; + this.displayFrame.updateDeformVertices(); + break; + } + } + if (this.displayFrame === null) { + this.returnToPool(); // + return; + } + this._valueOffset = this._animationData.frameFloatOffset; + this._valueCount = frameIntArray[frameIntOffset + 2 /* DeformValueCount */]; + this._deformCount = frameIntArray[frameIntOffset + 1 /* DeformCount */]; + this._deformOffset = frameIntArray[frameIntOffset + 3 /* DeformValueOffset */]; + this._sameValueOffset = frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] + this._animationData.frameFloatOffset; + this._valueScale = this._armature.armatureData.scale; + this._valueArray = dragonBonesData.frameFloatArray; + this._rd.length = this._valueCount * 2; + } + else { + this._deformCount = this.displayFrame.deformVertices.length; + } + }; + DeformTimelineState.prototype.blend = function (isDirty) { + var blendState = this.target; + var slot = blendState.target; + var blendWeight = blendState.blendWeight; + var result = this.displayFrame.deformVertices; + var valueArray = this._valueArray; + if (valueArray !== null) { + var valueCount = this._valueCount; + var deformOffset = this._deformOffset; + var sameValueOffset = this._sameValueOffset; + var rd = this._rd; + for (var i = 0; i < this._deformCount; ++i) { + var value = 0.0; + if (i < deformOffset) { + value = valueArray[sameValueOffset + i]; + } + else if (i < deformOffset + valueCount) { + value = rd[i - deformOffset]; + } + else { + value = valueArray[sameValueOffset + i - valueCount]; + } + if (blendState.dirty > 1) { + result[i] += value * blendWeight; + } + else { + result[i] = value * blendWeight; + } + } + } + else if (blendState.dirty === 1) { + for (var i = 0; i < this._deformCount; ++i) { + result[i] = 0.0; + } + } + if (isDirty || this.dirty) { + this.dirty = false; + if (slot._geometryData === this.displayFrame.getGeometryData()) { + slot._verticesDirty = true; + } + } + }; + return DeformTimelineState; + }(dragonBones.MutilpleValueTimelineState)); + dragonBones.DeformTimelineState = DeformTimelineState; + /** + * @internal + */ + var IKConstraintTimelineState = /** @class */ (function (_super) { + __extends(IKConstraintTimelineState, _super); + function IKConstraintTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + IKConstraintTimelineState.toString = function () { + return "[class dragonBones.IKConstraintTimelineState]"; + }; + IKConstraintTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var ikConstraint = this.target; + if (this._timelineData !== null) { + ikConstraint._bendPositive = this._currentA > 0.0; + ikConstraint._weight = this._currentB; + } + else { + var ikConstraintData = ikConstraint._constraintData; + ikConstraint._bendPositive = ikConstraintData.bendPositive; + ikConstraint._weight = ikConstraintData.weight; + } + ikConstraint.invalidUpdate(); + this.dirty = false; + }; + IKConstraintTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.01; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return IKConstraintTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.IKConstraintTimelineState = IKConstraintTimelineState; + /** + * @internal + */ + var AnimationProgressTimelineState = /** @class */ (function (_super) { + __extends(AnimationProgressTimelineState, _super); + function AnimationProgressTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationProgressTimelineState.toString = function () { + return "[class dragonBones.AnimationProgressTimelineState]"; + }; + AnimationProgressTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.currentTime = this._result * animationState.totalTime; + } + this.dirty = false; + }; + AnimationProgressTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationProgressTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AnimationProgressTimelineState = AnimationProgressTimelineState; + /** + * @internal + */ + var AnimationWeightTimelineState = /** @class */ (function (_super) { + __extends(AnimationWeightTimelineState, _super); + function AnimationWeightTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationWeightTimelineState.toString = function () { + return "[class dragonBones.AnimationWeightTimelineState]"; + }; + AnimationWeightTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.weight = this._result; + } + this.dirty = false; + }; + AnimationWeightTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationWeightTimelineState; + }(dragonBones.SingleValueTimelineState)); + dragonBones.AnimationWeightTimelineState = AnimationWeightTimelineState; + /** + * @internal + */ + var AnimationParametersTimelineState = /** @class */ (function (_super) { + __extends(AnimationParametersTimelineState, _super); + function AnimationParametersTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + AnimationParametersTimelineState.toString = function () { + return "[class dragonBones.AnimationParametersTimelineState]"; + }; + AnimationParametersTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var animationState = this.target; + if (animationState._parent !== null) { + animationState.parameterX = this._resultA; + animationState.parameterY = this._resultB; + } + this.dirty = false; + }; + AnimationParametersTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + this._valueOffset = this._animationData.frameIntOffset; + this._valueScale = 0.0001; + this._valueArray = this._animationData.parent.parent.frameIntArray; + }; + return AnimationParametersTimelineState; + }(dragonBones.DoubleValueTimelineState)); + dragonBones.AnimationParametersTimelineState = AnimationParametersTimelineState; +})(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 properties of the object carry basic information about an event, + * which are passed as parameter or parameter's parameter to event listeners when an event occurs. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = /** @class */ (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @internal + * @private + */ + EventObject.actionDataToInstance = function (data, instance, armature) { + if (data.type === 0 /* Play */) { + instance.type = EventObject.FRAME_EVENT; + } + else { + instance.type = data.type === 10 /* Frame */ ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; + } + instance.name = data.name; + instance.armature = armature; + instance.actionData = data; + instance.data = data.data; + if (data.bone !== null) { + instance.bone = armature.getBone(data.bone.name); + } + if (data.slot !== null) { + instance.slot = armature.getSlot(data.slot.name); + } + }; + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + EventObject.prototype._onClear = function () { + this.time = 0.0; + this.type = ""; + this.name = ""; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.actionData = null; + this.data = null; + }; + /** + * - Animation start play. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画开始播放。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * - Animation loop play complete once. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画循环播放完成一次。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * - Animation play complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * - Animation fade in start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * - Animation fade in complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * - Animation fade out start. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * - Animation fade out complete. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * - Animation frame event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * - Animation frame sound event. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 动画帧声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(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 DataParser = /** @class */ (function () { + function DataParser() { + } + DataParser._getArmatureType = function (value) { + switch (value.toLowerCase()) { + case "stage": + return 2 /* Stage */; + case "armature": + return 0 /* Armature */; + case "movieclip": + return 1 /* MovieClip */; + default: + return 0 /* Armature */; + } + }; + DataParser._getBoneType = function (value) { + switch (value.toLowerCase()) { + case "bone": + return 0 /* Bone */; + case "surface": + return 1 /* Surface */; + default: + return 0 /* Bone */; + } + }; + DataParser._getPositionMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "percent": + return 1 /* Percent */; + case "fixed": + return 0 /* Fixed */; + default: + return 1 /* Percent */; + } + }; + DataParser._getSpacingMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "length": + return 0 /* Length */; + case "percent": + return 2 /* Percent */; + case "fixed": + return 1 /* Fixed */; + default: + return 0 /* Length */; + } + }; + DataParser._getRotateMode = function (value) { + switch (value.toLocaleLowerCase()) { + case "tangent": + return 0 /* Tangent */; + case "chain": + return 1 /* Chain */; + case "chainscale": + return 2 /* ChainScale */; + default: + return 0 /* Tangent */; + } + }; + DataParser._getDisplayType = function (value) { + switch (value.toLowerCase()) { + case "image": + return 0 /* Image */; + case "mesh": + return 2 /* Mesh */; + case "armature": + return 1 /* Armature */; + case "boundingbox": + return 3 /* BoundingBox */; + case "path": + return 4 /* Path */; + default: + return 0 /* Image */; + } + }; + DataParser._getBoundingBoxType = function (value) { + switch (value.toLowerCase()) { + case "rectangle": + return 0 /* Rectangle */; + case "ellipse": + return 1 /* Ellipse */; + case "polygon": + return 2 /* Polygon */; + default: + return 0 /* Rectangle */; + } + }; + DataParser._getBlendMode = function (value) { + switch (value.toLowerCase()) { + case "normal": + return 0 /* Normal */; + case "add": + return 1 /* Add */; + case "alpha": + return 2 /* Alpha */; + case "darken": + return 3 /* Darken */; + case "difference": + return 4 /* Difference */; + case "erase": + return 5 /* Erase */; + case "hardlight": + return 6 /* HardLight */; + case "invert": + return 7 /* Invert */; + case "layer": + return 8 /* Layer */; + case "lighten": + return 9 /* Lighten */; + case "multiply": + return 10 /* Multiply */; + case "overlay": + return 11 /* Overlay */; + case "screen": + return 12 /* Screen */; + case "subtract": + return 13 /* Subtract */; + default: + return 0 /* Normal */; + } + }; + DataParser._getAnimationBlendType = function (value) { + switch (value.toLowerCase()) { + case "none": + return 0 /* None */; + case "1d": + return 1 /* E1D */; + default: + return 0 /* None */; + } + }; + DataParser._getActionType = function (value) { + switch (value.toLowerCase()) { + case "play": + return 0 /* Play */; + case "frame": + return 10 /* Frame */; + case "sound": + return 11 /* Sound */; + default: + return 0 /* Play */; + } + }; + DataParser.DATA_VERSION_2_3 = "2.3"; + DataParser.DATA_VERSION_3_0 = "3.0"; + DataParser.DATA_VERSION_4_0 = "4.0"; + DataParser.DATA_VERSION_4_5 = "4.5"; + DataParser.DATA_VERSION_5_0 = "5.0"; + DataParser.DATA_VERSION_5_5 = "5.5"; + DataParser.DATA_VERSION_5_6 = "5.6"; + DataParser.DATA_VERSION = DataParser.DATA_VERSION_5_6; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0, + DataParser.DATA_VERSION_5_5, + DataParser.DATA_VERSION_5_6 + ]; + DataParser.TEXTURE_ATLAS = "textureAtlas"; + DataParser.SUB_TEXTURE = "SubTexture"; + DataParser.FORMAT = "format"; + DataParser.IMAGE_PATH = "imagePath"; + DataParser.WIDTH = "width"; + DataParser.HEIGHT = "height"; + DataParser.ROTATED = "rotated"; + DataParser.FRAME_X = "frameX"; + DataParser.FRAME_Y = "frameY"; + DataParser.FRAME_WIDTH = "frameWidth"; + DataParser.FRAME_HEIGHT = "frameHeight"; + DataParser.DRADON_BONES = "dragonBones"; + DataParser.USER_DATA = "userData"; + DataParser.ARMATURE = "armature"; + DataParser.CANVAS = "canvas"; + DataParser.BONE = "bone"; + DataParser.SURFACE = "surface"; + DataParser.SLOT = "slot"; + DataParser.CONSTRAINT = "constraint"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.FRAME = "frame"; + DataParser.IK = "ik"; + DataParser.PATH_CONSTRAINT = "path"; + DataParser.ANIMATION = "animation"; + DataParser.TIMELINE = "timeline"; + DataParser.FFD = "ffd"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.DISPLAY_FRAME = "displayFrame"; + DataParser.COLOR_FRAME = "colorFrame"; + DataParser.DEFAULT_ACTIONS = "defaultActions"; + DataParser.ACTIONS = "actions"; + DataParser.EVENTS = "events"; + DataParser.INTS = "ints"; + DataParser.FLOATS = "floats"; + DataParser.STRINGS = "strings"; + DataParser.TRANSFORM = "transform"; + DataParser.PIVOT = "pivot"; + DataParser.AABB = "aabb"; + DataParser.COLOR = "color"; + DataParser.VERSION = "version"; + DataParser.COMPATIBLE_VERSION = "compatibleVersion"; + DataParser.FRAME_RATE = "frameRate"; + DataParser.TYPE = "type"; + DataParser.SUB_TYPE = "subType"; + DataParser.NAME = "name"; + DataParser.PARENT = "parent"; + DataParser.TARGET = "target"; + DataParser.STAGE = "stage"; + DataParser.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + DataParser.Z_ORDER = "zOrder"; + DataParser.Z_INDEX = "zIndex"; + DataParser.BLEND_MODE = "blendMode"; + DataParser.INHERIT_TRANSLATION = "inheritTranslation"; + DataParser.INHERIT_ROTATION = "inheritRotation"; + DataParser.INHERIT_SCALE = "inheritScale"; + DataParser.INHERIT_REFLECTION = "inheritReflection"; + DataParser.INHERIT_ANIMATION = "inheritAnimation"; + DataParser.INHERIT_DEFORM = "inheritDeform"; + DataParser.SEGMENT_X = "segmentX"; + DataParser.SEGMENT_Y = "segmentY"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.BLEND_TYPE = "blendType"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + DataParser.CLOCK_WISE = "clockwise"; + DataParser.CURVE = "curve"; + DataParser.SOUND = "sound"; + DataParser.EVENT = "event"; + DataParser.ACTION = "action"; + DataParser.X = "x"; + DataParser.Y = "y"; + DataParser.SKEW_X = "skX"; + DataParser.SKEW_Y = "skY"; + DataParser.SCALE_X = "scX"; + DataParser.SCALE_Y = "scY"; + DataParser.VALUE = "value"; + DataParser.ROTATE = "rotate"; + DataParser.SKEW = "skew"; + DataParser.ALPHA = "alpha"; + DataParser.ALPHA_OFFSET = "aO"; + DataParser.RED_OFFSET = "rO"; + DataParser.GREEN_OFFSET = "gO"; + DataParser.BLUE_OFFSET = "bO"; + DataParser.ALPHA_MULTIPLIER = "aM"; + DataParser.RED_MULTIPLIER = "rM"; + DataParser.GREEN_MULTIPLIER = "gM"; + DataParser.BLUE_MULTIPLIER = "bM"; + DataParser.UVS = "uvs"; + DataParser.VERTICES = "vertices"; + DataParser.TRIANGLES = "triangles"; + DataParser.WEIGHTS = "weights"; + DataParser.SLOT_POSE = "slotPose"; + DataParser.BONE_POSE = "bonePose"; + DataParser.BONES = "bones"; + DataParser.POSITION_MODE = "positionMode"; + DataParser.SPACING_MODE = "spacingMode"; + DataParser.ROTATE_MODE = "rotateMode"; + DataParser.SPACING = "spacing"; + DataParser.ROTATE_OFFSET = "rotateOffset"; + DataParser.ROTATE_MIX = "rotateMix"; + DataParser.TRANSLATE_MIX = "translateMix"; + DataParser.TARGET_DISPLAY = "targetDisplay"; + DataParser.CLOSED = "closed"; + DataParser.CONSTANT_SPEED = "constantSpeed"; + DataParser.VERTEX_COUNT = "vertexCount"; + DataParser.LENGTHS = "lengths"; + DataParser.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(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 ObjectDataParser = /** @class */ (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._geometry = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._frameValueType = 0 /* Step */; + _this._defaultColorOffset = -1; + _this._prevClockwise = 0; + _this._prevRotation = 0.0; + _this._frameDefaultValue = 0.0; + _this._frameValueScale = 1.0; + _this._helpMatrixA = new dragonBones.Matrix(); + _this._helpMatrixB = new dragonBones.Matrix(); + _this._helpTransform = new dragonBones.Transform(); + _this._helpColorTransform = new dragonBones.ColorTransform(); + _this._helpPoint = new dragonBones.Point(); + _this._helpArray = []; + _this._intArray = []; + _this._floatArray = []; + _this._frameIntArray = []; + _this._frameFloatArray = []; + _this._frameArray = []; + _this._timelineArray = []; + _this._colorArray = []; + _this._cacheRawMeshes = []; + _this._cacheMeshes = []; + _this._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._cacheBones = {}; + _this._slotChildActions = {}; + return _this; + } + ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "boolean") { + return value; + } + else if (type === "string") { + switch (value) { + case "0": + case "NaN": + case "": + case "false": + case "null": + case "undefined": + return false; + default: + return true; + } + } + else { + return !!value; + } + } + return defaultValue; + }; + ObjectDataParser._getNumber = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + if (value === null || value === "NaN") { + return defaultValue; + } + return +value || 0; + } + return defaultValue; + }; + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + return value; + } + return String(value); + } + return defaultValue; + }; + ObjectDataParser.prototype._getCurvePoint = function (x1, y1, x2, y2, x3, y3, x4, y4, t, result) { + var l_t = 1.0 - t; + var powA = l_t * l_t; + var powB = t * t; + var kA = l_t * powA; + var kB = 3.0 * t * powA; + var kC = 3.0 * l_t * powB; + var kD = t * powB; + result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; + result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; + }; + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + if (curveCount % 3 === 1) { + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); // float + while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + var isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; + var x1 = isInCurve ? curve[stepIndex] : 0.0; + var y1 = isInCurve ? curve[stepIndex + 1] : 0.0; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = isInCurve ? curve[stepIndex + 6] : 1.0; + var y4 = isInCurve ? curve[stepIndex + 7] : 1.0; + var lower = 0.0; + var higher = 1.0; + while (higher - lower > 0.0001) { + var percentage = (higher + lower) * 0.5; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0.0) { + lower = percentage; + } + else { + higher = percentage; + } + } + samples[i] = this._helpPoint.y; + } + return true; + } + else { + var stepIndex = 0; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); // float + while (curve[stepIndex + 6] < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + var x1 = curve[stepIndex]; + var y1 = curve[stepIndex + 1]; + var x2 = curve[stepIndex + 2]; + var y2 = curve[stepIndex + 3]; + var x3 = curve[stepIndex + 4]; + var y3 = curve[stepIndex + 5]; + var x4 = curve[stepIndex + 6]; + var y4 = curve[stepIndex + 7]; + var lower = 0.0; + var higher = 1.0; + while (higher - lower > 0.0001) { + var percentage = (higher + lower) * 0.5; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0.0) { + lower = percentage; + } + else { + higher = percentage; + } + } + samples[i] = this._helpPoint.y; + } + return false; + } + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (dragonBones.DataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (dragonBones.DataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (dragonBones.DataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (dragonBones.DataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (dragonBones.DataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[dragonBones.DataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = this._armature.actions.length; + var actions = this._parseActionData(rawData, type, bone, slot); + var frameIndex = 0; + var frame = null; + for (var _i = 0, actions_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + this._armature.addAction(action, false); + } + if (this._actionFrames.length === 0) { // First frame. + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _a = 0, _b = this._actionFrames; _a < _b.length; _a++) { // Get same frame. + var eachFrame = _b[_a]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + else if (eachFrame.frameStart > frameStart) { + break; + } + frameIndex++; + } + if (frame === null) { // Create and cache frame. + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.splice(frameIndex, 0, frame); + } + for (var i = 0; i < actions.length; ++i) { // Cache action offsets. + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + armature.type = dragonBones.DataParser._getArmatureType(rawData[dragonBones.DataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { // Data error. + armature.frameRate = 24; + } + this._armature = armature; + if (dragonBones.DataParser.CANVAS in rawData) { + var rawCanvas = rawData[dragonBones.DataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (dragonBones.DataParser.COLOR in rawCanvas) { + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.X, 0) * armature.scale; + canvas.y = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.Y, 0) * armature.scale; + canvas.width = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.WIDTH, 0) * armature.scale; + canvas.height = ObjectDataParser._getNumber(rawCanvas, dragonBones.DataParser.HEIGHT, 0) * armature.scale; + armature.canvas = canvas; + } + if (dragonBones.DataParser.AABB in rawData) { + var rawAABB = rawData[dragonBones.DataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.X, 0.0) * armature.scale; + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.Y, 0.0) * armature.scale; + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.WIDTH, 0.0) * armature.scale; + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, dragonBones.DataParser.HEIGHT, 0.0) * armature.scale; + } + if (dragonBones.DataParser.BONE in rawData) { + var rawBones = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, dragonBones.DataParser.PARENT, ""); + var bone = this._parseBone(rawBone); + if (parentName.length > 0) { // Get bone parent. + var parent_1 = armature.getBone(parentName); + if (parent_1 !== null) { + bone.parent = parent_1; + } + else { // Cache. + if (!(parentName in this._cacheBones)) { + this._cacheBones[parentName] = []; + } + this._cacheBones[parentName].push(bone); + } + } + if (bone.name in this._cacheBones) { + for (var _a = 0, _b = this._cacheBones[bone.name]; _a < _b.length; _a++) { + var child = _b[_a]; + child.parent = bone; + } + delete this._cacheBones[bone.name]; + } + armature.addBone(bone); + this._rawBones.push(bone); // Cache raw bones sort. + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawIKS = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + var constraint = this._parseIKConstraint(rawIK); + if (constraint) { + armature.addConstraint(constraint); + } + } + } + armature.sortBones(); + if (dragonBones.DataParser.SLOT in rawData) { + var zOrder = 0; + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot, zOrder++)); + } + } + if (dragonBones.DataParser.SKIN in rawData) { + var rawSkins = rawData[dragonBones.DataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (dragonBones.DataParser.PATH_CONSTRAINT in rawData) { + var rawPaths = rawData[dragonBones.DataParser.PATH_CONSTRAINT]; + for (var _f = 0, rawPaths_1 = rawPaths; _f < rawPaths_1.length; _f++) { + var rawPath = rawPaths_1[_f]; + var constraint = this._parsePathConstraint(rawPath); + if (constraint) { + armature.addConstraint(constraint); + } + } + } + for (var i = 0, l = this._cacheRawMeshes.length; i < l; ++i) { // Link mesh. + var rawData_1 = this._cacheRawMeshes[i]; + var shareName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SHARE, ""); + if (shareName.length === 0) { + continue; + } + var skinName = ObjectDataParser._getString(rawData_1, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + if (skinName.length === 0) { // + skinName = dragonBones.DataParser.DEFAULT_NAME; + } + var shareMesh = armature.getMesh(skinName, "", shareName); // TODO slot; + if (shareMesh === null) { + continue; // Error. + } + var mesh = this._cacheMeshes[i]; + mesh.geometry.shareFrom(shareMesh.geometry); + } + if (dragonBones.DataParser.ANIMATION in rawData) { + var rawAnimations = rawData[dragonBones.DataParser.ANIMATION]; + for (var _g = 0, rawAnimations_1 = rawAnimations; _g < rawAnimations_1.length; _g++) { + var rawAnimation = rawAnimations_1[_g]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (dragonBones.DataParser.DEFAULT_ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.DEFAULT_ACTIONS], 0 /* Play */, null, null); + for (var _h = 0, actions_3 = actions; _h < actions_3.length; _h++) { + var action = actions_3[_h]; + armature.addAction(action, true); + if (action.type === 0 /* Play */) { // Set default animation from default action. + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + } + } + } + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + for (var _j = 0, actions_4 = actions; _j < actions_4.length; _j++) { + var action = actions_4[_j]; + armature.addAction(action, false); + } + } + // Clear helper. + this._rawBones.length = 0; + this._cacheRawMeshes.length = 0; + this._cacheMeshes.length = 0; + this._armature = null; + for (var k in this._weightSlotPose) { + delete this._weightSlotPose[k]; + } + for (var k in this._weightBonePoses) { + delete this._weightBonePoses[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + return armature; + }; + ObjectDataParser.prototype._parseBone = function (rawData) { + var type = 0 /* Bone */; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + type = dragonBones.DataParser._getBoneType(rawData[dragonBones.DataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, 0 /* Bone */); + } + if (type === 0 /* Bone */) { + var scale = this._armature.scale; + var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.LENGTH, 0) * scale; + bone.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + bone.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + if (dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], bone.transform, scale); + } + return bone; + } + var surface = dragonBones.BaseObject.borrowObject(dragonBones.SurfaceData); + surface.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + surface.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + surface.segmentX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_X, 0); + surface.segmentY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SEGMENT_Y, 0); + this._parseGeometry(rawData, surface.geometry); + return surface; + }; + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.BONE, "")); + if (bone === null) { + return null; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (target === null) { + return null; + } + var chain = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CHAIN, 0); + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.SCALE, false); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true); + constraint.weight = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 0 /* IK */; + constraint.target = target; + if (chain > 0 && bone.parent !== null) { + constraint.root = bone.parent; + constraint.bone = bone; + } + else { + constraint.root = bone; + constraint.bone = null; + } + return constraint; + }; + ObjectDataParser.prototype._parsePathConstraint = function (rawData) { + var target = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET, "")); + if (target === null) { + return null; + } + var defaultSkin = this._armature.defaultSkin; + if (defaultSkin === null) { + return null; + } + //TODO + var targetDisplay = defaultSkin.getDisplay(target.name, ObjectDataParser._getString(rawData, dragonBones.DataParser.TARGET_DISPLAY, target.name)); + if (targetDisplay === null || !(targetDisplay instanceof dragonBones.PathDisplayData)) { + return null; + } + var bones = rawData[dragonBones.DataParser.BONES]; + if (bones === null || bones.length === 0) { + return null; + } + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraintData); + constraint.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + constraint.type = 1 /* Path */; + constraint.pathSlot = target; + constraint.pathDisplayData = targetDisplay; + constraint.target = target.parent; + constraint.positionMode = dragonBones.DataParser._getPositionMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.POSITION_MODE, "")); + constraint.spacingMode = dragonBones.DataParser._getSpacingMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.SPACING_MODE, "")); + constraint.rotateMode = dragonBones.DataParser._getRotateMode(ObjectDataParser._getString(rawData, dragonBones.DataParser.ROTATE_MODE, "")); + constraint.position = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.POSITION, 0); + constraint.spacing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SPACING, 0); + constraint.rotateOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_OFFSET, 0); + constraint.rotateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE_MIX, 1); + constraint.translateMix = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TRANSLATE_MIX, 1); + // + for (var _i = 0, bones_3 = bones; _i < bones_3.length; _i++) { + var boneName = bones_3[_i]; + var bone = this._armature.getBone(boneName); + if (bone !== null) { + constraint.AddBone(bone); + if (constraint.root === null) { + constraint.root = bone; + } + } + } + return constraint; + }; + ObjectDataParser.prototype._parseSlot = function (rawData, zOrder) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + slot.zOrder = zOrder; + slot.zIndex = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Z_INDEX, 0); + slot.alpha = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA, 1.0); + slot.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.PARENT, "")); // + if (dragonBones.DataParser.BLEND_MODE in rawData && typeof rawData[dragonBones.DataParser.BLEND_MODE] === "string") { + slot.blendMode = dragonBones.DataParser._getBlendMode(rawData[dragonBones.DataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLEND_MODE, 0 /* Normal */); + } + if (dragonBones.DataParser.COLOR in rawData) { + slot.color = dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[dragonBones.DataParser.COLOR], slot.color); + } + else { + slot.color = dragonBones.SlotData.DEFAULT_COLOR; + } + if (dragonBones.DataParser.ACTIONS in rawData) { + this._slotChildActions[slot.name] = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + } + return slot; + }; + ObjectDataParser.prototype._parseSkin = function (rawData) { + var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = dragonBones.DataParser.DEFAULT_NAME; + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawSlots = rawData[dragonBones.DataParser.SLOT]; + this._skin = skin; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, dragonBones.DataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (dragonBones.DataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[dragonBones.DataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + if (rawDisplay) { + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + else { + skin.addDisplay(slotName, null); + } + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, dragonBones.DataParser.PATH, ""); + var type = 0 /* Image */; + var display = null; + if (dragonBones.DataParser.TYPE in rawData && typeof rawData[dragonBones.DataParser.TYPE] === "string") { + type = dragonBones.DataParser._getDisplayType(rawData[dragonBones.DataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: { + var imageDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + } + case 1 /* Armature */: { + var armatureDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (dragonBones.DataParser.ACTIONS in rawData) { + var actions = this._parseActionData(rawData[dragonBones.DataParser.ACTIONS], 0 /* Play */, null, null); + for (var _i = 0, actions_5 = actions; _i < actions_5.length; _i++) { + var action = actions_5[_i]; + armatureDisplay.addAction(action); + } + } + else if (this._slot.name in this._slotChildActions) { + var displays = this._skin.getDisplays(this._slot.name); + if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { + for (var _a = 0, _b = this._slotChildActions[this._slot.name]; _a < _b.length; _a++) { + var action = _b[_a]; + armatureDisplay.addAction(action); + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + } + case 2 /* Mesh */: { + var meshDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.geometry.inheritDeform = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.INHERIT_DEFORM, true); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + if (dragonBones.DataParser.SHARE in rawData) { + meshDisplay.geometry.data = this._data; + this._cacheRawMeshes.push(rawData); + this._cacheMeshes.push(meshDisplay); + } + else { + this._parseMesh(rawData, meshDisplay); + } + break; + } + case 3 /* BoundingBox */: { + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + var boundingBoxDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + case 4 /* Path */: { + var rawCurveLengths = rawData[dragonBones.DataParser.LENGTHS]; + var pathDisplay = display = dragonBones.BaseObject.borrowObject(dragonBones.PathDisplayData); + pathDisplay.closed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CLOSED, false); + pathDisplay.constantSpeed = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.CONSTANT_SPEED, false); + pathDisplay.name = name; + pathDisplay.path = path.length > 0 ? path : name; + pathDisplay.curveLengths.length = rawCurveLengths.length; + for (var i = 0, l = rawCurveLengths.length; i < l; ++i) { + pathDisplay.curveLengths[i] = rawCurveLengths[i]; + } + this._parsePath(rawData, pathDisplay); + break; + } + } + if (display !== null && dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], display.transform, this._armature.scale); + } + return display; + }; + ObjectDataParser.prototype._parsePath = function (rawData, display) { + this._parseGeometry(rawData, display.geometry); + }; + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (dragonBones.DataParser.PIVOT in rawData) { + var rawPivot = rawData[dragonBones.DataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, dragonBones.DataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + this._parseGeometry(rawData, mesh.geometry); + if (dragonBones.DataParser.WEIGHTS in rawData) { // Cache pose data. + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var meshName = this._skin.name + "_" + this._slot.name + "_" + mesh.name; + this._weightSlotPose[meshName] = rawSlotPose; + this._weightBonePoses[meshName] = rawBonePoses; + } + }; + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (dragonBones.DataParser.SUB_TYPE in rawData && typeof rawData[dragonBones.DataParser.SUB_TYPE] === "string") { + type = dragonBones.DataParser._getBoundingBoxType(rawData[dragonBones.DataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + boundingBox = dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var polygonBoundingBox = dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + if (dragonBones.DataParser.VERTICES in rawData) { + var scale = this._armature.scale; + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertices = polygonBoundingBox.vertices; + vertices.length = rawVertices.length; + for (var i = 0, l = rawVertices.length; i < l; i += 2) { + var x = rawVertices[i] * scale; + var y = rawVertices[i + 1] * scale; + vertices[i] = x; + vertices[i + 1] = y; + // AABB. + if (i === 0) { + polygonBoundingBox.x = x; + polygonBoundingBox.y = y; + polygonBoundingBox.width = x; + polygonBoundingBox.height = y; + } + else { + if (x < polygonBoundingBox.x) { + polygonBoundingBox.x = x; + } + else if (x > polygonBoundingBox.width) { + polygonBoundingBox.width = x; + } + if (y < polygonBoundingBox.y) { + polygonBoundingBox.y = y; + } + else if (y > polygonBoundingBox.height) { + polygonBoundingBox.height = y; + } + } + } + polygonBoundingBox.width -= polygonBoundingBox.x; + polygonBoundingBox.height -= polygonBoundingBox.y; + } + else { + console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug."); + } + return polygonBoundingBox; + }; + ObjectDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.blendType = dragonBones.DataParser._getAnimationBlendType(ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); + animation.frameCount = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; // float + animation.fadeInTime = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.DataParser.DEFAULT_NAME; + } + animation.frameIntOffset = this._frameIntArray.length; + animation.frameFloatOffset = this._frameFloatArray.length; + animation.frameOffset = this._frameArray.length; + this._animation = animation; + if (dragonBones.DataParser.FRAME in rawData) { + var rawFrames = rawData[dragonBones.DataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount > 0) { + for (var i = 0, frameStart = 0; i < keyFrameCount; ++i) { + var rawFrame = rawFrames[i]; + this._parseActionDataInFrame(rawFrame, frameStart, null, null); + frameStart += ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + } + if (dragonBones.DataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[dragonBones.DataParser.Z_ORDER], null, dragonBones.DataParser.FRAME, 1 /* ZOrder */, 0 /* Step */, 0, this._parseZOrderFrame); + } + if (dragonBones.DataParser.BONE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (dragonBones.DataParser.FFD in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var skinName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SKIN, dragonBones.DataParser.DEFAULT_NAME); + var slotName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + if (skinName.length === 0) { // + skinName = dragonBones.DataParser.DEFAULT_NAME; + } + this._slot = this._armature.getSlot(slotName); + this._mesh = this._armature.getMesh(skinName, slotName, displayName); + if (this._slot === null || this._mesh === null) { + continue; + } + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 22 /* SlotDeform */, 2 /* Float */, 0, this._parseSlotDeformFrame); + if (timeline !== null) { + this._animation.addSlotTimeline(slotName, timeline); + } + this._slot = null; // + this._mesh = null; // + } + } + if (dragonBones.DataParser.IK in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.IK]; + for (var _c = 0, rawTimelines_4 = rawTimelines; _c < rawTimelines_4.length; _c++) { + var rawTimeline = rawTimelines_4[_c]; + var constraintName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var constraint = this._armature.getConstraint(constraintName); + if (constraint === null) { + continue; + } + var timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, 30 /* IKConstraint */, 1 /* Int */, 2, this._parseIKConstraintFrame); + if (timeline !== null) { + this._animation.addConstraintTimeline(constraintName, timeline); + } + } + } + if (this._actionFrames.length > 0) { + this._animation.actionTimeline = this._parseTimeline(null, this._actionFrames, "", 0 /* Action */, 0 /* Step */, 0, this._parseActionFrame); + this._actionFrames.length = 0; + } + if (dragonBones.DataParser.TIMELINE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; + for (var _d = 0, rawTimelines_5 = rawTimelines; _d < rawTimelines_5.length; _d++) { + var rawTimeline = rawTimelines_5[_d]; + var timelineType = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = null; + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 20 /* SlotDisplay */: // TODO + case 23 /* SlotZIndex */: + case 60 /* BoneAlpha */: + case 24 /* SlotAlpha */: + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + if (timelineType === 20 /* SlotDisplay */) { + this._frameValueType = 0 /* Step */; + this._frameValueScale = 1.0; + } + else { + this._frameValueType = 1 /* Int */; + if (timelineType === 23 /* SlotZIndex */) { + this._frameValueScale = 1.0; + } + else if (timelineType === 40 /* AnimationProgress */ || + timelineType === 41 /* AnimationWeight */) { + this._frameValueScale = 10000.0; + } + else { + this._frameValueScale = 100.0; + } + } + if (timelineType === 60 /* BoneAlpha */ || + timelineType === 24 /* SlotAlpha */ || + timelineType === 41 /* AnimationWeight */) { + this._frameDefaultValue = 1.0; + } + else { + this._frameDefaultValue = 0.0; + } + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); + var animaitonTimeline = timeline; + animaitonTimeline.x = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 1, this._parseSingleValueFrame, timeline); + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 30 /* IKConstraint */: + case 42 /* AnimationParameter */: + if (timelineType === 30 /* IKConstraint */ || + timelineType === 42 /* AnimationParameter */) { + this._frameValueType = 1 /* Int */; + if (timelineType === 42 /* AnimationParameter */) { + this._frameValueScale = 10000.0; + } + else { + this._frameValueScale = 100.0; + } + } + else { + if (timelineType === 12 /* BoneRotate */) { + this._frameValueScale = dragonBones.Transform.DEG_RAD; + } + else { + this._frameValueScale = 1.0; + } + this._frameValueType = 2 /* Float */; + } + if (timelineType === 13 /* BoneScale */ || + timelineType === 30 /* IKConstraint */) { + this._frameDefaultValue = 1.0; + } + else { + this._frameDefaultValue = 0.0; + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, this._frameValueType, 2, this._parseDoubleValueFrame); + break; + case 1 /* ZOrder */: + // TODO + break; + case 50 /* Surface */: { + var surface = this._armature.getBone(timelineName); + if (surface === null) { + continue; + } + this._geometry = surface.geometry; + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); + this._geometry = null; // + break; + } + case 22 /* SlotDeform */: { + this._geometry = null; // + for (var skinName in this._armature.skins) { + var skin = this._armature.skins[skinName]; + for (var slontName in skin.displays) { + var displays = skin.displays[slontName]; + for (var _e = 0, displays_1 = displays; _e < displays_1.length; _e++) { + var display = displays_1[_e]; + if (display !== null && display.name === timelineName) { + this._geometry = display.geometry; + break; + } + } + } + } + if (this._geometry === null) { + continue; + } + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 2 /* Float */, 0, this._parseDeformFrame); + this._geometry = null; // + break; + } + case 21 /* SlotColor */: + timeline = this._parseTimeline(rawTimeline, null, dragonBones.DataParser.FRAME, timelineType, 1 /* Int */, 1, this._parseSlotColorFrame); + break; + } + if (timeline !== null) { + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 1 /* ZOrder */: + // TODO + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 50 /* Surface */: + case 60 /* BoneAlpha */: + this._animation.addBoneTimeline(timelineName, timeline); + break; + case 20 /* SlotDisplay */: + case 21 /* SlotColor */: + case 22 /* SlotDeform */: + case 23 /* SlotZIndex */: + case 24 /* SlotAlpha */: + this._animation.addSlotTimeline(timelineName, timeline); + break; + case 30 /* IKConstraint */: + this._animation.addConstraintTimeline(timelineName, timeline); + break; + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + case 42 /* AnimationParameter */: + this._animation.addAnimationTimeline(timelineName, timeline); + break; + } + } + } + } + this._animation = null; // + return animation; + }; + ObjectDataParser.prototype._parseTimeline = function (rawData, rawFrames, framesKey, timelineType, frameValueType, frameValueCount, frameParser, timeline) { + if (timeline === void 0) { timeline = null; } + if (rawData !== null && framesKey.length > 0 && framesKey in rawData) { + rawFrames = rawData[framesKey]; + } + if (rawFrames === null) { + return null; + } + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var frameIntArrayLength = this._frameIntArray.length; + var frameFloatArrayLength = this._frameFloatArray.length; + var timelineOffset = this._timelineArray.length; + if (timeline === null) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + } + timeline.type = timelineType; + timeline.offset = timelineOffset; + this._frameValueType = frameValueType; + this._timeline = timeline; + this._timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + if (rawData !== null) { + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0) * 100); + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0.0) * 100); + } + else { + this._timelineArray[timelineOffset + 0 /* TimelineScale */] = 100; + this._timelineArray[timelineOffset + 1 /* TimelineOffset */] = 0; + } + this._timelineArray[timelineOffset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + this._timelineArray[timelineOffset + 3 /* TimelineFrameValueCount */] = frameValueCount; + switch (this._frameValueType) { + case 0 /* Step */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = 0; + break; + case 1 /* Int */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + break; + case 2 /* Float */: + this._timelineArray[timelineOffset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + break; + } + if (keyFrameCount === 1) { // Only one frame. + timeline.frameIndicesOffset = -1; + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + var frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var rawFrame = rawFrames[iK]; + frameStart = i; // frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + if (rawFrame instanceof ActionFrame) { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + else { + frameCount = ObjectDataParser._getNumber(rawFrame, dragonBones.DataParser.DURATION, 1); + } + } + this._timelineArray[timelineOffset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; // + return timeline; + }; + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + if (dragonBones.DataParser.TRANSLATE_FRAME in rawData) { + this._frameDefaultValue = 0.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.TRANSLATE_FRAME, 11 /* BoneTranslate */, 2 /* Float */, 2, this._parseDoubleValueFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.ROTATE_FRAME in rawData) { + this._frameDefaultValue = 0.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.ROTATE_FRAME, 12 /* BoneRotate */, 2 /* Float */, 2, this._parseBoneRotateFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.SCALE_FRAME in rawData) { + this._frameDefaultValue = 1.0; + this._frameValueScale = 1.0; + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.SCALE_FRAME, 13 /* BoneScale */, 2 /* Float */, 2, this._parseBoneScaleFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + if (dragonBones.DataParser.FRAME in rawData) { + var timeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 10 /* BoneAll */, 2 /* Float */, 6, this._parseBoneAllFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone.name, timeline); + } + } + this._bone = null; // + this._slot = null; // + }; + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, "")); + if (slot === null) { + return; + } + var displayTimeline = null; + var colorTimeline = null; + this._slot = slot; + if (dragonBones.DataParser.DISPLAY_FRAME in rawData) { + displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.DISPLAY_FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); + } + else { + displayTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 20 /* SlotDisplay */, 0 /* Step */, 0, this._parseSlotDisplayFrame); + } + if (dragonBones.DataParser.COLOR_FRAME in rawData) { + colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.COLOR_FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); + } + else { + colorTimeline = this._parseTimeline(rawData, null, dragonBones.DataParser.FRAME, 21 /* SlotColor */, 1 /* Int */, 1, this._parseSlotColorFrame); + } + if (displayTimeline !== null) { + this._animation.addSlotTimeline(slot.name, displayTimeline); + } + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot.name, colorTimeline); + } + this._slot = null; // + }; + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount) { + // tslint:disable-next-line:no-unused-expression + rawData; + // tslint:disable-next-line:no-unused-expression + frameCount; + var frameOffset = this._frameArray.length; + this._frameArray.length += 1; + this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (frameCount > 0) { + if (dragonBones.DataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + var isOmited = this._samplingEasingCurve(rawData[dragonBones.DataParser.CURVE], this._helpArray); + this._frameArray.length += 1 + 1 + this._helpArray.length; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = isOmited ? sampleCount : -sampleCount; + for (var i = 0; i < sampleCount; ++i) { + this._frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (dragonBones.DataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + this._frameArray.length += 1 + 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + this._frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + this._frameArray.length += 1; + this._frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseSingleValueFrame = function (rawData, frameStart, frameCount) { + var frameOffset = 0; + switch (this._frameValueType) { + case 0: { + frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue); + break; + } + case 1: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale); + break; + } + case 2: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 1; + this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, this._frameDefaultValue) * this._frameValueScale; + break; + } + } + return frameOffset; + }; + ObjectDataParser.prototype._parseDoubleValueFrame = function (rawData, frameStart, frameCount) { + var frameOffset = 0; + switch (this._frameValueType) { + case 0: { + frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 2; + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue); + this._frameArray[frameOffset + 2] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue); + break; + } + case 1: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameValueOffset] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale); + this._frameIntArray[frameValueOffset + 1] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale); + break; + } + case 2: { + frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameValueOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameValueOffset] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, this._frameDefaultValue) * this._frameValueScale; + this._frameFloatArray[frameValueOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, this._frameDefaultValue) * this._frameValueScale; + break; + } + } + return frameOffset; + }; + ObjectDataParser.prototype._parseActionFrame = function (frame, frameStart, frameCount) { + // tslint:disable-next-line:no-unused-expression + frameCount; + var frameOffset = this._frameArray.length; + var actionCount = frame.actions.length; + this._frameArray.length += 1 + 1 + actionCount; + this._frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + this._frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { // Action offsets. + this._frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + if (dragonBones.DataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[dragonBones.DataParser.Z_ORDER]; + if (rawZOrder.length > 0) { + var slotCount = this._armature.sortedSlots.length; + var unchanged = new Array(slotCount - rawZOrder.length / 2); + var zOrders = new Array(slotCount); + for (var i_1 = 0; i_1 < unchanged.length; ++i_1) { + unchanged[i_1] = 0; + } + for (var i_2 = 0; i_2 < slotCount; ++i_2) { + zOrders[i_2] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_3 = 0, l = rawZOrder.length; i_3 < l; i_3 += 2) { + var slotIndex = rawZOrder[i_3]; + var zOrderOffset = rawZOrder[i_3 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + var index = originalIndex + zOrderOffset; + zOrders[index] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + this._frameArray.length += 1 + slotCount; + this._frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + this._frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex] || 0; + } + else { + this._frameArray[frameOffset + 2 + i] = zOrders[i] || 0; + } + } + return frameOffset; + } + } + this._frameArray.length += 1; + this._frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneAllFrame = function (rawData, frameStart, frameCount) { + this._helpTransform.identity(); + if (dragonBones.DataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[dragonBones.DataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevClockwise === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + // + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 6; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + this._frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneTranslateFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneRotateFrame = function (rawData, frameStart, frameCount) { + // Modify rotation. + var rotation = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD; + if (frameStart !== 0) { + if (this._prevClockwise === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevClockwise > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevClockwise = this._prevClockwise > 0 ? this._prevClockwise - 1 : this._prevClockwise + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevClockwise; + } + } + this._prevClockwise = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.CLOCK_WISE, 0); + this._prevRotation = rotation; + // + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = rotation; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD; + return frameOffset; + }; + ObjectDataParser.prototype._parseBoneScaleFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameFloatOffset = this._frameFloatArray.length; + this._frameFloatArray.length += 2; + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 1.0); + this._frameFloatArray[frameFloatOffset++] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 1.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDisplayFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount); + this._frameArray.length += 1; + if (dragonBones.DataParser.VALUE in rawData) { + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.VALUE, 0); + } + else { + this._frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DISPLAY_INDEX, 0); + } + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var colorOffset = -1; + if (dragonBones.DataParser.VALUE in rawData || dragonBones.DataParser.COLOR in rawData) { + var rawColor = dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : rawData[dragonBones.DataParser.COLOR]; + for (var k in rawColor) { // Detects the presence of color. + // tslint:disable-next-line:no-unused-expression + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = this._colorArray.length; + this._colorArray.length += 8; + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + this._colorArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defaultColorOffset < 0) { + this._defaultColorOffset = colorOffset = this._colorArray.length; + this._colorArray.length += 8; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 100; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + this._colorArray[colorOffset++] = 0; + } + colorOffset = this._defaultColorOffset; + } + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1; + this._frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + ObjectDataParser.prototype._parseSlotDeformFrame = function (rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? rawData[dragonBones.DataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._mesh.geometry.offset + 0 /* GeometryVertexCount */]; + var meshName = this._mesh.parent.name + "_" + this._slot.name + "_" + this._mesh.name; + var weight = this._mesh.geometry.weight; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (weight !== null) { + var rawSlotPose = this._weightSlotPose[meshName]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + this._frameFloatArray.length += weight.count * 2; + iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.bones.length; + } + else { + this._frameFloatArray.length += vertexCount * 2; + } + for (var i = 0; i < vertexCount * 2; i += 2) { + if (rawVertices === null) { // Fill 0. + x = 0.0; + y = 0.0; + } + else { + if (i < offset || i - offset >= rawVertices.length) { + x = 0.0; + } + else { + x = rawVertices[i - offset]; + } + if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { + y = 0.0; + } + else { + y = rawVertices[i + 1 - offset]; + } + } + if (weight !== null) { // If mesh is skinned, transform point by bone bind pose. + var rawBonePoses = this._weightBonePoses[meshName]; + var vertexBoneCount = this._intArray[iB++]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var boneIndex = this._intArray[iB++]; + this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + this._frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._mesh.geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; + this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseIKConstraintFrame = function (rawData, frameStart, frameCount) { + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 2; + this._frameIntArray[frameIntOffset++] = ObjectDataParser._getBoolean(rawData, dragonBones.DataParser.BEND_POSITIVE, true) ? 1 : 0; + this._frameIntArray[frameIntOffset++] = Math.round(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WEIGHT, 1.0) * 100.0); + return frameOffset; + }; + ObjectDataParser.prototype._parseActionData = function (rawData, type, bone, slot) { + var actions = new Array(); + if (typeof rawData === "string") { + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + actions.push(action); + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_2 = rawData; _i < rawData_2.length; _i++) { + var rawAction = rawData_2[_i]; + var action = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (dragonBones.DataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.GOTO_AND_PLAY, ""); + } + else { + if (dragonBones.DataParser.TYPE in rawAction && typeof rawAction[dragonBones.DataParser.TYPE] === "string") { + action.type = dragonBones.DataParser._getActionType(rawAction[dragonBones.DataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, dragonBones.DataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, dragonBones.DataParser.NAME, ""); + } + if (dragonBones.DataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (dragonBones.DataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, dragonBones.DataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + var userData = null; + if (dragonBones.DataParser.INTS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[dragonBones.DataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + userData.addInt(rawValue); + } + } + if (dragonBones.DataParser.FLOATS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[dragonBones.DataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + userData.addFloat(rawValue); + } + } + if (dragonBones.DataParser.STRINGS in rawAction) { + if (userData === null) { + userData = dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[dragonBones.DataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + userData.addString(rawValue); + } + } + action.data = userData; + actions.push(action); + } + } + return actions; + }; + ObjectDataParser.prototype._parseDeformFrame = function (rawData, frameStart, frameCount) { + var frameFloatOffset = this._frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount); + var rawVertices = dragonBones.DataParser.VERTICES in rawData ? + rawData[dragonBones.DataParser.VERTICES] : + (dragonBones.DataParser.VALUE in rawData ? rawData[dragonBones.DataParser.VALUE] : null); + var offset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.OFFSET, 0); // uint + var vertexCount = this._intArray[this._geometry.offset + 0 /* GeometryVertexCount */]; + var weight = this._geometry.weight; + var x = 0.0; + var y = 0.0; + if (weight !== null) { + // TODO + } + else { + this._frameFloatArray.length += vertexCount * 2; + for (var i = 0; i < vertexCount * 2; i += 2) { + if (rawVertices !== null) { + if (i < offset || i - offset >= rawVertices.length) { + x = 0.0; + } + else { + x = rawVertices[i - offset]; + } + if (i + 1 < offset || i + 1 - offset >= rawVertices.length) { + y = 0.0; + } + else { + y = rawVertices[i + 1 - offset]; + } + } + else { + x = 0.0; + y = 0.0; + } + this._frameFloatArray[frameFloatOffset + i] = x; + this._frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntOffset = this._frameIntArray.length; + this._frameIntArray.length += 1 + 1 + 1 + 1 + 1; + this._frameIntArray[frameIntOffset + 0 /* DeformVertexOffset */] = this._geometry.offset; + this._frameIntArray[frameIntOffset + 1 /* DeformCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 2 /* DeformValueCount */] = this._frameFloatArray.length - frameFloatOffset; + this._frameIntArray[frameIntOffset + 3 /* DeformValueOffset */] = 0; + this._frameIntArray[frameIntOffset + 4 /* DeformFloatOffset */] = frameFloatOffset - this._animation.frameFloatOffset; + this._timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.Y, 0.0) * scale; + if (dragonBones.DataParser.ROTATE in rawData || dragonBones.DataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (dragonBones.DataParser.SKEW_X in rawData || dragonBones.DataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE_Y, 1.0); + }; + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.BLUE_OFFSET, 0); + }; + ObjectDataParser.prototype._parseGeometry = function (rawData, geometry) { + var rawVertices = rawData[dragonBones.DataParser.VERTICES]; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = 0; + var geometryOffset = this._intArray.length; + var verticesOffset = this._floatArray.length; + // + geometry.offset = geometryOffset; + geometry.data = this._data; + // + this._intArray.length += 1 + 1 + 1 + 1; + this._intArray[geometryOffset + 0 /* GeometryVertexCount */] = vertexCount; + this._intArray[geometryOffset + 2 /* GeometryFloatOffset */] = verticesOffset; + this._intArray[geometryOffset + 3 /* GeometryWeightOffset */] = -1; // + // + this._floatArray.length += vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + this._floatArray[verticesOffset + i] = rawVertices[i]; + } + if (dragonBones.DataParser.TRIANGLES in rawData) { + var rawTriangles = rawData[dragonBones.DataParser.TRIANGLES]; + triangleCount = Math.floor(rawTriangles.length / 3); // uint + // + this._intArray.length += triangleCount * 3; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + this._intArray[geometryOffset + 4 /* GeometryVertexIndices */ + i] = rawTriangles[i]; + } + } + // Fill triangle count. + this._intArray[geometryOffset + 1 /* GeometryTriangleCount */] = triangleCount; + if (dragonBones.DataParser.UVS in rawData) { + var rawUVs = rawData[dragonBones.DataParser.UVS]; + var uvOffset = verticesOffset + vertexCount * 2; + this._floatArray.length += vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + this._floatArray[uvOffset + i] = rawUVs[i]; + } + } + if (dragonBones.DataParser.WEIGHTS in rawData) { + var rawWeights = rawData[dragonBones.DataParser.WEIGHTS]; + var weightCount = Math.floor(rawWeights.length - vertexCount) / 2; // uint + var weightOffset = this._intArray.length; + var floatOffset = this._floatArray.length; + var weightBoneCount = 0; + var sortedBones = this._armature.sortedBones; + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = weightCount; + weight.offset = weightOffset; + this._intArray.length += 1 + 1 + weightBoneCount + vertexCount + weightCount; + this._intArray[weightOffset + 1 /* WeigthFloatOffset */] = floatOffset; + if (dragonBones.DataParser.BONE_POSE in rawData) { + var rawSlotPose = rawData[dragonBones.DataParser.SLOT_POSE]; + var rawBonePoses = rawData[dragonBones.DataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + weightBoneIndices.length = weightBoneCount; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + weightBoneIndices[i] = rawBoneIndex; + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += weightCount * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = this._intArray[iB++] = rawWeights[iW++]; // uint + var x = this._floatArray[verticesOffset + iD]; + var y = this._floatArray[verticesOffset + iD + 1]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint); + x = this._helpPoint.x; + y = this._helpPoint.y; + for (var j = 0; j < vertexBoneCount; ++j) { + var rawBoneIndex = rawWeights[iW++]; // uint + var boneIndex = weightBoneIndices.indexOf(rawBoneIndex); + this._helpMatrixB.copyFromArray(rawBonePoses, boneIndex * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + this._intArray[iB++] = boneIndex; + this._floatArray[iV++] = rawWeights[iW++]; + this._floatArray[iV++] = this._helpPoint.x; + this._floatArray[iV++] = this._helpPoint.y; + } + } + } + else { + var rawBones = rawData[dragonBones.DataParser.BONES]; + weightBoneCount = rawBones.length; + for (var i = 0; i < weightBoneCount; i++) { + var rawBoneIndex = rawBones[i]; + var bone = this._rawBones[rawBoneIndex]; + weight.addBone(bone); + this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i] = sortedBones.indexOf(bone); + } + this._floatArray.length += weightCount * 3; + for (var i = 0, iW = 0, iV = 0, iB = weightOffset + 2 /* WeigthBoneIndices */ + weightBoneCount, iF = floatOffset; i < weightCount; i++) { + var vertexBoneCount = rawWeights[iW++]; + this._intArray[iB++] = vertexBoneCount; + for (var j = 0; j < vertexBoneCount; j++) { + var boneIndex = rawWeights[iW++]; + var boneWeight = rawWeights[iW++]; + var x = rawVertices[iV++]; + var y = rawVertices[iV++]; + this._intArray[iB++] = rawBones.indexOf(boneIndex); + this._floatArray[iF++] = boneWeight; + this._floatArray[iF++] = x; + this._floatArray[iF++] = y; + } + } + } + geometry.weight = weight; + } + }; + ObjectDataParser.prototype._parseArray = function (rawData) { + // tslint:disable-next-line:no-unused-expression + rawData; + this._intArray.length = 0; + this._floatArray.length = 0; + this._frameIntArray.length = 0; + this._frameFloatArray.length = 0; + this._frameArray.length = 0; + this._timelineArray.length = 0; + this._colorArray.length = 0; + }; + ObjectDataParser.prototype._modifyArray = function () { + // Align. + if ((this._intArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._intArray.push(0); + } + if ((this._frameIntArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._frameIntArray.push(0); + } + if ((this._frameArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._frameArray.push(0); + } + if ((this._timelineArray.length % Uint16Array.BYTES_PER_ELEMENT) !== 0) { + this._timelineArray.push(0); + } + if ((this._timelineArray.length % Int16Array.BYTES_PER_ELEMENT) !== 0) { + this._colorArray.push(0); + } + var l1 = this._intArray.length * Int16Array.BYTES_PER_ELEMENT; + var l2 = this._floatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l3 = this._frameIntArray.length * Int16Array.BYTES_PER_ELEMENT; + var l4 = this._frameFloatArray.length * Float32Array.BYTES_PER_ELEMENT; + var l5 = this._frameArray.length * Int16Array.BYTES_PER_ELEMENT; + var l6 = this._timelineArray.length * Uint16Array.BYTES_PER_ELEMENT; + var l7 = this._colorArray.length * Int16Array.BYTES_PER_ELEMENT; + var lTotal = l1 + l2 + l3 + l4 + l5 + l6 + l7; + // + var binary = new ArrayBuffer(lTotal); + var intArray = new Int16Array(binary, 0, this._intArray.length); + var floatArray = new Float32Array(binary, l1, this._floatArray.length); + var frameIntArray = new Int16Array(binary, l1 + l2, this._frameIntArray.length); + var frameFloatArray = new Float32Array(binary, l1 + l2 + l3, this._frameFloatArray.length); + var frameArray = new Int16Array(binary, l1 + l2 + l3 + l4, this._frameArray.length); + var timelineArray = new Uint16Array(binary, l1 + l2 + l3 + l4 + l5, this._timelineArray.length); + var colorArray = new Int16Array(binary, l1 + l2 + l3 + l4 + l5 + l6, this._colorArray.length); + for (var i = 0, l = this._intArray.length; i < l; ++i) { + intArray[i] = this._intArray[i]; + } + for (var i = 0, l = this._floatArray.length; i < l; ++i) { + floatArray[i] = this._floatArray[i]; + } + for (var i = 0, l = this._frameIntArray.length; i < l; ++i) { + frameIntArray[i] = this._frameIntArray[i]; + } + for (var i = 0, l = this._frameFloatArray.length; i < l; ++i) { + frameFloatArray[i] = this._frameFloatArray[i]; + } + for (var i = 0, l = this._frameArray.length; i < l; ++i) { + frameArray[i] = this._frameArray[i]; + } + for (var i = 0, l = this._timelineArray.length; i < l; ++i) { + timelineArray[i] = this._timelineArray[i]; + } + for (var i = 0, l = this._colorArray.length; i < l; ++i) { + colorArray[i] = this._colorArray[i]; + } + this._data.binary = binary; + this._data.intArray = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = frameArray; + this._data.timelineArray = timelineArray; + this._data.colorArray = colorArray; + this._defaultColorOffset = -1; + }; + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined, "Data error."); + var version = ObjectDataParser._getString(rawData, dragonBones.DataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, dragonBones.DataParser.COMPATIBLE_VERSION, ""); + if (dragonBones.DataParser.DATA_VERSIONS.indexOf(version) >= 0 || + dragonBones.DataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { // Data error. + data.frameRate = 24; + } + if (dragonBones.DataParser.ARMATURE in rawData) { + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[dragonBones.DataParser.ARMATURE]; + for (var _i = 0, rawArmatures_1 = rawArmatures; _i < rawArmatures_1.length; _i++) { + var rawArmature = rawArmatures_1[_i]; + data.addArmature(this._parseArmature(rawArmature, scale)); + } + if (!this._data.binary) { // DragonBones.webAssembly ? 0 : null; + this._modifyArray(); + } + if (dragonBones.DataParser.STAGE in rawData) { + data.stage = data.getArmature(ObjectDataParser._getString(rawData, dragonBones.DataParser.STAGE, "")); + } + else if (data.armatureNames.length > 0) { + data.stage = data.getArmature(data.armatureNames[0]); + } + this._data = null; + } + if (dragonBones.DataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[dragonBones.DataParser.TEXTURE_ATLAS]; + } + return data; + } + else { + console.assert(false, "Nonsupport data version: " + version + "\n" + + "Please convert DragonBones data to support version.\n" + + "Read more: https://github.com/DragonBones/Tools/"); + } + return null; + }; + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 1.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null || this._rawTextureAtlases.length === 0) { + return false; + } + var rawTextureAtlas = this._rawTextureAtlases[this._rawTextureAtlasIndex++]; + this.parseTextureAtlasData(rawTextureAtlas, textureAtlasData, scale); + if (this._rawTextureAtlasIndex >= this._rawTextureAtlases.length) { + this._rawTextureAtlasIndex = 0; + this._rawTextureAtlases = null; + } + return true; + } + // Texture format. + textureAtlasData.width = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, dragonBones.DataParser.HEIGHT, 0); + textureAtlasData.scale = scale === 1.0 ? (1.0 / ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0)) : scale; + textureAtlasData.name = ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, dragonBones.DataParser.IMAGE_PATH, ""); + if (dragonBones.DataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[dragonBones.DataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var frameWidth = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_HEIGHT, -1.0); + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, dragonBones.DataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, dragonBones.DataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.X, 0.0); + textureData.region.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.Y, 0.0); + textureData.region.width = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.WIDTH, 0.0); + textureData.region.height = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.HEIGHT, 0.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_X, 0.0); + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, dragonBones.DataParser.FRAME_Y, 0.0); + textureData.frame.width = frameWidth; + textureData.frame.height = frameHeight; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + /** + * @private + */ + var ActionFrame = /** @class */ (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); + dragonBones.ActionFrame = ActionFrame; +})(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 BinaryDataParser = /** @class */ (function (_super) { + __extends(BinaryDataParser, _super); + function BinaryDataParser() { + return _super !== null && _super.apply(this, arguments) || this; + } + BinaryDataParser.prototype._inRange = function (a, min, max) { + return min <= a && a <= max; + }; + BinaryDataParser.prototype._decodeUTF8 = function (data) { + var EOF_byte = -1; + var EOF_code_point = -1; + var FATAL_POINT = 0xFFFD; + var pos = 0; + var result = ""; + var code_point; + var utf8_code_point = 0; + var utf8_bytes_needed = 0; + var utf8_bytes_seen = 0; + var utf8_lower_boundary = 0; + while (data.length > pos) { + var _byte = data[pos++]; + if (_byte === EOF_byte) { + if (utf8_bytes_needed !== 0) { + code_point = FATAL_POINT; + } + else { + code_point = EOF_code_point; + } + } + else { + if (utf8_bytes_needed === 0) { + if (this._inRange(_byte, 0x00, 0x7F)) { + code_point = _byte; + } + else { + if (this._inRange(_byte, 0xC2, 0xDF)) { + utf8_bytes_needed = 1; + utf8_lower_boundary = 0x80; + utf8_code_point = _byte - 0xC0; + } + else if (this._inRange(_byte, 0xE0, 0xEF)) { + utf8_bytes_needed = 2; + utf8_lower_boundary = 0x800; + utf8_code_point = _byte - 0xE0; + } + else if (this._inRange(_byte, 0xF0, 0xF4)) { + utf8_bytes_needed = 3; + utf8_lower_boundary = 0x10000; + utf8_code_point = _byte - 0xF0; + } + else { + } + utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); + code_point = null; + } + } + else if (!this._inRange(_byte, 0x80, 0xBF)) { + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + pos--; + code_point = _byte; + } + else { + utf8_bytes_seen += 1; + utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + if (utf8_bytes_seen !== utf8_bytes_needed) { + code_point = null; + } + else { + var cp = utf8_code_point; + var lower_boundary = utf8_lower_boundary; + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + if (this._inRange(cp, lower_boundary, 0x10FFFF) && !this._inRange(cp, 0xD800, 0xDFFF)) { + code_point = cp; + } + else { + code_point = _byte; + } + } + } + } + //Decode string + if (code_point !== null && code_point !== EOF_code_point) { + if (code_point <= 0xFFFF) { + if (code_point > 0) + result += String.fromCharCode(code_point); + } + else { + code_point -= 0x10000; + result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); + result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); + } + } + } + return result; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + var timeline = timelineData !== null ? timelineData : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArrayBuffer[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var frameIndicesOffset = 0; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + timeline.frameIndicesOffset = frameIndicesOffset; + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArrayBuffer[this._animation.frameOffset + this._timelineArrayBuffer[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + frameIndices[frameIndicesOffset + i] = iK - 1; + } + } + this._timeline = null; // + return timeline; + }; + BinaryDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.blendType = dragonBones.DataParser._getAnimationBlendType(dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.BLEND_TYPE, "")); + animation.frameCount = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.DURATION, 0); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; // float + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.DataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.DataParser.NAME, dragonBones.DataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.DataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.DataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.DataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.DataParser.ACTION]); + } + if (dragonBones.DataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.DataParser.Z_ORDER]); + } + if (dragonBones.DataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var bone = this._armature.getBone(k); + if (bone === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addBoneTimeline(bone.name, timeline); + } + } + } + if (dragonBones.DataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var slot = this._armature.getSlot(k); + if (slot === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addSlotTimeline(slot.name, timeline); + } + } + } + if (dragonBones.DataParser.CONSTRAINT in rawData) { + var rawTimeliness = rawData[dragonBones.DataParser.CONSTRAINT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + var constraint = this._armature.getConstraint(k); + if (constraint === null) { + continue; + } + for (var i = 0, l = rawTimelines.length; i < l; i += 2) { + var timelineType = rawTimelines[i]; + var timelineOffset = rawTimelines[i + 1]; + var timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addConstraintTimeline(constraint.name, timeline); + } + } + } + if (dragonBones.DataParser.TIMELINE in rawData) { + var rawTimelines = rawData[dragonBones.DataParser.TIMELINE]; + for (var _i = 0, rawTimelines_6 = rawTimelines; _i < rawTimelines_6.length; _i++) { + var rawTimeline = rawTimelines_6[_i]; + var timelineOffset = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.OFFSET, 0); + if (timelineOffset >= 0) { + var timelineType = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.TYPE, 0 /* Action */); + var timelineName = dragonBones.ObjectDataParser._getString(rawTimeline, dragonBones.DataParser.NAME, ""); + var timeline = null; + if (timelineType === 40 /* AnimationProgress */ && animation.blendType !== 0 /* None */) { + timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineData); + var animaitonTimeline = timeline; + animaitonTimeline.x = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.X, 0.0); + animaitonTimeline.y = dragonBones.ObjectDataParser._getNumber(rawTimeline, dragonBones.DataParser.Y, 0.0); + } + timeline = this._parseBinaryTimeline(timelineType, timelineOffset, timeline); + switch (timelineType) { + case 0 /* Action */: + // TODO + break; + case 1 /* ZOrder */: + // TODO + break; + case 11 /* BoneTranslate */: + case 12 /* BoneRotate */: + case 13 /* BoneScale */: + case 50 /* Surface */: + case 60 /* BoneAlpha */: + this._animation.addBoneTimeline(timelineName, timeline); + break; + case 20 /* SlotDisplay */: + case 21 /* SlotColor */: + case 22 /* SlotDeform */: + case 23 /* SlotZIndex */: + case 24 /* SlotAlpha */: + this._animation.addSlotTimeline(timelineName, timeline); + break; + case 30 /* IKConstraint */: + this._animation.addConstraintTimeline(timelineName, timeline); + break; + case 40 /* AnimationProgress */: + case 41 /* AnimationWeight */: + case 42 /* AnimationParameter */: + this._animation.addAnimationTimeline(timelineName, timeline); + break; + } + } + } + } + this._animation = null; + return animation; + }; + BinaryDataParser.prototype._parseGeometry = function (rawData, geometry) { + geometry.offset = rawData[dragonBones.DataParser.OFFSET]; + geometry.data = this._data; + var weightOffset = this._intArrayBuffer[geometry.offset + 3 /* GeometryWeightOffset */]; + if (weightOffset >= 0) { + var weight = dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArrayBuffer[geometry.offset + 0 /* GeometryVertexCount */]; + var boneCount = this._intArrayBuffer[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArrayBuffer[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.addBone(this._rawBones[boneIndex]); + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + var weightCount = 0; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArrayBuffer[boneIndicesOffset++]; + weightCount += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + weight.count = weightCount; + geometry.weight = weight; + } + }; + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.DataParser.OFFSET]; + var l1 = offsets[1]; + var l2 = offsets[3]; + var l3 = offsets[5]; + var l4 = offsets[7]; + var l5 = offsets[9]; + var l6 = offsets[11]; + var l7 = offsets.length > 12 ? offsets[13] : 0; // Color. + var intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], l1 / Int16Array.BYTES_PER_ELEMENT); + var floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], l2 / Float32Array.BYTES_PER_ELEMENT); + var frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], l3 / Int16Array.BYTES_PER_ELEMENT); + var frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], l4 / Float32Array.BYTES_PER_ELEMENT); + var frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], l5 / Int16Array.BYTES_PER_ELEMENT); + var timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], l6 / Uint16Array.BYTES_PER_ELEMENT); + var colorArray = l7 > 0 ? new Int16Array(this._binary, this._binaryOffset + offsets[12], l7 / Int16Array.BYTES_PER_ELEMENT) : intArray; // Color. + this._data.binary = this._binary; + this._data.intArray = this._intArrayBuffer = intArray; + this._data.floatArray = floatArray; + this._data.frameIntArray = frameIntArray; + this._data.frameFloatArray = frameFloatArray; + this._data.frameArray = this._frameArrayBuffer = frameArray; + this._data.timelineArray = this._timelineArrayBuffer = timelineArray; + this._data.colorArray = colorArray; + }; + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer, "Data error."); + var tag = new Uint8Array(rawData, 0, 8); + if (tag[0] !== "D".charCodeAt(0) || + tag[1] !== "B".charCodeAt(0) || + tag[2] !== "D".charCodeAt(0) || + tag[3] !== "T".charCodeAt(0)) { + console.assert(false, "Nonsupport data."); + return null; + } + var headerLength = new Uint32Array(rawData, 8, 1)[0]; + var headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); + var headerString = this._decodeUTF8(headerBytes); + var header = JSON.parse(headerString); + // + this._binaryOffset = 8 + 4 + headerLength; + this._binary = rawData; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * - Deprecated, please refer to {@link dragonBones.BaseFactory#parseDragonBonesData()}. + * @deprecated + * @language en_US + */ + /** + * - 已废弃,请参考 {@link dragonBones.BaseFactory#parseDragonBonesData()}。 + * @deprecated + * @language zh_CN + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(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) { + /** + * - Base class for the factory that create the armatures. (Typically only one global factory instance is required) + * The factory instance create armatures by parsed and added DragonBonesData instances and TextureAtlasData instances. + * Once the data has been parsed, it has been cached in the factory instance and does not need to be parsed again until it is cleared by the factory instance. + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建骨架的工厂基类。 (通常只需要一个全局工厂实例) + * 工厂通过解析并添加的 DragonBonesData 实例和 TextureAtlasData 实例来创建骨架。 + * 当数据被解析过之后,已经添加到工厂中,在没有被工厂清理之前,不需要再次解析。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = /** @class */ (function () { + /** + * - Create a factory instance. (typically only one global factory instance is required) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建一个工厂实例。 (通常只需要一个全局工厂实例) + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * @private + */ + this.autoSearch = false; + this._dragonBonesDataMap = {}; + this._textureAtlasDataMap = {}; + this._dragonBones = null; + this._dataParser = null; + if (BaseFactory._objectParser === null) { + BaseFactory._objectParser = new dragonBones.ObjectDataParser(); + } + if (BaseFactory._binaryParser === null) { + BaseFactory._binaryParser = new dragonBones.BinaryDataParser(); + } + this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; + } + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + BaseFactory.prototype._getTextureData = function (textureAtlasName, textureName) { + if (textureAtlasName in this._textureAtlasDataMap) { + for (var _i = 0, _a = this._textureAtlasDataMap[textureAtlasName]; _i < _a.length; _i++) { + var textureAtlasData = _a[_i]; + var textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + if (this.autoSearch) { // Will be search all data, if the autoSearch is true. + for (var k in this._textureAtlasDataMap) { + for (var _b = 0, _c = this._textureAtlasDataMap[k]; _b < _c.length; _b++) { + var textureAtlasData = _c[_b]; + if (textureAtlasData.autoSearch) { + var textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + } + } + return null; + }; + BaseFactory.prototype._fillBuildArmaturePackage = function (dataPackage, dragonBonesName, armatureName, skinName, textureAtlasName) { + var dragonBonesData = null; + var armatureData = null; + if (dragonBonesName.length > 0) { + if (dragonBonesName in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; + armatureData = dragonBonesData.getArmature(armatureName); + } + } + if (armatureData === null && (dragonBonesName.length === 0 || this.autoSearch)) { // Will be search all data, if do not give a data name or the autoSearch is true. + for (var k in this._dragonBonesDataMap) { + dragonBonesData = this._dragonBonesDataMap[k]; + if (dragonBonesName.length === 0 || dragonBonesData.autoSearch) { + armatureData = dragonBonesData.getArmature(armatureName); + if (armatureData !== null) { + dragonBonesName = k; + break; + } + } + } + } + if (armatureData !== null) { + dataPackage.dataName = dragonBonesName; + dataPackage.textureAtlasName = textureAtlasName; + dataPackage.data = dragonBonesData; + dataPackage.armature = armatureData; + dataPackage.skin = null; + if (skinName.length > 0) { + dataPackage.skin = armatureData.getSkin(skinName); + if (dataPackage.skin === null && this.autoSearch) { + for (var k in this._dragonBonesDataMap) { + var skinDragonBonesData = this._dragonBonesDataMap[k]; + var skinArmatureData = skinDragonBonesData.getArmature(skinName); + if (skinArmatureData !== null) { + dataPackage.skin = skinArmatureData.defaultSkin; + break; + } + } + } + } + if (dataPackage.skin === null) { + dataPackage.skin = armatureData.defaultSkin; + } + return true; + } + return false; + }; + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + for (var _i = 0, _a = dataPackage.armature.sortedBones; _i < _a.length; _i++) { + var boneData = _a[_i]; + var bone = dragonBones.BaseObject.borrowObject(boneData.type === 0 /* Bone */ ? dragonBones.Bone : dragonBones.Surface); + bone.init(boneData, armature); + } + }; + /** + * @private + */ + BaseFactory.prototype._buildSlots = function (dataPackage, armature) { + var currentSkin = dataPackage.skin; + var defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin === null || defaultSkin === null) { + return; + } + var skinSlots = {}; + for (var k in defaultSkin.displays) { + var displays = defaultSkin.getDisplays(k); + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.getDisplays(k); + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + var displayDatas = slotData.name in skinSlots ? skinSlots[slotData.name] : null; + var slot = this._buildSlot(dataPackage, slotData, armature); + if (displayDatas !== null) { + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + slot.replaceRawDisplayData(displayData, i); + if (displayData !== null) { + if (dataPackage.textureAtlasName.length > 0) { + var textureData = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + slot.replaceTextureData(textureData, i); + } + var display = this._getSlotDisplay(dataPackage, displayData, slot); + slot.replaceDisplay(display, i); + } + else { + slot.replaceDisplay(null); + } + } + } + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + BaseFactory.prototype._buildConstraints = function (dataPackage, armature) { + var constraints = dataPackage.armature.constraints; + for (var k in constraints) { + var constraintData = constraints[k]; + // TODO more constraint type. + switch (constraintData.type) { + case 0 /* IK */: + var ikConstraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + ikConstraint.init(constraintData, armature); + armature._addConstraint(ikConstraint); + break; + case 1 /* Path */: + var pathConstraint = dragonBones.BaseObject.borrowObject(dragonBones.PathConstraint); + pathConstraint.init(constraintData, armature); + armature._addConstraint(pathConstraint); + break; + default: + var constraint = dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + constraint.init(constraintData, armature); + armature._addConstraint(constraint); + break; + } + } + }; + BaseFactory.prototype._buildChildArmature = function (dataPackage, _slot, displayData) { + return this.buildArmature(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage !== null ? dataPackage.textureAtlasName : ""); + }; + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.parent.name; + var display = null; + switch (displayData.type) { + case 0 /* Image */: { + var imageDisplayData = displayData; + if (imageDisplayData.texture === null) { + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); + } + display = slot.rawDisplay; + break; + } + case 2 /* Mesh */: { + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + } + case 1 /* Armature */: { + var armatureDisplayData = displayData; + var childArmature = this._buildChildArmature(dataPackage, slot, armatureDisplayData); + if (childArmature !== null) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + var actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.length > 0) { + for (var _i = 0, actions_6 = actions; _i < actions_6.length; _i++) { + var action = actions_6[_i]; + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + dragonBones.EventObject.actionDataToInstance(action, eventObject, slot.armature); + eventObject.slot = slot; + slot.armature._bufferAction(eventObject, false); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + case 3 /* BoundingBox */: + break; + default: + break; + } + return display; + }; + /** + * - Parse the raw data to a DragonBonesData instance and cache it to the factory. + * @param rawData - The raw data. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for all armatures. (Default: 1.0) + * @returns DragonBonesData instance + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始数据解析为 DragonBonesData 实例,并缓存到工厂中。 + * @param rawData - 原始数据。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为所有的骨架指定一个缩放值。 (默认: 1.0) + * @returns DragonBonesData 实例 + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.parseDragonBonesData = function (rawData, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 1.0; } + var dataParser = rawData instanceof ArrayBuffer ? BaseFactory._binaryParser : this._dataParser; + var dragonBonesData = dataParser.parseDragonBonesData(rawData, scale); + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * - Parse the raw texture atlas data and the texture atlas object to a TextureAtlasData instance and cache it to the factory. + * @param rawData - The raw texture atlas data. + * @param textureAtlas - The texture atlas object. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (If not set, use the instance name instead) + * @param scale - Specify a scaling value for the map set. (Default: 1.0) + * @returns TextureAtlasData instance + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 将原始贴图集数据和贴图集对象解析为 TextureAtlasData 实例,并缓存到工厂中。 + * @param rawData - 原始贴图集数据。 + * @param textureAtlas - 贴图集对象。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @param scale - 为贴图集指定一个缩放值。 (默认: 1.0) + * @returns TextureAtlasData 实例 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 1.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * - Update texture atlases. + * @param textureAtlases - The texture atlas objects. + * @param name - The texture atlas name. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 更新贴图集对象。 + * @param textureAtlases - 多个贴图集对象。 + * @param name - 贴图集名称。 + * @version DragonBones 5.7 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlases = function (textureAtlases, name) { + var textureAtlasDatas = this.getTextureAtlasData(name); + if (textureAtlasDatas !== null) { + for (var i = 0, l = textureAtlasDatas.length; i < l; ++i) { + if (i < textureAtlases.length) { + this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); + } + } + } + }; + /** + * - Get a specific DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @returns DragonBonesData instance + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 DragonBonesData 实例。 + * @param name - DragonBonesData 实例的缓存名称。 + * @returns DragonBonesData 实例 + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.getDragonBonesData = function (name) { + return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; + }; + /** + * - Cache a DragonBonesData instance to the factory. + * @param data - The DragonBonesData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 DragonBonesData 实例缓存到工厂中。 + * @param data - DragonBonesData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.addDragonBonesData = function (data, name) { + if (name === void 0) { name = null; } + name = name !== null ? name : data.name; + if (name in this._dragonBonesDataMap) { + if (this._dragonBonesDataMap[name] === data) { + return; + } + console.warn("Can not add same name data: " + name); + return; + } + this._dragonBonesDataMap[name] = data; + }; + /** + * - Remove a DragonBonesData instance. + * @param name - The DragonBonesData instance cache name. + * @param disposeData - Whether to dispose data. (Default: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 DragonBonesData 实例。 + * @param name - DragonBonesData 实例缓存名称。 + * @param disposeData - 是否释放数据。 (默认: true) + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.removeDragonBonesData = function (name, disposeData) { + if (disposeData === void 0) { disposeData = true; } + if (name in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); + } + delete this._dragonBonesDataMap[name]; + } + }; + /** + * - Get a list of specific TextureAtlasData instances. + * @param name - The TextureAtlasData cahce name. + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 获取特定的 TextureAtlasData 实例列表。 + * @param name - TextureAtlasData 实例缓存名称。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.getTextureAtlasData = function (name) { + return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; + }; + /** + * - Cache a TextureAtlasData instance to the factory. + * @param data - The TextureAtlasData instance. + * @param name - Specify a cache name for the instance so that the instance can be obtained through this name. (if not set, use the instance name instead) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 将 TextureAtlasData 实例缓存到工厂中。 + * @param data - TextureAtlasData 实例。 + * @param name - 为该实例指定一个缓存名称,以便可以通过此名称获取该实例。 (如果未设置,则使用该实例中的名称) + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.addTextureAtlasData = function (data, name) { + if (name === void 0) { name = null; } + name = name !== null ? name : data.name; + var textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); + if (textureAtlasList.indexOf(data) < 0) { + textureAtlasList.push(data); + } + }; + /** + * - Remove a TextureAtlasData instance. + * @param name - The TextureAtlasData instance cache name. + * @param disposeData - Whether to dispose data. + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 移除 TextureAtlasData 实例。 + * @param name - TextureAtlasData 实例的缓存名称。 + * @param disposeData - 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.removeTextureAtlasData = function (name, disposeData) { + if (disposeData === void 0) { disposeData = true; } + if (name in this._textureAtlasDataMap) { + var textureAtlasDataList = this._textureAtlasDataMap[name]; + if (disposeData) { + for (var _i = 0, textureAtlasDataList_1 = textureAtlasDataList; _i < textureAtlasDataList_1.length; _i++) { + var textureAtlasData = textureAtlasDataList_1[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[name]; + } + }; + /** + * - Get a specific armature data. + * @param name - The armature data name. + * @param dragonBonesName - The cached name for DragonbonesData instance. + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language en_US + */ + /** + * - 获取特定的骨架数据。 + * @param name - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.getArmatureData = function (name, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { + return null; + } + return dataPackage.armature; + }; + /** + * - Clear all cached DragonBonesData instances and TextureAtlasData instances. + * @param disposeData - Whether to dispose data. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 清除缓存的所有 DragonBonesData 实例和 TextureAtlasData 实例。 + * @param disposeData - 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.clear = function (disposeData) { + if (disposeData === void 0) { disposeData = true; } + for (var k in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); + } + delete this._dragonBonesDataMap[k]; + } + for (var k in this._textureAtlasDataMap) { + if (disposeData) { + var textureAtlasDataList = this._textureAtlasDataMap[k]; + for (var _i = 0, textureAtlasDataList_2 = textureAtlasDataList; _i < textureAtlasDataList_2.length; _i++) { + var textureAtlasData = textureAtlasDataList_2[_i]; + this._dragonBones.bufferObject(textureAtlasData); + } + } + delete this._textureAtlasDataMap[k]; + } + }; + /** + * - Create a armature from cached DragonBonesData instances and TextureAtlasData instances. + * Note that when the created armature that is no longer in use, you need to explicitly dispose {@link #dragonBones.Armature#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature. + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架。 + * 注意,创建的骨架不再使用时,需要显式释放 {@link #dragonBones.Armature#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架。 + * @example + *
+         *     let armature = factory.buildArmature("armatureName", "dragonBonesName");
+         *     armature.clock = factory.clock;
+         * 
+ * @see dragonBones.DragonBonesData + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + if (skinName === void 0) { skinName = ""; } + if (textureAtlasName === void 0) { textureAtlasName = ""; } + var dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { + console.warn("No armature data: " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); + return null; + } + var armature = this._buildArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + this._buildConstraints(dataPackage, armature); + armature.invalidUpdate(null, true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * @private + */ + BaseFactory.prototype.replaceDisplay = function (slot, displayData, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + slot.replaceDisplayData(displayData, displayIndex); + if (displayData !== null) { + var display = this._getSlotDisplay(null, displayData, slot); + if (displayData.type === 0 /* Image */) { + var rawDisplayData = slot.getDisplayFrameAt(displayIndex).rawDisplayData; + if (rawDisplayData !== null && + rawDisplayData.type === 2 /* Mesh */) { + display = slot.meshDisplay; + } + } + slot.replaceDisplay(display, displayIndex); + } + else { + slot.replaceDisplay(null, displayIndex); + } + }; + /** + * - Replaces the current display data for a particular slot with a specific display data. + * Specify display data with "dragonBonesName/armatureName/slotName/displayName". + * @param dragonBonesName - The DragonBonesData instance cache name. + * @param armatureName - The armature data name. + * @param slotName - The slot data name. + * @param displayName - The display data name. + * @param slot - The slot. + * @param displayIndex - The index of the display data that is replaced. (If it is not set, replaces the current display data) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 用特定的显示对象数据替换特定插槽当前的显示对象数据。 + * 用 "dragonBonesName/armatureName/slotName/displayName" 指定显示对象数据。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 + * @param armatureName - 骨架数据名称。 + * @param slotName - 插槽数据名称。 + * @param displayName - 显示对象数据名称。 + * @param slot - 插槽。 + * @param displayIndex - 被替换的显示对象数据的索引。 (如果未设置,则替换当前的显示对象数据) + * @example + *
+         *     let slot = armature.getSlot("weapon");
+         *     factory.replaceSlotDisplay("dragonBonesName", "armatureName", "slotName", "displayName", slot);
+         * 
+ * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (armatureData === null || armatureData.defaultSkin === null) { + return false; + } + var displayData = armatureData.defaultSkin.getDisplay(slotName, displayName); + this.replaceDisplay(slot, displayData, displayIndex); + return true; + }; + /** + * @private + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var armatureData = this.getArmatureData(armatureName, dragonBonesName || ""); + if (!armatureData || !armatureData.defaultSkin) { + return false; + } + var displayDatas = armatureData.defaultSkin.getDisplays(slotName); + if (!displayDatas) { + return false; + } + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + this.replaceDisplay(slot, displayData, i); + } + return true; + }; + /** + * - Share specific skin data with specific armature. + * @param armature - The armature. + * @param skin - The skin data. + * @param isOverride - Whether it completely override the original skin. (Default: false) + * @param exclude - A list of slot names that do not need to be replace. + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 将特定的皮肤数据共享给特定的骨架使用。 + * @param armature - 骨架。 + * @param skin - 皮肤数据。 + * @param isOverride - 是否完全覆盖原来的皮肤。 (默认: false) + * @param exclude - 不需要被替换的插槽名称列表。 + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB && armatureDataB.defaultSkin) {
+         *     factory.replaceSkin(armatureA, armatureDataB.defaultSkin, false, ["arm_l", "weapon_l"]);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.6 + * @language zh_CN + */ + BaseFactory.prototype.replaceSkin = function (armature, skin, isOverride, exclude) { + if (isOverride === void 0) { isOverride = false; } + if (exclude === void 0) { exclude = null; } + var success = false; + var defaultSkin = skin.parent.defaultSkin; + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (exclude !== null && exclude.indexOf(slot.name) >= 0) { + continue; + } + var displayDatas = skin.getDisplays(slot.name); + if (displayDatas === null) { + if (defaultSkin !== null && skin !== defaultSkin) { + displayDatas = defaultSkin.getDisplays(slot.name); + } + if (displayDatas === null) { + if (isOverride) { + slot.displayFrameCount = 0; + } + continue; + } + } + slot.displayFrameCount = displayDatas.length; + for (var i = 0, l = slot.displayFrameCount; i < l; ++i) { + var displayData = displayDatas[i]; + slot.replaceRawDisplayData(displayData, i); + if (displayData !== null) { + slot.replaceDisplay(this._getSlotDisplay(null, displayData, slot), i); + } + else { + slot.replaceDisplay(null, i); + } + } + success = true; + } + return success; + }; + /** + * - Replaces the existing animation data for a specific armature with the animation data for the specific armature data. + * This enables you to make a armature template so that other armature without animations can share it's animations. + * @param armature - The armtaure. + * @param armatureData - The armature data. + * @param isOverride - Whether to completely overwrite the original animation. (Default: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language en_US + */ + /** + * - 用特定骨架数据的动画数据替换特定骨架现有的动画数据。 + * 这样就能实现制作一个骨架动画模板,让其他没有制作动画的骨架共享该动画。 + * @param armature - 骨架。 + * @param armatureData - 骨架数据。 + * @param isOverride - 是否完全覆盖原来的动画。(默认: false) + * @example + *
+         *     let armatureA = factory.buildArmature("armatureA", "dragonBonesA");
+         *     let armatureDataB = factory.getArmatureData("armatureB", "dragonBonesB");
+         *     if (armatureDataB) {
+         *     factory.replaceAnimation(armatureA, armatureDataB);
+         *     }
+         * 
+ * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 5.6 + * @language zh_CN + */ + BaseFactory.prototype.replaceAnimation = function (armature, armatureData, isOverride) { + if (isOverride === void 0) { isOverride = true; } + var skinData = armatureData.defaultSkin; + if (skinData === null) { + return false; + } + if (isOverride) { + armature.animation.animations = armatureData.animations; + } + else { + var rawAnimations = armature.animation.animations; + var animations = {}; + for (var k in rawAnimations) { + animations[k] = rawAnimations[k]; + } + for (var k in armatureData.animations) { + animations[k] = armatureData.animations[k]; + } + armature.animation.animations = animations; + } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var index = 0; + for (var _b = 0, _c = slot.displayList; _b < _c.length; _b++) { + var display = _c[_b]; + if (display instanceof dragonBones.Armature) { + var displayDatas = skinData.getDisplays(slot.name); + if (displayDatas !== null && index < displayDatas.length) { + var displayData = displayDatas[index]; + if (displayData !== null && displayData.type === 1 /* Armature */) { + var childArmatureData = this.getArmatureData(displayData.path, displayData.parent.parent.parent.name); + if (childArmatureData) { + this.replaceAnimation(display, childArmatureData, isOverride); + } + } + } + } + index++; + } + } + return true; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + Object.defineProperty(BaseFactory.prototype, "clock", { + /** + * - An Worldclock instance updated by engine. + * @version DragonBones 5.7 + * @language en_US + */ + /** + * - 由引擎驱动的 WorldClock 实例。 + * @version DragonBones 5.7 + * @language zh_CN + */ + get: function () { + return this._dragonBones.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseFactory.prototype, "dragonBones", { + /** + * @private + */ + get: function () { + return this._dragonBones; + }, + enumerable: true, + configurable: true + }); + BaseFactory._objectParser = null; + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; + /** + * @private + */ + var BuildArmaturePackage = /** @class */ (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; +})(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. + */ +if (CC_EDITOR) { + _Scene.Sandbox._globalsVerifier_loadPluginScript.ignoreNames['dragonBones'] = true; +} +var dragonBones; +(function (dragonBones) { + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property; + var DragonBonesAsset = /** @class */ (function (_super) { + __extends(DragonBonesAsset, _super); + function DragonBonesAsset() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.dragonBonesData = ""; + _this.textureAtlases = []; + _this.textures = []; + return _this; + } + __decorate([ + property + ], DragonBonesAsset.prototype, "dragonBonesData", void 0); + __decorate([ + property([cc.String]) + ], DragonBonesAsset.prototype, "textureAtlases", void 0); + __decorate([ + property([cc.Texture2D]) + ], DragonBonesAsset.prototype, "textures", void 0); + DragonBonesAsset = __decorate([ + ccclass("DragonBones.DragonBonesAsset") + ], DragonBonesAsset); + return DragonBonesAsset; + }(cc.Asset)); + dragonBones.DragonBonesAsset = DragonBonesAsset; +})(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 Cocos texture atlas data. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosTextureAtlasData = /** @class */ (function (_super) { + __extends(CocosTextureAtlasData, _super); + function CocosTextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._renderTexture = null; // Initial value. + return _this; + } + CocosTextureAtlasData.toString = function () { + return "[class dragonBones.CocosTextureAtlasData]"; + }; + CocosTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this._renderTexture !== null) { + // this._renderTexture.dispose(); + } + this._renderTexture = null; + }; + CocosTextureAtlasData.prototype.createTexture = function () { + return dragonBones.BaseObject.borrowObject(CocosTextureData); + }; + Object.defineProperty(CocosTextureAtlasData.prototype, "renderTexture", { + /** + * - The Cocos texture. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._renderTexture; + }, + set: function (value) { + if (this._renderTexture === value) { + return; + } + this._renderTexture = value; + if (this._renderTexture !== null) { + for (var k in this.textures) { + var textureData = this.textures[k]; + if (textureData.renderTexture !== null) { + textureData.renderTexture.destroy(); + } + var reat = cc.rect(textureData.region.x, textureData.region.y, textureData.rotated ? textureData.region.height : textureData.region.width, textureData.rotated ? textureData.region.width : textureData.region.height); + var offset = cc.v2(); + var originSize = cc.size(reat.size.width, reat.size.height); + textureData.renderTexture = new cc.SpriteFrame(this._renderTexture, reat, textureData.rotated, offset, originSize); + } + } + else { + for (var k in this.textures) { + var textureData = this.textures[k]; + if (textureData.renderTexture !== null) { + textureData.renderTexture.destroy(); + } + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + return CocosTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.CocosTextureAtlasData = CocosTextureAtlasData; + /** + * @internal + */ + var CocosTextureData = /** @class */ (function (_super) { + __extends(CocosTextureData, _super); + function CocosTextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.renderTexture = null; // Initial value. + return _this; + } + CocosTextureData.toString = function () { + return "[class dragonBones.CocosTextureData]"; + }; + CocosTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + this.renderTexture.destroy(); + } + this.renderTexture = null; + }; + return CocosTextureData; + }(dragonBones.TextureData)); + dragonBones.CocosTextureData = CocosTextureData; +})(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) { + // const _defaultItems = cc.Enum({ "None": -1 }); + // function _setItems(object: any, key: string, items: any) { + // (cc.Class as any).attr( // creator.d.ts error. + // object, + // key, + // { + // type: "Enum", + // enumList: (cc.Enum as any).getList(items), // creator.d.ts error. + // } + // ); + // } + var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property, executeInEditMode = _a.executeInEditMode, disallowMultiple = _a.disallowMultiple, playOnFocus = _a.playOnFocus, menu = _a.menu, help = _a.help; + /** + * @see dragonBones.IArmatureProxy + */ + var CocosArmatureComponent = /** @class */ (function (_super) { + __extends(CocosArmatureComponent, _super); + function CocosArmatureComponent() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @private + */ + _this.debugDraw = false; + _this._debugDraw = false; + /** + * @internal + */ + _this._armature = null; + // Editor. + /** + * @internal + */ + _this._armatureName = ""; + _this.dragonBonesName = ''; + /** + * @internal + */ + _this._animationName = ""; + // Visibie. + /** + * @internal + */ + _this._dragonBonesAsset = null; + /** + * @internal + */ + _this._armatureNames = []; + /** + * @internal + */ + _this._animationNames = []; + /** + * @internal + */ + _this._playTimes = -1; + /** + * @internal + */ + _this._timeScale = 1.0; + return _this; + } + CocosArmatureComponent_1 = CocosArmatureComponent; + CocosArmatureComponent.prototype.dbInit = function (armature) { + this._armature = armature; + }; + CocosArmatureComponent.prototype.dbClear = function () { + this._armature = null; + _super.prototype.destroy.call(this); + }; + CocosArmatureComponent.prototype.dbUpdate = function () { + var drawed = dragonBones.DragonBones.debugDraw || this.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + } + }; + CocosArmatureComponent.prototype.dispose = function (_isposeProxy) { + if (_isposeProxy === void 0) { _isposeProxy = true; } + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + CocosArmatureComponent.prototype.destroy = function () { + this.dispose(); + if (false) { // `super.destroy()` will be called in `dbClear()`. + _super.prototype.destroy.call(this); + } + return true; + }; + /** + * @private + */ + CocosArmatureComponent.prototype.dispatchDBEvent = function (type, eventObject) { + var event = new cc.Event.EventCustom(type, false); + event.setUserData(eventObject); + this.node.dispatchEvent(event); + }; + CocosArmatureComponent.prototype.hasDBEventListener = function (type) { + return this.node.hasEventListener(type, false); // creator.d.ts error. + }; + CocosArmatureComponent.prototype.addDBEventListener = function (type, listener, target) { + this.node.on(type, listener, target); + }; + CocosArmatureComponent.prototype.removeDBEventListener = function (type, listener, target) { + this.node.off(type, listener, target); + }; + Object.defineProperty(CocosArmatureComponent.prototype, "armature", { + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CocosArmatureComponent.prototype, "animation", { + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(CocosArmatureComponent.prototype, "dragonBonesAsset", { + get: function () { + return this._dragonBonesAsset || null; + }, + set: function (value) { + this._dragonBonesAsset = value; + this._loadAndDisplayDragonBones(); + }, + enumerable: true, + configurable: true + }); + CocosArmatureComponent.prototype._loadAndDisplayDragonBones = function () { + console.warn("\u5F00\u59CB\u521B\u5EFA DragonBones Armature"); + var notExistAsset = !this.dragonBonesAsset + || !this.dragonBonesAsset.dragonBonesData + || !this.dragonBonesAsset.textureAtlases + || !this.dragonBonesAsset.textures; + if (notExistAsset) { + console.error("dragonBonesAsset \u4E3A\u7A7A"); + return; + } + console.warn("\u521B\u5EFA DragonBones Armature"); + this._parseDragonAsset(); + this._parseDragonAtlasAsset(); + this.display(); + }; + CocosArmatureComponent.prototype._parseDragonAsset = function () { + var dragonBonesData; + if (typeof this.dragonBonesAsset.dragonBonesData === 'string') { + console.log("JSON.parse(this.dragonBonesAsset.dragonBonesData)"); + dragonBonesData = JSON.parse(this.dragonBonesAsset.dragonBonesData); + } + else { + dragonBonesData = this.dragonBonesAsset.dragonBonesData; + } + var data = dragonBones.CocosFactory.factory.parseDragonBonesData(dragonBonesData); + if (!data) { + console.warn("DragonBones Armature not exist"); + return; + } + this._armatureName = data.armatureNames[0]; + console.log("parseDragonBonesData", data); + }; + CocosArmatureComponent.prototype._parseDragonAtlasAsset = function () { + var _this = this; + var textureAtlases = this.dragonBonesAsset.textureAtlases; + if (typeof textureAtlases[0] === 'string') { + console.log('JSON.parse(this.dragonBonesAsset.textureAtlases)'); + textureAtlases = JSON.parse(textureAtlases); + } + else { + textureAtlases = this.dragonBonesAsset.textureAtlases; + } + var texture = Array.isArray(this.dragonBonesAsset.textures) ? this.dragonBonesAsset.textures[0] : this.dragonBonesAsset.textures; + if (typeof texture === 'string') { + cc.textureCache.addImage(texture, function (tex, error) { + if (error) { + console.error("error:" + error.message, error); + return; + } + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(textureAtlases, tex); + console.log("parseTextureAtlasData", data); + console.log("dragonBonesAsset", _this.dragonBonesAsset); + console.log("textureAtlases", textureAtlases); + console.log("texture", tex); + }, this); + } + else { + var data = dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, texture); + console.log("string parseTextureAtlasData", data); + console.log("string dragonBonesAsset", this.dragonBonesAsset); + } + }; + CocosArmatureComponent.prototype.display = function () { + console.warn("Armature name:" + this._armatureName + ",dragonBonesName:" + this.dragonBonesName); + var armatureComponent = dragonBones.CocosFactory.factory.buildArmatureComponent(this._armatureName, this.dragonBonesName); + if (!armatureComponent) { + console.log("armatureComponent is null"); + return; + } + armatureComponent.animation.play(armatureComponent.animation.animationNames[0], 0); + armatureComponent.node.x = 0.0; + armatureComponent.node.y = 0; + this.node.addChild(armatureComponent.node); + this._dragonBonesNode = armatureComponent.node; + console.log("play animation default animation"); + }; + CocosArmatureComponent.prototype.onLoad = function () { + // this.display(); + if (this._dragonBonesNode) { + var component = this._dragonBonesNode.getComponent(CocosArmatureComponent_1); + var state = component.animation.play(component.animation.animationNames[0], 0); + if (!state) { + return; + } + console.warn("\u64AD\u653E\u52A8\u753B\uFF1A" + state.name, state); + } + else { + this._loadAndDisplayDragonBones(); + // this.onLoad(); + // dragonBones.CocosFactory.factory.parseDragonBonesData(this.dragonBonesAsset.dragonBonesData); + // dragonBones.CocosFactory.factory.parseTextureAtlasData(this.dragonBonesAsset.textureAtlases, this.dragonBonesAsset.textures); + } + }; + var CocosArmatureComponent_1; + __decorate([ + property + ], CocosArmatureComponent.prototype, "_armatureName", void 0); + __decorate([ + property + ], CocosArmatureComponent.prototype, "_animationName", void 0); + __decorate([ + property(dragonBones.DragonBonesAsset) + ], CocosArmatureComponent.prototype, "_dragonBonesAsset", void 0); + __decorate([ + property({ + type: dragonBones.DragonBonesAsset, + displayName: "DragonBones", + tooltip: "DragonBones Asset", + }) + ], CocosArmatureComponent.prototype, "dragonBonesAsset", null); + __decorate([ + property({ + type: [cc.String], + displayName: "Armature", + tooltip: "The armature name.", + visible: true, + serializable: false, + }) + ], CocosArmatureComponent.prototype, "_armatureNames", void 0); + __decorate([ + property({ + type: [cc.String], + displayName: "Animation", + tooltip: "The animation name.", + visible: true, + serializable: false, + }) + ], CocosArmatureComponent.prototype, "_animationNames", void 0); + __decorate([ + property({ + type: cc.Integer, + displayName: "Play times", + tooltip: "The animation play times.", + visible: true, + slide: true, + range: [-1, 99, 1], + }) + ], CocosArmatureComponent.prototype, "_playTimes", void 0); + __decorate([ + property({ + type: cc.Float, + displayName: "TimeScale", + tooltip: "The animation play speed.", + visible: true, + slide: true, + range: [-2, 2, 0.01], + }) + ], CocosArmatureComponent.prototype, "_timeScale", void 0); + CocosArmatureComponent = CocosArmatureComponent_1 = __decorate([ + ccclass("CocosArmatureComponent"), + executeInEditMode, + disallowMultiple, + playOnFocus, + menu("DragonBones/Armature"), + executeInEditMode, + help("https://github.com/DragonBones/") + ], CocosArmatureComponent); + return CocosArmatureComponent; + }(cc.Component)); + dragonBones.CocosArmatureComponent = CocosArmatureComponent; +})(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 Cocos slot. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosSlot = /** @class */ (function (_super) { + __extends(CocosSlot, _super); + function CocosSlot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._ccMeshDirty = false; + return _this; + } + CocosSlot.toString = function () { + return "[class dragonBones.CocosSlot]"; + }; + CocosSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._textureScale = 1.0; + this._renderDisplay = null; + }; + CocosSlot.prototype._initDisplay = function (_value, _isRetain) { + }; + CocosSlot.prototype._disposeDisplay = function (value, isRelease) { + if (!isRelease) { + value.destroy(); + } + }; + CocosSlot.prototype._onUpdateDisplay = function () { + this._renderDisplay = (this._display ? this._display : this._rawDisplay); + }; + CocosSlot.prototype._addDisplay = function () { + var container = this._armature.display; + container.addChild(this._renderDisplay, this._zOrder); + }; + CocosSlot.prototype._replaceDisplay = function (value) { + var container = this._armature.display; + var prevDisplay = value; + if (this._renderDisplay.parent !== container) { + container.addChild(this._renderDisplay, prevDisplay.getLocalZOrder()); + } + // container.removeChild(prevDisplay, false); + this._renderDisplay.active = true; + prevDisplay.active = false; + this._textureScale = 1.0; + }; + CocosSlot.prototype._removeDisplay = function () { + this._renderDisplay.parent.removeChild(this._renderDisplay, false); + }; + CocosSlot.prototype._updateZOrder = function () { + if (this._renderDisplay.getLocalZOrder() === this._zOrder) { + return; + } + this._renderDisplay.setLocalZOrder(this._zOrder); + }; + /** + * @internal + */ + CocosSlot.prototype._updateVisible = function () { + this._renderDisplay.active = this._parent.visible && this._visible; + }; + CocosSlot.prototype._updateBlendMode = function () { + var sprite = this._renderDisplay.getComponent(cc.Sprite); + if (sprite) { + switch (this._blendMode) { + case 0 /* Normal */: + break; + case 1 /* Add */: + var texture = sprite.spriteFrame.getTexture(); + var BlendFunc = cc.BlendFunc; // creator.d.ts error. + if (texture && texture.hasPremultipliedAlpha()) { + sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.ONE, BlendFunc.BlendFactor.ONE); // creator.d.ts error. + } + else { + sprite._sgNode.setBlendFunc(BlendFunc.BlendFactor.SRC_ALPHA, BlendFunc.BlendFactor.ONE); // creator.d.ts error. + } + break; + case 3 /* Darken */: + break; + case 4 /* Difference */: + break; + case 6 /* HardLight */: + break; + case 9 /* Lighten */: + break; + case 10 /* Multiply */: + break; + case 11 /* Overlay */: + break; + case 12 /* Screen */: + break; + default: + break; + } + } + else if (this._childArmature !== null) { + for (var _i = 0, _a = this._childArmature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + slot._blendMode = this._blendMode; + slot._updateBlendMode(); + } + } + }; + CocosSlot.prototype._updateColor = function () { + var alpha = this._colorTransform.alphaMultiplier * this._globalAlpha * 255; + var color = this._renderDisplay.color; + this._renderDisplay.opacity = alpha; + color.setR(this._colorTransform.redMultiplier * 0xFF); + color.setG(this._colorTransform.greenMultiplier * 0xFF); + color.setB(this._colorTransform.blueMultiplier * 0xFF); + this._renderDisplay.setColor(color); // creator.d.ts error. + }; + CocosSlot.prototype._updateFrame = function () { + var currentTextureData = this._textureData; + var sprite = this._renderDisplay.getComponent(cc.Sprite); + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + var currentTextureAtlasData = currentTextureData.parent; + if (this._armature.replacedTexture !== null) { // Update replaced texture atlas. + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData; + } + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); + } + var renderTexture = currentTextureData.renderTexture; + if (renderTexture !== null) { + if (this._geometryData !== null) { // Mesh. + var data = this._geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[this._geometryData.offset + 0 /* GeometryVertexCount */]; + var triangleCount = intArray[this._geometryData.offset + 1 /* GeometryTriangleCount */]; + var vertexOffset = intArray[this._geometryData.offset + 2 /* GeometryFloatOffset */]; + if (vertexOffset < 0) { + vertexOffset += 65536; // Fixed out of bouds bug. + } + var uvOffset = vertexOffset + vertexCount * 2; + var scale = this._armature._armatureData.scale; + var textureAtlasSize = renderTexture.getTexture().getContentSizeInPixels(); + var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : textureAtlasSize.width; + var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : textureAtlasSize.height; + var region = currentTextureData.region; + var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); + var polygonInfo = { + triangles: { + verts: [], + indices: [] + }, + rect: boundsRect + }; + for (var i = 0, l = vertexCount * 2; i < l; i += 2) { + var vertex = { + x: floatArray[vertexOffset + i] * scale, + y: -floatArray[vertexOffset + i + 1] * scale, + u: floatArray[uvOffset + i], + v: floatArray[uvOffset + i + 1] + }; + if (currentTextureData.rotated) { + var backU = vertex.u; + vertex.u = (region.x + (1.0 - vertex.v) * region.width) / textureAtlasWidth; + vertex.v = (region.y + backU * region.height) / textureAtlasHeight; + } + else { + vertex.u = (region.x + vertex.u * region.width) / textureAtlasWidth; + vertex.v = (region.y + vertex.v * region.height) / textureAtlasHeight; + } + polygonInfo.triangles.verts[i / 2] = vertex; + if (boundsRect.x > vertex.x) { + boundsRect.x = vertex.x; + } + if (boundsRect.width < vertex.x) { + boundsRect.width = vertex.x; + } + if (boundsRect.y > vertex.y) { + boundsRect.y = vertex.y; + } + if (boundsRect.height < vertex.y) { + boundsRect.height = vertex.y; + } + } + for (var i = 0; i < triangleCount * 3; ++i) { + polygonInfo.triangles.indices[i] = intArray[this._geometryData.offset + 4 /* GeometryVertexIndices */ + i]; + } + this._textureScale = 1.0; + sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.MESH); // creator.d.ts error. + sprite.spriteFrame = renderTexture; + sprite._sgNode.setMeshPolygonInfo(polygonInfo); // creator.d.ts error. + sprite._sgNode.setContentSize(cc.size(boundsRect.width, boundsRect.height)); // creator.d.ts error. + var isSkinned = this._geometryData.weight !== null; + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + if (isSkinned || isSurface) { + this._identityTransform(); + } + // Delay to update cocos mesh. (some cocos bug.) + this._ccMeshDirty = true; + } + else { // Normal texture. + this._textureScale = currentTextureData.parent.scale * this._armature._armatureData.scale; + sprite._sgNode.setRenderingType(cc.Scale9Sprite.RenderingType.SIMPLE); // creator.d.ts error. + sprite.spriteFrame = renderTexture; + sprite._sgNode.setContentSize(renderTexture.getOriginalSize()); // creator.d.ts error. + } + this._visibleDirty = true; + // this._blendModeDirty = true; + // this._colorDirty = true; + return; + } + } + this._renderDisplay.active = false; + this._renderDisplay.setPosition(0.0, 0.0); + }; + CocosSlot.prototype._updateMesh = function () { + var scale = this._armature._armatureData.scale; + var deformVertices = this._displayFrame.deformVertices; + var bones = this._geometryBones; + var geometryData = this._geometryData; + var weightData = geometryData.weight; + var hasDeform = deformVertices.length > 0 && geometryData.inheritDeform; + var meshDisplay = this._renderDisplay.getComponent(cc.Sprite)._sgNode; // as cc.Scale9Sprite; + var polygonInfo = meshDisplay.getMeshPolygonInfo(); + if (!polygonInfo) { + return; + } + var verticesAndUVs = polygonInfo.triangles.verts; + var boundsRect = cc.rect(999999.0, 999999.0, -999999.0, -999999.0); + if (weightData !== null) { + var data = geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; + if (weightFloatOffset < 0) { + weightFloatOffset += 65536; // Fixed out of bouds bug. + } + for (var i = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + bones.length, iV = weightFloatOffset, iF = 0; i < vertexCount; ++i) { + var boneCount = intArray[iB++]; + var xG = 0.0, yG = 0.0; + for (var j = 0; j < boneCount; ++j) { + var boneIndex = intArray[iB++]; + var bone = bones[boneIndex]; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var xL = floatArray[iV++] * scale; + var yL = floatArray[iV++] * scale; + if (hasDeform) { + xL += deformVertices[iF++]; + yL += deformVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + var vertex = verticesAndUVs[i]; + vertex.x = xG; + vertex.y = yG; + if (boundsRect.x > xG) { + boundsRect.x = xG; + } + if (boundsRect.width < xG) { + boundsRect.width = xG; + } + if (boundsRect.y > yG) { + boundsRect.y = yG; + } + if (boundsRect.height < yG) { + boundsRect.height = yG; + } + } + } + else { + var isSurface = this._parent._boneData.type !== 0 /* Bone */; + var data = geometryData.data; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[geometryData.offset + 0 /* GeometryVertexCount */]; + var vertexOffset = intArray[geometryData.offset + 2 /* GeometryFloatOffset */]; + if (vertexOffset < 0) { + vertexOffset += 65536; // Fixed out of bouds bug. + } + for (var i = 0, l = vertexCount * 2; i < l; i += 2) { + var iH = i / 2; // int. + var x = floatArray[vertexOffset + i] * scale; + var y = floatArray[vertexOffset + i + 1] * scale; + if (hasDeform) { + x += deformVertices[i]; + y += deformVertices[i + 1]; + } + var vertex = verticesAndUVs[iH]; + if (isSurface) { + var matrix = this._parent._getGlobalTransformMatrix(x, y); + vertex.x = matrix.a * x + matrix.c * y + matrix.tx; + vertex.y = matrix.b * x + matrix.d * y + matrix.ty; + // + x = vertex.x; + y = vertex.y; + } + else { + vertex.x = x; + y = vertex.y = -y; + } + if (boundsRect.x > x) { + boundsRect.x = x; + } + if (boundsRect.width < x) { + boundsRect.width = x; + } + if (boundsRect.y > y) { + boundsRect.y = y; + } + if (boundsRect.height < y) { + boundsRect.height = y; + } + } + } + boundsRect.width -= boundsRect.x; + boundsRect.height -= boundsRect.y; + polygonInfo.rect = boundsRect; + meshDisplay.setContentSize(cc.size(boundsRect.width, boundsRect.height)); + meshDisplay.setMeshPolygonInfo(polygonInfo); + if (weightData !== null) { + this._identityTransform(); + } + else { + var transform = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); + this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); + this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; + this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; + this._renderDisplay.scaleX = transform.scaleX * this._textureScale; + this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; + } + if (this._ccMeshDirty) { + this._ccMeshDirty = false; + this._verticesDirty = true; + } + }; + CocosSlot.prototype._updateTransform = function () { + // const globalTransformMatrix = this.globalTransformMatrix; + // const helpMatrix = TransformObject._helpMatrix; + // helpMatrix.a = globalTransformMatrix.a; + // helpMatrix.b = globalTransformMatrix.b; + // helpMatrix.c = -globalTransformMatrix.c; + // helpMatrix.d = -globalTransformMatrix.d; + // if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + // helpMatrix.tx = globalTransformMatrix.tx - (globalTransformMatrix.a * this._pivotX + globalTransformMatrix.c * this._pivotY); + // helpMatrix.ty = (globalTransformMatrix.ty - (globalTransformMatrix.b * this._pivotX + globalTransformMatrix.d * this._pivotY)); + // } + // else { + // helpMatrix.tx = globalTransformMatrix.tx; + // helpMatrix.ty = globalTransformMatrix.ty; + // } + // (this._renderDisplay as any)._sgNode._renderCmd.setNodeToParentTransform(helpMatrix); // creator.d.ts error. + this.updateGlobalTransform(); + var transform = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.x = transform.x - (globalTransformMatrix.a * this._pivotX - globalTransformMatrix.c * this._pivotY); + this._renderDisplay.y = transform.y - (globalTransformMatrix.b * this._pivotX - globalTransformMatrix.d * this._pivotY); + } + else { + this._renderDisplay.x = transform.x; + this._renderDisplay.y = transform.y; + } + this._renderDisplay.rotationX = -(transform.rotation + transform.skew) * dragonBones.Transform.RAD_DEG; + this._renderDisplay.rotationY = -transform.rotation * dragonBones.Transform.RAD_DEG; + this._renderDisplay.scaleX = transform.scaleX * this._textureScale; + this._renderDisplay.scaleY = -transform.scaleY * this._textureScale; + }; + CocosSlot.prototype._identityTransform = function () { + // const helpMatrix = TransformObject._helpMatrix; + // helpMatrix.a = 1.0; + // helpMatrix.b = 0.0; + // helpMatrix.c = -0.0; + // helpMatrix.d = -1.0; + // helpMatrix.tx = 0.0; + // helpMatrix.ty = 0.0; + // (this._renderDisplay as any)._renderCmd.setNodeToParentTransform(helpMatrix); + this._renderDisplay.x = 0.0; + this._renderDisplay.y = 0.0; + this._renderDisplay.rotationX = 0.0; + this._renderDisplay.rotationY = 0.0; + this._renderDisplay.scaleX = 1.0; + this._renderDisplay.scaleY = 1.0; + }; + return CocosSlot; + }(dragonBones.Slot)); + dragonBones.CocosSlot = CocosSlot; +})(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) { + var ccclass = cc._decorator.ccclass; + var ClockHandler = /** @class */ (function (_super) { + __extends(ClockHandler, _super); + function ClockHandler() { + return _super !== null && _super.apply(this, arguments) || this; + } + ClockHandler.prototype.update = function (passedTime) { + CocosFactory.factory.dragonBones.advanceTime(passedTime); + }; + ClockHandler = __decorate([ + ccclass + ], ClockHandler); + return ClockHandler; + }(cc.Component)); + /** + * - The Cocos factory. + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - Cocos 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var CocosFactory = /** @class */ (function (_super) { + __extends(CocosFactory, _super); + function CocosFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + var _this = _super.call(this, dataParser) || this; + _this._node = null; + _this._armatureNode = null; + if (!CC_EDITOR) { // Is playing. + if (_this._node === null) { + var nodeName = "DragonBones Node"; + _this._node = cc.find(nodeName); + if (_this._node === null) { + _this._node = new cc.Node(nodeName); + cc.game.addPersistRootNode(_this._node); + } + } + if (!_this._node.getComponent(ClockHandler)) { + _this._node.addComponent(ClockHandler); + } + var eventManager = _this._node.getComponent(dragonBones.CocosArmatureComponent) || _this._node.addComponent(dragonBones.CocosArmatureComponent); + if (CocosFactory._dragonBonesInstance === null) { + CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); + // + dragonBones.DragonBones.yDown = false; + } + } + else { + if (CocosFactory._dragonBonesInstance === null) { + CocosFactory._dragonBonesInstance = new dragonBones.DragonBones(null); + // + dragonBones.DragonBones.yDown = false; + } + } + _this._dragonBones = CocosFactory._dragonBonesInstance; + return _this; + } + Object.defineProperty(CocosFactory, "factory", { + /** + * - A global factory instance that can be used directly. + * @version DragonBones 4.7 + * @language en_US + */ + /** + * - 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + if (this._factory === null) { + this._factory = new CocosFactory(); + } + return this._factory; + }, + enumerable: true, + configurable: true + }); + CocosFactory.prototype._isSupportMesh = function () { + if (cc._renderType !== cc.game.RENDER_TYPE_WEBGL) { // creator.d.ts error. + console.warn("Only webgl mode can support mesh."); + return false; + } + return true; + }; + CocosFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.CocosTextureAtlasData); + } + return textureAtlasData; + }; + CocosFactory.prototype._buildArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplay = this._armatureNode === null ? new cc.Node(dataPackage.armature.name) : this._armatureNode; + var armatureComponent = armatureDisplay.getComponent(dragonBones.CocosArmatureComponent) || armatureDisplay.addComponent(dragonBones.CocosArmatureComponent); + armatureDisplay.setOpacityModifyRGB(false); + armatureDisplay.setCascadeOpacityEnabled(true); + armatureDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. + this._armatureNode = null; + armatureComponent._armature = armature; + armature.init(dataPackage.armature, armatureComponent, armatureDisplay, this._dragonBones); + return armature; + }; + CocosFactory.prototype._buildChildArmature = function (dataPackage, slot, displayData) { + var childDisplayName = slot.slotData.name + " (" + displayData.path.replace("/", "_") + ")"; // + var proxy = slot.armature.proxy; + var childNode = cc.find(childDisplayName, proxy.node); + var childArmature = null; + if (!childNode) { + if (dataPackage !== null) { + childArmature = this.buildArmature(displayData.path, dataPackage.dataName); + } + else { + childArmature = this.buildArmature(displayData.path, displayData.parent.parent.parent.name); + } + } + else { + var childArmatureComponent = childNode.getComponent(dragonBones.CocosArmatureComponent) || null; + if (childArmatureComponent === null) { + if (dataPackage !== null) { + childArmatureComponent = this.buildArmatureComponent(displayData.path, dataPackage !== null ? dataPackage.dataName : "", "", dataPackage.textureAtlasName, childNode); + } + else { + childArmatureComponent = this.buildArmatureComponent(displayData.path, "", "", "", childNode); + } + } + if (childArmatureComponent !== null) { + childArmature = childArmatureComponent.armature; + } + } + if (childArmature === null) { + return null; + } + var childArmatureDisplay = childArmature.display; + childArmatureDisplay.name = childDisplayName; + if (childArmatureDisplay.parent !== proxy.node) { + proxy.node.addChild(childArmatureDisplay, slot._zOrder); + } + childArmatureDisplay.active = false; + return childArmature; + }; + CocosFactory.prototype._buildSlot = function (_dataPackage, slotData, armature) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.CocosSlot); + var armatureDisplay = armature.display; + var rawSlotDisplay = cc.find(slotData.name, armatureDisplay) || new cc.Node(slotData.name); + rawSlotDisplay.addComponent(cc.Sprite); + rawSlotDisplay.setAnchorPoint(0.0, 0.0); + rawSlotDisplay.setOpacityModifyRGB(false); + rawSlotDisplay.setCascadeOpacityEnabled(true); + rawSlotDisplay._sgNode.setCascadeColorEnabled(true); // creator.d.ts error. + slot.init(slotData, armature, rawSlotDisplay, rawSlotDisplay); + return slot; + }; + /** + * - Create a armature component from cached DragonBonesData instances and TextureAtlasData instances, then use the {@link #clock} to update it. + * - The difference is that the armature created by {@link #buildArmature} is not WorldClock instance update. + * - Note that when the created armature proxy that is no longer in use, you need to explicitly dispose {@link #dragonBones.IArmatureProxy#dispose()}. + * @param armatureName - The armature data name. + * @param dragonBonesName - The cached name of the DragonBonesData instance. (If not set, all DragonBonesData instances are retrieved, and when multiple DragonBonesData instances contain a the same name armature data, it may not be possible to accurately create a specific armature) + * @param skinName - The skin name, you can set a different ArmatureData name to share it's skin data. (If not set, use the default skin data) + * @returns The armature component. + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language en_US + */ + /** + * - 通过缓存的 DragonBonesData 实例和 TextureAtlasData 实例创建一个骨架组件,并用 {@link #clock} 更新该骨架。 + * - 区别在于由 {@link #buildArmature} 创建的骨架没有 WorldClock 实例驱动。 + * - 注意,创建的骨架代理不再使用时,需要显式释放 {@link #dragonBones.IArmatureProxy#dispose()}。 + * @param armatureName - 骨架数据名称。 + * @param dragonBonesName - DragonBonesData 实例的缓存名称。 (如果未设置,将检索所有的 DragonBonesData 实例,当多个 DragonBonesData 实例中包含同名的骨架数据时,可能无法准确的创建出特定的骨架) + * @param skinName - 皮肤名称,可以设置一个其他骨架数据名称来共享其皮肤数据。(如果未设置,则使用默认的皮肤数据) + * @returns 骨架组件。 + * @see dragonBones.IArmatureProxy + * @see dragonBones.BaseFactory#buildArmature + * @version DragonBones 4.5 + * @example + * + *
+         *     let armatureComponent = factory.buildArmatureComponent("armatureName", "dragonBonesName");
+         * 
+ * @language zh_CN + */ + CocosFactory.prototype.buildArmatureComponent = function (armatureName, dragonBonesName, skinName, textureAtlasName, node) { + if (dragonBonesName === void 0) { dragonBonesName = ""; } + if (skinName === void 0) { skinName = ""; } + if (textureAtlasName === void 0) { textureAtlasName = ""; } + if (node === void 0) { node = null; } + this._armatureNode = node; + var armature = this.buildArmature(armatureName, dragonBonesName || "", skinName || "", textureAtlasName || ""); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.proxy; + } + return null; + }; + /** + * - Create the display object with the specified texture. + * @param textureName - The texture data name. + * @param textureAtlasName - The texture atlas data name. (Of not set, all texture atlas data will be searched) + * @version DragonBones 3.0 + * @language en_US + */ + /** + * - 创建带有指定贴图的显示对象。 + * @param textureName - 贴图数据名称。 + * @param textureAtlasName - 贴图集数据名称。 (如果未设置,将检索所有的贴图集数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + CocosFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { + if (textureAtlasName === void 0) { textureAtlasName = null; } + var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); + if (textureData !== null && textureData.renderTexture !== null) { + var texture = textureData.renderTexture; + var sprite = new cc.Sprite(); + sprite.spriteFrame = texture; + return sprite; + } + return null; + }; + Object.defineProperty(CocosFactory.prototype, "soundEventManager", { + /** + * - A global sound event manager. + * Sound events can be listened to uniformly from the manager. + * @version DragonBones 4.5 + * @language en_US + */ + /** + * - 全局声音事件管理器。 + * 声音事件可以从该管理器统一侦听。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._dragonBones.eventManager.node; + }, + enumerable: true, + configurable: true + }); + CocosFactory._dragonBonesInstance = null; + CocosFactory._factory = null; + return CocosFactory; + }(dragonBones.BaseFactory)); + dragonBones.CocosFactory = CocosFactory; +})(dragonBones || (dragonBones = {}));