diff --git a/.gitignore b/.gitignore index 32858aa..8c6f20f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,17 @@ *.war *.ear +*.iml +*.ipr +*.iws + +.gradle +.idea + +/build +/out +/classes +/target + # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..dff5f3a --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: java diff --git a/README.md b/README.md index 33eb802..627cd1b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # DragonBonesJAVA -coming soon... \ No newline at end of file +``` +./gradlew check +``` \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..f23acfa --- /dev/null +++ b/build.gradle @@ -0,0 +1,20 @@ +allprojects { + group 'com.dragonbones' + version '0.1' + + apply plugin: 'java' + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + + repositories { + mavenLocal() + jcenter() + mavenCentral() + } + + dependencies { + compile "org.jetbrains:annotations:13.0" + testCompile group: 'junit', name: 'junit', version: '4.12' + } +} \ No newline at end of file diff --git a/dragonbones-core/.gitignore b/dragonbones-core/.gitignore new file mode 100644 index 0000000..e0b93f7 --- /dev/null +++ b/dragonbones-core/.gitignore @@ -0,0 +1,4 @@ +/build +/out +/classes +/target diff --git a/dragonbones-core/build.gradle b/dragonbones-core/build.gradle new file mode 100644 index 0000000..7d82dc7 --- /dev/null +++ b/dragonbones-core/build.gradle @@ -0,0 +1,2 @@ +dependencies { +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/ActionTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/ActionTimelineState.java new file mode 100644 index 0000000..9407c5c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/ActionTimelineState.java @@ -0,0 +1,260 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Armature; +import com.dragonbones.armature.Slot; +import com.dragonbones.core.ActionType; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.BinaryOffset; +import com.dragonbones.event.EventObject; +import com.dragonbones.event.EventStringType; +import com.dragonbones.event.IEventDispatcher; +import com.dragonbones.model.ActionData; +import com.dragonbones.model.TimelineData; +import com.dragonbones.util.Array; + +/** + * @internal + * @private + */ +public class ActionTimelineState extends TimelineState { + private void _onCrossFrame(int frameIndex) { + IEventDispatcher eventDispatcher = this._armature.getEventDispatcher(); + if (this._animationState.actionEnabled) { + int frameOffset = this._animationData.frameOffset + this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineFrameOffset.v + frameIndex); + int actionCount = this._frameArray.get(frameOffset + 1); + Array actions = this._armature.armatureData.actions; + for (int i = 0; i < actionCount; ++i) { + int actionIndex = this._frameArray.get(frameOffset + 2 + i); + ActionData action = actions.get(actionIndex); + if (action.type == ActionType.Play) { + if (action.slot != null) { + Slot slot = this._armature.getSlot(action.slot.name); + if (slot != null) { + Armature childArmature = slot.getChildArmature(); + if (childArmature != null) { + childArmature._bufferAction(action, true); + } + } + } else if (action.bone != null) { + for (Slot slot : this._armature.getSlots()) { + Armature childArmature = slot.getChildArmature(); + if (childArmature != null && slot.getParent().boneData == action.bone) { + childArmature._bufferAction(action, true); + } + } + } else { + this._armature._bufferAction(action, true); + } + } else { + EventStringType eventType = action.type == ActionType.Frame ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; + if (action.type == ActionType.Sound || eventDispatcher.hasEvent(eventType)) { + EventObject eventObject = BaseObject.borrowObject(EventObject.class); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray.get(frameOffset) / this._frameRate; + eventObject.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + + if (action.bone != null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + + if (action.slot != null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + } + } + + protected void _onArriveAtFrame() { + } + + protected void _onUpdateFrame() { + } + + public void update(float passedTime) { + int prevState = this.playState; + float prevPlayTimes = this.currentPlayTimes; + float prevTime = this.currentTime; + + if (this.playState <= 0 && this._setCurrentTime(passedTime)) { + IEventDispatcher eventDispatcher = this._armature.getEventDispatcher(); + 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 (eventDispatcher.hasEvent(EventObject.START)) { + EventObject eventObject = BaseObject.borrowObject(EventObject.class); + eventObject.type = EventObject.START; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(eventObject); + } + } else { + return; + } + } + + boolean isReverse = this._animationState.timeScale < 0f; + EventObject loopCompleteEvent = null; + EventObject completeEvent = null; + if (this.currentPlayTimes != prevPlayTimes) { + if (eventDispatcher.hasEvent(EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = BaseObject.borrowObject(EventObject.class); + loopCompleteEvent.type = EventObject.LOOP_COMPLETE; + loopCompleteEvent.armature = this._armature; + loopCompleteEvent.animationState = this._animationState; + } + + if (this.playState > 0) { + if (eventDispatcher.hasEvent(EventObject.COMPLETE)) { + completeEvent = BaseObject.borrowObject(EventObject.class); + completeEvent.type = EventObject.COMPLETE; + completeEvent.armature = this._armature; + completeEvent.animationState = this._animationState; + } + + } + } + + if (this._frameCount > 1) { + TimelineData timelineData = this._timelineData; + int timelineFrameIndex = (int) Math.floor(this.currentTime * this._frameRate); // uint + int frameIndex = this._frameIndices.get(timelineData.frameIndicesOffset + timelineFrameIndex); + if (this._frameIndex != frameIndex) { // Arrive at frame. + int crossedFrameIndex = this._frameIndex; + this._frameIndex = frameIndex; + if (this._timelineArray != null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray.get(timelineData.offset + BinaryOffset.TimelineFrameOffset.v + this._frameIndex); + if (isReverse) { + if (crossedFrameIndex < 0) { + int prevFrameIndex = (int) Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices.get(timelineData.frameIndicesOffset + prevFrameIndex); + if (this.currentPlayTimes == prevPlayTimes) { // Start. + if (crossedFrameIndex == frameIndex) { // Uncrossed. + crossedFrameIndex = -1; + } + } + } + + while (crossedFrameIndex >= 0) { + int frameOffset = this._animationData.frameOffset + this._timelineArray.get(timelineData.offset + BinaryOffset.TimelineFrameOffset.v + crossedFrameIndex); + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + float framePosition = this._frameArray.get(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) { + int prevFrameIndex = (int) Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices.get(timelineData.frameIndicesOffset + prevFrameIndex); + int frameOffset = this._animationData.frameOffset + this._timelineArray.get(timelineData.offset + BinaryOffset.TimelineFrameOffset.v + crossedFrameIndex); + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + float framePosition = this._frameArray.get(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; + } + + int frameOffset = this._animationData.frameOffset + this._timelineArray.get(timelineData.offset + BinaryOffset.TimelineFrameOffset.v + crossedFrameIndex); + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + float framePosition = this._frameArray.get(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.get(this._timelineData.offset + BinaryOffset.TimelineFrameOffset.v); + // Arrive at frame. + float framePosition = this._frameArray.get(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); + } + } + } + + public void setCurrentTime(float value) { + this._setCurrentTime(value); + this._frameIndex = -1; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/Animation.java b/dragonbones-core/src/main/java/com/dragonbones/animation/Animation.java new file mode 100644 index 0000000..c41daac --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/Animation.java @@ -0,0 +1,851 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Armature; +import com.dragonbones.armature.Bone; +import com.dragonbones.armature.Slot; +import com.dragonbones.core.AnimationFadeOutMode; +import com.dragonbones.core.BaseObject; +import com.dragonbones.model.AnimationConfig; +import com.dragonbones.model.AnimationData; +import com.dragonbones.util.Array; +import com.dragonbones.util.Console; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * 动画控制器,用来播放动画数据,管理动画状态。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationData + * @see AnimationState + */ +public class Animation extends BaseObject { + /** + * 播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * + * @default 1f + * @version DragonBones 3.0 + * @language zh_CN + */ + public float timeScale; + + private boolean _animationDirty; // Update bones and slots cachedFrameIndices. + /** + * @internal + * @private + */ + public boolean _timelineDirty; // Updata animationStates timelineStates. + private final Array _animationNames = new Array<>(); + private final Array _animationStates = new Array<>(); + private final Map _animations = new HashMap<>(); + private Armature _armature; + @Nullable + private AnimationConfig _animationConfig = null; // Initial value. + @Nullable + private AnimationState _lastAnimationState; + + /** + * @private + */ + protected void _onClear() { + for (AnimationState animationState : this._animationStates) { + animationState.returnToPool(); + } + + for (String k : this._animations.keySet()) { + this._animations.remove(k); + } + + if (this._animationConfig != null) { + this._animationConfig.returnToPool(); + } + + this.timeScale = 1f; + + this._animationDirty = false; + this._timelineDirty = false; + this._animationNames.clear(); + this._animationStates.clear(); + //this._animations.clear(); + this._armature = null; // + this._animationConfig = null; // + this._lastAnimationState = null; + } + + private void _fadeOut(AnimationConfig animationConfig) { + switch (animationConfig.fadeOutMode) { + case SameLayer: + for (AnimationState animationState : this._animationStates) { + if (animationState.layer == animationConfig.layer) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + + case SameGroup: + for (AnimationState animationState : this._animationStates) { + if (Objects.equals(animationState.group, animationConfig.group)) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + + case SameLayerAndGroup: + for (AnimationState animationState : this._animationStates) { + if ( + animationState.layer == animationConfig.layer && + Objects.equals(animationState.group, animationConfig.group) + ) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + + case All: + for (AnimationState animationState : this._animationStates) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + + case None: + case Single: + default: + break; + } + } + + /** + * @internal + * @private + */ + public void init(Armature armature) { + if (this._armature != null) { + return; + } + + this._armature = armature; + this._animationConfig = BaseObject.borrowObject(AnimationConfig.class); + } + + /** + * @internal + * @private + */ + public void advanceTime(float passedTime) { + if (passedTime < 0f) { // Only animationState can reverse play. + passedTime = -passedTime; + } + + if (this._armature.inheritAnimation && this._armature._parent != null) { // Inherit parent animation timeScale. + passedTime *= this._armature._parent._armature.getAnimation().timeScale; + } + + if (this.timeScale != 1f) { + passedTime *= this.timeScale; + } + + int animationStateCount = this._animationStates.size(); + if (animationStateCount == 1) { + AnimationState animationState = this._animationStates.get(0); + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + this._armature._dragonBones.bufferObject(animationState); + this._animationStates.clear(); + this._lastAnimationState = null; + } else { + AnimationData animationData = animationState.animationData; + float cacheFrameRate = animationData.cacheFrameRate; + if (this._animationDirty && cacheFrameRate > 0f) { // Update cachedFrameIndices. + this._animationDirty = false; + for (Bone bone : this._armature.getBones()) { + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); + } + + for (Slot slot : this._armature.getSlots()) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + + if (this._timelineDirty) { + animationState.updateTimelines(); + } + + animationState.advanceTime(passedTime, cacheFrameRate); + } + } else if (animationStateCount > 1) { + for (int i = 0, r = 0; i < animationStateCount; ++i) { + AnimationState animationState = this._animationStates.get(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.set(i - r, animationState); + } + + if (this._timelineDirty) { + animationState.updateTimelines(); + } + + animationState.advanceTime(passedTime, 0f); + } + + if (i == animationStateCount - 1 && r > 0) { // Modify animation states size. + this._animationStates.setLength(this._animationStates.size() - r); + if (this._lastAnimationState == null && this._animationStates.size() > 0) { + this._lastAnimationState = this._animationStates.get(this._animationStates.size() - 1); + } + } + } + + this._armature._cacheFrameIndex = -1; + } else { + this._armature._cacheFrameIndex = -1; + } + + this._timelineDirty = false; + } + + /** + * 清除所有动画状态。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + public void reset() { + for (AnimationState animationState : this._animationStates) { + animationState.returnToPool(); + } + + this._animationDirty = false; + this._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.clear(); + this._lastAnimationState = null; + } + + public void stop() { + stop(null); + } + + /** + * 暂停播放动画。 + * + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationState + */ + public void stop(String animationName) { + if (animationName != null) { + AnimationState animationState = this.getState(animationName); + if (animationState != null) { + animationState.stop(); + } + } else { + for (AnimationState animationState : this._animationStates) { + animationState.stop(); + } + } + } + + /** + * 通过动画配置来播放动画。 + * + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @version DragonBones 5.0 + * @beta + * @language zh_CN + * @see AnimationConfig + * @see AnimationState + */ + public AnimationState playConfig(AnimationConfig animationConfig) { + String animationName = animationConfig.animation; + if (!(this._animations.containsKey(animationName))) { + Console.warn( + "Non-existent animation.\n" + + "DragonBones name: " + this._armature.armatureData.parent.name + + "Armature name: " + this._armature.getName() + + "Animation name: " + animationName + ); + + return null; + } + + AnimationData animationData = this._animations.get(animationName); + + if (animationConfig.fadeOutMode == AnimationFadeOutMode.Single) { + for (AnimationState animationState : this._animationStates) { + if (animationState.animationData == animationData) { + return animationState; + } + } + } + + if (this._animationStates.size() == 0) { + animationConfig.fadeInTime = 0f; + } else if (animationConfig.fadeInTime < 0f) { + animationConfig.fadeInTime = animationData.fadeInTime; + } + + if (animationConfig.fadeOutTime < 0f) { + animationConfig.fadeOutTime = animationConfig.fadeInTime; + } + + if (animationConfig.timeScale <= -100.0) { + animationConfig.timeScale = 1f / animationData.scale; + } + + if (animationData.frameCount > 1) { + if (animationConfig.position < 0f) { + 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 > 0f && 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 = 0f; + if (animationConfig.duration > 0f) { + animationConfig.duration = 0f; + } + } + + if (animationConfig.duration == 0f) { + animationConfig.duration = -1f; + } + + this._fadeOut(animationConfig); + + AnimationState animationState = BaseObject.borrowObject(AnimationState.class); + animationState.init(this._armature, animationData, animationConfig); + this._animationDirty = true; + this._armature._cacheFrameIndex = -1; + + if (this._animationStates.size() > 0) { + boolean added = false; + for (int i = 0, l = this._animationStates.size(); i < l; ++i) { + if (animationState.layer >= this._animationStates.get(i).layer) { + } else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + + if (!added) { + this._animationStates.add(animationState); + } + } else { + this._animationStates.add(animationState); + } + + // Child armature play same name animation. + for (Slot slot : this._armature.getSlots()) { + Armature childArmature = slot.getChildArmature(); + if ( + childArmature != null && childArmature.inheritAnimation && + childArmature.getAnimation().hasAnimation(animationName) && + childArmature.getAnimation().getState(animationName) == null + ) { + childArmature.getAnimation().fadeIn(animationName); // + } + } + + if (animationConfig.fadeInTime <= 0f) { // Blend animation state, update armature. + this._armature.advanceTime(0f); + } + + this._lastAnimationState = animationState; + + return animationState; + } + + public AnimationState play() { + return play(null, -1); + } + + public AnimationState play(String animationName) { + return play(animationName, -1); + } + + /** + * 播放动画。 + * + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationState + */ + public AnimationState play(String animationName, int playTimes) { + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0f; + this._animationConfig.animation = animationName != null ? animationName : ""; + + if (animationName != null && animationName.length() > 0) { + this.playConfig(this._animationConfig); + } else if (this._lastAnimationState == null) { + AnimationData 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; + } + + @Nullable + public AnimationState fadeIn(String animationName) { + return fadeIn(animationName, -1f, -1, 0, null, AnimationFadeOutMode.SameLayerAndGroup); + } + + /** + * 淡入播放动画。 + * + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationFadeOutMode + * @see AnimationState + */ + @Nullable + public AnimationState fadeIn( + String animationName, float fadeInTime, int playTimes, + int layer, @Nullable String group, AnimationFadeOutMode fadeOutMode + ) { + 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); + } + + @Nullable + public AnimationState gotoAndPlayByTime(String animationName) { + return gotoAndPlayByTime(animationName, 0f, -1); + } + + /** + * 从指定时间开始播放动画。 + * + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + @Nullable + public AnimationState gotoAndPlayByTime(String animationName, float time, int playTimes) { + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.position = time; + this._animationConfig.fadeInTime = 0f; + this._animationConfig.animation = animationName; + + return this.playConfig(this._animationConfig); + } + + @Nullable + public AnimationState gotoAndPlayByFrame(String animationName) { + return gotoAndPlayByFrame(animationName, 0, -1); + } + + /** + * 从指定帧开始播放动画。 + * + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + @Nullable + public AnimationState gotoAndPlayByFrame(String animationName, int frame, int playTimes) { + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0f; + this._animationConfig.animation = animationName; + + AnimationData animationData = this._animations.get(animationName); + if (animationData != null) { + this._animationConfig.position = animationData.duration * frame / animationData.frameCount; + } + + return this.playConfig(this._animationConfig); + } + + @Nullable + public AnimationState gotoAndPlayByProgress(String animationName) { + return gotoAndPlayByProgress(animationName, 0f, -1); + } + + /** + * 从指定进度开始播放动画。 + * + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + @Nullable + public AnimationState gotoAndPlayByProgress(String animationName, float progress, int playTimes) { + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0f; + this._animationConfig.animation = animationName; + + AnimationData animationData = this._animations.get(animationName); + if (animationData != null) { + this._animationConfig.position = animationData.duration * (progress > 0f ? progress : 0f); + } + + return this.playConfig(this._animationConfig); + } + + public AnimationState gotoAndStopByTime(String animationName) { + return gotoAndStopByTime(animationName, 0f); + } + + /** + * 将动画停止到指定的时间。 + * + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + @Nullable + public AnimationState gotoAndStopByTime(String animationName, float time) { + AnimationState animationState = this.gotoAndPlayByTime(animationName, time, 1); + if (animationState != null) { + animationState.stop(); + } + + return animationState; + } + + public @Nullable + AnimationState gotoAndStopByFrame(String animationName) { + return gotoAndStopByFrame(animationName, 0); + } + + /** + * 将动画停止到指定的帧。 + * + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + public @Nullable + AnimationState gotoAndStopByFrame(String animationName, int frame) { + AnimationState animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + if (animationState != null) { + animationState.stop(); + } + + return animationState; + } + + @Nullable + public AnimationState gotoAndStopByProgress(String animationName) { + return gotoAndStopByProgress(animationName, 0f); + } + + /** + * 将动画停止到指定的进度。 + * + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState + */ + @Nullable + public AnimationState gotoAndStopByProgress(String animationName, float progress) { + AnimationState animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + if (animationState != null) { + animationState.stop(); + } + + return animationState; + } + + /** + * 获取动画状态。 + * + * @param animationName 动画状态的名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationState + */ + public @Nullable + AnimationState getState(String animationName) { + int i = this._animationStates.size(); + while (i-- != 0) { + AnimationState animationState = this._animationStates.get(i); + if (Objects.equals(animationState.name, animationName)) { + return animationState; + } + } + + return null; + } + + /** + * 是否包含动画数据。 + * + * @param animationName 动画数据的名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationData + */ + public boolean hasAnimation(String animationName) { + return this._animations.containsKey(animationName); + } + + /** + * 获取所有的动画状态。 + * + * @version DragonBones 5.1 + * @language zh_CN + * @see AnimationState + */ + public Array getStates() { + return this._animationStates; + } + + /** + * 动画是否处于播放状态。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public boolean isPlaying() { + for (AnimationState animationState : this._animationStates) { + if (animationState.isPlaying()) { + return true; + } + } + + return false; + } + + /** + * 所有动画状态是否均已播放完毕。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationState + */ + public boolean isCompleted() { + for (AnimationState animationState : this._animationStates) { + if (!animationState.isCompleted()) { + return false; + } + } + + return this._animationStates.size() > 0; + } + + /** + * 上一个正在播放的动画状态名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see #getLastAnimationState() + */ + public String getLastAnimationName() { + return this._lastAnimationState != null ? this._lastAnimationState.name : ""; + } + + /** + * 所有动画数据名称。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see #getAnimations() + */ + public Array getAnimationNames() { + return this._animationNames; + } + + /** + * 所有动画数据。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationData + */ + public Map getAnimations() { + return this._animations; + } + + public void setAnimations(Map value) { + if (this._animations == value) { + return; + } + + this._animationNames.clear(); + this._animations.clear(); + + for (String k : value.keySet()) { + this._animations.put(k, value.get(k)); + this._animationNames.add(k); + } + } + + /** + * 一个可以快速使用的动画配置实例。 + * + * @version DragonBones 5.0 + * @language zh_CN + * @see AnimationConfig + */ + public AnimationConfig getAnimationConfig() { + this._animationConfig.clear(); + return this._animationConfig; + } + + /** + * 上一个正在播放的动画状态。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationState + */ + public @Nullable + AnimationState getLastAnimationState() { + return this._lastAnimationState; + } + + public AnimationState gotoAndPlay(String animationName) { + return gotoAndPlay(animationName, -1, -1, -1, 0, null, AnimationFadeOutMode.SameLayerAndGroup, true, true); + } + + /** + * @see #play() + * @see #fadeIn(String) + * @see #gotoAndPlayByTime(String, float, int) + * @see #gotoAndPlayByFrame(String, int, int) + * @see #gotoAndPlayByProgress(String, float, int) + * @deprecated 已废弃,请参考 @see + */ + @Nullable + public AnimationState gotoAndPlay( + String animationName, float fadeInTime, float duration, int playTimes, + int layer, @Nullable String group, AnimationFadeOutMode fadeOutMode, + boolean pauseFadeOut, boolean pauseFadeIn + ) { + //pauseFadeOut; + //pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + + AnimationData animationData = this._animations.get(animationName); + if (animationData != null && duration > 0f) { + this._animationConfig.timeScale = animationData.duration / duration; + } + + return this.playConfig(this._animationConfig); + } + + public @Nullable + AnimationState gotoAndStop(String animationName) { + return gotoAndStop(animationName, 0f); + } + + /** + * @see #gotoAndStopByTime(String, float) + * @see #gotoAndStopByFrame(String) + * @see #gotoAndStopByProgress(String, float) + * @deprecated 已废弃,请参考 @see + */ + public @Nullable + AnimationState gotoAndStop(String animationName, float time) { + return this.gotoAndStopByTime(animationName, time); + } + + /** + * @see #getAnimationNames() + * @see #getAnimations() + * @deprecated 已废弃,请参考 @see + */ + public Array getAnimationList() { + return this._animationNames; + } + + /** + * @see #getAnimationNames() + * @see #getAnimations() + * @deprecated 已废弃,请参考 @see + */ + public Array getAnimationDataList() { + Array list = new Array<>(); + for (int i = 0, l = this._animationNames.size(); i < l; ++i) { + list.push(this._animations.get(this._animationNames.get(i))); + } + + return list; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/AnimationState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/AnimationState.java new file mode 100644 index 0000000..808bc7f --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/AnimationState.java @@ -0,0 +1,985 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Armature; +import com.dragonbones.armature.Bone; +import com.dragonbones.armature.Slot; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.DisplayType; +import com.dragonbones.event.EventObject; +import com.dragonbones.event.EventStringType; +import com.dragonbones.geom.Transform; +import com.dragonbones.model.*; +import com.dragonbones.util.Array; +import com.dragonbones.util.IntArray; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Animation + * @see AnimationData + */ +public class AnimationState extends BaseObject { + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ + public boolean resetToPose; + /** + * 是否以增加的方式混合。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public boolean additiveBlending; + /** + * 是否对插槽的显示对象有控制权。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot#displayController + */ + public boolean displayControl; + /** + * 是否能触发行为。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean actionEnabled; + /** + * 混合图层。 + * + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public float layer; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public int playTimes; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float timeScale; + /** + * 混合权重。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float weight; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float autoFadeOutTime; + /** + * @private + */ + public float fadeTotalTime; + /** + * 动画名称。 + * + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public String name; + /** + * 混合组。 + * + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public String group; + /** + * 动画数据。 + * + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + * @see AnimationData + */ + public AnimationData animationData; + + private boolean _timelineDirty; + /** + * @internal + * @private xx: Play Enabled, Fade Play Enabled + */ + public int _playheadState; + /** + * @internal + * @private -1: Fade in, 0: Fade complete, 1: Fade out; + */ + public float _fadeState; + /** + * @internal + * @private -1: Fade start, 0: Fading, 1: Fade complete; + */ + public float _subFadeState; + /** + * @internal + * @private + */ + public float _position; + /** + * @internal + * @private + */ + public float _duration; + private float _fadeTime; + private float _time; + /** + * @internal + * @private + */ + public float _fadeProgress; + private float _weightResult; + private Array _boneMask = new Array<>(); + private Array _boneTimelines = new Array<>(); + private Array _slotTimelines = new Array<>(); + private Map _bonePoses = new HashMap<>(); + private Armature _armature; + /** + * @internal + * @private + */ + public ActionTimelineState _actionTimeline = null; // Initial value. + @Nullable + private ZOrderTimelineState _zOrderTimeline = null; // Initial value. + + /** + * @private + */ + protected void _onClear() { + for (BoneTimelineState timeline : this._boneTimelines) { + timeline.returnToPool(); + } + + for (SlotTimelineState timeline : this._slotTimelines) { + timeline.returnToPool(); + } + + for (String k : this._bonePoses.keySet()) { + this._bonePoses.get(k).returnToPool(); + this._bonePoses.remove(k); + } + + if (this._actionTimeline != null) { + this._actionTimeline.returnToPool(); + } + + if (this._zOrderTimeline != null) { + this._zOrderTimeline.returnToPool(); + } + + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1f; + this.weight = 1f; + this.autoFadeOutTime = 0f; + this.fadeTotalTime = 0f; + this.name = ""; + this.group = ""; + this.animationData = null; // + + this._timelineDirty = true; + this._playheadState = 0; + this._fadeState = -1; + this._subFadeState = -1; + this._position = 0f; + this._duration = 0f; + this._fadeTime = 0f; + this._time = 0f; + this._fadeProgress = 0f; + this._weightResult = 0f; + this._boneMask.clear(); + this._boneTimelines.clear(); + this._slotTimelines.clear(); + // this._bonePoses.clear(); + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + } + + private boolean _isDisabled(Slot slot) { + if (this.displayControl) { + String displayController = slot.displayController; + if ( + displayController == null || + Objects.equals(displayController, this.name) || + Objects.equals(displayController, this.group) + ) { + return false; + } + } + + return true; + } + + private void _advanceFadeTime(float passedTime) { + boolean isFadeOut = this._fadeState > 0; + + if (this._subFadeState < 0) { // Fade start event. + this._subFadeState = 0; + + EventStringType eventType = isFadeOut ? EventObject.FADE_OUT : EventObject.FADE_IN; + if (this._armature.getEventDispatcher().hasEvent(eventType)) { + EventObject eventObject = BaseObject.borrowObject(EventObject.class); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + + if (passedTime < 0f) { + passedTime = -passedTime; + } + + this._fadeTime += passedTime; + + if (this._fadeTime >= this.fadeTotalTime) { // Fade complete. + this._subFadeState = 1; + this._fadeProgress = isFadeOut ? 0f : 1f; + } else if (this._fadeTime > 0f) { // Fading. + this._fadeProgress = isFadeOut ? (1f - this._fadeTime / this.fadeTotalTime) : (this._fadeTime / this.fadeTotalTime); + } else { // Before fade. + this._fadeProgress = isFadeOut ? 1f : 0f; + } + + if (this._subFadeState > 0) { // Fade complete event. + if (!isFadeOut) { + this._playheadState |= 1; // x1 + this._fadeState = 0; + } + + EventStringType eventType = isFadeOut ? EventObject.FADE_OUT_COMPLETE : EventObject.FADE_IN_COMPLETE; + if (this._armature.getEventDispatcher().hasEvent(eventType)) { + EventObject eventObject = BaseObject.borrowObject(EventObject.class); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + + private void _blendBoneTimline(BoneTimelineState timeline) { + final Bone bone = timeline.bone; + final Transform bonePose = timeline.bonePose.result; + Transform animationPose = bone.animationPose; + float boneWeight = this._weightResult > 0f ? this._weightResult : -this._weightResult; + + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1f; + + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1f) * boneWeight + 1f; + animationPose.scaleY = (bonePose.scaleY - 1f) * boneWeight + 1f; + } else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1f) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1f) * boneWeight; + } + + if (this._fadeState != 0 || this._subFadeState != 0) { + bone._transformDirty = true; + } + } + + /** + * @private + * @internal + */ + public void init(Armature armature, AnimationData animationData, AnimationConfig animationConfig) { + if (this._armature != null) { + return; + } + + this._armature = armature; + + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length() > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + + if (animationConfig.pauseFadeIn) { + this._playheadState = 2; // 10 + } else { + this._playheadState = 3; // 11 + } + + if (animationConfig.duration < 0f) { + this._position = 0f; + this._duration = this.animationData.duration; + if (animationConfig.position != 0f) { + if (this.timeScale >= 0f) { + this._time = animationConfig.position; + } else { + this._time = animationConfig.position - this._duration; + } + } else { + this._time = 0f; + } + } else { + this._position = animationConfig.position; + this._duration = animationConfig.duration; + this._time = 0f; + } + + if (this.timeScale < 0f && this._time == 0f) { + this._time = -0.000001f; // Turn to end. + } + + if (this.fadeTotalTime <= 0f) { + this._fadeProgress = 0.999999f; // Make different. + } + + if (animationConfig.boneMask.size() > 0) { + this._boneMask.setLength(animationConfig.boneMask.size()); + for (int i = 0, l = this._boneMask.size(); i < l; ++i) { + this._boneMask.set(i, animationConfig.boneMask.get(i)); + } + } + + this._actionTimeline = BaseObject.borrowObject(ActionTimelineState.class); + this._actionTimeline.init(this._armature, this, this.animationData.actionTimeline); + this._actionTimeline.currentTime = this._time; + if (this._actionTimeline.currentTime < 0f) { + this._actionTimeline.currentTime = this._duration - this._actionTimeline.currentTime; + } + + if (this.animationData.zOrderTimeline != null) { + this._zOrderTimeline = BaseObject.borrowObject(ZOrderTimelineState.class); + this._zOrderTimeline.init(this._armature, this, this.animationData.zOrderTimeline); + } + } + + /** + * @private + * @internal + */ + public void updateTimelines() { + Map> boneTimelines = new HashMap<>(); + for (BoneTimelineState timeline : this._boneTimelines) { // Create bone timelines map. + String timelineName = timeline.bone.name; + if (!(boneTimelines.containsKey(timelineName))) { + boneTimelines.put(timelineName, new Array<>()); + } + + boneTimelines.get(timelineName).add(timeline); + } + + for (Bone bone : this._armature.getBones()) { + String timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + + Array timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (boneTimelines.containsKey(timelineName)) { // Remove bone timeline from map. + boneTimelines.remove(timelineName); + } else { // Create new bone timeline. + if (!this._bonePoses.containsKey(timelineName)) { + this._bonePoses.put(timelineName, BaseObject.borrowObject(BonePose.class)); + } + BonePose bonePose = this._bonePoses.get(timelineName); + if (timelineDatas != null) { + for (TimelineData timelineData : timelineDatas) { + switch (timelineData.type) { + case BoneAll: + BoneAllTimelineState timeline = BaseObject.borrowObject(BoneAllTimelineState.class); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + + case BoneT: + case BoneR: + case BoneS: + // TODO + break; + + case BoneX: + case BoneY: + case BoneRotate: + case BoneSkew: + case BoneScaleX: + case BoneScaleY: + // TODO + break; + } + } + } else if (this.resetToPose) { // Pose timeline. + BoneAllTimelineState timeline = BaseObject.borrowObject(BoneAllTimelineState.class); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + + for (String k : boneTimelines.keySet()) { // Remove bone timelines. + for (BoneTimelineState timeline : boneTimelines.get(k)) { + this._boneTimelines.splice(this._boneTimelines.indexOfObject(timeline), 1); + timeline.returnToPool(); + } + } + + Map> slotTimelines = new HashMap<>(); + IntArray ffdFlags = new IntArray(); + for (SlotTimelineState timeline : this._slotTimelines) { // Create slot timelines map. + String timelineName = timeline.slot.name; + if (!(slotTimelines.containsKey(timelineName))) { + slotTimelines.put(timelineName, new Array<>()); + } + + slotTimelines.get(timelineName).add(timeline); + } + + for (Slot slot : this._armature.getSlots()) { + String boneName = slot.getParent().name; + if (!this.containsBoneMask(boneName)) { + continue; + } + + String timelineName = slot.name; + Array timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (slotTimelines.containsKey(timelineName)) { + slotTimelines.remove(timelineName); + } else { // Create new slot timeline. + boolean displayIndexFlag = false; + boolean colorFlag = false; + ffdFlags.clear(); + + if (timelineDatas != null) { + for (TimelineData timelineData : timelineDatas) { + switch (timelineData.type) { + case SlotDisplay: { + SlotDislayIndexTimelineState timeline = BaseObject.borrowObject(SlotDislayIndexTimelineState.class); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + + case SlotColor: { + SlotColorTimelineState timeline = BaseObject.borrowObject(SlotColorTimelineState.class); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + + case SlotFFD: { + SlotFFDTimelineState timeline = BaseObject.borrowObject(SlotFFDTimelineState.class); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + + if (this.resetToPose) { // Pose timeline. + if (!displayIndexFlag) { + SlotDislayIndexTimelineState timeline = BaseObject.borrowObject(SlotDislayIndexTimelineState.class); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + + if (!colorFlag) { + SlotColorTimelineState timeline = BaseObject.borrowObject(SlotColorTimelineState.class); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + + for (DisplayData displayData : slot._rawDisplayDatas) { + if (displayData != null && displayData.type == DisplayType.Mesh && ffdFlags.indexOfObject(((MeshDisplayData) displayData).offset) < 0) { + SlotFFDTimelineState timeline = BaseObject.borrowObject(SlotFFDTimelineState.class); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + + for (String k : slotTimelines.keySet()) { // Remove slot timelines. + for (SlotTimelineState timeline : slotTimelines.get(k)) { + this._slotTimelines.splice(this._slotTimelines.indexOfObject(timeline), 1); + timeline.returnToPool(); + } + } + } + + /** + * @private + * @internal + */ + public void advanceTime(float passedTime, float cacheFrameRate) { + // Update fade time. + if (this._fadeState != 0 || this._subFadeState != 0) { + this._advanceFadeTime(passedTime); + } + + // Update time. + if (this._playheadState == 3) { // 11 + if (this.timeScale != 1f) { + passedTime *= this.timeScale; + } + + this._time += passedTime; + } + + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + + if (this.weight == 0f) { + return; + } + + boolean isCacheEnabled = this._fadeState == 0 && cacheFrameRate > 0f; + boolean isUpdateTimeline = true; + boolean isUpdateBoneTimeline = true; + float time = this._time; + this._weightResult = this.weight * this._fadeProgress; + + this._actionTimeline.update(time); // Update main timeline. + + if (isCacheEnabled) { // Cache time internval. + float internval = cacheFrameRate * 2.0f; + this._actionTimeline.currentTime = (float) (Math.floor(this._actionTimeline.currentTime * internval) / internval); + } + + if (this._zOrderTimeline != null) { // Update zOrder timeline. + this._zOrderTimeline.update(time); + } + + if (isCacheEnabled) { // Update cache. + int cacheFrameIndex = (int) 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.getBool(cacheFrameIndex)) { // Cached. + isUpdateBoneTimeline = false; + } else { // Cache. + this.animationData.cachedFrames.setBool(cacheFrameIndex, true); + } + } + } + + if (isUpdateTimeline) { + if (isUpdateBoneTimeline) { // Update bone timelines. + Bone bone = null; + BoneTimelineState prevTimeline = null; // + for (int i = 0, l = this._boneTimelines.size(); i < l; ++i) { + BoneTimelineState timeline = this._boneTimelines.get(i); + if (bone != timeline.bone) { // Blend bone pose. + if (bone != null) { + this._blendBoneTimline(prevTimeline); + + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0f) { + if (bone._blendLayer != this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0f; + bone = null; + } else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0f; + } + } + } else { + bone = null; + } + } + } + + bone = timeline.bone; + } + + if (bone != null) { + timeline.update(time); + if (i == l - 1) { + this._blendBoneTimline(timeline); + } else { + prevTimeline = timeline; + } + } + } + } + + for (int i = 0, l = this._slotTimelines.size(); i < l; ++i) { + SlotTimelineState timeline = this._slotTimelines.get(i); + if (this._isDisabled(timeline.slot)) { + continue; + } + + timeline.update(time); + } + } + + if (this._fadeState == 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0f) { // Auto fade out. + this.fadeOut(this.autoFadeOutTime); + } + } + } + } + + /** + * 继续播放。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public void play() { + this._playheadState = 3; // 11 + } + + /** + * 暂停播放。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public void stop() { + this._playheadState &= 1; // 0x + } + + public void fadeOut(float fadeOutTime) { + fadeOut(fadeOutTime, true); + } + + /** + * 淡出动画。 + * + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void fadeOut(float fadeOutTime, boolean pausePlayhead) { + if (fadeOutTime < 0f) { + fadeOutTime = 0f; + } + + 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 <= 0f || this._fadeProgress <= 0f) { + this._fadeProgress = 0.000001f; // Modify fade progress to different value. + } + + for (BoneTimelineState timeline : this._boneTimelines) { + timeline.fadeOut(); + } + + for (SlotTimelineState timeline : this._slotTimelines) { + timeline.fadeOut(); + } + } + + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0f; + this._fadeTime = this.fadeTotalTime * (1f - this._fadeProgress); + } + + /** + * 是否包含骨骼遮罩。 + * + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public boolean containsBoneMask(String name) { + return this._boneMask.size() == 0 || this._boneMask.indexOf(name) >= 0; + } + + public void addBoneMask(String name) { + addBoneMask(name, true); + } + + /** + * 添加骨骼遮罩。 + * + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void addBoneMask(String name, boolean recursive) { + Bone currentBone = this._armature.getBone(name); + if (currentBone == null) { + return; + } + + if (this._boneMask.indexOf(name) < 0) { // Add mixing + this._boneMask.add(name); + } + + if (recursive) { // Add recursive mixing. + for (Bone bone : this._armature.getBones()) { + if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { + this._boneMask.add(bone.name); + } + } + } + + this._timelineDirty = true; + } + + public void removeBoneMask(String name) { + removeBoneMask(name, true); + } + + /** + * 删除骨骼遮罩。 + * + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void removeBoneMask(String name, boolean recursive) { + int index = this._boneMask.indexOf(name); + if (index >= 0) { // Remove mixing. + this._boneMask.splice(index, 1); + } + + if (recursive) { + Bone currentBone = this._armature.getBone(name); + if (currentBone != null) { + Array bones = this._armature.getBones(); + if (this._boneMask.size() > 0) { // Remove recursive mixing. + for (Bone bone : bones) { + int index2 = this._boneMask.indexOf(bone.name); + if (index2 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index2, 1); + } + } + } else { // Add unrecursive mixing. + for (Bone bone : bones) { + if (bone == currentBone) { + continue; + } + + if (!currentBone.contains(bone)) { + this._boneMask.add(bone.name); + } + } + } + } + } + + this._timelineDirty = true; + } + + /** + * 删除所有骨骼遮罩。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public void removeAllBoneMask() { + this._boneMask.clear(); + this._timelineDirty = true; + } + + /** + * 是否正在淡入。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ + public boolean isFadeIn() { + return this._fadeState < 0; + } + + /** + * 是否正在淡出。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ + public boolean isFadeOut() { + return this._fadeState > 0; + } + + /** + * 是否淡入完毕。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ + public boolean isFadeComplete() { + return this._fadeState == 0; + } + + /** + * 是否正在播放。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public boolean isPlaying() { + return (this._playheadState & 2) != 0 && this._actionTimeline.playState <= 0; + } + + /** + * 是否播放完毕。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public boolean isCompleted() { + return this._actionTimeline.playState > 0; + } + + /** + * 当前播放次数。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public int getCurrentPlayTimes() { + return this._actionTimeline.currentPlayTimes; + } + + /** + * 总时间。 (以秒为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float getTotalTime() { + return this._duration; + } + + /** + * 当前播放的时间。 (以秒为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float getCurrentTime() { + return this._actionTimeline.currentTime; + } + + public void setCurrentTime(float value) { + int 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) { + value = this._duration - 0.000001f; + } + + if (this._time == value) { + return; + } + + this._time = value; + this._actionTimeline.setCurrentTime(this._time); + + if (this._zOrderTimeline != null) { + this._zOrderTimeline.playState = -1; + } + + for (BoneTimelineState timeline : this._boneTimelines) { + timeline.playState = -1; + } + + for (SlotTimelineState timeline : this._slotTimelines) { + timeline.playState = -1; + } + } + + /** + * @see #animationData + * @deprecated 已废弃,请参考 @see + */ + public AnimationData getClip() { + return this.animationData; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/BoneAllTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/BoneAllTimelineState.java new file mode 100644 index 0000000..88a7957 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/BoneAllTimelineState.java @@ -0,0 +1,84 @@ +package com.dragonbones.animation; + +import com.dragonbones.geom.Transform; +import com.dragonbones.util.FloatArray; + +/** + * @internal + * @private + */ +public class BoneAllTimelineState extends BoneTimelineState { + protected void _onArriveAtFrame() { + super._onArriveAtFrame(); + + if (this._timelineData != null) { + FloatArray frameFloatArray = this._dragonBonesData.frameFloatArray; + Transform current = this.bonePose.current; + Transform delta = this.bonePose.delta; + int valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + + current.x = frameFloatArray.get(valueOffset++); + current.y = frameFloatArray.get(valueOffset++); + current.rotation = frameFloatArray.get(valueOffset++); + current.skew = frameFloatArray.get(valueOffset++); + current.scaleX = frameFloatArray.get(valueOffset++); + current.scaleY = frameFloatArray.get(valueOffset++); + + if (this._tweenState == TweenState.Always) { + if (this._frameIndex == this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + + delta.x = frameFloatArray.get(valueOffset++) - current.x; + delta.y = frameFloatArray.get(valueOffset++) - current.y; + delta.rotation = frameFloatArray.get(valueOffset++) - current.rotation; + delta.skew = frameFloatArray.get(valueOffset++) - current.skew; + delta.scaleX = frameFloatArray.get(valueOffset++) - current.scaleX; + delta.scaleY = frameFloatArray.get(valueOffset++) - current.scaleY; + } + // else { + // delta.x = 0f; + // delta.y = 0f; + // delta.rotation = 0f; + // delta.skew = 0f; + // delta.scaleX = 0f; + // delta.scaleY = 0f; + // } + } else { // Pose. + Transform current = this.bonePose.current; + current.x = 0f; + current.y = 0f; + current.rotation = 0f; + current.skew = 0f; + current.scaleX = 1f; + current.scaleY = 1f; + } + } + + protected void _onUpdateFrame() { + super._onUpdateFrame(); + + Transform current = this.bonePose.current; + Transform delta = this.bonePose.delta; + Transform result = this.bonePose.result; + + this.bone._transformDirty = true; + if (this._tweenState != TweenState.Always) { + this._tweenState = TweenState.None; + } + + float scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + } + + public void fadeOut() { + Transform result = this.bonePose.result; + result.rotation = Transform.normalizeRadian(result.rotation); + result.skew = Transform.normalizeRadian(result.skew); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/BonePose.java b/dragonbones-core/src/main/java/com/dragonbones/animation/BonePose.java new file mode 100644 index 0000000..4341858 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/BonePose.java @@ -0,0 +1,20 @@ +package com.dragonbones.animation; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.geom.Transform; + +/** + * @internal + * @private + */ +public class BonePose extends BaseObject { + public final Transform current = new Transform(); + public final Transform delta = new Transform(); + public final Transform result = new Transform(); + + protected void _onClear() { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/BoneTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/BoneTimelineState.java new file mode 100644 index 0000000..bbef789 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/BoneTimelineState.java @@ -0,0 +1,19 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Bone; + +/** + * @internal + * @private + */ +public abstract class BoneTimelineState extends TweenTimelineState { + public Bone bone; + public BonePose bonePose; + + protected void _onClear() { + super._onClear(); + + this.bone = null; // + this.bonePose = null; // + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/IAnimatable.java b/dragonbones-core/src/main/java/com/dragonbones/animation/IAnimatable.java new file mode 100644 index 0000000..032ad58 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/IAnimatable.java @@ -0,0 +1,31 @@ +package com.dragonbones.animation; + +/** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see WorldClock + * @see com.dragonbones.armature.Armature + */ +public interface IAnimatable { + /** + * 更新时间。 + * + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + void advanceTime(float passedTime); + + /** + * 当前所属的 WordClock 实例。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + WorldClock getClock(); + + void setClock(WorldClock value); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/SlotColorTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotColorTimelineState.java new file mode 100644 index 0000000..8ac0f0a --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotColorTimelineState.java @@ -0,0 +1,149 @@ +package com.dragonbones.animation; + +import com.dragonbones.geom.ColorTransform; +import com.dragonbones.util.FloatArray; +import com.dragonbones.util.ShortArray; + +/** + * @internal + * @private + */ +public class SlotColorTimelineState extends SlotTimelineState { + private boolean _dirty; + private final FloatArray _current = new FloatArray(new float[]{0, 0, 0, 0, 0, 0, 0, 0}); + private final FloatArray _delta = new FloatArray(new float[]{0, 0, 0, 0, 0, 0, 0, 0}); + private final FloatArray _result = new FloatArray(new float[]{0f, 0f, 0f, 0f, 0f, 0f, 0f, 0f}); + + protected void _onClear() { + super._onClear(); + + this._dirty = false; + } + + protected void _onArriveAtFrame() { + super._onArriveAtFrame(); + + if (this._timelineData != null) { + ShortArray intArray = this._dragonBonesData.intArray; + ShortArray frameIntArray = this._dragonBonesData.frameIntArray; + int valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + int colorOffset = frameIntArray.get(valueOffset); + this._current.set(0, intArray.get(colorOffset++)); + this._current.set(1, intArray.get(colorOffset++)); + this._current.set(2, intArray.get(colorOffset++)); + this._current.set(3, intArray.get(colorOffset++)); + this._current.set(4, intArray.get(colorOffset++)); + this._current.set(5, intArray.get(colorOffset++)); + this._current.set(6, intArray.get(colorOffset++)); + this._current.set(7, intArray.get(colorOffset++)); + + if (this._tweenState == TweenState.Always) { + if (this._frameIndex == this._frameCount - 1) { + colorOffset = frameIntArray.get(this._animationData.frameIntOffset + this._frameValueOffset); + } else { + colorOffset = frameIntArray.get(valueOffset + 1 * 1); + } + + this._delta.set(0, intArray.get(colorOffset++) - this._current.get(0)); + this._delta.set(1, intArray.get(colorOffset++) - this._current.get(1)); + this._delta.set(2, intArray.get(colorOffset++) - this._current.get(2)); + this._delta.set(3, intArray.get(colorOffset++) - this._current.get(3)); + this._delta.set(4, intArray.get(colorOffset++) - this._current.get(4)); + this._delta.set(5, intArray.get(colorOffset++) - this._current.get(5)); + this._delta.set(6, intArray.get(colorOffset++) - this._current.get(6)); + this._delta.set(7, intArray.get(colorOffset++) - this._current.get(7)); + } + } else { // Pose. + ColorTransform color = this.slot.slotData.color; + this._current.set(0, color.alphaMultiplier * 100f); + this._current.set(1, color.redMultiplier * 100f); + this._current.set(2, color.greenMultiplier * 100f); + this._current.set(3, color.blueMultiplier * 100f); + this._current.set(4, color.alphaOffset); + this._current.set(5, color.redOffset); + this._current.set(6, color.greenOffset); + this._current.set(7, color.blueOffset); + } + } + + protected void _onUpdateFrame() { + super._onUpdateFrame(); + + this._dirty = true; + if (this._tweenState != TweenState.Always) { + this._tweenState = TweenState.None; + } + + this._result.set(0, (this._current.get(0) + this._delta.get(0) * this._tweenProgress) * 0.01f); + this._result.set(1, (this._current.get(1) + this._delta.get(1) * this._tweenProgress) * 0.01f); + this._result.set(2, (this._current.get(2) + this._delta.get(2) * this._tweenProgress) * 0.01f); + this._result.set(3, (this._current.get(3) + this._delta.get(3) * this._tweenProgress) * 0.01f); + this._result.set(4, (this._current.get(4) + this._delta.get(4) * this._tweenProgress)); + this._result.set(5, (this._current.get(5) + this._delta.get(5) * this._tweenProgress)); + this._result.set(6, (this._current.get(6) + this._delta.get(6) * this._tweenProgress)); + this._result.set(7, (this._current.get(7) + this._delta.get(7) * this._tweenProgress)); + } + + public void fadeOut() { + this._tweenState = TweenState.None; + this._dirty = false; + } + + public void update(float passedTime) { + super.update(passedTime); + + // Fade animation. + if (this._tweenState != TweenState.None || this._dirty) { + ColorTransform result = this.slot._colorTransform; + + if (this._animationState._fadeState != 0 || this._animationState._subFadeState != 0) { + if ( + result.alphaMultiplier != this._result.get(0) || + result.redMultiplier != this._result.get(1) || + result.greenMultiplier != this._result.get(2) || + result.blueMultiplier != this._result.get(3) || + result.alphaOffset != this._result.get(4) || + result.redOffset != this._result.get(5) || + result.greenOffset != this._result.get(6) || + result.blueOffset != this._result.get(7) + ) { + float fadeProgress = (float) Math.pow(this._animationState._fadeProgress, 4); + + result.alphaMultiplier += (this._result.get(0) - result.alphaMultiplier) * fadeProgress; + result.redMultiplier += (this._result.get(1) - result.redMultiplier) * fadeProgress; + result.greenMultiplier += (this._result.get(2) - result.greenMultiplier) * fadeProgress; + result.blueMultiplier += (this._result.get(3) - result.blueMultiplier) * fadeProgress; + result.alphaOffset += (this._result.get(4) - result.alphaOffset) * fadeProgress; + result.redOffset += (this._result.get(5) - result.redOffset) * fadeProgress; + result.greenOffset += (this._result.get(6) - result.greenOffset) * fadeProgress; + result.blueOffset += (this._result.get(7) - result.blueOffset) * fadeProgress; + + this.slot._colorDirty = true; + } + } else if (this._dirty) { + this._dirty = false; + if ( + result.alphaMultiplier != this._result.get(1) || + result.redMultiplier != this._result.get(1) || + result.greenMultiplier != this._result.get(1) || + result.blueMultiplier != this._result.get(1) || + result.alphaOffset != this._result.get(1) || + result.redOffset != this._result.get(1) || + result.greenOffset != this._result.get(1) || + result.blueOffset != this._result.get(1) + ) { + result.alphaMultiplier = this._result.get(1); + result.redMultiplier = this._result.get(1); + result.greenMultiplier = this._result.get(1); + result.blueMultiplier = this._result.get(1); + result.alphaOffset = (int) this._result.get(1); + result.redOffset = (int) this._result.get(1); + result.greenOffset = (int) this._result.get(1); + result.blueOffset = (int) this._result.get(1); + + this.slot._colorDirty = true; + } + } + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/SlotDislayIndexTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotDislayIndexTimelineState.java new file mode 100644 index 0000000..9afac3a --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotDislayIndexTimelineState.java @@ -0,0 +1,16 @@ +package com.dragonbones.animation; + +/** + * @internal + * @private + */ +public class SlotDislayIndexTimelineState extends SlotTimelineState { + protected void _onArriveAtFrame() { + if (this.playState >= 0) { + int displayIndex = this._timelineData != null ? this._frameArray.get(this._frameOffset + 1) : this.slot.slotData.displayIndex; + if (this.slot.getDisplayIndex() != displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/SlotFFDTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotFFDTimelineState.java new file mode 100644 index 0000000..4556fca --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotFFDTimelineState.java @@ -0,0 +1,176 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Armature; +import com.dragonbones.core.BinaryOffset; +import com.dragonbones.model.TimelineData; +import com.dragonbones.util.FloatArray; +import com.dragonbones.util.ShortArray; +import org.jetbrains.annotations.Nullable; + +/** + * @internal + * @private + */ +public class SlotFFDTimelineState extends SlotTimelineState { + public int meshOffset; + + private boolean _dirty; + private int _frameFloatOffset; + private int _valueCount; + private float _ffdCount; + private int _valueOffset; + private final FloatArray _current = new FloatArray(); + private final FloatArray _delta = new FloatArray(); + private final FloatArray _result = new FloatArray(); + + protected void _onClear() { + super._onClear(); + + this.meshOffset = 0; + + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.clear(); + this._delta.clear(); + this._result.clear(); + } + + protected void _onArriveAtFrame() { + super._onArriveAtFrame(); + + if (this._timelineData != null) { + boolean isTween = this._tweenState == TweenState.Always; + FloatArray frameFloatArray = this._dragonBonesData.frameFloatArray; + int valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + + if (isTween) { + int nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex == this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + + for (int i = 0; i < this._valueCount; ++i) { + float v = frameFloatArray.get(valueOffset + i); + this._current.set(i, v); + this._delta.set(i, frameFloatArray.get(nextValueOffset + i) - v); + } + } else { + for (int i = 0; i < this._valueCount; ++i) { + this._current.set(i, frameFloatArray.get(valueOffset + i)); + } + } + } else { + for (int i = 0; i < this._valueCount; ++i) { + this._current.set(i, 0f); + } + } + } + + protected void _onUpdateFrame() { + super._onUpdateFrame(); + + this._dirty = true; + if (this._tweenState != TweenState.Always) { + this._tweenState = TweenState.None; + } + + for (int i = 0; i < this._valueCount; ++i) { + this._result.set(i, this._current.get(i) + this._delta.get(i) * this._tweenProgress); + } + } + + public void init(Armature armature, AnimationState animationState, @Nullable TimelineData timelineData) { + super.init(armature, animationState, timelineData); + + if (this._timelineData != null) { + ShortArray frameIntArray = this._dragonBonesData.frameIntArray; + int frameIntOffset = this._animationData.frameIntOffset + this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineFrameValueCount.v); + this.meshOffset = frameIntArray.get(frameIntOffset + BinaryOffset.FFDTimelineMeshOffset.v); + this._ffdCount = frameIntArray.get(frameIntOffset + BinaryOffset.FFDTimelineFFDCount.v); + this._valueCount = frameIntArray.get(frameIntOffset + BinaryOffset.FFDTimelineValueCount.v); + this._valueOffset = frameIntArray.get(frameIntOffset + BinaryOffset.FFDTimelineValueOffset.v); + this._frameFloatOffset = frameIntArray.get(frameIntOffset + BinaryOffset.FFDTimelineFloatOffset.v) + this._animationData.frameFloatOffset; + } else { + this._valueCount = 0; + } + + this._current.setLength(this._valueCount); + this._delta.setLength(this._valueCount); + this._result.setLength(this._valueCount); + + for (int i = 0; i < this._valueCount; ++i) { + this._delta.set(i, 0f); + } + } + + public void fadeOut() { + this._tweenState = TweenState.None; + this._dirty = false; + } + + public void update(float passedTime) { + if (this.slot._meshData == null || (this._timelineData != null && this.slot._meshData.offset != this.meshOffset)) { + return; + } + + super.update(passedTime); + + // Fade animation. + if (this._tweenState != TweenState.None || this._dirty) { + FloatArray result = this.slot._ffdVertices; + if (this._timelineData != null) { + FloatArray frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState != 0 || this._animationState._subFadeState != 0) { + float fadeProgress = (float) Math.pow(this._animationState._fadeProgress, 2); + + for (int i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result.set(i, result.get(i) + (frameFloatArray.get(this._frameFloatOffset + i) - result.get(i)) * fadeProgress); + } else if (i < this._valueOffset + this._valueCount) { + result.set(i, result.get(i) + (this._result.get(i - this._valueOffset) - result.get(i)) * fadeProgress); + } else { + result.set(i, result.get(i) + (frameFloatArray.get(this._frameFloatOffset + i - this._valueCount) - result.get(i)) * fadeProgress); + } + } + + this.slot._meshDirty = true; + } else if (this._dirty) { + this._dirty = false; + + for (int i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result.set(i, frameFloatArray.get(this._frameFloatOffset + i)); + } else if (i < this._valueOffset + this._valueCount) { + result.set(i, this._result.get(i - this._valueOffset)); + } else { + result.set(i, frameFloatArray.get(this._frameFloatOffset + i - this._valueCount)); + } + } + + this.slot._meshDirty = true; + } + } else { + this._ffdCount = result.size(); // + if (this._animationState._fadeState != 0 || this._animationState._subFadeState != 0) { + float fadeProgress = (float) Math.pow(this._animationState._fadeProgress, 2); + for (int i = 0; i < this._ffdCount; ++i) { + result.set(i, result.get(i) + (0f - result.get(i)) * fadeProgress); + } + + this.slot._meshDirty = true; + } else if (this._dirty) { + this._dirty = false; + + for (int i = 0; i < this._ffdCount; ++i) { + result.set(i, 0f); + } + + this.slot._meshDirty = true; + } + } + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/SlotTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotTimelineState.java new file mode 100644 index 0000000..cb063d6 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/SlotTimelineState.java @@ -0,0 +1,17 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Slot; + +/** + * @internal + * @private + */ +public abstract class SlotTimelineState extends TweenTimelineState { + public Slot slot; + + protected void _onClear() { + super._onClear(); + + this.slot = null; // + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/TimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/TimelineState.java new file mode 100644 index 0000000..11ebd32 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/TimelineState.java @@ -0,0 +1,208 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Armature; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.BinaryOffset; +import com.dragonbones.model.AnimationData; +import com.dragonbones.model.DragonBonesData; +import com.dragonbones.model.TimelineData; +import com.dragonbones.util.CharArray; +import com.dragonbones.util.FloatArray; +import com.dragonbones.util.IntArray; +import com.dragonbones.util.ShortArray; +import org.jetbrains.annotations.Nullable; + +/** + * @internal + * @private + */ +public abstract class TimelineState extends BaseObject { + public int playState; // -1: start, 0: play, 1: complete; + public int currentPlayTimes; + public float currentTime; + + protected TweenState _tweenState; + protected float _frameRate; + protected int _frameValueOffset; + protected int _frameCount; + protected int _frameOffset; + protected int _frameIndex; + protected float _frameRateR; + protected float _position; + protected float _duration; + protected float _timeScale; + protected float _timeOffset; + protected DragonBonesData _dragonBonesData; + protected AnimationData _animationData; + @Nullable + protected TimelineData _timelineData; + protected Armature _armature; + protected AnimationState _animationState; + protected TimelineState _actionTimeline; + protected ShortArray _frameArray; + protected ShortArray _frameIntArray; + protected FloatArray _frameFloatArray; + protected CharArray _timelineArray; + protected IntArray _frameIndices; + + protected void _onClear() { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1f; + + this._tweenState = TweenState.None; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 0; + this._frameIndex = -1; + this._frameRateR = 0f; + this._position = 0f; + this._duration = 0f; + this._timeScale = 1f; + this._timeOffset = 0f; + this._dragonBonesData = null; // + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._frameIntArray = null; // + this._frameFloatArray = null; // + this._timelineArray = null; // + this._frameIndices = null; // + } + + protected abstract void _onArriveAtFrame(); + + protected abstract void _onUpdateFrame(); + + protected boolean _setCurrentTime(float passedTime) { + float prevState = this.playState; + float prevPlayTimes = this.currentPlayTimes; + float 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 != 1f || this._timeOffset != 0f) { // Action timeline or has scale and offset. + int playTimes = this._animationState.playTimes; + float totalTime = playTimes * this._duration; + + passedTime *= this._timeScale; + if (this._timeOffset != 0f) { + 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 < 0f) { + this.currentTime = 0f; + } else { + this.currentTime = this._duration; + } + } else { + if (this.playState != 0 && this._animationState._playheadState == 3) { + this.playState = 0; + } + + if (passedTime < 0f) { + passedTime = -passedTime; + this.currentPlayTimes = (int) Math.floor(passedTime / this._duration); + this.currentTime = this._duration - (passedTime % this._duration); + } else { + this.currentPlayTimes = (int) 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; + } + + public void init(Armature armature, AnimationState animationState, @Nullable TimelineData timelineData) { + this._armature = armature; + this._animationState = animationState; + this._timelineData = timelineData; + this._actionTimeline = this._animationState._actionTimeline; + + if (this == this._actionTimeline) { + this._actionTimeline = null; // + } + + this._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1f / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + + if (this._timelineData != null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._dragonBonesData.frameIndices; + + this._frameCount = this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineKeyFrameCount.v); + this._frameValueOffset = this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineFrameValueOffset.v); + this._timeScale = 100f / this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineScale.v); + this._timeOffset = this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineOffset.v) * 0.01f; + } + } + + public void fadeOut() { + } + + public void update(float passedTime) { + if (this.playState <= 0 && this._setCurrentTime(passedTime)) { + if (this._frameCount > 1) { + int timelineFrameIndex = (int) Math.floor(this.currentTime * this._frameRate); // uint + int frameIndex = this._frameIndices.get(this._timelineData.frameIndicesOffset + timelineFrameIndex); + if (this._frameIndex != frameIndex) { + this._frameIndex = frameIndex; + this._frameOffset = this._animationData.frameOffset + this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineFrameOffset.v + 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.get(this._timelineData.offset + BinaryOffset.TimelineFrameOffset.v); + } + + this._onArriveAtFrame(); + } + + if (this._tweenState != TweenState.None) { + this._onUpdateFrame(); + } + } + } +} + + diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/TweenState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/TweenState.java new file mode 100644 index 0000000..d96c4d6 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/TweenState.java @@ -0,0 +1,7 @@ +package com.dragonbones.animation; + +public enum TweenState { + None, + Once, + Always +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/TweenTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/TweenTimelineState.java new file mode 100644 index 0000000..8ca1db4 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/TweenTimelineState.java @@ -0,0 +1,106 @@ +package com.dragonbones.animation; + +import com.dragonbones.core.BinaryOffset; +import com.dragonbones.core.TweenType; +import com.dragonbones.util.ShortArray; + +/** + * @internal + * @private + */ +public abstract class TweenTimelineState extends TimelineState { + private static float _getEasingValue(TweenType tweenType, float progress, float easing) { + float value = progress; + + switch (tweenType) { + case QuadIn: + value = (float) Math.pow(progress, 2f); + break; + + case QuadOut: + value = (float) (1f - Math.pow(1f - progress, 2f)); + break; + + case QuadInOut: + value = (float) (0.5 * (1f - Math.cos(progress * Math.PI))); + break; + } + + return (value - progress) * easing + progress; + } + + private static float _getEasingCurveValue(float progress, ShortArray samples, float count, int offset) { + if (progress <= 0f) { + return 0f; + } else if (progress >= 1f) { + return 1f; + } + + float segmentCount = count + 1; // + 2 - 1 + int valueIndex = (int) Math.floor(progress * segmentCount); + float fromValue = valueIndex == 0 ? 0f : samples.get(offset + valueIndex - 1); + float toValue = (valueIndex == segmentCount - 1) ? 10000f : samples.get(offset + valueIndex); + + return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001f; + } + + protected TweenType _tweenType; + protected float _curveCount; + protected float _framePosition; + protected float _frameDurationR; + protected float _tweenProgress; + protected float _tweenEasing; + + protected void _onClear() { + super._onClear(); + + this._tweenType = TweenType.None; + this._curveCount = 0; + this._framePosition = 0f; + this._frameDurationR = 0f; + this._tweenProgress = 0f; + this._tweenEasing = 0f; + } + + protected void _onArriveAtFrame() { + if ( + this._frameCount > 1 && + ( + this._frameIndex != this._frameCount - 1 || + this._animationState.playTimes == 0 || + this._animationState.getCurrentPlayTimes() < this._animationState.playTimes - 1 + ) + ) { + this._tweenType = TweenType.values[this._frameArray.get(this._frameOffset + BinaryOffset.FrameTweenType.v)]; // TODO recode ture tween type. + this._tweenState = this._tweenType == TweenType.None ? TweenState.Once : TweenState.Always; + if (this._tweenType == TweenType.Curve) { + this._curveCount = this._frameArray.get(this._frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount.v); + } else if (this._tweenType != TweenType.None && this._tweenType != TweenType.Line) { + this._tweenEasing = this._frameArray.get(this._frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount.v) * 0.01f; + } + + this._framePosition = this._frameArray.get(this._frameOffset) * this._frameRateR; + if (this._frameIndex == this._frameCount - 1) { + this._frameDurationR = 1f / (this._animationData.duration - this._framePosition); + } else { + int nextFrameOffset = this._animationData.frameOffset + (int) this._timelineArray.get(this._timelineData.offset + BinaryOffset.TimelineFrameOffset.v + this._frameIndex + 1); + this._frameDurationR = 1f / (this._frameArray.get(nextFrameOffset) * this._frameRateR - this._framePosition); + } + } else { + this._tweenState = TweenState.Once; + } + } + + protected void _onUpdateFrame() { + if (this._tweenState == TweenState.Always) { + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + if (this._tweenType == TweenType.Curve) { + this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + BinaryOffset.FrameCurveSamples.v); + } else if (this._tweenType != TweenType.Line) { + this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); + } + } else { + this._tweenProgress = 0f; + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/WorldClock.java b/dragonbones-core/src/main/java/com/dragonbones/animation/WorldClock.java new file mode 100644 index 0000000..cf1ca6f --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/WorldClock.java @@ -0,0 +1,206 @@ +package com.dragonbones.animation; + +import com.dragonbones.armature.Armature; +import com.dragonbones.util.Array; +import org.jetbrains.annotations.Nullable; + +/** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see IAnimatable + * @see Armature + */ +public class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public static final WorldClock clock = new WorldClock(); + /** + * 当前时间。 (以秒为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float time = 0f; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * + * @default 1f + * @version DragonBones 3.0 + * @language zh_CN + */ + public float timeScale = 1f; + private final Array _animatebles = new Array<>(); + @Nullable + private WorldClock _clock = null; + + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public WorldClock() { + this(-1f); + } + + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public WorldClock(float time) { + if (time < 0f) { + this.time = System.currentTimeMillis() * 0.001f; + } else { + this.time = time; + } + } + + /** + * 为所有的 IAnimatable 实例更新时间。 + * + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + public void advanceTime(float passedTime) { + if (passedTime != passedTime) { // isNaN + passedTime = 0f; + } + + if (passedTime < 0f) { + passedTime = System.currentTimeMillis() * 0.001f - this.time; + } + + if (this.timeScale != 1f) { + passedTime *= this.timeScale; + } + + if (passedTime < 0f) { + this.time -= passedTime; + } else { + this.time += passedTime; + } + + if (passedTime == 0f) { + return; + } + + int i = 0, r = 0, l = this._animatebles.size(); + for (; i < l; ++i) { + IAnimatable animatable = this._animatebles.get(i); + if (animatable != null) { + if (r > 0) { + this._animatebles.set(i - r, animatable); + this._animatebles.set(i, null); + } + + animatable.advanceTime(passedTime); + } else { + r++; + } + } + + if (r > 0) { + l = this._animatebles.size(); + for (; i < l; ++i) { + IAnimatable animateble = this._animatebles.get(i); + if (animateble != null) { + this._animatebles.set(i - r, animateble); + } else { + r++; + } + } + + this._animatebles.setLength(this._animatebles.size() - r); + } + } + + /** + * 是否包含 IAnimatable 实例 + * + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public boolean contains(IAnimatable value) { + return this._animatebles.indexOf(value) >= 0; + } + + /** + * 添加 IAnimatable 实例。 + * + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void add(IAnimatable value) { + if (this._animatebles.indexOf(value) < 0) { + this._animatebles.add(value); + value.setClock(this); + } + } + + /** + * 移除 IAnimatable 实例。 + * + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void remove(IAnimatable value) { + int index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles.set(index, null); + value.setClock(null); + } + } + + /** + * 清除所有的 IAnimatable 实例。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public void clear() { + for (IAnimatable animatable : this._animatebles) { + if (animatable != null) { + animatable.setClock(null); + } + } + } + + /** + * @inheritDoc + */ + public WorldClock getClock() { + return this._clock; + } + + public void setClock(WorldClock 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); + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/animation/ZOrderTimelineState.java b/dragonbones-core/src/main/java/com/dragonbones/animation/ZOrderTimelineState.java new file mode 100644 index 0000000..db2dd0e --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/animation/ZOrderTimelineState.java @@ -0,0 +1,21 @@ +package com.dragonbones.animation; + +/** + * @internal + * @private + */ +public class ZOrderTimelineState extends TimelineState { + protected void _onArriveAtFrame() { + if (this.playState >= 0) { + int count = this._frameArray.get(this._frameOffset + 1); + if (count > 0) { + this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); + } else { + this._armature._sortZOrder(null, 0); + } + } + } + + protected void _onUpdateFrame() { + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/Armature.java b/dragonbones-core/src/main/java/com/dragonbones/armature/Armature.java new file mode 100644 index 0000000..28fd8dc --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/Armature.java @@ -0,0 +1,950 @@ +package com.dragonbones.armature; + +import com.dragonbones.animation.Animation; +import com.dragonbones.animation.IAnimatable; +import com.dragonbones.animation.WorldClock; +import com.dragonbones.core.ActionType; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.DragonBones; +import com.dragonbones.event.EventStringType; +import com.dragonbones.event.IEventDispatcher; +import com.dragonbones.geom.Point; +import com.dragonbones.model.*; +import com.dragonbones.util.Array; +import com.dragonbones.util.Console; +import com.dragonbones.util.Function; +import com.dragonbones.util.ShortArray; +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; + +/** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see ArmatureData + * @see Bone + * @see Slot + * @see Animation + */ +public class Armature extends BaseObject implements IAnimatable { + private static int _onSortSlots(Slot a, Slot b) { + return a._zOrder > b._zOrder ? 1 : -1; + } + + /** + * 是否继承父骨架的动画状态。 + * + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + public boolean inheritAnimation; + /** + * @private + */ + public boolean debugDraw; + /** + * 获取骨架数据。 + * + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + * @see ArmatureData + */ + public ArmatureData armatureData; + /** + * 用于存储临时数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Object userData; + + private boolean _debugDraw; + private boolean _lockUpdate; + private boolean _bonesDirty; + private boolean _slotsDirty; + private boolean _zOrderDirty; + private boolean _flipX; + private boolean _flipY; + /** + * @internal + * @private + */ + public int _cacheFrameIndex; + private final Array _bones = new Array<>(); + private final Array _slots = new Array<>(); + private final Array _actions = new Array<>(); + @Nullable + private Animation _animation = null; // Initial value. + @Nullable + private IArmatureProxy _proxy = null; // Initial value. + private Object _display; + /** + * @private + */ + @Nullable + public TextureAtlasData _replaceTextureAtlasData = null; // Initial value. + private Object _replacedTexture; + /** + * @internal + * @private + */ + public DragonBones _dragonBones; + @Nullable + private WorldClock _clock = null; // Initial value. + /** + * @internal + * @private + */ + @Nullable + public Slot _parent; + + @Override + public void setClock(WorldClock value) { + this._clock = value; + } + + /** + * @private + */ + protected void _onClear() { + if (this._clock != null) { // Remove clock first. + this._clock.remove(this); + } + + for (Bone bone : this._bones) { + bone.returnToPool(); + } + + for (Slot slot : this._slots) { + slot.returnToPool(); + } + + for (ActionData action : this._actions) { + action.returnToPool(); + } + + if (this._animation != null) { + this._animation.returnToPool(); + } + + if (this._proxy != null) { + this._proxy.clear(); + } + + if (this._replaceTextureAtlasData != null) { + this._replaceTextureAtlasData.returnToPool(); + } + + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null; // + this.userData = null; + + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.clear(); + this._slots.clear(); + this._actions.clear(); + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + } + + private void _sortBones() { + int total = this._bones.size(); + if (total <= 0) { + return; + } + + Array sortHelper = this._bones.copy(); + int index = 0; + int count = 0; + + this._bones.clear(); + while (count < total) { + Bone bone = sortHelper.get(index++); + if (index >= total) { + index = 0; + } + + if (this._bones.indexOf(bone) >= 0) { + continue; + } + + if (bone.constraints.size() > 0) { // Wait constraint. + boolean flag = false; + for (Constraint constraint : bone.constraints) { + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + + if (flag) { + continue; + } + } + + if (bone.getParent() != null && this._bones.indexOf(bone.getParent()) < 0) { // Wait parent. + continue; + } + + this._bones.add(bone); + count++; + } + } + + private void _sortSlots() { + this._slots.sort(Armature::_onSortSlots); + } + + /** + * @internal + * @private + */ + public void _sortZOrder(@Nullable ShortArray slotIndices, int offset) { + Array slotDatas = this.armatureData.sortedSlots; + boolean isOriginal = slotIndices == null; + + if (this._zOrderDirty || !isOriginal) { + for (int i = 0, l = slotDatas.size(); i < l; ++i) { + int slotIndex = isOriginal ? i : slotIndices.get(offset + i); + if (slotIndex < 0 || slotIndex >= l) { + continue; + } + + SlotData slotData = slotDatas.get(slotIndex); + Slot slot = this.getSlot(slotData.name); + if (slot != null) { + slot._setZorder(i); + } + } + + this._slotsDirty = true; + this._zOrderDirty = !isOriginal; + } + } + + /** + * @internal + * @private + */ + public void _addBoneToBoneList(Bone value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.add(value); + this._animation._timelineDirty = true; + } + } + + /** + * @internal + * @private + */ + public void _removeBoneFromBoneList(Bone value) { + int index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + } + + /** + * @internal + * @private + */ + public void _addSlotToSlotList(Slot value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.add(value); + this._animation._timelineDirty = true; + } + } + + /** + * @internal + * @private + */ + public void _removeSlotFromSlotList(Slot value) { + int index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + } + + /** + * @internal + * @private + */ + public void _bufferAction(ActionData action, boolean append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.add(action); + } else { + this._actions.unshiftObject(action); + } + } + } + + /** + * 释放骨架。 (回收到对象池) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public void dispose() { + if (this.armatureData != null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + } + + /** + * @private + */ + public void init( + ArmatureData armatureData, + IArmatureProxy proxy, Object display, DragonBones dragonBones + ) { + if (this.armatureData != null) { + return; + } + + this.armatureData = armatureData; + this._animation = BaseObject.borrowObject(Animation.class); + this._proxy = proxy; + this._display = display; + this._dragonBones = dragonBones; + + this._proxy.init(this); + this._animation.init(this); + this._animation.setAnimations(this.armatureData.animations); + } + + /** + * 更新骨架和动画。 + * + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + * @see IAnimatable + * @see WorldClock + */ + public void advanceTime(float passedTime) { + if (this._lockUpdate) { + return; + } + + if (this.armatureData == null) { + Console._assert(false, "The armature has been disposed."); + return; + } else if (this.armatureData.parent == null) { + Console._assert(false, "The armature data has been disposed."); + return; + } + + int prevCacheFrameIndex = this._cacheFrameIndex; + + // Update nimation. + this._animation.advanceTime(passedTime); + + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + + // Update bones and slots. + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex != prevCacheFrameIndex) { + int i = 0, l = 0; + for (i = 0, l = this._bones.size(); i < l; ++i) { + this._bones.get(i).update(this._cacheFrameIndex); + } + + for (i = 0, l = this._slots.size(); i < l; ++i) { + this._slots.get(i).update(this._cacheFrameIndex); + } + } + + if (this._actions.size() > 0) { + this._lockUpdate = true; + for (ActionData action : this._actions) { + if (action.type == ActionType.Play) { + this._animation.fadeIn(action.name); + } + } + + this._actions.clear(); + this._lockUpdate = false; + } + + // + boolean drawed = this.debugDraw || DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + } + + public void invalidUpdate() { + invalidUpdate(null, false); + } + + public void invalidUpdate(@Nullable String boneName) { + invalidUpdate(boneName, false); + } + + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + * @see Bone + * @see Slot + */ + public void invalidUpdate(@Nullable String boneName, boolean updateSlotDisplay) { + if (boneName != null && boneName.length() > 0) { + Bone bone = this.getBone(boneName); + if (bone != null) { + bone.invalidUpdate(); + + if (updateSlotDisplay) { + for (Slot slot : this._slots) { + if (slot.getParent() == bone) { + slot.invalidUpdate(); + } + } + } + } + } else { + for (Bone bone : this._bones) { + bone.invalidUpdate(); + } + + if (updateSlotDisplay) { + for (Slot slot : this._slots) { + slot.invalidUpdate(); + } + } + } + } + + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + @Nullable + public Slot containsPoint(float x, float y) { + for (Slot slot : this._slots) { + if (slot.containsPoint(x, y)) { + return slot; + } + } + + return null; + } + + @Nullable + public Slot intersectsSegment( + float xA, float yA, float xB, float yB + ) { + return intersectsSegment(xA, yA, xB, yB, null, null, null); + } + + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * + * @param xA 线段起点的水平坐标。(骨架内坐标系) + * @param yA 线段起点的垂直坐标。(骨架内坐标系) + * @param xB 线段终点的水平坐标。(骨架内坐标系) + * @param yB 线段终点的垂直坐标。(骨架内坐标系) + * @param intersectionPointA 线段从起点到终点与包围盒相交的第一个交点。(骨架内坐标系) + * @param intersectionPointB 线段从终点到起点与包围盒相交的第一个交点。(骨架内坐标系) + * @param normalRadians 碰撞点处包围盒切线的法线弧度。 [x: 第一个碰撞点处切线的法线弧度, y: 第二个碰撞点处切线的法线弧度] + * @returns 线段从起点到终点相交的第一个自定义包围盒的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + @Nullable + public Slot intersectsSegment( + float xA, float yA, float xB, float yB, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) + + { + boolean isV = xA == xB; + float dMin = 0f; + float dMax = 0f; + float intXA = 0f; + float intYA = 0f; + float intXB = 0f; + float intYB = 0f; + float intAN = 0f; + float intBN = 0f; + Slot intSlotA = null; + Slot intSlotB = null; + + for (Slot slot : this._slots) { + int intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionPointA != null || intersectionPointB != null) { + if (intersectionPointA != null) { + float d = isV ? intersectionPointA.y - yA : intersectionPointA.x - xA; + if (d < 0f) { + d = -d; + } + + if (intSlotA == null || d < dMin) { + dMin = d; + intXA = intersectionPointA.x; + intYA = intersectionPointA.y; + intSlotA = slot; + + if (normalRadians != null) { + intAN = normalRadians.x; + } + } + } + + if (intersectionPointB != null) { + float d = intersectionPointB.x - xA; + if (d < 0f) { + 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; + } + + /** + * 获取指定名称的骨骼。 + * + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + * @see Bone + */ + @Nullable + public Bone getBone(String name) { + for (Bone bone : this._bones) { + if (Objects.equals(bone.name, name)) { + return bone; + } + } + + return null; + } + + /** + * 通过显示对象获取骨骼。 + * + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + * @see Bone + */ + @Nullable + public Bone getBoneByDisplay(Object display) { + Slot slot = this.getSlotByDisplay(display); + return slot != null ? slot.getParent() : null; + } + + /** + * 获取插槽。 + * + * @param name 插槽的名称。 + * @returns 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot + */ + @Nullable + public Slot getSlot(String name) { + for (Slot slot : this._slots) { + if (Objects.equals(slot.name, name)) { + return slot; + } + } + + return null; + } + + /** + * 通过显示对象获取插槽。 + * + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot + */ + @Nullable + public Slot getSlotByDisplay(Object display) { + if (display != null) { + for (Slot slot : this._slots) { + if (slot.getDisplay() == display) { + return slot; + } + } + } + + return null; + } + + public void addBone(Bone value) { + addBone(value, null); + } + + /** + * @deprecated + */ + public void addBone(Bone value, @Nullable String parentName) { + Console._assert(value != null); + + value._setArmature(this); + value._setParent(parentName != null ? this.getBone(parentName) : null); + } + + /** + * @deprecated + */ + public void removeBone(Bone value) { + Console._assert(value != null && value.getArmature() == this); + + value._setParent(null); + value._setArmature(null); + } + + /** + * @deprecated + */ + public void addSlot(Slot value, String parentName) { + Bone bone = this.getBone(parentName); + + Console._assert(value != null && bone != null); + + value._setArmature(this); + value._setParent(bone); + } + + /** + * @deprecated + */ + public void removeSlot(Slot value) { + Console._assert(value != null && value.getArmature() == this); + + value._setParent(null); + value._setArmature(null); + } + + /** + * 获取所有骨骼。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Bone + */ + public Array getBones() { + return this._bones; + } + + /** + * 获取所有插槽。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot + */ + public Array getSlots() { + return this._slots; + } + + public boolean getFlipX() { + return this._flipX; + } + + public void setFlipX(boolean value) { + if (this._flipX == value) { + return; + } + + this._flipX = value; + this.invalidUpdate(); + } + + public boolean getFlipY() { + return this._flipY; + } + + public void setFlipY(boolean value) { + if (this._flipY == value) { + return; + } + + this._flipY = value; + this.invalidUpdate(); + } + + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see DragonBonesData#frameRate + * @see ArmatureData#frameRate + */ + public float getCacheFrameRate() { + return this.armatureData.cacheFrameRate; + } + + public void setCacheFrameRate(float value) { + if (this.armatureData.cacheFrameRate != value) { + this.armatureData.cacheFrames(value); + + // Set child armature frameRate. + for (Slot slot : this._slots) { + Armature childArmature = slot.getChildArmature(); + if (childArmature != null) { + childArmature.setCacheFrameRate(value); + } + } + } + } + + /** + * 骨架名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see ArmatureData#name + */ + public String getName() { + return this.armatureData.name; + } + + /** + * 获得动画控制器。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Animation + */ + public Animation getAnimation() { + return this._animation; + } + + /** + * @pivate + */ + public IArmatureProxy getProxy() { + return this._proxy; + } + + /** + * @pivate + */ + public IEventDispatcher getEventDispatcher() { + return this._proxy; + } + + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + public Object getReplacedTexture() { + return this._replacedTexture; + } + + public void setReplacedTexture(Object value) { + if (this._replacedTexture == value) { + return; + } + + if (this._replaceTextureAtlasData != null) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + + this._replacedTexture = value; + + for (Slot slot : this._slots) { + slot.invalidUpdate(); + slot.update(-1); + } + } + + /** + * @inheritDoc + */ + @Nullable + public WorldClock getClock() { + return this._clock; + } + + public void clock(@Nullable WorldClock 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); + } + + // Update childArmature clock. + for (Slot slot : this._slots) { + Armature childArmature = slot.getChildArmature(); + if (childArmature != null) { + childArmature.setClock(this._clock); + } + } + } + + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * + * @version DragonBones 4.5 + * @language zh_CN + * @see Slot + */ + @Nullable + public Slot getParent() { + return this._parent; + } + + /** + * @see Armature#setReplacedTexture(Object) + * @deprecated 已废弃,请参考 @see + */ + public void replaceTexture(Object texture) { + this.setReplacedTexture(texture); + } + + /** + * @see Armature#getEventDispatcher() + * @deprecated 已废弃,请参考 @see + */ + public boolean hasEventListener(EventStringType type) { + return this._proxy.hasEvent(type); + } + + /** + * @see Armature#getEventDispatcher() + * @deprecated 已废弃,请参考 @see + */ + public void addEventListener(EventStringType type, Function listener, Object target) { + this._proxy.addEvent(type, listener, target); + } + + /** + * @see Armature#getEventDispatcher() + * @deprecated 已废弃,请参考 @see + */ + public void removeEventListener(EventStringType type, Function listener, Object target) { + this._proxy.removeEvent(type, listener, target); + } + + /** + * @see #setCacheFrameRate(float) + * @deprecated 已废弃,请参考 @see + */ + public void enableAnimationCache(float frameRate) { + this.setCacheFrameRate(frameRate); + } + + ///** + // * @deprecated + // * 已废弃,请参考 @see + // * @see #_display + // */ + //@Override + //public Object getDisplay() { + // return this._display; + //} + + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Object getDisplay() { + return this._display; + } + +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/Bone.java b/dragonbones-core/src/main/java/com/dragonbones/armature/Bone.java new file mode 100644 index 0000000..46b6f76 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/Bone.java @@ -0,0 +1,514 @@ +package com.dragonbones.armature; + +import com.dragonbones.core.DragonBones; +import com.dragonbones.core.OffsetMode; +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Transform; +import com.dragonbones.model.BoneData; +import com.dragonbones.util.Array; +import com.dragonbones.util.IntArray; +import org.jetbrains.annotations.Nullable; + +/** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see BoneData + * @see Armature + * @see Slot + */ +public class Bone extends TransformObject { + /** + * @private + */ + public OffsetMode offsetMode; + /** + * @internal + * @private + */ + public final Transform animationPose = new Transform(); + /** + * @internal + * @private + */ + public final Array constraints = new Array<>(); + /** + * @readonly + */ + public BoneData boneData; + /** + * @internal + * @private + */ + public boolean _transformDirty; + /** + * @internal + * @private + */ + public boolean _childrenTransformDirty; + /** + * @internal + * @private + */ + public boolean _blendDirty; + private boolean _localDirty; + private boolean _visible; + private int _cachedFrameIndex; + /** + * @internal + * @private + */ + public float _blendLayer; + /** + * @internal + * @private + */ + public float _blendLeftWeight; + /** + * @internal + * @private + */ + public float _blendLayerWeight; + private final Array _bones = new Array<>(); + private final Array _slots = new Array<>(); + /** + * @internal + * @private + */ + @Nullable + public IntArray _cachedFrameIndices = new IntArray(); + + /** + * @private + */ + protected void _onClear() { + super._onClear(); + + for (Constraint constraint : this.constraints) { + constraint.returnToPool(); + } + + this.offsetMode = OffsetMode.Additive; + this.animationPose.identity(); + this.constraints.clear(); + this.boneData = null; // + + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1f; + this._blendLayerWeight = 0f; + this._bones.clear(); + this._slots.clear(); + this._cachedFrameIndices = null; + } + + /** + * @private + */ + private void _updateGlobalTransformMatrix(boolean isCache) { + boolean flipX = this._armature.getFlipX(); + boolean flipY = this._armature.getFlipY() == DragonBones.yDown; + Transform global = this.global; + Matrix globalTransformMatrix = this.globalTransformMatrix; + boolean inherit = this._parent != null; + float dR = 0f; + + if (this.offsetMode == OffsetMode.Additive) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } else if (this.offsetMode == OffsetMode.None) { + global.copyFrom(this.origin).add(this.animationPose); + } else { + inherit = false; + global.copyFrom(this.offset); + } + + if (inherit) { + Matrix parentMatrix = this._parent.globalTransformMatrix; + + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + + if (this.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 (this.boneData.inheritTranslation) { + float x = global.x; + float y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } else { + if (flipX) { + global.x = -global.x; + } + + if (flipY) { + global.y = -global.y; + } + } + + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + + if (this._parent.global.scaleX < 0f) { + dR += Math.PI; + } + + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0f) { + dR -= global.rotation * 2.0; + + if (flipX != flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + + global.rotation += dR; + } else if (flipX || flipY) { + if (flipX && flipY) { + dR = (float)Math.PI; + } else { + dR = -global.rotation * 2.0f; + if (flipX) { + dR += Math.PI; + } + + global.skew += Math.PI; + } + + global.rotation += dR; + } + + global.toMatrix(globalTransformMatrix); + } + } else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + + if (flipY) { + global.y = -global.y; + } + + if (flipX && flipY) { + dR = (float)Math.PI; + } else { + dR = -global.rotation * 2.0f; + if (flipX) { + dR += Math.PI; + } + + global.skew += Math.PI; + } + + global.rotation += dR; + } + + global.toMatrix(globalTransformMatrix); + } + } + + /** + * @internal + * @private + */ + public void _setArmature(@Nullable Armature value) { + if (this._armature == value) { + return; + } + + Array oldSlots = null; + Array oldBones = null; + + if (this._armature != null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + + this._armature = value; // + + if (this._armature != null) { + this._armature._addBoneToBoneList(this); + } + + if (oldSlots != null) { + for (Slot slot : oldSlots) { + if (slot.getParent() == this) { + slot._setArmature(this._armature); + } + } + } + + if (oldBones != null) { + for (Bone bone : oldBones) { + if (bone.getParent() == this) { + bone._setArmature(this._armature); + } + } + } + } + + /** + * @internal + * @private + */ + public void init(BoneData boneData) { + if (this.boneData != null) { + return; + } + + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + } + + /** + * @internal + * @private + */ + public void update(int cacheFrameIndex) { + this._blendDirty = false; + + if (cacheFrameIndex >= 0 && this._cachedFrameIndices != null) { + int cachedFrameIndex = this._cachedFrameIndices.get(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.constraints.size() > 0) { // Update constraints. + for (Constraint constraint : this.constraints) { + 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.set(cacheFrameIndex, this._cachedFrameIndex); + } else { // Dirty. + this._transformDirty = true; + this._cachedFrameIndex = -1; + } + } + } else { + if (this.constraints.size() > 0) { // Update constraints. + for (Constraint constraint : this.constraints) { + 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) { + boolean isCache = cacheFrameIndex >= 0; + if (this._localDirty) { + this._updateGlobalTransformMatrix(isCache); + } + + if (isCache && this._cachedFrameIndices != null) { + int vv = this._armature.armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + this._cachedFrameIndices.set(cacheFrameIndex, vv); + this._cachedFrameIndex = vv; + } + } else { + this._armature.armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + } else if (this._childrenTransformDirty) { + this._childrenTransformDirty = false; + } + + this._localDirty = true; + } + + /** + * @internal + * @private + */ + public void updateByConstraint() { + if (this._localDirty) { + this._localDirty = false; + if (this._transformDirty || (this._parent != null && this._parent._childrenTransformDirty)) { + this._updateGlobalTransformMatrix(true); + } + + this._transformDirty = true; + } + } + + /** + * @internal + * @private + */ + public void addConstraint(Constraint constraint) { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.add(constraint); + } + } + + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public void invalidUpdate() { + this._transformDirty = true; + } + + /** + * 是否包含骨骼或插槽。 + * + * @returns + * @version DragonBones 3.0 + * @language zh_CN + * @see TransformObject + */ + public boolean contains(TransformObject child) { + if (child == this) { + return false; + } + + TransformObject ancestor = child; + while (ancestor != this && ancestor != null) { + ancestor = ancestor.getParent(); + } + + return ancestor == this; + } + + /** + * 所有的子骨骼。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Array getBones() { + this._bones.clear(); + + for (Bone bone : this._armature.getBones()) { + if (bone.getParent() == this) { + this._bones.add(bone); + } + } + + return this._bones; + } + + /** + * 所有的插槽。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot + */ + public Array getSlots() { + this._slots.clear(); + + for (Slot slot : this._armature.getSlots()) { + if (slot.getParent() == this) { + this._slots.add(slot); + } + } + + return this._slots; + } + + /** + * 控制此骨骼所有插槽的可见。 + * + * @default true + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot + */ + public boolean getVisible() { + return this._visible; + } + + public void setVisible(boolean value) { + if (this._visible == value) { + return; + } + + this._visible = value; + + for (Slot slot : this._armature.getSlots()) { + if (slot._parent == this) { + slot._updateVisible(); + } + } + } + + /** + * @see #boneData + * @see BoneData#length + * @deprecated 已废弃,请参考 @see + */ + public float getLength() { + return this.boneData.length; + } + + /** + * @see Armature#getSlot(String) + * @deprecated 已废弃,请参考 @see + */ + @Nullable + public Slot getSlot() { + for (Slot slot : this._armature.getSlots()) { + if (slot.getParent() == this) { + return slot; + } + } + + return null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/Constraint.java b/dragonbones-core/src/main/java/com/dragonbones/armature/Constraint.java new file mode 100644 index 0000000..e84b00b --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/Constraint.java @@ -0,0 +1,30 @@ +package com.dragonbones.armature; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Point; +import com.dragonbones.geom.Transform; +import org.jetbrains.annotations.Nullable; + +/** + * @private + * @internal + */ +public abstract class Constraint extends BaseObject { + protected static final Matrix _helpMatrix = new Matrix(); + protected static final Transform _helpTransform = new Transform(); + protected static final Point _helpPoint = new Point(); + + public Bone target; + public Bone bone; + @Nullable + public Bone root; + + protected void _onClear() { + this.target = null; // + this.bone = null; // + this.root = null; // + } + + public abstract void update(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/IArmatureProxy.java b/dragonbones-core/src/main/java/com/dragonbones/armature/IArmatureProxy.java new file mode 100644 index 0000000..043f6dd --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/IArmatureProxy.java @@ -0,0 +1,49 @@ +package com.dragonbones.armature; + +import com.dragonbones.animation.Animation; +import com.dragonbones.event.IEventDispatcher; + +/** + * @version DragonBones 5.0 + * @language zh_CN + * 骨架代理接口。 + */ +public interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + void init(Armature armature); + + /** + * @private + */ + void clear(); + + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + void dispose(boolean disposeProxy); + + /** + * @private + */ + void debugUpdate(boolean isEnabled); + + /** + * @language zh_CN + * 获取骨架。 + * @version DragonBones 4.5 + * @see Armature + */ + Armature armature(); + + /** + * @language zh_CN + * 获取动画控制器。 + * @version DragonBones 4.5 + * @see Animation + */ + Animation animation(); +} \ No newline at end of file diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/IKConstraint.java b/dragonbones-core/src/main/java/com/dragonbones/armature/IKConstraint.java new file mode 100644 index 0000000..f46d0d0 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/IKConstraint.java @@ -0,0 +1,124 @@ +package com.dragonbones.armature; + +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Transform; + +/** + * @private + * @internal + */ +public class IKConstraint extends Constraint { + public boolean bendPositive; + public boolean scaleEnabled; // TODO + public float weight; + + protected void _onClear() { + super._onClear(); + + this.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1f; + } + + private void _computeA() { + Transform ikGlobal = this.target.global; + Transform global = this.bone.global; + Matrix globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + + float ikRadian = (float) Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0f) { + ikRadian += Math.PI; + } + + global.rotation += (ikRadian - global.rotation) * this.weight; + global.toMatrix(globalTransformMatrix); + } + + private void _computeB() { + float boneLength = this.bone.boneData.length; + Bone parent = this.root; + Transform ikGlobal = this.target.global; + Transform parentGlobal = parent.global; + Transform global = this.bone.global; + Matrix globalTransformMatrix = this.bone.globalTransformMatrix; + + float x = globalTransformMatrix.a * boneLength; + float y = globalTransformMatrix.b * boneLength; + + float lLL = x * x + y * y; + float lL = (float) Math.sqrt(lLL); + + float dX = global.x - parentGlobal.x; + float dY = global.y - parentGlobal.y; + float lPP = dX * dX + dY * dY; + float lP = (float) Math.sqrt(lPP); + float rawRadianA = (float) Math.atan2(dY, dX); + + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + float lTT = dX * dX + dY * dY; + float lT = (float) Math.sqrt(lTT); + + float ikRadianA = 0f; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = (float) Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } else if (lP < lL) { + ikRadianA += Math.PI; + } + } else { + float h = (float) ((lPP - lLL + lTT) / (2.0 * lTT)); + float r = (float) (Math.sqrt(lPP - h * h * lTT) / lT); + float hX = parentGlobal.x + (dX * h); + float hY = parentGlobal.y + (dY * h); + float rX = -dY * r; + float rY = dX * r; + + boolean isPPR = false; + if (parent._parent != null) { + Matrix parentParentMatrix = parent._parent.globalTransformMatrix; + isPPR = parentParentMatrix.a * parentParentMatrix.d - parentParentMatrix.b * parentParentMatrix.c < 0f; + } + + if (isPPR != this.bendPositive) { + global.x = hX - rX; + global.y = hY - rY; + } else { + global.x = hX + rX; + global.y = hY + rY; + } + + ikRadianA = (float) Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + + float dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + + float parentRadian = rawRadianA + dR; + global.x = (float) (parentGlobal.x + Math.cos(parentRadian) * lP); + global.y = (float) (parentGlobal.y + Math.sin(parentRadian) * lP); + + float ikRadianB = (float) Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0f) { + ikRadianB += Math.PI; + } + + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + } + + public void update() { + if (this.root == null) { + this.bone.updateByConstraint(); + this._computeA(); + } else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/Slot.java b/dragonbones-core/src/main/java/com/dragonbones/armature/Slot.java new file mode 100644 index 0000000..9ef761d --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/Slot.java @@ -0,0 +1,1056 @@ +package com.dragonbones.armature; + +import com.dragonbones.animation.AnimationState; +import com.dragonbones.core.BinaryOffset; +import com.dragonbones.core.BlendMode; +import com.dragonbones.core.DisplayType; +import com.dragonbones.geom.ColorTransform; +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Point; +import com.dragonbones.geom.Rectangle; +import com.dragonbones.model.*; +import com.dragonbones.util.Array; +import com.dragonbones.util.FloatArray; +import com.dragonbones.util.IntArray; +import org.jetbrains.annotations.Nullable; + +/** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Armature + * @see Bone + * @see SlotData + */ +public abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * + * @default null + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationState#displayControl + * @see AnimationState#name + * @see AnimationState#group + */ + @Nullable + public String displayController; + /** + * @readonly + */ + public SlotData slotData; + /** + * @private + */ + protected boolean _displayDirty; + /** + * @private + */ + protected boolean _zOrderDirty; + /** + * @private + */ + protected boolean _visibleDirty; + /** + * @private + */ + protected boolean _blendModeDirty; + /** + * @private + */ + public boolean _colorDirty; + /** + * @private + */ + public boolean _meshDirty; + /** + * @private + */ + protected boolean _transformDirty; + /** + * @private + */ + protected boolean _visible; + /** + * @private + */ + protected BlendMode _blendMode; + /** + * @private + */ + protected int _displayIndex; + /** + * @private + */ + protected float _animationDisplayIndex; + /** + * @private + */ + public float _zOrder; + /** + * @private + */ + protected int _cachedFrameIndex; + /** + * @private + */ + public float _pivotX; + /** + * @private + */ + public float _pivotY; + /** + * @private + */ + protected final Matrix _localMatrix = new Matrix(); + /** + * @private + */ + public final ColorTransform _colorTransform = new ColorTransform(); + /** + * @private + */ + public final FloatArray _ffdVertices = new FloatArray(); + /** + * @private + */ + public final Array _displayDatas = new Array<>(); + /** + * @private + */ + // ArrayList + protected final Array _displayList = new Array<>(); + /** + * @private + */ + protected final Array _meshBones = new Array<>(); + /** + * @internal + * @private + */ + public Array _rawDisplayDatas = new Array<>(); + /** + * @private + */ + @Nullable + protected DisplayData _displayData; + /** + * @private + */ + @Nullable + protected TextureData _textureData; + /** + * @private + */ + @Nullable + public MeshDisplayData _meshData; + /** + * @private + */ + @Nullable + protected BoundingBoxData _boundingBoxData; + /** + * @private + */ + protected Object _rawDisplay = null; // Initial value. + /** + * @private + */ + protected Object _meshDisplay = null; // Initial value. + /** + * @private + */ + protected Object _display; + /** + * @private + */ + @Nullable + protected Armature _childArmature; + /** + * @internal + * @private + */ + @Nullable + public IntArray _cachedFrameIndices; + + /** + * @private + */ + protected void _onClear() { + super._onClear(); + + Array disposeDisplayList = new Array<>(); + for (Object eachDisplay : this._displayList) { + if ( + eachDisplay != null && eachDisplay != this._rawDisplay && eachDisplay != this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0 + ) { + disposeDisplayList.add(eachDisplay); + } + } + + for (Object eachDisplay : disposeDisplayList) { + if (eachDisplay instanceof Armature) { + ((Armature) eachDisplay).dispose(); + } else { + this._disposeDisplay(eachDisplay); + } + } + + if (this._meshDisplay != null && this._meshDisplay != this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. + this._disposeDisplay(this._meshDisplay); + } + + if (this._rawDisplay != null) { + this._disposeDisplay(this._rawDisplay); + } + + this.displayController = null; + this.slotData = null; // + + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = BlendMode.Normal; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0f; + this._pivotY = 0f; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.clear(); + this._displayList.clear(); + this._displayDatas.clear(); + this._meshBones.clear(); + this._rawDisplayDatas = null; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + } + + /** + * @private + */ + protected abstract void _initDisplay(Object value); + + /** + * @private + */ + protected abstract void _disposeDisplay(Object value); + + /** + * @private + */ + protected abstract void _onUpdateDisplay(); + + /** + * @private + */ + protected abstract void _addDisplay(); + + /** + * @private + */ + protected abstract void _replaceDisplay(Object value); + + /** + * @private + */ + protected abstract void _removeDisplay(); + + /** + * @private + */ + protected abstract void _updateZOrder(); + + /** + * @private + */ + public abstract void _updateVisible(); + + /** + * @private + */ + protected abstract void _updateBlendMode(); + + /** + * @private + */ + protected abstract void _updateColor(); + + /** + * @private + */ + protected abstract void _updateFrame(); + + /** + * @private + */ + protected abstract void _updateMesh(); + + /** + * @private + */ + protected abstract void _updateTransform(boolean isSkinnedMesh); + + /** + * @private + */ + protected void _updateDisplayData() { + final DisplayData prevDisplayData = this._displayData; + final TextureData prevTextureData = this._textureData; + final MeshDisplayData prevMeshData = this._meshData; + final DisplayData rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.size() ? this._rawDisplayDatas.get(this._displayIndex) : null; + + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.size()) { + this._displayData = this._displayDatas.get(this._displayIndex); + } else { + this._displayData = null; + } + + // Update texture and mesh data. + if (this._displayData != null) { + if (this._displayData.type == DisplayType.Image || this._displayData.type == DisplayType.Mesh) { + this._textureData = ((ImageDisplayData) this._displayData).texture; + if (this._displayData.type == DisplayType.Mesh) { + this._meshData = (MeshDisplayData) this._displayData; + } else if (rawDisplayData != null && rawDisplayData.type == DisplayType.Mesh) { + this._meshData = (MeshDisplayData) rawDisplayData; + } else { + this._meshData = null; + } + } else { + this._textureData = null; + this._meshData = null; + } + } else { + this._textureData = null; + this._meshData = null; + } + + // Update bounding box data. + if (this._displayData != null && this._displayData.type == DisplayType.BoundingBox) { + this._boundingBoxData = ((BoundingBoxDisplayData) this._displayData).boundingBox; + } else if (rawDisplayData != null && rawDisplayData.type == DisplayType.BoundingBox) { + this._boundingBoxData = ((BoundingBoxDisplayData) rawDisplayData).boundingBox; + } else { + this._boundingBoxData = null; + } + + if (this._displayData != prevDisplayData || this._textureData != prevTextureData || this._meshData != prevMeshData) { + // Update pivot offset. + if (this._meshData != null) { + this._pivotX = 0f; + this._pivotY = 0f; + } else if (this._textureData != null) { + final ImageDisplayData imageDisplayData = (ImageDisplayData) this._displayData; + float scale = this._armature.armatureData.scale; + Rectangle frame = this._textureData.frame; + + this._pivotX = imageDisplayData.pivot.x; + this._pivotY = imageDisplayData.pivot.y; + + Rectangle rect = frame != null ? frame : this._textureData.region; + float width = rect.width * scale; + float height = rect.height * scale; + + if (this._textureData.rotated && frame == null) { + width = rect.height; + height = rect.width; + } + + this._pivotX *= width; + this._pivotY *= height; + + if (frame != null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } else { + this._pivotX = 0f; + this._pivotY = 0f; + } + + // Update mesh bones and ffd vertices. + if (this._meshData != prevMeshData) { + if (this._meshData != null) { // && this._meshData == this._displayData + if (this._meshData.weight != null) { + this._ffdVertices.setLength(this._meshData.weight.count * 2); + this._meshBones.setLength(this._meshData.weight.bones.size()); + + for (int i = 0, l = this._meshBones.size(); i < l; ++i) { + this._meshBones.set(i, this._armature.getBone(this._meshData.weight.bones.get(i).name)); + } + } else { + int vertexCount = this._meshData.parent.parent.intArray.get(this._meshData.offset + BinaryOffset.MeshVertexCount.v); + this._ffdVertices.setLength(vertexCount * 2); + this._meshBones.clear(); + } + + for (int i = 0, l = this._ffdVertices.size(); i < l; ++i) { + this._ffdVertices.set(i, 0f); + } + + this._meshDirty = true; + } else { + this._ffdVertices.clear(); + this._meshBones.clear(); + } + } else if (this._meshData != null && this._textureData != prevTextureData) { // Update mesh after update frame. + this._meshDirty = true; + } + + if (this._displayData != null && rawDisplayData != null && this._displayData != rawDisplayData && this._meshData == null) { + rawDisplayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0f, 0f, Slot._helpPoint); + this._pivotX -= Slot._helpPoint.x; + this._pivotY -= Slot._helpPoint.y; + + this._displayData.transform.toMatrix(Slot._helpMatrix); + Slot._helpMatrix.invert(); + Slot._helpMatrix.transformPoint(0f, 0f, Slot._helpPoint); + this._pivotX += Slot._helpPoint.x; + this._pivotY += Slot._helpPoint.y; + } + + // Update original transform. + if (rawDisplayData != null) { + this.origin = rawDisplayData.transform; + } else if (this._displayData != null) { + this.origin = this._displayData.transform; + } + + this._displayDirty = true; + this._transformDirty = true; + } + } + + /** + * @private + */ + protected void _updateDisplay() { + Object prevDisplay = this._display != null ? this._display : this._rawDisplay; + Armature prevChildArmature = this._childArmature; + + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.size()) { + this._display = this._displayList.get(this._displayIndex); + if (this._display != null && this._display instanceof Armature) { + this._childArmature = (Armature) this._display; + this._display = this._childArmature.getDisplay(); + } else { + this._childArmature = null; + } + } else { + this._display = null; + this._childArmature = null; + } + + // Update display. + Object currentDisplay = this._display != null ? this._display : this._rawDisplay; + if (currentDisplay != prevDisplay) { + this._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + + // Update frame. + if (currentDisplay == this._rawDisplay || currentDisplay == this._meshDisplay) { + this._updateFrame(); + } + + // Update child armature. + if (this._childArmature != prevChildArmature) { + if (prevChildArmature != null) { + prevChildArmature._parent = null; // Update child armature parent. + prevChildArmature.setClock(null); + if (prevChildArmature.inheritAnimation) { + prevChildArmature.getAnimation().reset(); + } + } + + if (this._childArmature != null) { + this._childArmature._parent = this; // Update child armature parent. + this._childArmature.setClock(this._armature.getClock()); + if (this._childArmature.inheritAnimation) { // Set child armature cache frameRate. + if (this._childArmature.getCacheFrameRate() == 0) { + float cacheFrameRate = this._armature.getCacheFrameRate(); + if (cacheFrameRate != 0) { + this._childArmature.setCacheFrameRate(cacheFrameRate); + } + } + + // Child armature action. + Array actions = null; + if (this._displayData != null && this._displayData.type == DisplayType.Armature) { + actions = ((ArmatureDisplayData) this._displayData).actions; + } else { + DisplayData rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.size() ? this._rawDisplayDatas.get(this._displayIndex) : null; + if (rawDisplayData != null && rawDisplayData.type == DisplayType.Armature) { + actions = ((ArmatureDisplayData) rawDisplayData).actions; + } + } + + if (actions != null && actions.size() > 0) { + for (ActionData action : actions) { + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } else { + this._childArmature.getAnimation().play(); + } + } + } + } + } + + /** + * @private + */ + protected void _updateGlobalTransformMatrix(boolean isCache) { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } else { + this._globalDirty = true; + } + } + + /** + * @private + */ + protected boolean _isMeshBonesUpdate() { + for (Bone bone : this._meshBones) { + if (bone != null && bone._childrenTransformDirty) { + return true; + } + } + + return false; + } + + /** + * @internal + * @private + */ + public void _setArmature(@Nullable Armature value) { + if (this._armature == value) { + return; + } + + if (this._armature != null) { + this._armature._removeSlotFromSlotList(this); + } + + this._armature = value; // + + this._onUpdateDisplay(); + + if (this._armature != null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } else { + this._removeDisplay(); + } + } + + public boolean _setDisplayIndex(int value) { + return _setDisplayIndex(value, false); + } + + /** + * @internal + * @private + */ + public boolean _setDisplayIndex(int value, boolean isAnimation) { + if (isAnimation) { + if (this._animationDisplayIndex == value) { + return false; + } + + this._animationDisplayIndex = value; + } + + if (this._displayIndex == value) { + return false; + } + + this._displayIndex = value; + this._displayDirty = true; + + this._updateDisplayData(); + + return this._displayDirty; + } + + /** + * @internal + * @private + */ + public boolean _setZorder(float value) { + if (this._zOrder == value) { + //return false; + } + + this._zOrder = value; + this._zOrderDirty = true; + + return this._zOrderDirty; + } + + /** + * @internal + * @private + */ + public boolean _setColor(ColorTransform value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + + return this._colorDirty; + } + + /** + * @private + */ + public boolean _setDisplayList(@Nullable Array value) { + if (value != null && value.size() > 0) { + if (this._displayList.size() != value.size()) { + this._displayList.setLength(value.size()); + } + + for (int i = 0, l = value.size(); i < l; ++i) { // Retain input render displays. + Object eachDisplay = value.get(i); + if ( + eachDisplay != null && eachDisplay != this._rawDisplay && eachDisplay != this._meshDisplay && + !(eachDisplay instanceof Armature) && this._displayList.indexOf(eachDisplay) < 0 + ) { + this._initDisplay(eachDisplay); + } + + this._displayList.set(i, eachDisplay); + } + } else if (this._displayList.size() > 0) { + this._displayList.clear(); + } + + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.size()) { + this._displayDirty = this._display != this._displayList.get(this._displayIndex); + } else { + this._displayDirty = this._display != null; + } + + this._updateDisplayData(); + + return this._displayDirty; + } + + /** + * @private + */ + public void init(SlotData slotData, @Nullable Array displayDatas, Object rawDisplay, Object meshDisplay) { + if (this.slotData != null) { + return; + } + + this.slotData = slotData; + this.name = this.slotData.name; + + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + + this._displayDatas.setLength(this._rawDisplayDatas.size()); + for (int i = 0, l = this._displayDatas.size(); i < l; ++i) { + this._displayDatas.set(i, this._rawDisplayDatas.get(i)); + } + } + + /** + * @internal + * @private + */ + public void update(int cacheFrameIndex) { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + + if (this._transformDirty) { // Update local matrix. (Only updated when both display and transform are dirty.) + if (this.origin != null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + + if (cacheFrameIndex >= 0 && this._cachedFrameIndices != null) { + int cachedFrameIndex = this._cachedFrameIndices.get(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.set(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._display == null) { + return; + } + + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + + if (this._meshData != null && this._display == this._meshDisplay) { + boolean isSkinned = this._meshData.weight != null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + + return; + } + } + + if (this._transformDirty) { + this._transformDirty = false; + + if (this._cachedFrameIndex < 0) { + boolean isCache = cacheFrameIndex >= 0; + this._updateGlobalTransformMatrix(isCache); + + if (isCache && this._cachedFrameIndices != null) { + int vv = this._armature.armatureData.setCacheFrame(this.globalTransformMatrix, this.global); + this._cachedFrameIndices.set(cacheFrameIndex, vv); + this._cachedFrameIndex = vv; + } + } else { + this._armature.armatureData.getCacheFrame(this.globalTransformMatrix, this.global, this._cachedFrameIndex); + } + + this._updateTransform(false); + } + } + + /** + * @private + */ + public void updateTransformAndMatrix() { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + } + + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean containsPoint(float x, float 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); + } + + public float intersectsSegment( + float xA, float yA, float xB, float yB + ) { + return intersectsSegment(xA, yA, xB, yB, null, null, null); + } + + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * + * @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 + */ + public int intersectsSegment( + float xA, float yA, float xB, float yB, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) { + 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; + + int 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((float)Math.cos(normalRadians.x), (float)Math.sin(normalRadians.x), Slot._helpPoint, true); + normalRadians.x = (float)Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + + this.globalTransformMatrix.transformPoint((float)Math.cos(normalRadians.y), (float)Math.sin(normalRadians.y), Slot._helpPoint, true); + normalRadians.y = (float)Math.atan2(Slot._helpPoint.y, Slot._helpPoint.x); + } + } + + return intersectionCount; + } + + /** + * 在下一帧更新显示对象的状态。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public void invalidUpdate() { + this._displayDirty = true; + this._transformDirty = true; + } + + /** + * 此时显示的显示对象在显示列表中的索引。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public int getDisplayIndex() { + return this._displayIndex; + } + + public void setDisplayIndex(int value) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + } + + /** + * 包含显示对象或子骨架的显示列表。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Array getDisplayList() { + return this._displayList.copy(); + } + + public void setDisplayList(Array value) { + Array backupDisplayList = this._displayList.copy(); // Copy. + Array disposeDisplayList = new Array(); + + if (this._setDisplayList(value)) { + this.update(-1); + } + + // Release replaced displays. + for (Object eachDisplay : backupDisplayList) { + if ( + eachDisplay != null && eachDisplay != this._rawDisplay && eachDisplay != this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0 + ) { + disposeDisplayList.add(eachDisplay); + } + } + + for (Object eachDisplay : disposeDisplayList) { + if (eachDisplay instanceof Armature) { + ((Armature) eachDisplay).dispose(); + } else { + this._disposeDisplay(eachDisplay); + } + } + } + + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @version DragonBones 3.0 + * @see Armature + */ + @Nullable + public BoundingBoxData getBoundingBoxData() { + return this._boundingBoxData; + } + + /** + * @private + */ + public Object getRawDisplay() { + return this._rawDisplay; + } + + /** + * @private + */ + public Object getMeshDisplay() { + return this._meshDisplay; + } + + public void setDisplay(Object value) { + if (this._display == value) { + return; + } + + int displayListLength = this._displayList.size(); + if (this._displayIndex < 0 && displayListLength == 0) { // Emprty. + this._displayIndex = 0; + } + + if (this._displayIndex < 0) { + return; + } else { + Array replaceDisplayList = this.getDisplayList(); // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.setLength(this._displayIndex + 1); + } + + replaceDisplayList.set(this._displayIndex, value); + this.setDisplayList(replaceDisplayList); + } + } + + /** + * 此时显示的子骨架。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Armature + */ + @Nullable + public Armature getChildArmature() { + return this._childArmature; + } + + public void setChildArmature(@Nullable Armature value) { + if (this._childArmature == value) { + return; + } + + this.setDisplay(value); + } + + /** + * 此时显示的显示对象。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + //@Override + public Object getDisplay() { + return this._display; + } + + ///** + // * @see #display + // * @deprecated 已废弃,请参考 @see + // */ + //public Object getDisplay() { + // return this._display; + //} + + ///** + // * @see #display + // * @deprecated 已废弃,请参考 @see + // */ + //public void setDisplay(Object value) { + // this._display = value; + // +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/armature/TransformObject.java b/dragonbones-core/src/main/java/com/dragonbones/armature/TransformObject.java new file mode 100644 index 0000000..fadfdcd --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/armature/TransformObject.java @@ -0,0 +1,150 @@ +package com.dragonbones.armature; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Point; +import com.dragonbones.geom.Transform; +import org.jetbrains.annotations.Nullable; + +/** + * 基础变换对象。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ +public abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static final Matrix _helpMatrix = new Matrix(); + /** + * @private + */ + protected static final Transform _helpTransform = new Transform(); + /** + * @private + */ + protected static final Point _helpPoint = new Point(); + /** + * 对象的名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * 相对于骨架坐标系的矩阵。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public final Matrix globalTransformMatrix = new Matrix(); + /** + * 相对于骨架坐标系的变换。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Transform + */ + public final Transform global = new Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Transform + */ + public final Transform offset = new Transform(); + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + * @see Transform + */ + public Transform origin; + /** + * 可以用于存储临时数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Object userData; + /** + * @private + */ + protected boolean _globalDirty; + /** + * @private + */ + public Armature _armature; + /** + * @private + */ + public Bone _parent; + + /** + * @private + */ + protected void _onClear() { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; // + this.userData = null; + + this._globalDirty = false; + this._armature = null; // + this._parent = null; // + } + + /** + * @internal + * @private + */ + public void _setArmature(@Nullable Armature value) { + this._armature = value; + } + + /** + * @internal + * @private + */ + public void _setParent(@Nullable Bone value) { + this._parent = value; + } + + /** + * @private + */ + public void updateGlobalTransform() { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + } + + /** + * 所属的骨架。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Armature + */ + public Armature getArmature() { + return this._armature; + } + + /** + * 所属的父骨骼。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Bone + */ + public Bone getParent() { + return this._parent; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/ActionType.java b/dragonbones-core/src/main/java/com/dragonbones/core/ActionType.java new file mode 100644 index 0000000..0c30878 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/ActionType.java @@ -0,0 +1,18 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum ActionType { + Play(0), + Frame(10), + Sound(11); + + public final int v; + + ActionType(int v) { + this.v = v; + } + + public static ActionType[] values = values(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/AnimationFadeOutMode.java b/dragonbones-core/src/main/java/com/dragonbones/core/AnimationFadeOutMode.java new file mode 100644 index 0000000..6dd47f4 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/AnimationFadeOutMode.java @@ -0,0 +1,57 @@ +package com.dragonbones.core; + +/** + * @version DragonBones 4.5 + * @language zh_CN + * 动画混合的淡出方式。 + */ +public enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + None(0), + /** + * 淡出同层的动画。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer(1), + /** + * 淡出同组的动画。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup(2), + /** + * 淡出同层并且同组的动画。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup(3), + /** + * 淡出所有动画。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + All(4), + /** + * 不替换同名动画。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ + Single(5); + + public int v; + + AnimationFadeOutMode(int v) { + this.v = v; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/ArmatureType.java b/dragonbones-core/src/main/java/com/dragonbones/core/ArmatureType.java new file mode 100644 index 0000000..dce81c8 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/ArmatureType.java @@ -0,0 +1,18 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum ArmatureType { + Armature(0), + MovieClip(1), + Stage(2); + + final public int v; + + ArmatureType(int v) { + this.v = v; + } + + public static ArmatureType[] values = values(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/BaseObject.java b/dragonbones-core/src/main/java/com/dragonbones/core/BaseObject.java new file mode 100644 index 0000000..9b95060 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/BaseObject.java @@ -0,0 +1,150 @@ +package com.dragonbones.core; + +import com.dragonbones.util.Array; +import com.dragonbones.util.Console; +import org.jetbrains.annotations.NotNull; + +import java.util.HashMap; +import java.util.Map; + +/** + * 基础对象。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ +public abstract class BaseObject { + private static int _hashCode = 0; + private static int _defaultMaxCount = 1000; + private static final Map, Integer> _maxCountMap = new HashMap<>(); + private static final Map, Array> _poolsMap = new HashMap<>(); + + private static void _returnObject(BaseObject object) { + Class classType = object.getClass(); + int maxCount = BaseObject._maxCountMap.containsKey(classType) ? BaseObject._defaultMaxCount : BaseObject._maxCountMap.get(classType); + if (!BaseObject._poolsMap.containsKey(classType)) { + BaseObject._poolsMap.put(classType, new Array<>()); + } + Array pool = BaseObject._poolsMap.get(classType); + if (pool.size() < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.add(object); + } else { + Console._assert(false, "The object is already in the pool."); + } + } else { + } + } + + /** + * 设置每种对象池的最大缓存数量。 + * + * @param classType 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + public static void setMaxCount(Class classType, int maxCount) { + if (maxCount < 0) { // isNaN + maxCount = 0; + } + + if (classType != null) { + Array pool = BaseObject._poolsMap.get(classType); + if (pool != null && pool.size() > maxCount) { + pool.setLength(maxCount); + } + + BaseObject._maxCountMap.put(classType, maxCount); + } else { + BaseObject._defaultMaxCount = maxCount; + for (Class classType2 : BaseObject._poolsMap.keySet()) { + if (BaseObject._maxCountMap.containsKey(classType2)) { + continue; + } + + Array pool = BaseObject._poolsMap.get(classType2); + if (pool.size() > maxCount) { + pool.setLength(maxCount); + } + + BaseObject._maxCountMap.put(classType2, maxCount); + } + } + } + + public static void clearPool() { + for (Array pool : BaseObject._poolsMap.values()) { + pool.clear(); + } + } + + /** + * 清除对象池缓存的对象。 + * + * @param classType 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + public static void clearPool(@NotNull Class classType) { + Array pool = BaseObject._poolsMap.get(classType); + if (pool != null && pool.size() > 0) { + pool.clear(); + } + } + + /** + * 从对象池中创建指定对象。 + * + * @param classType 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + + public static T borrowObject(Class classType) { + Array pool = BaseObject._poolsMap.get(classType); + if (pool != null && pool.size() > 0) { + T object = (T) pool.popObject(); + object._isInPool = false; + return object; + } + + try { + final T object = classType.newInstance(); + object._onClear(); + return object; + } catch (InstantiationException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } catch (IllegalAccessException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + + /** + * 对象的唯一标识。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public final int hashCode = BaseObject._hashCode++; + boolean _isInPool = false; + + /** + * @private + */ + protected abstract void _onClear(); + + /** + * 清除数据并返还对象池。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public void returnToPool() { + this._onClear(); + BaseObject._returnObject(this); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/BinaryOffset.java b/dragonbones-core/src/main/java/com/dragonbones/core/BinaryOffset.java new file mode 100644 index 0000000..9089376 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/BinaryOffset.java @@ -0,0 +1,40 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum BinaryOffset { + WeigthBoneCount(0), + WeigthFloatOffset(1), + WeigthBoneIndices(2), + + MeshVertexCount(0), + MeshTriangleCount(1), + MeshFloatOffset(2), + MeshWeightOffset(3), + MeshVertexIndices(4), + + TimelineScale(0), + TimelineOffset(1), + TimelineKeyFrameCount(2), + TimelineFrameValueCount(3), + TimelineFrameValueOffset(4), + TimelineFrameOffset(5), + + FramePosition(0), + FrameTweenType(1), + FrameTweenEasingOrCurveSampleCount(2), + FrameCurveSamples(3), + + FFDTimelineMeshOffset(0), + FFDTimelineFFDCount(1), + FFDTimelineValueCount(2), + FFDTimelineValueOffset(3), + FFDTimelineFloatOffset(4); + + public final int v; + + BinaryOffset(int v) { + this.v = v; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/BlendMode.java b/dragonbones-core/src/main/java/com/dragonbones/core/BlendMode.java new file mode 100644 index 0000000..f5c5ace --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/BlendMode.java @@ -0,0 +1,29 @@ +package com.dragonbones.core; + +/** + * @private + */ +public 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); + + final public int v; + + BlendMode(int v) { + this.v = v; + } + + public static BlendMode[] values = values(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/BoundingBoxType.java b/dragonbones-core/src/main/java/com/dragonbones/core/BoundingBoxType.java new file mode 100644 index 0000000..4973bbd --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/BoundingBoxType.java @@ -0,0 +1,20 @@ +package com.dragonbones.core; + +/** + * @version DragonBones 5.0 + * @language zh_CN + * 包围盒类型。 + */ +public enum BoundingBoxType { + Rectangle(0), + Ellipse(1), + Polygon(2); + + public final int v; + + BoundingBoxType(int v) { + this.v = v; + } + + public static BoundingBoxType[] values = values(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/DisplayType.java b/dragonbones-core/src/main/java/com/dragonbones/core/DisplayType.java new file mode 100644 index 0000000..1557c6a --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/DisplayType.java @@ -0,0 +1,19 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum DisplayType { + Image(0), + Armature(1), + Mesh(2), + BoundingBox(3); + + final public int v; + + DisplayType(int v) { + this.v = v; + } + + public static DisplayType[] values = values(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/DragonBones.java b/dragonbones-core/src/main/java/com/dragonbones/core/DragonBones.java new file mode 100644 index 0000000..f2b535a --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/DragonBones.java @@ -0,0 +1,74 @@ +package com.dragonbones.core; + +import com.dragonbones.animation.WorldClock; +import com.dragonbones.armature.Armature; +import com.dragonbones.event.EventObject; +import com.dragonbones.event.IEventDispatcher; +import com.dragonbones.util.Array; + +/** + * @private + */ +public class DragonBones { + public static boolean yDown = true; + public static boolean debug = false; + public static boolean debugDraw = false; + public static String VERSION = "5.1f"; + + private final WorldClock _clock = new WorldClock(); + private final Array _events = new Array<>(); + private final Array _objects = new Array<>(); + private IEventDispatcher _eventManager = null; + + public DragonBones(IEventDispatcher eventManager) { + this._eventManager = eventManager; + } + + public void advanceTime(float passedTime) { + if (this._objects.size() > 0) { + for (BaseObject object : this._objects) { + object.returnToPool(); + } + + this._objects.clear(); + } + + this._clock.advanceTime(passedTime); + + if (this._events.size() > 0) { + for (int i = 0; i < this._events.size(); ++i) { + EventObject eventObject = this._events.get(i); + Armature armature = eventObject.armature; + + armature.getEventDispatcher()._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type == EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(eventObject.type, eventObject); + } + + this.bufferObject(eventObject); + } + + this._events.clear(); + } + } + + public void bufferEvent(EventObject value) { + if (this._events.indexOf(value) < 0) { + this._events.add(value); + } + } + + public void bufferObject(BaseObject object) { + if (this._objects.indexOf(object) < 0) { + this._objects.add(object); + } + } + + public WorldClock getClock() { + return this._clock; + } + + public IEventDispatcher getEventManager() { + return this._eventManager; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/OffsetMode.java b/dragonbones-core/src/main/java/com/dragonbones/core/OffsetMode.java new file mode 100644 index 0000000..87a547d --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/OffsetMode.java @@ -0,0 +1,10 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum OffsetMode { + None, + Additive, + Override +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/TimelineType.java b/dragonbones-core/src/main/java/com/dragonbones/core/TimelineType.java new file mode 100644 index 0000000..c62b85e --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/TimelineType.java @@ -0,0 +1,35 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum TimelineType { + Action(0), + ZOrder(1), + + BoneAll(10), + BoneT(11), + BoneR(12), + BoneS(13), + BoneX(14), + BoneY(15), + BoneRotate(16), + BoneSkew(17), + BoneScaleX(18), + BoneScaleY(19), + + SlotVisible(23), + SlotDisplay(20), + SlotColor(21), + SlotFFD(22), + + AnimationTime(40), + AnimationWeight(41); + + public static TimelineType[] values = values(); + final int v; + + TimelineType(int v) { + this.v = v; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/core/TweenType.java b/dragonbones-core/src/main/java/com/dragonbones/core/TweenType.java new file mode 100644 index 0000000..4987a5f --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/core/TweenType.java @@ -0,0 +1,21 @@ +package com.dragonbones.core; + +/** + * @private + */ +public enum TweenType { + None(0), + Line(1), + Curve(2), + QuadIn(3), + QuadOut(4), + QuadInOut(5); + + final public int v; + + TweenType(int v) { + this.v = v; + } + + public static TweenType[] values = values(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/event/EventObject.java b/dragonbones-core/src/main/java/com/dragonbones/event/EventObject.java new file mode 100644 index 0000000..28d1dc3 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/event/EventObject.java @@ -0,0 +1,152 @@ +package com.dragonbones.event; + +import com.dragonbones.animation.AnimationState; +import com.dragonbones.armature.Armature; +import com.dragonbones.armature.Bone; +import com.dragonbones.armature.Slot; +import com.dragonbones.core.BaseObject; +import com.dragonbones.model.UserData; +import org.jetbrains.annotations.Nullable; + +/** + * 事件数据。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ +public class EventObject extends BaseObject { + /** + * 动画开始。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType START = EventStringType.start; + /** + * 动画循环播放一次完成。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType LOOP_COMPLETE = EventStringType.loopComplete; + /** + * 动画播放完成。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType COMPLETE = EventStringType.complete; + /** + * 动画淡入开始。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType FADE_IN = EventStringType.fadeIn; + /** + * 动画淡入完成。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType FADE_IN_COMPLETE = EventStringType.fadeInComplete; + /** + * 动画淡出开始。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType FADE_OUT = EventStringType.fadeOut; + /** + * 动画淡出完成。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType FADE_OUT_COMPLETE = EventStringType.fadeOutComplete; + /** + * 动画帧事件。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType FRAME_EVENT = EventStringType.frameEvent; + /** + * 动画声音事件。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public static final EventStringType SOUND_EVENT = EventStringType.soundEvent; + /** + * @private + */ + public float time; + /** + * 事件类型。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public EventStringType type; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public String name; + /** + * 发出事件的骨架。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public Armature armature; + /** + * 发出事件的骨骼。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + @Nullable + public Bone bone; + /** + * 发出事件的插槽。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + @Nullable + public Slot slot; + /** + * 发出事件的动画状态。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ + public AnimationState animationState; + /** + * 自定义数据 + * + * @version DragonBones 5.0 + * @language zh_CN + * @see UserData + */ + @Nullable + public UserData data; + + /** + * @private + */ + protected void _onClear() { + this.time = 0f; + this.type = EventStringType.start; + this.name = ""; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.data = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/event/EventStringType.java b/dragonbones-core/src/main/java/com/dragonbones/event/EventStringType.java new file mode 100644 index 0000000..32e0b7c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/event/EventStringType.java @@ -0,0 +1,8 @@ +package com.dragonbones.event; + +/** + * @private + */ +public enum EventStringType { + start, loopComplete, complete, fadeIn, fadeInComplete, fadeOut, fadeOutComplete, frameEvent, soundEvent; +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/event/IEventDispatcher.java b/dragonbones-core/src/main/java/com/dragonbones/event/IEventDispatcher.java new file mode 100644 index 0000000..4d1e479 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/event/IEventDispatcher.java @@ -0,0 +1,45 @@ +package com.dragonbones.event; + +import com.dragonbones.util.Function; + +/** + * 事件接口。 + * + * @version DragonBones 4.5 + * @language zh_CN + */ +public interface IEventDispatcher { + /** + * @private + */ + void _dispatchEvent(EventStringType type, EventObject eventObject); + + /** + * 是否包含指定类型的事件。 + * + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + boolean hasEvent(EventStringType type); + + /** + * 添加事件。 + * + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + void addEvent(EventStringType type, Function listener, Object target); + + /** + * 移除事件。 + * + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + void removeEvent(EventStringType type, Function listener, Object target); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/factory/BaseFactory.java b/dragonbones-core/src/main/java/com/dragonbones/factory/BaseFactory.java new file mode 100644 index 0000000..9bd8e27 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/factory/BaseFactory.java @@ -0,0 +1,957 @@ +package com.dragonbones.factory; + +import com.dragonbones.armature.Armature; +import com.dragonbones.armature.Bone; +import com.dragonbones.armature.IKConstraint; +import com.dragonbones.armature.Slot; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.DisplayType; +import com.dragonbones.core.DragonBones; +import com.dragonbones.model.*; +import com.dragonbones.parser.BinaryDataParser; +import com.dragonbones.parser.DataParser; +import com.dragonbones.parser.ObjectDataParser; +import com.dragonbones.util.Array; +import com.dragonbones.util.Console; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * + * @version DragonBones 3.0 + * @language zh_CN + * @see DragonBonesData + * @see TextureAtlasData + * @see ArmatureData + * @see Armature + */ +public abstract class BaseFactory { + /** + * @private + */ + protected static ObjectDataParser _objectParser = null; + /** + * @private + */ + protected static BinaryDataParser _binaryParser = null; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * + * @version DragonBones 4.5 + * @language zh_CN + * @see DragonBonesData#autoSearch + * @see com.dragonbones.model.TextureAtlasData#autoSearch + */ + public boolean autoSearch = false; + /** + * @private + */ + protected final Map _dragonBonesDataMap = new HashMap<>(); + /** + * @private + */ + protected final Map> _textureAtlasDataMap = new HashMap<>(); + /** + * @private + */ + protected DragonBones _dragonBones = null; + /** + * @private + */ + protected DataParser _dataParser = null; + + public BaseFactory() { + this(null); + } + + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public BaseFactory(@Nullable DataParser dataParser) { + if (BaseFactory._objectParser == null) { + BaseFactory._objectParser = new ObjectDataParser(); + } + + if (BaseFactory._binaryParser == null) { + BaseFactory._binaryParser = new BinaryDataParser(); + } + + this._dataParser = dataParser != null ? dataParser : BaseFactory._objectParser; + } + + /** + * @private + */ + protected boolean _isSupportMesh() { + return true; + } + + /** + * @private + */ + @Nullable + protected TextureData _getTextureData(String textureAtlasName, String textureName) { + if (this._textureAtlasDataMap.containsKey(textureAtlasName)) { + for (TextureAtlasData textureAtlasData : this._textureAtlasDataMap.get(textureAtlasName)) { + TextureData textureData = textureAtlasData.getTexture(textureName); + if (textureData != null) { + return textureData; + } + } + } + + if (this.autoSearch) { // Will be search all data, if the autoSearch is true. + for (String k : this._textureAtlasDataMap.keySet()) { + for (TextureAtlasData textureAtlasData : this._textureAtlasDataMap.get(k)) { + if (textureAtlasData.autoSearch) { + TextureData textureData = textureAtlasData.getTexture(textureName); + if (textureData != null) { + return textureData; + } + } + } + } + } + + return null; + } + + /** + * @private + */ + protected boolean _fillBuildArmaturePackage( + BuildArmaturePackage dataPackage, + String dragonBonesName, String armatureName, String skinName, String textureAtlasName + ) { + DragonBonesData dragonBonesData = null; + ArmatureData armatureData = null; + + if (dragonBonesName.length() > 0) { + if (this._dragonBonesDataMap.containsKey(dragonBonesName)) { + dragonBonesData = this._dragonBonesDataMap.get(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 (String k : this._dragonBonesDataMap.keySet()) { + dragonBonesData = this._dragonBonesDataMap.get(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 (String k : this._dragonBonesDataMap.keySet()) { + DragonBonesData skinDragonBonesData = this._dragonBonesDataMap.get(k); + ArmatureData skinArmatureData = skinDragonBonesData.getArmature(skinName); + if (skinArmatureData != null) { + dataPackage.skin = skinArmatureData.defaultSkin; + break; + } + } + } + } + + if (dataPackage.skin == null) { + dataPackage.skin = armatureData.defaultSkin; + } + + return true; + } + + return false; + } + + /** + * @private + */ + protected void _buildBones(BuildArmaturePackage dataPackage, Armature armature) { + Array bones = dataPackage.armature.sortedBones; + for (int i = 0; i < bones.size(); ++i) { + BoneData boneData = bones.get(i); + Bone bone = BaseObject.borrowObject(Bone.class); + bone.init(boneData); + + if (boneData.parent != null) { + armature.addBone(bone, boneData.parent.name); + } else { + armature.addBone(bone); + } + + Array constraints = boneData.constraints; + for (int j = 0; j < constraints.size(); ++j) { + ConstraintData constraintData = constraints.get(j); + Bone target = armature.getBone(constraintData.target.name); + if (target == null) { + continue; + } + + // TODO more constraint type. + IKConstraintData ikConstraintData = (IKConstraintData) constraintData; + IKConstraint constraint = BaseObject.borrowObject(IKConstraint.class); + Bone root = ikConstraintData.root != null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + + if (root != null) { + root.addConstraint(constraint); + } else { + bone.addConstraint(constraint); + } + } + } + } + + /** + * @private + */ + protected void _buildSlots(BuildArmaturePackage dataPackage, Armature armature) { + SkinData currentSkin = dataPackage.skin; + SkinData defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin == null || defaultSkin == null) { + return; + } + + Map> skinSlots = new HashMap<>(); + for (String k : defaultSkin.displays.keySet()) { + Array displays = defaultSkin.displays.get(k); + skinSlots.put(k, displays); + } + + if (currentSkin != defaultSkin) { + for (String k : currentSkin.displays.keySet()) { + Array displays = currentSkin.displays.get(k); + skinSlots.put(k, displays); + } + } + + for (SlotData slotData : dataPackage.armature.sortedSlots) { + if (!(skinSlots.containsKey(slotData.name))) { + continue; + } + + Array displays = skinSlots.get(slotData.name); + Slot slot = this._buildSlot(dataPackage, slotData, displays, armature); + Array displayList = new Array<>(); + for (DisplayData displayData : displays) { + if (displayData != null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } else { + displayList.push(null); + } + } + + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + } + + /** + * @private + */ + protected Object _getSlotDisplay(@Nullable BuildArmaturePackage dataPackage, DisplayData displayData, @Nullable DisplayData rawDisplayData, Slot slot) { + String dataName = dataPackage != null ? dataPackage.dataName : displayData.parent.parent.name; + Object display = null; + switch (displayData.type) { + case Image: + ImageDisplayData imageDisplayData = (ImageDisplayData) displayData; + if (imageDisplayData.texture == null) { + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); + } else if (dataPackage != null && dataPackage.textureAtlasName.length() > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + + if (rawDisplayData != null && rawDisplayData.type == DisplayType.Mesh && this._isSupportMesh()) { + display = slot.getMeshDisplay(); + } else { + display = slot.getRawDisplay(); + } + break; + + case Mesh: + MeshDisplayData meshDisplayData = (MeshDisplayData) displayData; + if (meshDisplayData.texture == null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } else if (dataPackage != null && dataPackage.textureAtlasName.length() > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + + if (this._isSupportMesh()) { + display = slot.getMeshDisplay(); + } else { + display = slot.getRawDisplay(); + } + break; + + case Armature: + ArmatureDisplayData armatureDisplayData = (ArmatureDisplayData) displayData; + Armature childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage != null ? dataPackage.textureAtlasName : null); + if (childArmature != null) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + Array actions = armatureDisplayData.actions.size() > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.size() > 0) { + for (ActionData action : actions) { + childArmature._bufferAction(action, true); + } + } else { + childArmature.getAnimation().play(); + } + } + + armatureDisplayData.armature = childArmature.armatureData; // + } + + display = childArmature; + break; + } + + return display; + } + + /** + * @private + */ + protected void _replaceSlotDisplay(BuildArmaturePackage dataPackage, @Nullable DisplayData displayData, Slot slot, int displayIndex) + + { + if (displayIndex < 0) { + displayIndex = slot.getDisplayIndex(); + } + + if (displayIndex < 0) { + displayIndex = 0; + } + + Array displayList = slot.getDisplayList(); // Copy. + if (displayList.size() <= displayIndex) { + displayList.setLength(displayIndex + 1); + + // @TODO: Not required in java + for (int i = 0, l = displayList.size(); i < l; ++i) { // Clean undefined. + if (displayList.get(i) == null) { + displayList.set(i, null); + } + } + } + + if (slot._displayDatas.size() <= displayIndex) { + displayList.setLength(displayIndex + 1); + + // @TODO: Not required in java + for (int i = 0, l = slot._displayDatas.size(); i < l; ++i) { // Clean undefined. + if (slot._displayDatas.get(i) == null) { + slot._displayDatas.set(i, null); + } + } + } + + slot._displayDatas.set(displayIndex, displayData); + if (displayData != null) { + displayList.set(displayIndex, this._getSlotDisplay( + dataPackage, + displayData, + displayIndex < slot._rawDisplayDatas.size() ? slot._rawDisplayDatas.get(displayIndex) : null, + slot + )); + } else { + displayList.set(displayIndex, null); + } + + slot.setDisplayList(displayList); + } + + /** + * @private + */ + protected abstract TextureAtlasData _buildTextureAtlasData(@Nullable TextureAtlasData textureAtlasData, Object textureAtlas); + + /** + * @private + */ + protected abstract Armature _buildArmature(BuildArmaturePackage dataPackage); + + /** + * @private + */ + protected abstract Slot _buildSlot(BuildArmaturePackage dataPackage, SlotData slotData, Array displays, Armature armature); + + public DragonBonesData parseDragonBonesData(Object rawData) { + return parseDragonBonesData(rawData, null, 1f); + } + + /** + * 解析并添加龙骨数据。 + * + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @returns DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + * @see #getDragonBonesData(String) + * @see #addDragonBonesData(DragonBonesData, String) + * @see #removeDragonBonesData(String, boolean) + * @see DragonBonesData + */ + @Nullable + public DragonBonesData parseDragonBonesData(Object rawData, @Nullable String name, float scale) { + DragonBonesData dragonBonesData = null; + if (rawData instanceof byte[]) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + + while (true) { + TextureAtlasData textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } else { + textureAtlasData.returnToPool(); + break; + } + } + + if (dragonBonesData != null) { + this.addDragonBonesData(dragonBonesData, name); + } + + return dragonBonesData; + } + + public TextureAtlasData parseTextureAtlasData(Object rawData, Object textureAtlas) { + return parseTextureAtlasData(rawData, textureAtlas, null, 0f); + } + + /** + * 解析并添加贴图集数据。 + * + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @version DragonBones 4.5 + * @language zh_CN + * @see #getTextureAtlasData(String) + * @see #addTextureAtlasData(TextureAtlasData, String) + * @see #removeTextureAtlasData(String, boolean) + * @see TextureAtlasData + */ + public TextureAtlasData parseTextureAtlasData(Object rawData, Object textureAtlas, @Nullable String name, float scale) { + TextureAtlasData textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas); + this.addTextureAtlasData(textureAtlasData, name); + + return textureAtlasData; + } + + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + public void updateTextureAtlasData(String name, Array textureAtlases) { + Array textureAtlasDatas = this.getTextureAtlasData(name); + if (textureAtlasDatas != null) { + for (int i = 0, l = textureAtlasDatas.size(); i < l; ++i) { + if (i < textureAtlases.size()) { + this._buildTextureAtlasData(textureAtlasDatas.get(i), textureAtlases.get(i)); + } + } + } + } + + /** + * 获取指定名称的龙骨数据。 + * + * @param name 数据名称。 + * @returns DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + * @see #parseDragonBonesData(Object, String, float) + * @see #addDragonBonesData(DragonBonesData, String) + * @see #removeDragonBonesData(String, boolean) + * @see DragonBonesData + */ + @Nullable + public DragonBonesData getDragonBonesData(String name) { + return this._dragonBonesDataMap.get(name); + } + + public void addDragonBonesData(DragonBonesData data) { + addDragonBonesData(data, null); + } + + /** + * 添加龙骨数据。 + * + * @param data 龙骨数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see #parseDragonBonesData(Object, String, float) + * @see #getDragonBonesData(String) + * @see #removeDragonBonesData(String, boolean) + * @see DragonBonesData + */ + public void addDragonBonesData(DragonBonesData data, @Nullable String name) { + name = name != null ? name : data.name; + if (this._dragonBonesDataMap.containsKey(name)) { + if (this._dragonBonesDataMap.get(name) == data) { + return; + } + + Console.warn("Replace data: " + name); + this._dragonBonesDataMap.get(name).returnToPool(); + } + + this._dragonBonesDataMap.put(name, data); + } + + public void removeDragonBonesData(String name) { + removeDragonBonesData(name, true); + } + + /** + * 移除龙骨数据。 + * + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @version DragonBones 3.0 + * @language zh_CN + * @see #parseDragonBonesData(Object, String, float) + * @see #getDragonBonesData(String) + * @see #addDragonBonesData(DragonBonesData, String) + * @see DragonBonesData + */ + public void removeDragonBonesData(String name, boolean disposeData) { + if (this._dragonBonesDataMap.containsKey(name)) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap.get(name)); + } + + this._dragonBonesDataMap.remove(name); + } + } + + /** + * 获取指定名称的贴图集数据列表。 + * + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @version DragonBones 3.0 + * @language zh_CN + * @see #parseTextureAtlasData(Object, Object, String, float) + * @see #addTextureAtlasData(TextureAtlasData, String) + * @see #removeTextureAtlasData(String, boolean) + * @see TextureAtlasData + */ + public Array getTextureAtlasData(String name) { + return this._textureAtlasDataMap.get(name); + } + + public void addTextureAtlasData(TextureAtlasData data) { + addTextureAtlasData(data, null); + } + + /** + * 添加贴图集数据。 + * + * @param data 贴图集数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see #parseTextureAtlasData(Object, Object, String, float) + * @see #getTextureAtlasData(String) + * @see #removeTextureAtlasData(String, boolean) + * @see TextureAtlasData + */ + public void addTextureAtlasData(TextureAtlasData data, @Nullable String name) { + name = name != null ? name : data.name; + if (!this._textureAtlasDataMap.containsKey(name)) { + this._textureAtlasDataMap.put(name, new Array<>()); + } + Array textureAtlasList = this._textureAtlasDataMap.get(name); + + if (textureAtlasList.indexOf(data) < 0) { + textureAtlasList.add(data); + } + } + + public void removeTextureAtlasData(String name) { + removeTextureAtlasData(name, true); + } + + /** + * 移除贴图集数据。 + * + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @version DragonBones 3.0 + * @language zh_CN + * @see #parseTextureAtlasData(Object, Object, String, float) + * @see #getTextureAtlasData(String) + * @see #addTextureAtlasData(TextureAtlasData, String) + * @see TextureAtlasData + */ + public void removeTextureAtlasData(String name, boolean disposeData) { + if (this._textureAtlasDataMap.containsKey(name)) { + Array textureAtlasDataList = this._textureAtlasDataMap.get(name); + if (disposeData) { + for (TextureAtlasData textureAtlasData : textureAtlasDataList) { + this._dragonBones.bufferObject(textureAtlasData); + } + } + + this._textureAtlasDataMap.remove(name); + } + } + + @Nullable + public ArmatureData getArmatureData(String name) { + return getArmatureData(name, ""); + } + + /** + * 获取骨架数据。 + * + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @version DragonBones 5.1 + * @language zh_CN + * @see ArmatureData + */ + @Nullable + public ArmatureData getArmatureData(String name, String dragonBonesName) { + BuildArmaturePackage dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { + return null; + } + + return dataPackage.armature; + } + + public void clear() { + clear(true); + } + + /** + * 清除所有的数据。 + * + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public void clear(boolean disposeData) { + for (String k : this._dragonBonesDataMap.keySet()) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap.get(k)); + } + + this._dragonBonesDataMap.remove(k); + } + + for (String k : this._textureAtlasDataMap.keySet()) { + if (disposeData) { + Array textureAtlasDataList = this._textureAtlasDataMap.get(k); + for (TextureAtlasData textureAtlasData : textureAtlasDataList) { + this._dragonBones.bufferObject(textureAtlasData); + } + } + + this._textureAtlasDataMap.remove(k); + } + } + + @Nullable + public Armature buildArmature(String armatureName) { + return buildArmature(armatureName, null, null, null); + } + + /** + * 创建一个骨架。 + * + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @version DragonBones 3.0 + * @language zh_CN + * @see ArmatureData + * @see Armature + */ + @Nullable + public Armature buildArmature(String armatureName, @Nullable String dragonBonesName, @Nullable String skinName, @Nullable String textureAtlasName) { + BuildArmaturePackage dataPackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, (dragonBonesName != null) ? dragonBonesName : "", armatureName, (skinName != null) ? skinName : "", (textureAtlasName != null) ? textureAtlasName : "")) { + Console.warn("No armature data. " + armatureName + ", " + (dragonBonesName != null ? dragonBonesName : "")); + return null; + } + + Armature armature = this._buildArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0f); // Update armature pose. + + return armature; + } + + public void replaceSlotDisplay( + @Nullable String dragonBonesName, + String armatureName, String slotName, String displayName, + Slot slot + ) { + replaceSlotDisplay(dragonBonesName, armatureName, slotName, displayName, slot, -1); + } + + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public void replaceSlotDisplay( + @Nullable String dragonBonesName, + String armatureName, String slotName, String displayName, + Slot slot, int displayIndex + ) + + { + BuildArmaturePackage dataPackage = new BuildArmaturePackage(); + if ( + !this._fillBuildArmaturePackage( + dataPackage, + (dragonBonesName != null) ? dragonBonesName : "", + armatureName, "", "" + ) || dataPackage.skin == null + ) { + return; + } + + Array displays = dataPackage.skin.getDisplays(slotName); + if (displays == null) { + return; + } + + for (DisplayData display : displays) { + if (display != null && Objects.equals(display.name, displayName)) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + } + + /** + * 用指定资源列表替换插槽的显示对象列表。 + * + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public void replaceSlotDisplayList( + @Nullable String dragonBonesName, + String armatureName, + String slotName, + Slot slot + ) + + { + BuildArmaturePackage dataPackage = new BuildArmaturePackage(); + if ( + !this._fillBuildArmaturePackage( + dataPackage, + (dragonBonesName != null) ? dragonBonesName : "", + armatureName, "", "" + ) || dataPackage.skin == null + ) { + return; + } + + Array displays = dataPackage.skin.getDisplays(slotName); + if (displays == null) { + return; + } + + int displayIndex = 0; + for (DisplayData displayData : displays) { + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + } + + public void changeSkin(Armature armature, SkinData skin) { + changeSkin(armature, skin, null); + } + + /** + * 更换骨架皮肤。 + * + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @version DragonBones 5.1 + * @language zh_CN + * @see Armature + * @see SkinData + */ + public void changeSkin(Armature armature, SkinData skin, @Nullable Array exclude) { + for (Slot slot : armature.getSlots()) { + if (!(skin.displays.containsKey(slot.name)) || (exclude != null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + + Array displays = skin.displays.get(slot.name); + Array displayList = slot.getDisplayList(); // Copy. + displayList.setLength(displays.size()); // Modify displayList length. + for (int i = 0, l = displays.size(); i < l; ++i) { + DisplayData displayData = displays.get(i); + if (displayData != null) { + displayList.set(i, this._getSlotDisplay(null, displayData, null, slot)); + } else { + displayList.set(i, null); + } + } + + slot._rawDisplayDatas = displays; + slot._displayDatas.setLength(displays.size()); + for (int i = 0, l = slot._displayDatas.size(); i < l; ++i) { + slot._displayDatas.set(i, displays.get(i)); + } + + slot.setDisplayList(displayList); + } + } + + public boolean copyAnimationsToArmature(Armature toArmature, String fromArmatreName) { + return copyAnimationsToArmature(toArmature, fromArmatreName, null, null, true); + } + + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @version DragonBones 4.5 + * @language zh_CN + * @see Armature + * @see ArmatureData + */ + public boolean copyAnimationsToArmature( + Armature toArmature, + String fromArmatreName, + @Nullable String fromSkinName, + @Nullable String fromDragonBonesDataName, + boolean replaceOriginalAnimation + ) + + { + BuildArmaturePackage dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage( + dataPackage, + (fromDragonBonesDataName != null) ? fromDragonBonesDataName : "", + fromArmatreName, + (fromSkinName != null) ? fromSkinName : "", + "" + )) { + ArmatureData fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.getAnimation().setAnimations(fromArmatureData.animations); + } else { + Map animations = new HashMap<>(); + + for (String animationName : toArmature.getAnimation().getAnimations().keySet()) { + animations.put(animationName, toArmature.getAnimation().getAnimations().get(animationName)); + } + + for (String animationName : fromArmatureData.animations.keySet()) { + animations.put(animationName, fromArmatureData.animations.get(animationName)); + } + + toArmature.getAnimation().setAnimations(animations); + } + + if (dataPackage.skin != null) { + Array slots = toArmature.getSlots(); + for (int i = 0, l = slots.size(); i < l; ++i) { + Slot toSlot = slots.get(i); + Array toSlotDisplayList = toSlot.getDisplayList(); + for (int j = 0, lJ = toSlotDisplayList.size(); j < lJ; ++j) { + Object toDisplayObject = toSlotDisplayList.get(j); + if (toDisplayObject instanceof Armature) { + Array displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays != null && j < displays.size()) { + DisplayData fromDisplayData = displays.get(j); + if (fromDisplayData != null && fromDisplayData.type == DisplayType.Armature) { + this.copyAnimationsToArmature((Armature) toDisplayObject, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + + return true; + } + } + + return false; + } + + /** + * @private + */ + public Map getAllDragonBonesData() { + return this._dragonBonesDataMap; + } + + /** + * @private + */ + public Map> getAllTextureAtlasData() { + return this._textureAtlasDataMap; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/factory/BuildArmaturePackage.java b/dragonbones-core/src/main/java/com/dragonbones/factory/BuildArmaturePackage.java new file mode 100644 index 0000000..29fd055 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/factory/BuildArmaturePackage.java @@ -0,0 +1,18 @@ +package com.dragonbones.factory; + +import com.dragonbones.model.ArmatureData; +import com.dragonbones.model.DragonBonesData; +import com.dragonbones.model.SkinData; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public class BuildArmaturePackage { + public String dataName = ""; + public String textureAtlasName = ""; + public DragonBonesData data; + public ArmatureData armature; + public @Nullable + SkinData skin = null; +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/geom/ColorTransform.java b/dragonbones-core/src/main/java/com/dragonbones/geom/ColorTransform.java new file mode 100644 index 0000000..93fe412 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/geom/ColorTransform.java @@ -0,0 +1,51 @@ +package com.dragonbones.geom; + +/** + * @private + */ +public class ColorTransform { + public float alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier; + public int alphaOffset, redOffset, greenOffset, blueOffset; + + /* + public ColorTransform( + float alphaMultiplier = 1f, float redMultiplier = 1f, float greenMultiplier = 1f, float blueMultiplier = 1f, + int alphaOffset = 0, int redOffset = 0, int greenOffset = 0, int blueOffset = 0 + ) { + } + */ + + public ColorTransform() { + this(1, 1, 1, 1, 0, 0, 0, 0); + } + + public ColorTransform( + float alphaMultiplier, float redMultiplier, float greenMultiplier, float blueMultiplier, + int alphaOffset, int redOffset, int greenOffset, int blueOffset + ) { + this.alphaMultiplier = alphaMultiplier; + this.redMultiplier = redMultiplier; + this.greenMultiplier = greenMultiplier; + this.blueMultiplier = blueMultiplier; + this.alphaOffset = alphaOffset; + this.redOffset = redOffset; + this.greenOffset = greenOffset; + this.blueOffset = blueOffset; + } + + public void copyFrom(ColorTransform 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; + } + + public void identity() { + this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1f; + this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/geom/Matrix.java b/dragonbones-core/src/main/java/com/dragonbones/geom/Matrix.java new file mode 100644 index 0000000..f1b47c7 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/geom/Matrix.java @@ -0,0 +1,204 @@ +package com.dragonbones.geom; + +import com.dragonbones.util.FloatArray; + +/** + * 2D 矩阵。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public class Matrix { + public float a, b, c, d, tx, ty; + + public Matrix() { + this(1, 0, 0, 1, 0, 0); + } + + public Matrix(float a, float b, float c, float d, float tx, float ty) { + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.tx = tx; + this.ty = ty; + } + + /** + * @private + */ + public String toString() { + return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty; + } + + /** + * @private + */ + public Matrix copyFrom(Matrix 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; + } + + /** + * @param value + * @private + */ + public Matrix copyFromArray(FloatArray value) { + return copyFromArray(value, 0); + } + + /** + * @private + */ + public Matrix copyFromArray(FloatArray value, int offset) { + this.a = value.get(offset); + this.b = value.get(offset + 1); + this.c = value.get(offset + 2); + this.d = value.get(offset + 3); + this.tx = value.get(offset + 4); + this.ty = value.get(offset + 5); + + return this; + } + + /** + * 转换为单位矩阵。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Matrix identity() { + this.a = this.d = 1f; + this.b = this.c = 0f; + this.tx = this.ty = 0f; + + return this; + } + + /** + * 将当前矩阵与另一个矩阵相乘。 + * + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public Matrix concat(Matrix value) { + float aA = this.a * value.a; + float bA = 0f; + float cA = 0f; + float dA = this.d * value.d; + float txA = this.tx * value.a + value.tx; + float tyA = this.ty * value.d + value.ty; + + if (this.b != 0f || this.c != 0f) { + aA += this.b * value.c; + bA += this.b * value.d; + cA += this.c * value.a; + dA += this.c * value.b; + } + + if (value.b != 0f || value.c != 0f) { + 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; + } + + /** + * 转换为逆矩阵。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public Matrix invert() { + float aA = this.a; + float bA = this.b; + float cA = this.c; + float dA = this.d; + final float txA = this.tx; + final float tyA = this.ty; + + if (bA == 0f && cA == 0f) { + this.b = this.c = 0f; + if (aA == 0f || dA == 0f) { + this.a = this.b = this.tx = this.ty = 0f; + } else { + aA = this.a = 1f / aA; + dA = this.d = 1f / dA; + this.tx = -aA * txA; + this.ty = -dA * tyA; + } + + return this; + } + + float determinant = aA * dA - bA * cA; + if (determinant == 0f) { + this.a = this.d = 1f; + this.b = this.c = 0f; + this.tx = this.ty = 0f; + + return this; + } + + determinant = 1f / determinant; + float 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; + } + + /** + * 将矩阵转换应用于指定点。 + * + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void transformPoint(float x, float y, Point result) { + transformPoint(x, y, result, false); + } + + /** + * 将矩阵转换应用于指定点。 + * + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public void transformPoint(float x, float y, Point result, boolean delta) { + 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; + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/geom/Point.java b/dragonbones-core/src/main/java/com/dragonbones/geom/Point.java new file mode 100644 index 0000000..3431a9c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/geom/Point.java @@ -0,0 +1,23 @@ +package com.dragonbones.geom; + +public class Point { + public float x, y; + + public Point() { + this(0, 0); + } + + public Point(float x, float y) { + this.x = x; + this.y = y; + } + + public void copyFrom(Point value) { + this.x = value.x; + this.y = value.y; + } + + public void clear() { + this.x = this.y = 0f; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/geom/Rectangle.java b/dragonbones-core/src/main/java/com/dragonbones/geom/Rectangle.java new file mode 100644 index 0000000..9a82aaf --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/geom/Rectangle.java @@ -0,0 +1,28 @@ +package com.dragonbones.geom; + +public class Rectangle { + public float x, y, width, height; + + public Rectangle() { + this(0, 0, 0, 0); + } + + public Rectangle(float x, float y, float width, float height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public void copyFrom(Rectangle value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + } + + public void clear() { + this.x = this.y = 0f; + this.width = this.height = 0f; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/geom/Transform.java b/dragonbones-core/src/main/java/com/dragonbones/geom/Transform.java new file mode 100644 index 0000000..316299b --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/geom/Transform.java @@ -0,0 +1,232 @@ +package com.dragonbones.geom; + +/** + * 2D 变换。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public class Transform { + /** + * @private + */ + public static final float PI_D = (float) (Math.PI * 2.0); + /** + * @private + */ + public static final float PI_H = (float) (Math.PI / 2.0); + /** + * @private + */ + public static final float PI_Q = (float) (Math.PI / 4.0); + /** + * @private + */ + public static final float RAD_DEG = (float) (180.0 / Math.PI); + /** + * @private + */ + public static final float DEG_RAD = (float) (Math.PI / 180.0); + + /** + * @private + */ + public static float normalizeRadian(float value) { + value = (float) ((value + Math.PI) % (Math.PI * 2.0)); + value += value > 0f ? -Math.PI : Math.PI; + + return value; + } + + /** + * 水平位移。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float x; + /** + * 垂直位移。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float y; + /** + * 倾斜。 (以弧度为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float skew; + /** + * 旋转。 (以弧度为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float rotation; + /** + * 水平缩放。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float scaleX; + /** + * 垂直缩放。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float scaleY; + + public Transform() { + this(0, 0, 0, 0, 1, 1); + } + + public Transform(float x, float y, float skew, float rotation, float scaleX, float scaleY) { + this.x = x; + this.y = y; + this.skew = skew; + this.rotation = rotation; + this.scaleX = scaleX; + this.scaleY = scaleY; + } + + /** + * @private + */ + public String toString() { + 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 + */ + public Transform copyFrom(Transform 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 + */ + public Transform identity() { + this.x = this.y = 0f; + this.skew = this.rotation = 0f; + this.scaleX = this.scaleY = 1f; + + return this; + } + + /** + * @private + */ + public Transform add(Transform 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 + */ + public Transform minus(Transform 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; + } + + /** + * 矩阵转换为变换。 + * + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public Transform fromMatrix(Matrix matrix) { + final float backupScaleX = this.scaleX, backupScaleY = this.scaleY; + final float PI_Q = Transform.PI_Q; + + this.x = matrix.tx; + this.y = matrix.ty; + this.rotation = (float) Math.atan(matrix.b / matrix.a); + float skewX = (float) Math.atan(-matrix.c / matrix.d); + + this.scaleX = (float) ((this.rotation > -PI_Q && this.rotation < PI_Q) ? matrix.a / Math.cos(this.rotation) : matrix.b / Math.sin(this.rotation)); + this.scaleY = (float) ((skewX > -PI_Q && skewX < PI_Q) ? matrix.d / Math.cos(skewX) : -matrix.c / Math.sin(skewX)); + + if (backupScaleX >= 0f && this.scaleX < 0f) { + this.scaleX = -this.scaleX; + this.rotation = (float) (this.rotation - Math.PI); + } + + if (backupScaleY >= 0f && this.scaleY < 0f) { + this.scaleY = -this.scaleY; + skewX = (float) (skewX - Math.PI); + } + + this.skew = skewX - this.rotation; + + return this; + } + + /** + * 转换为矩阵。 + * + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public Transform toMatrix(Matrix matrix) { + if (this.skew != 0f || this.rotation != 0f) { + matrix.a = (float) Math.cos(this.rotation); + matrix.b = (float) Math.sin(this.rotation); + + if (this.skew == 0f) { + matrix.c = -matrix.b; + matrix.d = matrix.a; + } else { + matrix.c = (float) -Math.sin(this.skew + this.rotation); + matrix.d = (float) Math.cos(this.skew + this.rotation); + } + + if (this.scaleX != 1f) { + matrix.a *= this.scaleX; + matrix.b *= this.scaleX; + } + + if (this.scaleY != 1f) { + matrix.c *= this.scaleY; + matrix.d *= this.scaleY; + } + } else { + matrix.a = this.scaleX; + matrix.b = 0f; + matrix.c = 0f; + matrix.d = this.scaleY; + } + + matrix.tx = this.x; + matrix.ty = this.y; + + return this; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/ActionData.java b/dragonbones-core/src/main/java/com/dragonbones/model/ActionData.java new file mode 100644 index 0000000..6714870 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/ActionData.java @@ -0,0 +1,31 @@ +package com.dragonbones.model; + +import com.dragonbones.core.ActionType; +import com.dragonbones.core.BaseObject; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public class ActionData extends BaseObject { + public ActionType type; + public String name; // Frame event name | Sound event name | Animation name + public @Nullable + BoneData bone; + public @Nullable + SlotData slot; + public @Nullable + UserData data = null; // + + protected void _onClear() { + if (this.data != null) { + this.data.returnToPool(); + } + + this.type = ActionType.Play; + this.name = ""; + this.bone = null; + this.slot = null; + this.data = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/AnimationConfig.java b/dragonbones-core/src/main/java/com/dragonbones/model/AnimationConfig.java new file mode 100644 index 0000000..aa173db --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/AnimationConfig.java @@ -0,0 +1,321 @@ +package com.dragonbones.model; + +import com.dragonbones.animation.AnimationState; +import com.dragonbones.armature.Armature; +import com.dragonbones.armature.Bone; +import com.dragonbones.core.AnimationFadeOutMode; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.TweenType; +import com.dragonbones.util.Array; + +/** + * 动画配置,描述播放一个动画所需要的全部信息。 + * + * @version DragonBones 5.0 + * @beta + * @language zh_CN + * @see AnimationState + */ +public class AnimationConfig extends BaseObject { + /** + * 是否暂停淡出的动画。 + * + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean pauseFadeOut; + /** + * 淡出模式。 + * + * @default dragonBones.AnimationFadeOutMode.All + * @version DragonBones 5.0 + * @language zh_CN + * @see AnimationFadeOutMode + */ + public AnimationFadeOutMode fadeOutMode; + /** + * 淡出缓动方式。 + * + * @default TweenType.Line + * @version DragonBones 5.0 + * @language zh_CN + * @see TweenType + */ + public TweenType fadeOutTweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float fadeOutTime; + + /** + * 否能触发行为。 + * + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean actionEnabled; + /** + * 是否以增加的方式混合。 + * + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean additiveBlending; + /** + * 是否对插槽的显示对象有控制权。 + * + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean displayControl; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public boolean pauseFadeIn; + /** + * 是否将没有动画的对象重置为初始值。 + * + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + public boolean resetToPose; + /** + * 淡入缓动方式。 + * + * @default TweenType.Line + * @version DragonBones 5.0 + * @language zh_CN + * @see TweenType + */ + public TweenType fadeInTweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public int playTimes; + /** + * 混合图层,图层高会优先获取混合权重。 + * + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float layer; + /** + * 开始时间。 (以秒为单位) + * + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float position; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float duration; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + public float timeScale; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float fadeInTime; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float autoFadeOutTime; + /** + * 混合权重。 + * + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public float weight; + /** + * 动画状态名。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public String name; + /** + * 动画数据名。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public String animation; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public String group; + /** + * 骨骼遮罩。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public final Array boneMask = new Array<>(); + + /** + * @private + */ + protected void _onClear() { + this.pauseFadeOut = true; + this.fadeOutMode = AnimationFadeOutMode.All; + this.fadeOutTweenType = TweenType.Line; + this.fadeOutTime = -1f; + + this.actionEnabled = true; + this.additiveBlending = false; + this.displayControl = true; + this.pauseFadeIn = true; + this.resetToPose = true; + this.fadeInTweenType = TweenType.Line; + this.playTimes = -1; + this.layer = 0; + this.position = 0f; + this.duration = -1f; + this.timeScale = -100f; + this.fadeInTime = -1f; + this.autoFadeOutTime = -1f; + this.weight = 1f; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.clear(); + } + + public void clear() { + this._onClear(); + } + + public void copyFrom(AnimationConfig value) { + this.pauseFadeOut = value.pauseFadeOut; + this.fadeOutMode = value.fadeOutMode; + this.autoFadeOutTime = value.autoFadeOutTime; + this.fadeOutTweenType = value.fadeOutTweenType; + + this.actionEnabled = value.actionEnabled; + this.additiveBlending = value.additiveBlending; + 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.setLength(value.boneMask.size()); + for (int i = 0, l = this.boneMask.size(); i < l; ++i) { + this.boneMask.set(i, value.boneMask.get(i)); + } + } + + public boolean containsBoneMask(String name) { + return this.boneMask.size() == 0 || this.boneMask.indexOfObject(name) >= 0; + } + + public void addBoneMask(Armature armature, String name) { + addBoneMask(armature, name, true); + } + + public void addBoneMask(Armature armature, String name, boolean recursive) { + Bone currentBone = armature.getBone(name); + if (currentBone == null) { + return; + } + + if (this.boneMask.indexOfObject(name) < 0) { // Add mixing + this.boneMask.add(name); + } + + if (recursive) { // Add recursive mixing. + for (Bone bone : armature.getBones()) { + if (this.boneMask.indexOfObject(bone.name) < 0 && currentBone.contains(bone)) { + this.boneMask.add(bone.name); + } + } + } + } + + public void removeBoneMask(Armature armature, String name) { + removeBoneMask(armature, name, true); + } + + public void removeBoneMask(Armature armature, String name, boolean recursive) { + int index = this.boneMask.indexOfObject(name); + if (index >= 0) { // Remove mixing. + this.boneMask.splice(index, 1); + } + + if (recursive) { + Bone currentBone = armature.getBone(name); + if (currentBone != null) { + if (this.boneMask.size() > 0) { // Remove recursive mixing. + for (Bone bone : armature.getBones()) { + int index2 = this.boneMask.indexOfObject(bone.name); + if (index2 >= 0 && currentBone.contains(bone)) { + this.boneMask.splice(index2, 1); + } + } + } else { // Add unrecursive mixing. + for (Bone bone : armature.getBones()) { + if (bone == currentBone) { + continue; + } + + if (!currentBone.contains(bone)) { + this.boneMask.add(bone.name); + } + } + } + } + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/AnimationData.java b/dragonbones-core/src/main/java/com/dragonbones/model/AnimationData.java new file mode 100644 index 0000000..6d44a68 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/AnimationData.java @@ -0,0 +1,249 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.util.Array; +import com.dragonbones.util.BoolArray; +import com.dragonbones.util.IntArray; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +/** + * 动画数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public class AnimationData extends BaseObject { + /** + * @private + */ + public int frameIntOffset; // FrameIntArray. + /** + * @private + */ + public int frameFloatOffset; // FrameFloatArray. + /** + * @private + */ + public int frameOffset; // FrameArray. + /** + * 持续的帧数。 ([1~N]) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public int frameCount; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public int playTimes; + /** + * 持续时间。 (以秒为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float duration; + /** + * @private + */ + public float scale; + /** + * 淡入时间。 (以秒为单位) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float fadeInTime; + /** + * @private + */ + public float cacheFrameRate; + /** + * 数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * @private + */ + public BoolArray cachedFrames = new BoolArray(); + /** + * @private + */ + public final Map> boneTimelines = new HashMap<>(); + /** + * @private + */ + public final Map> slotTimelines = new HashMap<>(); + /** + * @private + */ + public final Map boneCachedFrameIndices = new HashMap<>(); + /** + * @private + */ + public final Map slotCachedFrameIndices = new HashMap<>(); + /** + * @private + */ + @Nullable + public TimelineData actionTimeline = null; // Initial value. + /** + * @private + */ + @Nullable + public TimelineData zOrderTimeline = null; // Initial value. + /** + * @private + */ + public ArmatureData parent; + + /** + * @private + */ + protected void _onClear() { + for (String k : this.boneTimelines.keySet()) { + Array timelineData = this.boneTimelines.get(k); + for (int kA = 0; kA < timelineData.size(); kA++) { + timelineData.get(kA).returnToPool(); + } + + this.boneTimelines.remove(k); + } + + for (String k : this.slotTimelines.keySet()) { + for (int kA = 0; kA < this.slotTimelines.size(); kA++) { + this.slotTimelines.get(k).get(kA).returnToPool(); + } + + this.slotTimelines.remove(k); + } + + this.boneCachedFrameIndices.clear(); + this.slotCachedFrameIndices.clear(); + + if (this.actionTimeline != null) { + this.actionTimeline.returnToPool(); + } + + if (this.zOrderTimeline != null) { + this.zOrderTimeline.returnToPool(); + } + + this.frameIntOffset = 0; + this.frameFloatOffset = 0; + this.frameOffset = 0; + this.frameCount = 0; + this.playTimes = 0; + this.duration = 0f; + this.scale = 1f; + this.fadeInTime = 0f; + this.cacheFrameRate = 0f; + this.name = ""; + this.cachedFrames.clear(); + //this.boneTimelines.clear(); + //this.slotTimelines.clear(); + //this.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + } + + /** + * @private + */ + public void cacheFrames(float frameRate) { + if (this.cacheFrameRate > 0f) { // TODO clear cache. + return; + } + + this.cacheFrameRate = (float) Math.max(Math.ceil(frameRate * this.scale), 1f); + int cacheFrameCount = (int) (Math.ceil(this.cacheFrameRate * this.duration) + 1); // Cache one more frame. + + this.cachedFrames.setLength(cacheFrameCount); + for (int i = 0, l = this.cachedFrames.size(); i < l; ++i) { + this.cachedFrames.setBool(i, false); + } + + for (BoneData bone : this.parent.sortedBones) { + IntArray indices = new IntArray(cacheFrameCount); + for (int i = 0, l = indices.size(); i < l; ++i) { + indices.set(i, -1); + } + + this.boneCachedFrameIndices.put(bone.name, indices); + } + + for (SlotData slot : this.parent.sortedSlots) { + IntArray indices = new IntArray(cacheFrameCount); + for (int i = 0, l = indices.size(); i < l; ++i) { + indices.set(i, -1); + } + + this.slotCachedFrameIndices.put(slot.name, indices); + } + } + + /** + * @private + */ + public void addBoneTimeline(BoneData bone, TimelineData timeline) { + if (!this.boneTimelines.containsKey(bone.name)) { + this.boneTimelines.put(bone.name, new Array<>()); + } + Array timelines = this.boneTimelines.get(bone.name); + if (timelines.indexOf(timeline) < 0) { + timelines.add(timeline); + } + } + + /** + * @private + */ + public void addSlotTimeline(SlotData slot, TimelineData timeline) { + if (!this.slotTimelines.containsKey(slot.name)) { + this.slotTimelines.put(slot.name, new Array<>()); + } + Array timelines = this.slotTimelines.get(slot.name); + if (timelines.indexOf(timeline) < 0) { + timelines.add(timeline); + } + } + + /** + * @private + */ + public Array getBoneTimelines(String name) { + return this.boneTimelines.get(name); + } + + /** + * @private + */ + public Array getSlotTimeline(String name) { + return this.slotTimelines.get(name); + } + + /** + * @private + */ + public IntArray getBoneCachedFrameIndices(String name) { + return this.boneCachedFrameIndices.get(name); + } + + /** + * @private + */ + public IntArray getSlotCachedFrameIndices(String name) { + return this.slotCachedFrameIndices.get(name); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/ArmatureData.java b/dragonbones-core/src/main/java/com/dragonbones/model/ArmatureData.java new file mode 100644 index 0000000..4d09ef9 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/ArmatureData.java @@ -0,0 +1,417 @@ +package com.dragonbones.model; + +import com.dragonbones.core.ArmatureType; +import com.dragonbones.core.BaseObject; +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Rectangle; +import com.dragonbones.geom.Transform; +import com.dragonbones.util.Array; +import com.dragonbones.util.Console; +import com.dragonbones.util.FloatArray; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +/** + * 骨架数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public class ArmatureData extends BaseObject { + /** + * @private + */ + public ArmatureType type; + /** + * 动画帧率。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float frameRate; + /** + * @private + */ + public float cacheFrameRate; + /** + * @private + */ + public float scale; + /** + * 数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * @private + */ + public final Rectangle aabb = new Rectangle(); + /** + * 所有动画数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public final Array animationNames = new Array<>(); + /** + * @private + */ + public final Array sortedBones = new Array<>(); + /** + * @private + */ + public final Array sortedSlots = new Array<>(); + /** + * @private + */ + public final Array defaultActions = new Array<>(); + /** + * @private + */ + public final Array actions = new Array<>(); + /** + * 所有骨骼数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see BoneData + */ + public final Map bones = new HashMap<>(); + /** + * 所有插槽数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see SlotData + */ + public final Map slots = new HashMap<>(); + /** + * 所有皮肤数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see SkinData + */ + public final Map skins = new HashMap<>(); + /** + * 所有动画数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationData + */ + public final Map animations = new HashMap<>(); + /** + * 获取默认皮肤数据。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see SkinData + */ + @Nullable + public SkinData defaultSkin; + /** + * 获取默认动画数据。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see AnimationData + */ + @Nullable + public AnimationData defaultAnimation; + /** + * @private + */ + @Nullable + public CanvasData canvas = null; // Initial value. + /** + * @private + */ + @Nullable + public UserData userData = null; // Initial value. + /** + * 所属的龙骨数据。 + * + * @version DragonBones 4.5 + * @language zh_CN + * @see DragonBonesData + */ + public DragonBonesData parent; + + /** + * @private + */ + protected void _onClear() { + for (ActionData action : this.defaultActions) { + action.returnToPool(); + } + + for (ActionData action : this.actions) { + action.returnToPool(); + } + + for (String k : this.bones.keySet()) { + this.bones.get(k).returnToPool(); + this.bones.remove(k); + } + + for (String k : this.slots.keySet()) { + this.slots.get(k).returnToPool(); + this.slots.remove(k); + } + + for (String k : this.skins.keySet()) { + this.skins.get(k).returnToPool(); + this.skins.remove(k); + } + + for (String k : this.animations.keySet()) { + this.animations.get(k).returnToPool(); + this.animations.remove(k); + } + + if (this.canvas != null) { + this.canvas.returnToPool(); + } + + if (this.userData != null) { + this.userData.returnToPool(); + } + + this.type = ArmatureType.Armature; + this.frameRate = 0; + this.cacheFrameRate = 0; + this.scale = 1f; + this.name = ""; + this.aabb.clear(); + this.animationNames.clear(); + this.sortedBones.clear(); + this.sortedSlots.clear(); + this.defaultActions.clear(); + this.actions.clear(); + //this.bones.clear(); + //this.slots.clear(); + //this.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + } + + /** + * @private + */ + public void sortBones() { + int total = this.sortedBones.size(); + if (total <= 0) { + return; + } + + Array sortHelper = this.sortedBones.copy(); + int index = 0; + int count = 0; + this.sortedBones.clear(); + while (count < total) { + BoneData bone = sortHelper.get(index++); + if (index >= total) { + index = 0; + } + + if (this.sortedBones.indexOfObject(bone) >= 0) { + continue; + } + + if (bone.constraints.size() > 0) { // Wait constraint. + boolean flag = false; + for (ConstraintData constraint : bone.constraints) { + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + + if (flag) { + continue; + } + } + + if (bone.parent != null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. + continue; + } + + this.sortedBones.add(bone); + count++; + } + } + + /** + * @private + */ + public void cacheFrames(float frameRate) { + if (this.cacheFrameRate > 0) { // TODO clear cache. + return; + } + + this.cacheFrameRate = frameRate; + for (String k : this.animations.keySet()) { + this.animations.get(k).cacheFrames(this.cacheFrameRate); + } + } + + /** + * @private + */ + public int setCacheFrame(Matrix globalTransformMatrix, Transform transform) { + FloatArray dataArray = this.parent.cachedFrames; + int arrayOffset = dataArray.size(); + + dataArray.setLength(dataArray.size() + 10); + dataArray.set(arrayOffset + 0, globalTransformMatrix.a); + dataArray.set(arrayOffset + 1, globalTransformMatrix.b); + dataArray.set(arrayOffset + 2, globalTransformMatrix.c); + dataArray.set(arrayOffset + 3, globalTransformMatrix.d); + dataArray.set(arrayOffset + 4, globalTransformMatrix.tx); + dataArray.set(arrayOffset + 5, globalTransformMatrix.ty); + dataArray.set(arrayOffset + 6, transform.rotation); + dataArray.set(arrayOffset + 7, transform.skew); + dataArray.set(arrayOffset + 8, transform.scaleX); + dataArray.set(arrayOffset + 9, transform.scaleY); + + return arrayOffset; + } + + /** + * @private + */ + public void getCacheFrame(Matrix globalTransformMatrix, Transform transform, int arrayOffset) { + FloatArray dataArray = this.parent.cachedFrames; + globalTransformMatrix.a = dataArray.get(arrayOffset); + globalTransformMatrix.b = dataArray.get(arrayOffset + 1); + globalTransformMatrix.c = dataArray.get(arrayOffset + 2); + globalTransformMatrix.d = dataArray.get(arrayOffset + 3); + globalTransformMatrix.tx = dataArray.get(arrayOffset + 4); + globalTransformMatrix.ty = dataArray.get(arrayOffset + 5); + transform.rotation = dataArray.get(arrayOffset + 6); + transform.skew = dataArray.get(arrayOffset + 7); + transform.scaleX = dataArray.get(arrayOffset + 8); + transform.scaleY = dataArray.get(arrayOffset + 9); + transform.x = globalTransformMatrix.tx; + transform.y = globalTransformMatrix.ty; + } + + /** + * @private + */ + public void addBone(BoneData value) { + if (this.bones.containsKey(value.name)) { + Console.warn("Replace bone: " + value.name); + this.bones.get(value.name).returnToPool(); + } + + this.bones.put(value.name, value); + this.sortedBones.add(value); + } + + /** + * @private + */ + public void addSlot(SlotData value) { + if (this.slots.containsKey(value.name)) { + Console.warn("Replace slot: " + value.name); + this.slots.get(value.name).returnToPool(); + } + + this.slots.put(value.name, value); + this.sortedSlots.add(value); + } + + /** + * @private + */ + public void addSkin(SkinData value) { + if (this.skins.containsKey(value.name)) { + Console.warn("Replace skin: " + value.name); + this.skins.get(value.name).returnToPool(); + } + + this.skins.put(value.name, value); + if (this.defaultSkin == null) { + this.defaultSkin = value; + } + } + + /** + * @private + */ + public void addAnimation(AnimationData value) { + if (this.animations.containsKey(value.name)) { + Console.warn("Replace animation: " + value.name); + this.animations.get(value.name).returnToPool(); + } + + value.parent = this; + this.animations.put(value.name, value); + this.animationNames.add(value.name); + if (this.defaultAnimation == null) { + this.defaultAnimation = value; + } + } + + /** + * 获取骨骼数据。 + * + * @param name 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see BoneData + */ + @Nullable + public BoneData getBone(String name) { + return this.bones.get(name); + } + + /** + * 获取插槽数据。 + * + * @param name 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see SlotData + */ + @Nullable + public SlotData getSlot(String name) { + return this.slots.get(name); + } + + /** + * 获取皮肤数据。 + * + * @param name 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see SkinData + */ + @Nullable + public SkinData getSkin(String name) { + return this.skins.get(name); + } + + /** + * 获取动画数据。 + * + * @param name 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see AnimationData + */ + @Nullable + public AnimationData getAnimation(String name) { + return this.animations.get(name); + } +} + diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/ArmatureDisplayData.java b/dragonbones-core/src/main/java/com/dragonbones/model/ArmatureDisplayData.java new file mode 100644 index 0000000..0475a5a --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/ArmatureDisplayData.java @@ -0,0 +1,28 @@ +package com.dragonbones.model; + +import com.dragonbones.core.DisplayType; +import com.dragonbones.util.Array; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public class ArmatureDisplayData extends DisplayData { + public boolean inheritAnimation; + public final Array actions = new Array<>(); + @Nullable + public ArmatureData armature; + + protected void _onClear() { + super._onClear(); + + for (ActionData action : this.actions) { + action.returnToPool(); + } + + this.type = DisplayType.Armature; + this.inheritAnimation = false; + this.actions.clear(); + this.armature = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/BoneData.java b/dragonbones-core/src/main/java/com/dragonbones/model/BoneData.java new file mode 100644 index 0000000..f422ec2 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/BoneData.java @@ -0,0 +1,87 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.geom.Transform; +import com.dragonbones.util.Array; +import org.jetbrains.annotations.Nullable; + +/** + * 骨骼数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public class BoneData extends BaseObject { + /** + * @private + */ + public boolean inheritTranslation; + /** + * @private + */ + public boolean inheritRotation; + /** + * @private + */ + public boolean inheritScale; + /** + * @private + */ + public boolean inheritReflection; + /** + * @private + */ + public float length; + /** + * 数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * @private + */ + public final Transform transform = new Transform(); + /** + * @private + */ + public final Array constraints = new Array<>(); + /** + * @private + */ + @Nullable + public UserData userData = null; // Initial value. + /** + * 所属的父骨骼数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + @Nullable + public BoneData parent; + + /** + * @private + */ + protected void _onClear() { + for (ConstraintData constraint : this.constraints) { + constraint.returnToPool(); + } + + if (this.userData != null) { + this.userData.returnToPool(); + } + + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0f; + this.name = ""; + this.transform.identity(); + this.constraints.clear(); + this.userData = null; + this.parent = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/BoundingBoxData.java b/dragonbones-core/src/main/java/com/dragonbones/model/BoundingBoxData.java new file mode 100644 index 0000000..581241b --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/BoundingBoxData.java @@ -0,0 +1,74 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.BoundingBoxType; +import com.dragonbones.geom.Point; +import org.jetbrains.annotations.Nullable; + +/** + * 边界框数据基类。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ +public abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public BoundingBoxType type; + /** + * 边界框颜色。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public int color; + /** + * 边界框宽。(本地坐标系) + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public float width; + /** + * 边界框高。(本地坐标系) + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public float height; + + /** + * @private + */ + protected void _onClear() { + this.color = 0x000000; + this.width = 0f; + this.height = 0f; + } + + /** + * 是否包含点。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public abstract boolean containsPoint(float pX, float pY); + + /** + * 是否与线段相交。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public abstract int intersectsSegment( + float xA, float yA, float xB, float yB, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ); +} + diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/BoundingBoxDisplayData.java b/dragonbones-core/src/main/java/com/dragonbones/model/BoundingBoxDisplayData.java new file mode 100644 index 0000000..54c57f4 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/BoundingBoxDisplayData.java @@ -0,0 +1,23 @@ +package com.dragonbones.model; + +import com.dragonbones.core.DisplayType; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public class BoundingBoxDisplayData extends DisplayData { + @Nullable + public BoundingBoxData boundingBox = null; // Initial value. + + protected void _onClear() { + super._onClear(); + + if (this.boundingBox != null) { + this.boundingBox.returnToPool(); + } + + this.type = DisplayType.BoundingBox; + this.boundingBox = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/CanvasData.java b/dragonbones-core/src/main/java/com/dragonbones/model/CanvasData.java new file mode 100644 index 0000000..e5746dd --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/CanvasData.java @@ -0,0 +1,27 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; + +/** + * @private + */ +public class CanvasData extends BaseObject { + public boolean hasBackground; + public int color; + public float x; + public float y; + public float width; + public float height; + + /** + * @private + */ + protected void _onClear() { + this.hasBackground = false; + this.color = 0x000000; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + } +} \ No newline at end of file diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/ConstraintData.java b/dragonbones-core/src/main/java/com/dragonbones/model/ConstraintData.java new file mode 100644 index 0000000..1f3a797 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/ConstraintData.java @@ -0,0 +1,22 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public abstract class ConstraintData extends BaseObject { + public float order; + public BoneData target; + public BoneData bone; + @Nullable + public BoneData root; + + protected void _onClear() { + this.order = 0; + this.target = null; // + this.bone = null; // + this.root = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/DisplayData.java b/dragonbones-core/src/main/java/com/dragonbones/model/DisplayData.java new file mode 100644 index 0000000..349c506 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/DisplayData.java @@ -0,0 +1,24 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.DisplayType; +import com.dragonbones.geom.Transform; + +/** + * @private + */ +public abstract class DisplayData extends BaseObject { + public DisplayType type; + public String name; + public String path; + public final Transform transform = new Transform(); + public ArmatureData parent; + + protected void _onClear() { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null; // + } +} + diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/DragonBonesData.java b/dragonbones-core/src/main/java/com/dragonbones/model/DragonBonesData.java new file mode 100644 index 0000000..8cb2a5d --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/DragonBonesData.java @@ -0,0 +1,166 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.util.*; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +/** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see ArmatureData + */ +public class DragonBonesData extends BaseObject { + /** + * 是否开启共享搜索。 + * + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + public boolean autoSearch; + /** + * 动画帧频。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float frameRate; + /** + * 数据版本。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String version; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * @private + */ + public final IntArray frameIndices = new IntArray(); + /** + * @private + */ + public final FloatArray cachedFrames = new FloatArray(); + /** + * 所有骨架数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see #armatures + */ + public final Array armatureNames = new Array<>(); + /** + * 所有骨架数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see ArmatureData + */ + public final Map armatures = new HashMap<>(); + /** + * @private + */ + public ShortArray intArray; + /** + * @private + */ + public FloatArray floatArray; + /** + * @private + */ + public ShortArray frameIntArray; + /** + * @private + */ + public FloatArray frameFloatArray; + /** + * @private + */ + public ShortArray frameArray; + /** + * @private + */ + public CharArray timelineArray; + /** + * @private + */ + @Nullable + public UserData userData = null; // Initial value. + + /** + * @private + */ + protected void _onClear() { + for (String k : this.armatures.keySet()) { + this.armatures.get(k).returnToPool(); + this.armatures.remove(k); + } + + if (this.userData != null) { + this.userData.returnToPool(); + } + + this.autoSearch = false; + this.frameRate = 0; + this.version = ""; + this.name = ""; + this.frameIndices.clear(); + this.cachedFrames.clear(); + this.armatureNames.clear(); + //this.armatures.clear(); + this.intArray = null; // + this.floatArray = null; // + this.frameIntArray = null; // + this.frameFloatArray = null; // + this.frameArray = null; // + this.timelineArray = null; // + this.userData = null; + } + + /** + * @private + */ + public void addArmature(ArmatureData value) { + if (this.armatures.containsKey(value.name)) { + Console.warn("Replace armature: " + value.name); + this.armatures.get(value.name).returnToPool(); + } + + value.parent = this; + this.armatures.put(value.name, value); + this.armatureNames.add(value.name); + } + + /** + * 获取骨架数据。 + * + * @param name 骨架数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + * @see ArmatureData + */ + @Nullable + public ArmatureData getArmature(String name) { + return this.armatures.get(name); + } + + /** + * @deprecated 已废弃,请参考 @see + */ + public void dispose() { + Console.warn("已废弃,请参考 @see"); + this.returnToPool(); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/EllipseBoundingBoxData.java b/dragonbones-core/src/main/java/com/dragonbones/model/EllipseBoundingBoxData.java new file mode 100644 index 0000000..c9ad4d4 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/EllipseBoundingBoxData.java @@ -0,0 +1,176 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BoundingBoxType; +import com.dragonbones.geom.Point; +import org.jetbrains.annotations.Nullable; + +/** + * 椭圆边界框。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ +public class EllipseBoundingBoxData extends BoundingBoxData { + public static int ellipseIntersectsSegment( + float xA, float yA, float xB, float yB, + float xC, float yC, float widthH, float heightH + ) { + return ellipseIntersectsSegment(xA, yA, xB, yB, xC, yC, widthH, heightH, null, null, null); + } + + /** + * @private + */ + public static int ellipseIntersectsSegment( + float xA, float yA, float xB, float yB, + float xC, float yC, float widthH, float heightH, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) { + float d = widthH / heightH; + float dd = d * d; + + yA *= d; + yB *= d; + + float dX = xB - xA; + float dY = yB - yA; + float lAB = (float) Math.sqrt(dX * dX + dY * dY); + float xD = dX / lAB; + float yD = dY / lAB; + float a = (xC - xA) * xD + (yC - yA) * yD; + float aa = a * a; + float ee = xA * xA + yA * yA; + float rr = widthH * widthH; + float dR = rr - ee + aa; + int intersectionCount = 0; + + if (dR >= 0f) { + float dT = (float) Math.sqrt(dR); + float sA = a - dT; + float sB = a + dT; + float inSideA = sA < 0f ? -1 : (sA <= lAB ? 0 : 1); + float inSideB = sB < 0f ? -1 : (sB <= lAB ? 0 : 1); + float 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 = (float) Math.atan2(yB / rr * dd, xB / rr); + normalRadians.y = (float) (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 = (float) Math.atan2(yA / rr * dd, xA / rr); + normalRadians.y = (float) (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 = (float) 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 = (float) Math.atan2(intersectionPointB.y / rr * dd, intersectionPointB.x / rr); + } + } + } + } + } + + return intersectionCount; + } + + /** + * @private + */ + protected void _onClear() + + { + super._onClear(); + + this.type = BoundingBoxType.Ellipse; + } + + /** + * @inherDoc + */ + public boolean containsPoint(float pX, float pY) + + { + float widthH = (float) (this.width * 0.5); + if (pX >= -widthH && pX <= widthH) { + float heightH = (float) (this.height * 0.5); + if (pY >= -heightH && pY <= heightH) { + pY *= widthH / heightH; + return Math.sqrt(pX * pX + pY * pY) <= widthH; + } + } + + return false; + } + + public int intersectsSegment(float xA, float yA, float xB, float yB) { + return intersectsSegment(xA, yA, xB, yB, null, null, null); + } + + + /** + * @inherDoc + */ + public int intersectsSegment( + float xA, float yA, float xB, float yB, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) + + { + return EllipseBoundingBoxData.ellipseIntersectsSegment( + xA, yA, xB, yB, + 0f, 0f, this.width * 0.5f, this.height * 0.5f, + intersectionPointA, intersectionPointB, normalRadians + ); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/IKConstraintData.java b/dragonbones-core/src/main/java/com/dragonbones/model/IKConstraintData.java new file mode 100644 index 0000000..dfa2e3c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/IKConstraintData.java @@ -0,0 +1,18 @@ +package com.dragonbones.model; + +/** + * @private + */ +public class IKConstraintData extends ConstraintData { + public boolean bendPositive; + public boolean scaleEnabled; + public float weight; + + protected void _onClear() { + super._onClear(); + + this.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1f; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/ImageDisplayData.java b/dragonbones-core/src/main/java/com/dragonbones/model/ImageDisplayData.java new file mode 100644 index 0000000..dd950ca --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/ImageDisplayData.java @@ -0,0 +1,22 @@ +package com.dragonbones.model; + +import com.dragonbones.core.DisplayType; +import com.dragonbones.geom.Point; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public class ImageDisplayData extends DisplayData { + public final Point pivot = new Point(); + @Nullable + public TextureData texture; + + protected void _onClear() { + super._onClear(); + + this.type = DisplayType.Image; + this.pivot.clear(); + this.texture = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/MeshDisplayData.java b/dragonbones-core/src/main/java/com/dragonbones/model/MeshDisplayData.java new file mode 100644 index 0000000..0e9abb6 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/MeshDisplayData.java @@ -0,0 +1,27 @@ +package com.dragonbones.model; + +import com.dragonbones.core.DisplayType; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public class MeshDisplayData extends ImageDisplayData { + public boolean inheritAnimation; + public int offset; // IntArray. + @Nullable + public WeightData weight = null; // Initial value. + + protected void _onClear() { + super._onClear(); + + if (this.weight != null) { + this.weight.returnToPool(); + } + + this.type = DisplayType.Mesh; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/OutCode.java b/dragonbones-core/src/main/java/com/dragonbones/model/OutCode.java new file mode 100644 index 0000000..32af953 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/OutCode.java @@ -0,0 +1,25 @@ +package com.dragonbones.model; + +/** + * Cohen–Sutherland algorithm https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm + * ---------------------- + * | 0101 | 0100 | 0110 | + * ---------------------- + * | 0001 | 0000 | 0010 | + * ---------------------- + * | 1001 | 1000 | 1010 | + * ---------------------- + */ +public enum OutCode { + InSide(0), // 0000 + Left(1), // 0001 + Right(2), // 0010 + Top(4), // 0100 + Bottom(8); // 1000 + + public final int v; + + OutCode(int v) { + this.v = v; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/PolygonBoundingBoxData.java b/dragonbones-core/src/main/java/com/dragonbones/model/PolygonBoundingBoxData.java new file mode 100644 index 0000000..f8908a5 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/PolygonBoundingBoxData.java @@ -0,0 +1,266 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BoundingBoxType; +import com.dragonbones.geom.Point; +import com.dragonbones.util.FloatArray; +import org.jetbrains.annotations.Nullable; + +/** + * 多边形边界框。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ +public class PolygonBoundingBoxData extends BoundingBoxData { + public static int polygonIntersectsSegment( + float xA, float yA, float xB, float yB, + FloatArray vertices, int offset, int count + ) { + return polygonIntersectsSegment(xA, yA, xB, yB, vertices, offset, count, null, null, null); + } + + /** + * @private + */ + public static int polygonIntersectsSegment( + float xA, float yA, float xB, float yB, + FloatArray vertices, int offset, int count, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) { + if (xA == xB) { + xA = xB + 0.000001f; + } + + if (yA == yB) { + yA = yB + 0.000001f; + } + + final float dXAB = xA - xB; + final float dYAB = yA - yB; + final float llAB = xA * yB - yA * xB; + int intersectionCount = 0; + float xC = vertices.get(offset + count - 2); + float yC = vertices.get(offset + count - 1); + float dMin = 0f; + float dMax = 0f; + float xMin = 0f; + float yMin = 0f; + float xMax = 0f; + float yMax = 0f; + + for (int i = 0; i < count; i += 2) { + float xD = vertices.get(offset + i); + float yD = vertices.get(offset + i + 1); + + if (xC == xD) { + xC = xD + 0.0001f; + } + + if (yC == yD) { + yC = yD + 0.0001f; + } + + float dXCD = xC - xD; + float dYCD = yC - yD; + float llCD = xC * yD - yC * xD; + float ll = dXAB * dYCD - dYAB * dXCD; + float x = (llAB * dXCD - dXAB * llCD) / ll; + + if (((x >= xC && x <= xD) || (x >= xD && x <= xC)) && (dXAB == 0f || (x >= xA && x <= xB) || (x >= xB && x <= xA))) { + float y = (llAB * dYCD - dYAB * llCD) / ll; + if (((y >= yC && y <= yD) || (y >= yD && y <= yC)) && (dYAB == 0f || (y >= yA && y <= yB) || (y >= yB && y <= yA))) { + if (intersectionPointB != null) { + float d = x - xA; + if (d < 0f) { + d = -d; + } + + if (intersectionCount == 0) { + dMin = d; + dMax = d; + xMin = x; + yMin = y; + xMax = x; + yMax = y; + + if (normalRadians != null) { + normalRadians.x = (float) (Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5f); + normalRadians.y = normalRadians.x; + } + } else { + if (d < dMin) { + dMin = d; + xMin = x; + yMin = y; + + if (normalRadians != null) { + normalRadians.x = (float) (Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5f); + } + } + + if (d > dMax) { + dMax = d; + xMax = x; + yMax = y; + + if (normalRadians != null) { + normalRadians.y = (float) (Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5f); + } + } + } + + intersectionCount++; + } else { + xMin = x; + yMin = y; + xMax = x; + yMax = y; + intersectionCount++; + + if (normalRadians != null) { + normalRadians.x = (float) (Math.atan2(yD - yC, xD - xC) - Math.PI * 0.5f); + 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 = (float) (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; + } + + /** + * @private + */ + public int count; + /** + * @private + */ + public int offset; // FloatArray. + /** + * @private + */ + public float x; + /** + * @private + */ + public float y; + /** + * 多边形顶点。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ + public FloatArray vertices; // FloatArray. + /** + * @private + */ + @Nullable + public WeightData weight = null; // Initial value. + + /** + * @private + */ + protected void _onClear() + + { + super._onClear(); + + if (this.weight != null) { + this.weight.returnToPool(); + } + + this.type = BoundingBoxType.Polygon; + this.count = 0; + this.offset = 0; + this.x = 0f; + this.y = 0f; + this.vertices = null; // + this.weight = null; + } + + /** + * @inherDoc + */ + public boolean containsPoint(float pX, float pY) + + { + boolean isInSide = false; + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { + for (int i = 0, l = this.count, iP = l - 2; i < l; i += 2) { + float yA = this.vertices.get(this.offset + iP + 1); + float yB = this.vertices.get(this.offset + i + 1); + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + float xA = this.vertices.get(this.offset + iP); + float xB = this.vertices.get(this.offset + i); + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + + iP = i; + } + } + + return isInSide; + } + + public int intersectsSegment(float xA, float yA, float xB, float yB) { + return intersectsSegment(xA, yA, xB, yB, null, null, null); + } + + /** + * @inherDoc + */ + public int intersectsSegment( + float xA, float yA, float xB, float yB, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) { + int intersectionCount = 0; + if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.width, this.height, null, null, null) != 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment( + xA, yA, xB, yB, + this.vertices, this.offset, this.count, + intersectionPointA, intersectionPointB, normalRadians + ); + } + + return intersectionCount; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/RectangleBoundingBoxData.java b/dragonbones-core/src/main/java/com/dragonbones/model/RectangleBoundingBoxData.java new file mode 100644 index 0000000..df8416f --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/RectangleBoundingBoxData.java @@ -0,0 +1,231 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BoundingBoxType; +import com.dragonbones.geom.Point; +import org.jetbrains.annotations.Nullable; + +/** + * 矩形边界框。 + * + * @version DragonBones 5.1 + * @language zh_CN + */ +public class RectangleBoundingBoxData extends BoundingBoxData { + /** + * Compute the bit code for a point (x, y) using the clip rectangle + */ + private static int _computeOutCode(float x, float y, float xMin, float yMin, float xMax, float yMax) { + int code = OutCode.InSide.v; // initialised as being inside of [[clip window]] + + if (x < xMin) { // to the left of clip window + code |= OutCode.Left.v; + } else if (x > xMax) { // to the right of clip window + code |= OutCode.Right.v; + } + + if (y < yMin) { // below the clip window + code |= OutCode.Top.v; + } else if (y > yMax) { // above the clip window + code |= OutCode.Bottom.v; + } + + return code; + } + + public static int rectangleIntersectsSegment( + float xA, float yA, float xB, float yB, + float xMin, float yMin, float xMax, float yMax + ) { + return rectangleIntersectsSegment(xA, yA, xB, yB, xMin, yMin, xMax, yMax, null, null, null); + } + + /** + * @private + */ + public static int rectangleIntersectsSegment( + float xA, float yA, float xB, float yB, + float xMin, float yMin, float xMax, float yMax, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) { + boolean inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; + boolean inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; + + if (inSideA && inSideB) { + return -1; + } + + int intersectionCount = 0; + int outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + int 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 + float x = 0f; + float y = 0f; + float normalRadian = 0f; + + // At least one endpoint is outside the clip rectangle; pick it. + final int outcodeOut = outcode0 != 0 ? outcode0 : outcode1; + + // Now find the intersection point; + if ((outcodeOut & OutCode.Top.v) != 0) { // point is above the clip rectangle + x = xA + (xB - xA) * (yMin - yA) / (yB - yA); + y = yMin; + + if (normalRadians != null) { + normalRadian = (float) (-Math.PI * 0.5); + } + } else if ((outcodeOut & OutCode.Bottom.v) != 0) { // point is below the clip rectangle + x = xA + (xB - xA) * (yMax - yA) / (yB - yA); + y = yMax; + + if (normalRadians != null) { + normalRadian = (float) (Math.PI * 0.5); + } + } else if ((outcodeOut & OutCode.Right.v) != 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 & OutCode.Left.v) != 0) { // point is to the left of clip rectangle + y = yA + (yB - yA) * (xMin - xA) / (xB - xA); + x = xMin; + + if (normalRadians != null) { + normalRadian = (float) 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 != 0) { + 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 = (float) (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 = (float) (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; + } + + /** + * @private + */ + protected void _onClear() { + super._onClear(); + + this.type = BoundingBoxType.Rectangle; + } + + /** + * @inherDoc + */ + public boolean containsPoint(float pX, float pY) { + final float widthH = (float) (this.width * 0.5); + if (pX >= -widthH && pX <= widthH) { + final float heightH = (float) (this.height * 0.5); + if (pY >= -heightH && pY <= heightH) { + return true; + } + } + + return false; + } + + public int intersectsSegment( + float xA, float yA, float xB, float yB + ) { + return intersectsSegment(xA, yA, xB, yB, null, null, null); + } + + /** + * @inherDoc + */ + public int intersectsSegment( + float xA, float yA, float xB, float yB, + @Nullable Point intersectionPointA, + @Nullable Point intersectionPointB, + @Nullable Point normalRadians + ) { + final float widthH = (float) (this.width * 0.5); + final float heightH = (float) (this.height * 0.5); + final int intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment( + xA, yA, xB, yB, + -widthH, -heightH, widthH, heightH, + intersectionPointA, intersectionPointB, normalRadians + ); + + return intersectionCount; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/SkinData.java b/dragonbones-core/src/main/java/com/dragonbones/model/SkinData.java new file mode 100644 index 0000000..75cebda --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/SkinData.java @@ -0,0 +1,89 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.util.Array; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public class SkinData extends BaseObject { + /** + * 数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * @private + */ + public final Map> displays = new HashMap<>(); + + /** + * @private + */ + protected void _onClear() { + for (String k : this.displays.keySet()) { + Array slotDisplays = this.displays.get(k); + for (DisplayData display : slotDisplays) { + if (display != null) { + display.returnToPool(); + } + } + + this.displays.remove(k); + } + + this.name = ""; + // this.displays.clear(); + } + + /** + * @private + */ + public void addDisplay(String slotName, @Nullable DisplayData value) { + if (!(this.displays.containsKey(slotName))) { + this.displays.put(slotName, new Array<>()); + } + + Array slotDisplays = this.displays.get(slotName); // TODO clear prev + slotDisplays.add(value); + } + + /** + * @private + */ + @Nullable + public DisplayData getDisplay(String slotName, String displayName) { + Array slotDisplays = this.getDisplays(slotName); + if (slotDisplays != null) { + for (DisplayData display : slotDisplays) { + if (display != null && Objects.equals(display.name, displayName)) { + return display; + } + } + } + + return null; + } + + /** + * @private + */ + @Nullable + public Array getDisplays(String slotName) { + if (!(this.displays.containsKey(slotName))) { + return null; + } + + return this.displays.get(slotName); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/SlotData.java b/dragonbones-core/src/main/java/com/dragonbones/model/SlotData.java new file mode 100644 index 0000000..e97d2a7 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/SlotData.java @@ -0,0 +1,83 @@ +package com.dragonbones.model; + +import com.dragonbones.armature.Slot; +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.BlendMode; +import com.dragonbones.geom.ColorTransform; +import org.jetbrains.annotations.Nullable; + +/** + * 插槽数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see Slot + */ +public class SlotData extends BaseObject { + /** + * @private + */ + public static final ColorTransform DEFAULT_COLOR = new ColorTransform(); + + /** + * @private + */ + public static ColorTransform createColor() { + return new ColorTransform(); + } + + /** + * @private + */ + public BlendMode blendMode; + /** + * @private + */ + public int displayIndex; + /** + * @private + */ + public float zOrder; + /** + * 数据名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * @private + */ + @Nullable + public ColorTransform color = null; // Initial value. + /** + * @private + */ + @Nullable + public UserData userData = null; // Initial value. + /** + * 所属的父骨骼数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + * @see BoneData + */ + public BoneData parent; + + /** + * @private + */ + protected void _onClear() { + if (this.userData != null) { + this.userData.returnToPool(); + } + + this.blendMode = BlendMode.Normal; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/TextureAtlasData.java b/dragonbones-core/src/main/java/com/dragonbones/model/TextureAtlasData.java new file mode 100644 index 0000000..c8ae3d3 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/TextureAtlasData.java @@ -0,0 +1,127 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.util.Console; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +/** + * 贴图集数据。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ +public abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + public boolean autoSearch; + /** + * @private + */ + public float width; + /** + * @private + */ + public float height; + /** + * 贴图集缩放系数。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public float scale; + /** + * 贴图集名称。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String name; + /** + * 贴图集图片路径。 + * + * @version DragonBones 3.0 + * @language zh_CN + */ + public String imagePath; + /** + * @private + */ + public final Map textures = new HashMap<>(); + + /** + * @private + */ + protected void _onClear() { + for (String k : this.textures.keySet()) { + this.textures.get(k).returnToPool(); + this.textures.remove(k); + } + + this.autoSearch = false; + this.width = 0; + this.height = 0; + this.scale = 1f; + // this.textures.clear(); + this.name = ""; + this.imagePath = ""; + } + + /** + * @private + */ + public void copyFrom(TextureAtlasData 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 (String k : this.textures.keySet()) { + this.textures.get(k).returnToPool(); + this.textures.remove(k); + } + + // this.textures.clear(); + + for (String k : value.textures.keySet()) { + TextureData texture = this.createTexture(); + texture.copyFrom(value.textures.get(k)); + this.textures.put(k, texture); + } + } + + /** + * @private + */ + public abstract TextureData createTexture(); + + /** + * @private + */ + public void addTexture(TextureData value) { + if (this.textures.containsKey(value.name)) { + Console.warn("Replace texture: " + value.name); + this.textures.get(value.name).returnToPool(); + } + + value.parent = this; + this.textures.put(value.name, value); + } + + /** + * @private + */ + @Nullable + public TextureData getTexture(String name) { + return this.textures.get(name); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/TextureData.java b/dragonbones-core/src/main/java/com/dragonbones/model/TextureData.java new file mode 100644 index 0000000..c30ac42 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/TextureData.java @@ -0,0 +1,46 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.geom.Rectangle; +import org.jetbrains.annotations.Nullable; + +/** + * @private + */ +public abstract class TextureData extends BaseObject { + public static Rectangle createRectangle() { + return new Rectangle(); + } + + public boolean rotated; + public String name; + public final Rectangle region = new Rectangle(); + public TextureAtlasData parent; + @Nullable + public Rectangle frame = null; // Initial value. + + protected void _onClear() { + this.rotated = false; + this.name = ""; + this.region.clear(); + this.parent = null; // + this.frame = null; + } + + public void copyFrom(TextureData 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); + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/TimelineData.java b/dragonbones-core/src/main/java/com/dragonbones/model/TimelineData.java new file mode 100644 index 0000000..abe6d7c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/TimelineData.java @@ -0,0 +1,19 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.TimelineType; + +/** + * @private + */ +public class TimelineData extends BaseObject { + public TimelineType type; + public int offset; // TimelineArray. + public int frameIndicesOffset; // FrameIndices. + + protected void _onClear() { + this.type = TimelineType.BoneAll; + this.offset = 0; + this.frameIndicesOffset = -1; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/UserData.java b/dragonbones-core/src/main/java/com/dragonbones/model/UserData.java new file mode 100644 index 0000000..a02c40a --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/UserData.java @@ -0,0 +1,105 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.util.Array; +import com.dragonbones.util.FloatArray; +import com.dragonbones.util.IntArray; + +/** + * 自定义数据。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ +public class UserData extends BaseObject { + /** + * 自定义整数。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public final IntArray ints = new IntArray(); + /** + * 自定义浮点数。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public final FloatArray floats = new FloatArray(); + /** + * 自定义字符串。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public final Array strings = new Array<>(); + + /** + * @private + */ + protected void _onClear() { + this.ints.clear(); + this.floats.clear(); + this.strings.clear(); + } + + /** + * 获取自定义整数。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public int getInt() { + return getInt(0); + } + + /** + * 获取自定义整数。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public int getInt(int index) { + return index >= 0 && index < this.ints.size() ? this.ints.get(index) : 0; + } + + /** + * 获取自定义浮点数。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public float getFloat() { + return getFloat(0); + } + + /** + * 获取自定义浮点数。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public float getFloat(int index) { + return index >= 0 && index < this.floats.size() ? this.floats.get(index) : 0f; + } + + /** + * 获取自定义字符串。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public String getString() { + return getString(0); + } + + /** + * 获取自定义字符串。 + * + * @version DragonBones 5.0 + * @language zh_CN + */ + public String getString(int index) { + return index >= 0 && index < this.strings.size() ? this.strings.get(index) : ""; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/model/WeightData.java b/dragonbones-core/src/main/java/com/dragonbones/model/WeightData.java new file mode 100644 index 0000000..d04c3a0 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/model/WeightData.java @@ -0,0 +1,19 @@ +package com.dragonbones.model; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.util.Array; + +/** + * @private + */ +public class WeightData extends BaseObject { + public int count; + public int offset; // IntArray. + public final Array bones = new Array<>(); + + protected void _onClear() { + this.count = 0; + this.offset = 0; + this.bones.clear(); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/parser/ActionFrame.java b/dragonbones-core/src/main/java/com/dragonbones/parser/ActionFrame.java new file mode 100644 index 0000000..25c287c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/parser/ActionFrame.java @@ -0,0 +1,8 @@ +package com.dragonbones.parser; + +import com.dragonbones.util.IntArray; + +class ActionFrame { + public int frameStart = 0; + public final IntArray actions = new IntArray(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/parser/BinaryDataParser.java b/dragonbones-core/src/main/java/com/dragonbones/parser/BinaryDataParser.java new file mode 100644 index 0000000..597fdc5 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/parser/BinaryDataParser.java @@ -0,0 +1,359 @@ +package com.dragonbones.parser; + +import com.dragonbones.core.BaseObject; +import com.dragonbones.core.BinaryOffset; +import com.dragonbones.core.TimelineType; +import com.dragonbones.factory.BaseFactory; +import com.dragonbones.model.*; +import com.dragonbones.util.*; +import com.dragonbones.util.buffer.*; +import com.dragonbones.util.json.JSON; +import org.jetbrains.annotations.Nullable; + +import java.nio.charset.StandardCharsets; + +import static com.dragonbones.util.Dynamic.*; + +/** + * @private + */ +public class BinaryDataParser extends ObjectDataParser { + private ArrayBuffer _binary; + private int _binaryOffset; + private ShortArray _intArray; + private FloatArray _floatArray; + private ShortArray _frameIntArray; + private FloatArray _frameFloatArray; + private ShortArray _frameArray; + private CharArray _timelineArray; + + /* + private boolean _inRange(float a, float min, float max) { + return min <= a && a <= max; + } + + private String _decodeUTF8(Uint8Array data) { + int EOF_byte = -1; + int EOF_code_point = -1; + int FATAL_POINT = 0xFFFD; + + int pos = 0; + String result = ""; + Integer code_point = null; + int utf8_code_point = 0; + int utf8_bytes_needed = 0; + int utf8_bytes_seen = 0; + int utf8_lower_boundary = 0; + + while (data.length() > pos) { + + int _byte = data.get(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 * (int) 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) * (int) Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + + if (utf8_bytes_seen != utf8_bytes_needed) { + code_point = null; + } else { + + int cp = utf8_code_point; + int 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 += StringUtil.fromCodePoint(code_point); + } else { + code_point -= 0x10000; + result += StringUtil.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); + result += StringUtil.fromCharCode(0xDC00 + (code_point & 0x3ff)); + } + } + } + + return result; + } + + private String _getUTF16Key(String value) { + for (int i = 0, l = value.length(); i < l; ++i) { + if (value.charAt(i) > 255) { + return encodeURI(value); + } + } + + return value; + } + + private String encodeURI(String value) { + throw new RuntimeException("encodeURI not implemented"); + } + */ + + private TimelineData _parseBinaryTimeline(TimelineType type, int offset, @Nullable TimelineData timelineData) { + TimelineData timeline = timelineData != null ? timelineData : BaseObject.borrowObject(TimelineData.class); + timeline.type = type; + timeline.offset = offset; + + this._timeline = timeline; + + int keyFrameCount = this._timelineArray.get(timeline.offset + BinaryOffset.TimelineKeyFrameCount.v); + if (keyFrameCount == 1) { + timeline.frameIndicesOffset = -1; + } else { + int totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + IntArray frameIndices = this._data.frameIndices; + timeline.frameIndicesOffset = frameIndices.length(); + frameIndices.incrementLength(totalFrameCount); + + for ( + int i = 0, iK = 0, frameStart = 0, frameCount = 0; + i < totalFrameCount; + ++i + ) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray.get(this._animation.frameOffset + this._timelineArray.get(timeline.offset + BinaryOffset.TimelineFrameOffset.v + iK)); + if (iK == keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } else { + frameCount = this._frameArray.get(this._animation.frameOffset + this._timelineArray.get(timeline.offset + BinaryOffset.TimelineFrameOffset.v + iK + 1)) - frameStart; + } + + iK++; + } + + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + } + + this._timeline = null; // + + return timeline; + } + + /** + * @private + */ + protected void _parseMesh(Object rawData, MeshDisplayData mesh) { + mesh.offset = getInt(rawData, ObjectDataParser.OFFSET); + + int weightOffset = this._intArray.get(mesh.offset + BinaryOffset.MeshWeightOffset.v); + if (weightOffset >= 0) { + WeightData weight = BaseObject.borrowObject(WeightData.class); + int vertexCount = this._intArray.get(mesh.offset + BinaryOffset.MeshVertexCount.v); + int boneCount = this._intArray.get(weightOffset + BinaryOffset.WeigthBoneCount.v); + weight.offset = weightOffset; + weight.bones.setLength(boneCount); + + for (int i = 0; i < boneCount; ++i) { + int boneIndex = this._intArray.get(weightOffset + BinaryOffset.WeigthBoneIndices.v + i); + weight.bones.set(i, this._rawBones.get(boneIndex)); + } + + int boneIndicesOffset = weightOffset + BinaryOffset.WeigthBoneIndices.v + boneCount; + for (int i = 0, l = vertexCount; i < l; ++i) { + int vertexBoneCount = this._intArray.get(boneIndicesOffset++); + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + + mesh.weight = weight; + } + } + + /** + * @private + */ + protected PolygonBoundingBoxData _parsePolygonBoundingBox(Object rawData) { + PolygonBoundingBoxData polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData.class); + polygonBoundingBox.offset = getInt(rawData, ObjectDataParser.OFFSET); + polygonBoundingBox.vertices = this._floatArray; + + return polygonBoundingBox; + } + + /** + * @private + */ + protected AnimationData _parseAnimation(Object rawData) { + AnimationData animation = BaseObject.borrowObject(AnimationData.class); + animation.frameCount = Math.max(getInt(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = getInt(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = getFloat(rawData, ObjectDataParser.FADE_IN_TIME, 0f); + animation.scale = getFloat(rawData, ObjectDataParser.SCALE, 1f); + animation.name = getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (animation.name.length() == 0) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + + // Offsets. + IntArray offsets = getIntArray(rawData, ObjectDataParser.OFFSET); + animation.frameIntOffset = offsets.get(0); + animation.frameFloatOffset = offsets.get(1); + animation.frameOffset = offsets.get(2); + + this._animation = animation; + + if (in(rawData, ObjectDataParser.ACTION)) { + animation.actionTimeline = this._parseBinaryTimeline(TimelineType.Action, getInt(rawData, ObjectDataParser.ACTION), null); + } + + if (in(rawData, ObjectDataParser.Z_ORDER)) { + animation.zOrderTimeline = this._parseBinaryTimeline(TimelineType.ZOrder, getInt(rawData, ObjectDataParser.Z_ORDER), null); + } + + if (in(rawData, ObjectDataParser.BONE)) { + ArrayBase rawTimeliness = getArray(rawData, ObjectDataParser.BONE); + for (int k = 0; k < rawTimeliness.length(); k++) { + ArrayBase rawTimelines = (ArrayBase) rawTimeliness.getObject(k); + BoneData bone = this._armature.getBone("" + k); + if (bone == null) { + continue; + } + + for (int i = 0, l = rawTimelines.size(); i < l; i += 2) { + int timelineType = (int) rawTimelines.getObject(i); + int timelineOffset = (int) rawTimelines.getObject(i + 1); + TimelineData timeline = this._parseBinaryTimeline(TimelineType.values[timelineType], timelineOffset, null); + this._animation.addBoneTimeline(bone, timeline); + } + } + } + + if (in(rawData, ObjectDataParser.SLOT)) { + ArrayBase rawTimeliness = getArray(rawData, ObjectDataParser.SLOT); + for (int k = 0; k < rawTimeliness.size(); k++) { + ArrayBase rawTimelines = (ArrayBase) rawTimeliness.getObject(k); + + SlotData slot = this._armature.getSlot("" + k); + if (slot == null) { + continue; + } + + for (int i = 0, l = rawTimelines.size(); i < l; i += 2) { + int timelineType = (int) rawTimelines.getObject(i); + int timelineOffset = (int) rawTimelines.getObject(i + 1); + TimelineData timeline = this._parseBinaryTimeline(TimelineType.values[timelineType], timelineOffset, null); + this._animation.addSlotTimeline(slot, timeline); + } + } + } + + this._animation = null; + + return animation; + } + + /** + * @private + */ + protected void _parseArray(Object rawData) { + IntArray offsets = getIntArray(rawData, ObjectDataParser.OFFSET); + + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets.get(0), offsets.get(1) / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets.get(2), offsets.get(3) / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets.get(4), offsets.get(5) / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets.get(6), offsets.get(7) / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets.get(8), offsets.get(9) / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets.get(10), offsets.get(11) / Uint16Array.BYTES_PER_ELEMENT); + } + + @Nullable + public DragonBonesData parseDragonBonesDataInstance(Object rawData) { + return parseDragonBonesData(rawData, 1f); + } + + /** + * @inheritDoc + */ + @Nullable + public DragonBonesData parseDragonBonesData(Object rawData, float scale) { + Console._assert(rawData != null && rawData instanceof ArrayBuffer); + ArrayBuffer buffer = (ArrayBuffer) rawData; + + Uint8Array tag = new Uint8Array(buffer, 0, 8); + if (tag.get(0) != 'D' || tag.get(1) != 'B' || tag.get(2) != 'D' || tag.get(3) != 'T') { + Console._assert(false, "Nonsupport data."); + return null; + } + + int headerLength = new Uint32Array(buffer, 8, 1).get(0); + + //String headerString = this._decodeUTF8(new Uint8Array(buffer, 8 + 4, headerLength)); + String headerString = new String(buffer.getBytes(8 + 4, headerLength), StandardCharsets.UTF_8); + + Object header = JSON.parse(headerString); + + this._binary = buffer; + this._binaryOffset = 8 + 4 + headerLength; + + return super.parseDragonBonesData(header, scale); + } + + /** + * @private + */ + private static BinaryDataParser _binaryDataParserInstance = null; + + /** + * @see BaseFactory#parseDragonBonesData(Object, String, float) + * @deprecated 已废弃,请参考 @see + */ + public static BinaryDataParser getInstance() { + if (BinaryDataParser._binaryDataParserInstance == null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + + return BinaryDataParser._binaryDataParserInstance; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/parser/DataParser.java b/dragonbones-core/src/main/java/com/dragonbones/parser/DataParser.java new file mode 100644 index 0000000..e813e1d --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/parser/DataParser.java @@ -0,0 +1,349 @@ +package com.dragonbones.parser; + +import com.dragonbones.core.*; +import com.dragonbones.factory.BaseFactory; +import com.dragonbones.geom.Rectangle; +import com.dragonbones.model.DragonBonesData; +import com.dragonbones.model.TextureAtlasData; +import com.dragonbones.util.ArrayBase; +import com.dragonbones.util.Console; +import com.dragonbones.util.buffer.ArrayBuffer; +import com.dragonbones.util.json.JSON; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Map; + +import static com.dragonbones.util.Dynamic.*; + +/** + * @private + */ +public abstract class DataParser { + protected static final String DATA_VERSION_2_3 = "2.3"; + protected static final String DATA_VERSION_3_0 = "3.0"; + protected static final String DATA_VERSION_4_0 = "4.0"; + protected static final String DATA_VERSION_4_5 = "4.5"; + protected static final String DATA_VERSION_5_0 = "5.0"; + protected static final String DATA_VERSION = DataParser.DATA_VERSION_5_0; + + protected static final String[] DATA_VERSIONS = new String[]{ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + }; + + protected static final String TEXTURE_ATLAS = "textureAtlas"; + protected static final String SUB_TEXTURE = "SubTexture"; + protected static final String FORMAT = "format"; + protected static final String IMAGE_PATH = "imagePath"; + protected static final String WIDTH = "width"; + protected static final String HEIGHT = "height"; + protected static final String ROTATED = "rotated"; + protected static final String FRAME_X = "frameX"; + protected static final String FRAME_Y = "frameY"; + protected static final String FRAME_WIDTH = "frameWidth"; + protected static final String FRAME_HEIGHT = "frameHeight"; + + protected static final String DRADON_BONES = "dragonBones"; + protected static final String USER_DATA = "userData"; + protected static final String ARMATURE = "armature"; + protected static final String BONE = "bone"; + protected static final String IK = "ik"; + protected static final String SLOT = "slot"; + protected static final String SKIN = "skin"; + protected static final String DISPLAY = "display"; + protected static final String ANIMATION = "animation"; + protected static final String Z_ORDER = "zOrder"; + protected static final String FFD = "ffd"; + protected static final String FRAME = "frame"; + protected static final String TRANSLATE_FRAME = "translateFrame"; + protected static final String ROTATE_FRAME = "rotateFrame"; + protected static final String SCALE_FRAME = "scaleFrame"; + protected static final String VISIBLE_FRAME = "visibleFrame"; + protected static final String DISPLAY_FRAME = "displayFrame"; + protected static final String COLOR_FRAME = "colorFrame"; + protected static final String DEFAULT_ACTIONS = "defaultActions"; + protected static final String ACTIONS = "actions"; + protected static final String EVENTS = "events"; + protected static final String INTS = "ints"; + protected static final String FLOATS = "floats"; + protected static final String STRINGS = "strings"; + protected static final String CANVAS = "canvas"; + + protected static final String TRANSFORM = "transform"; + protected static final String PIVOT = "pivot"; + protected static final String AABB = "aabb"; + protected static final String COLOR = "color"; + + protected static final String VERSION = "version"; + protected static final String COMPATIBLE_VERSION = "compatibleVersion"; + protected static final String FRAME_RATE = "frameRate"; + protected static final String TYPE = "type"; + protected static final String SUB_TYPE = "subType"; + protected static final String NAME = "name"; + protected static final String PARENT = "parent"; + protected static final String TARGET = "target"; + protected static final String SHARE = "share"; + protected static final String PATH = "path"; + protected static final String LENGTH = "length"; + protected static final String DISPLAY_INDEX = "displayIndex"; + protected static final String BLEND_MODE = "blendMode"; + protected static final String INHERIT_TRANSLATION = "inheritTranslation"; + protected static final String INHERIT_ROTATION = "inheritRotation"; + protected static final String INHERIT_SCALE = "inheritScale"; + protected static final String INHERIT_REFLECTION = "inheritReflection"; + protected static final String INHERIT_ANIMATION = "inheritAnimation"; + protected static final String INHERIT_FFD = "inheritFFD"; + protected static final String BEND_POSITIVE = "bendPositive"; + protected static final String CHAIN = "chain"; + protected static final String WEIGHT = "weight"; + + protected static final String FADE_IN_TIME = "fadeInTime"; + protected static final String PLAY_TIMES = "playTimes"; + protected static final String SCALE = "scale"; + protected static final String OFFSET = "offset"; + protected static final String POSITION = "position"; + protected static final String DURATION = "duration"; + protected static final String TWEEN_TYPE = "tweenType"; + protected static final String TWEEN_EASING = "tweenEasing"; + protected static final String TWEEN_ROTATE = "tweenRotate"; + protected static final String TWEEN_SCALE = "tweenScale"; + protected static final String CURVE = "curve"; + protected static final String SOUND = "sound"; + protected static final String EVENT = "event"; + protected static final String ACTION = "action"; + + protected static final String X = "x"; + protected static final String Y = "y"; + protected static final String SKEW_X = "skX"; + protected static final String SKEW_Y = "skY"; + protected static final String SCALE_X = "scX"; + protected static final String SCALE_Y = "scY"; + protected static final String VALUE = "value"; + protected static final String ROTATE = "rotate"; + protected static final String SKEW = "skew"; + + protected static final String ALPHA_OFFSET = "aO"; + protected static final String RED_OFFSET = "rO"; + protected static final String GREEN_OFFSET = "gO"; + protected static final String BLUE_OFFSET = "bO"; + protected static final String ALPHA_MULTIPLIER = "aM"; + protected static final String RED_MULTIPLIER = "rM"; + protected static final String GREEN_MULTIPLIER = "gM"; + protected static final String BLUE_MULTIPLIER = "bM"; + + protected static final String UVS = "uvs"; + protected static final String VERTICES = "vertices"; + protected static final String TRIANGLES = "triangles"; + protected static final String WEIGHTS = "weights"; + protected static final String SLOT_POSE = "slotPose"; + protected static final String BONE_POSE = "bonePose"; + + protected static final String GOTO_AND_PLAY = "gotoAndPlay"; + + protected static final String DEFAULT_NAME = "default"; + + protected static ArmatureType _getArmatureType(String value) { + switch (value.toLowerCase()) { + case "stage": + return ArmatureType.Stage; + + case "armature": + return ArmatureType.Armature; + + case "movieclip": + return ArmatureType.MovieClip; + + default: + return ArmatureType.Armature; + } + } + + protected static DisplayType _getDisplayType(String value) { + switch (value.toLowerCase()) { + case "image": + return DisplayType.Image; + + case "mesh": + return DisplayType.Mesh; + + case "armature": + return DisplayType.Armature; + + case "boundingbox": + return DisplayType.BoundingBox; + + default: + return DisplayType.Image; + } + } + + protected static BoundingBoxType _getBoundingBoxType(String value) { + switch (value.toLowerCase()) { + case "rectangle": + return BoundingBoxType.Rectangle; + + case "ellipse": + return BoundingBoxType.Ellipse; + + case "polygon": + return BoundingBoxType.Polygon; + + default: + return BoundingBoxType.Rectangle; + } + } + + protected static ActionType _getActionType(String value) { + switch (value.toLowerCase()) { + case "play": + return ActionType.Play; + + case "frame": + return ActionType.Frame; + + case "sound": + return ActionType.Sound; + + default: + return ActionType.Play; + } + } + + protected static BlendMode _getBlendMode(String value) { + switch (value.toLowerCase()) { + case "normal": + return BlendMode.Normal; + + case "add": + return BlendMode.Add; + + case "alpha": + return BlendMode.Alpha; + + case "darken": + return BlendMode.Darken; + + case "difference": + return BlendMode.Difference; + + case "erase": + return BlendMode.Erase; + + case "hardlight": + return BlendMode.HardLight; + + case "invert": + return BlendMode.Invert; + + case "layer": + return BlendMode.Layer; + + case "lighten": + return BlendMode.Lighten; + + case "multiply": + return BlendMode.Multiply; + + case "overlay": + return BlendMode.Overlay; + + case "screen": + return BlendMode.Screen; + + case "subtract": + return BlendMode.Subtract; + + default: + return BlendMode.Normal; + } + } + + /** + * @private + */ + public abstract @Nullable + DragonBonesData parseDragonBonesData(Object rawData, float scale); + + /** + * @private + */ + public abstract boolean parseTextureAtlasData(Object rawData, TextureAtlasData textureAtlasData, float scale); + + /** + * @see BaseFactory#parseDragonBonesData(Object, String, float) + * @deprecated 已废弃,请参考 @see + */ + @Nullable + public static DragonBonesData parseDragonBonesData(Object rawData) { + if (rawData instanceof ArrayBuffer) { + return parseDragonBonesDataBinary((ArrayBuffer)rawData); + } else { + return parseDragonBonesDataObject(rawData); + } + } + + @Nullable + public static DragonBonesData parseDragonBonesDataBinary(ArrayBuffer arrayBuffer) { + return BinaryDataParser.getInstance().parseDragonBonesData(arrayBuffer, 0f); + } + + @Nullable + public static DragonBonesData parseDragonBonesDataObject(Object obj) { + return ObjectDataParser.getInstance().parseDragonBonesData(obj, 0f); + } + + @Nullable + public static DragonBonesData parseDragonBonesDataJson(String json) { + return ObjectDataParser.getInstance().parseDragonBonesData(JSON.parse(json), 0f); + } + + public static Map parseTextureAtlasData(Object rawData) { + return parseTextureAtlasData(rawData, 1f); + } + + /** + * @see BaseFactory#parseTextureAtlasData(Object, Object, String, float) + * @deprecated 已废弃,请参考 @see + */ + public static Map parseTextureAtlasData(Object rawData, float scale) { + Console.warn("已废弃,请参考 @see"); + Map textureAtlasData = new HashMap(); + + ArrayBase subTextureList = getArray(rawData, DataParser.SUB_TEXTURE); + for (int i = 0, len = subTextureList.length(); i < len; i++) { + Object subTextureObject = subTextureList.getObject(i); + String subTextureName = getString(subTextureObject, DataParser.NAME); + Rectangle subTextureRegion = new Rectangle(); + Rectangle subTextureFrame = null; + + subTextureRegion.x = getFloat(subTextureObject, DataParser.X) / scale; + subTextureRegion.y = getFloat(subTextureObject, DataParser.Y) / scale; + subTextureRegion.width = getFloat(subTextureObject, DataParser.WIDTH) / scale; + subTextureRegion.height = getFloat(subTextureObject, DataParser.HEIGHT) / scale; + + if (in(subTextureObject, DataParser.FRAME_WIDTH)) { + subTextureFrame = new Rectangle(); + subTextureFrame.x = getFloat(subTextureObject, DataParser.FRAME_X) / scale; + subTextureFrame.y = getFloat(subTextureObject, DataParser.FRAME_Y) / scale; + subTextureFrame.width = getFloat(subTextureObject, DataParser.FRAME_WIDTH) / scale; + subTextureFrame.height = getFloat(subTextureObject, DataParser.FRAME_HEIGHT) / scale; + } + + Rectangle finalSubTextureFrame = subTextureFrame; + textureAtlasData.put(subTextureName, + new HashMap() { + { + put("region", subTextureRegion); + put("frame", finalSubTextureFrame); + put("rotated", false); + } + } + ); + } + + return textureAtlasData; + } +} + diff --git a/dragonbones-core/src/main/java/com/dragonbones/parser/ObjectDataParser.java b/dragonbones-core/src/main/java/com/dragonbones/parser/ObjectDataParser.java new file mode 100644 index 0000000..1f35306 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/parser/ObjectDataParser.java @@ -0,0 +1,1653 @@ +package com.dragonbones.parser; + +import com.dragonbones.core.*; +import com.dragonbones.factory.BaseFactory; +import com.dragonbones.geom.ColorTransform; +import com.dragonbones.geom.Matrix; +import com.dragonbones.geom.Point; +import com.dragonbones.geom.Transform; +import com.dragonbones.model.*; +import com.dragonbones.util.*; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; + +import static com.dragonbones.util.Dynamic.*; + +/** + * @private + */ +public class ObjectDataParser extends DataParser { + + /** + * @private + */ + + private IntArray _intArrayJson = new IntArray(); + private FloatArray _floatArrayJson = new FloatArray(); + private IntArray _frameIntArrayJson = new IntArray(); + private FloatArray _frameFloatArrayJson = new FloatArray(); + private FloatArray _frameArrayJson = new FloatArray(); + private FloatArray _timelineArrayJson = new FloatArray(); + + private ShortArray _intArrayBuffer; + private FloatArray _floatArrayBuffer; + private ShortArray _frameIntArrayBuffer; + private FloatArray _frameFloatArrayBuffer; + private ShortArray _frameArrayBuffer; + private CharArray _timelineArrayBuffer; + + public ObjectDataParser() { + } + + protected int _rawTextureAtlasIndex = 0; + protected final Array _rawBones = new Array<>(); + protected DragonBonesData _data = null; // + protected ArmatureData _armature = null; // + protected BoneData _bone = null; // + protected SlotData _slot = null; // + protected SkinData _skin = null; // + protected MeshDisplayData _mesh = null; // + protected AnimationData _animation = null; // + protected TimelineData _timeline = null; // + protected Array _rawTextureAtlases = null; + + private int _defalultColorOffset = -1; + private float _prevTweenRotate = 0; + private float _prevRotation = 0f; + private final Matrix _helpMatrixA = new Matrix(); + + private final Matrix _helpMatrixB = new Matrix(); + + private final Transform _helpTransform = new Transform(); + + private final ColorTransform _helpColorTransform = new ColorTransform(); + + private final Point _helpPoint = new Point(); + + private final FloatArray _helpArray = new FloatArray(); + private final Array _actionFrames = new Array<>(); + private final Map _weightSlotPose = new HashMap<>(); + + private Map _weightBonePoses = new HashMap<>(); + private final Map _weightBoneIndices = new HashMap<>(); + + private final Map> _cacheBones = new HashMap<>(); + private final Map _meshs = new HashMap<>(); + private final Map> _slotChildActions = new HashMap<>(); + + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + + /** + * @private + */ + private void _getCurvePoint(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float t, Point result) + + { + float l_t = 1f - t; + float powA = l_t * l_t; + float powB = t * t; + float kA = l_t * powA; + float kB = (float) (3.0 * t * powA); + float kC = (float) (3.0 * l_t * powB); + float kD = t * powB; + + result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; + result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; + } + + /** + * @private + */ + private void _samplingEasingCurve(FloatArray curve, FloatArray samples) + + { + int curveCount = curve.length(); + int stepIndex = -2; + for (int i = 0, l = samples.length(); i < l; ++i) { + int t = (i + 1) / (l + 1); + while ((stepIndex + 6 < curveCount ? curve.get(stepIndex + 6) : 1) < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + + boolean isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; + float x1 = isInCurve ? curve.get(stepIndex) : 0f; + float y1 = isInCurve ? curve.get(stepIndex + 1) : 0f; + float x2 = curve.get(stepIndex + 2); + float y2 = curve.get(stepIndex + 3); + float x3 = curve.get(stepIndex + 4); + float y3 = curve.get(stepIndex + 5); + float x4 = isInCurve ? curve.get(stepIndex + 6) : 1f; + float y4 = isInCurve ? curve.get(stepIndex + 7) : 1f; + + float lower = 0f; + float higher = 1f; + while (higher - lower > 0.0001) { + float percentage = (higher + lower) * 0.5f; + this._getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, percentage, this._helpPoint); + if (t - this._helpPoint.x > 0f) { + lower = percentage; + } else { + higher = percentage; + } + } + + samples.set(i, this._helpPoint.y); + } + } + + private int _sortActionFrame(ActionFrame a, ActionFrame b) + + { + return a.frameStart > b.frameStart ? 1 : -1; + } + + private void _parseActionDataInFrame(Object rawData, int frameStart, @Nullable BoneData bone, @Nullable SlotData slot) + + { + if (in(rawData, ObjectDataParser.EVENT)) { + this._mergeActionFrame(get(rawData, ObjectDataParser.EVENT), frameStart, ActionType.Frame, bone, slot); + } + + if (in(rawData, ObjectDataParser.SOUND)) { + this._mergeActionFrame(get(rawData, ObjectDataParser.SOUND), frameStart, ActionType.Sound, bone, slot); + } + + if (in(rawData, ObjectDataParser.ACTION)) { + this._mergeActionFrame(get(rawData, ObjectDataParser.ACTION), frameStart, ActionType.Play, bone, slot); + } + + if (in(rawData, ObjectDataParser.EVENTS)) { + this._mergeActionFrame(get(rawData, ObjectDataParser.EVENTS), frameStart, ActionType.Frame, bone, slot); + } + + if (in(rawData, ObjectDataParser.ACTIONS)) { + this._mergeActionFrame(get(rawData, ObjectDataParser.ACTIONS), frameStart, ActionType.Play, bone, slot); + } + } + + private void _mergeActionFrame(Object rawData, int frameStart, ActionType type, @Nullable BoneData bone, @Nullable SlotData slot) + + { + int actionOffset = this._armature.actions.size(); + int actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + ActionFrame frame = null; + + if (this._actionFrames.size() == 0) { // First frame. + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.add(frame); + frame = null; + } + + for (ActionFrame eachFrame : this._actionFrames) { // Get same frame. + if (eachFrame.frameStart == frameStart) { + frame = eachFrame; + break; + } + } + + if (frame == null) { // Create and cache frame. + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.add(frame); + } + + for (int i = 0; i < actionCount; ++i) { // Cache action offsets. + frame.actions.push(actionOffset + i); + } + } + + private int _parseCacheActionFrame(ActionFrame frame) + + { + ShortArray frameArray = (this._data.frameArray); + int frameOffset = frameArray.length(); + int actionCount = frame.actions.size(); + frameArray.incrementLength(1 + 1 + actionCount); + frameArray.set(frameOffset + BinaryOffset.FramePosition.v, frame.frameStart); + frameArray.set(frameOffset + BinaryOffset.FramePosition.v + 1, actionCount); // Action count. + + for (int i = 0; i < actionCount; ++i) { // Action offsets. + frameArray.set(frameOffset + BinaryOffset.FramePosition.v + 2 + i, frame.actions.get(i)); + } + + return frameOffset; + } + + /** + * @private + */ + protected ArmatureData _parseArmature(Object rawData, float scale) + + { + ArmatureData armature = BaseObject.borrowObject(ArmatureData.class); + armature.name = getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = getFloat(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + + if (in(rawData, ObjectDataParser.TYPE) && get(rawData, ObjectDataParser.TYPE) instanceof String) { + armature.type = ObjectDataParser._getArmatureType(Objects.toString(get(rawData, ObjectDataParser.TYPE))); + } else { + armature.type = ArmatureType.values[getInt(rawData, ObjectDataParser.TYPE, ArmatureType.Armature.v)]; + } + + if (armature.frameRate == 0) { // Data error. + armature.frameRate = 24; + } + + this._armature = armature; + + if (in(rawData, ObjectDataParser.AABB)) { + Object rawAABB = get(rawData, ObjectDataParser.AABB); + armature.aabb.x = getFloat(rawAABB, ObjectDataParser.X, 0f); + armature.aabb.y = getFloat(rawAABB, ObjectDataParser.Y, 0f); + armature.aabb.width = getFloat(rawAABB, ObjectDataParser.WIDTH, 0f); + armature.aabb.height = getFloat(rawAABB, ObjectDataParser.HEIGHT, 0f); + } + + if (in(rawData, ObjectDataParser.CANVAS)) { + Object rawCanvas = get(rawData, ObjectDataParser.CANVAS); + CanvasData canvas = BaseObject.borrowObject(CanvasData.class); + + if (in(rawCanvas, ObjectDataParser.COLOR)) { + getFloat(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } else { + canvas.hasBackground = false; + } + + canvas.color = getInt(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = getFloat(rawCanvas, ObjectDataParser.X, 0); + canvas.y = getFloat(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = getFloat(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = getFloat(rawCanvas, ObjectDataParser.HEIGHT, 0); + + armature.canvas = canvas; + } + + if (in(rawData, ObjectDataParser.BONE)) { + Array rawBones = getArray(rawData, ObjectDataParser.BONE); + for (Object rawBone : rawBones) { + String parentName = getString(rawBone, ObjectDataParser.PARENT, ""); + BoneData bone = this._parseBone(rawBone); + + if (parentName.length() > 0) { // Get bone parent. + BoneData parent = armature.getBone(parentName); + if (parent != null) { + bone.parent = parent; + } else { // Cache. + if (!this._cacheBones.containsKey(parentName)) { + this._cacheBones.put(parentName, new Array<>()); + } + this._cacheBones.get(parentName).push(bone); + } + } + + if (in(this._cacheBones, bone.name)) { + for (BoneData child : this._cacheBones.get(bone.name)) { + child.parent = bone; + } + + this._cacheBones.remove(bone.name); + } + + armature.addBone(bone); + + this._rawBones.add(bone); // Raw bone sort. + } + } + + if (in(rawData, ObjectDataParser.IK)) { + Array rawIKS = getArray(rawData, ObjectDataParser.IK); + for (Object rawIK : rawIKS) { + this._parseIKConstraint(rawIK); + } + } + + armature.sortBones(); + + if (in(rawData, ObjectDataParser.SLOT)) { + Array rawSlots = getArray(rawData, ObjectDataParser.SLOT); + for (Object rawSlot : rawSlots) { + armature.addSlot(this._parseSlot(rawSlot)); + } + } + + if (in(rawData, ObjectDataParser.SKIN)) { + Array rawSkins = getArray(rawData, ObjectDataParser.SKIN); + for (Object rawSkin : rawSkins) { + armature.addSkin(this._parseSkin(rawSkin)); + } + } + + if (in(rawData, ObjectDataParser.ANIMATION)) { + Array rawAnimations = getArray(rawData, ObjectDataParser.ANIMATION); + for (Object rawAnimation : rawAnimations) { + AnimationData animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + + if (in(rawData, ObjectDataParser.DEFAULT_ACTIONS)) { + this._parseActionData(get(rawData, ObjectDataParser.DEFAULT_ACTIONS), armature.defaultActions, ActionType.Play, null, null); + } + + if (in(rawData, ObjectDataParser.ACTIONS)) { + this._parseActionData(get(rawData, ObjectDataParser.ACTIONS), armature.actions, ActionType.Play, null, null); + } + + for (int i = 0; i < armature.defaultActions.size(); ++i) { + ActionData action = armature.defaultActions.get(i); + if (action.type == ActionType.Play) { + AnimationData animation = armature.getAnimation(action.name); + if (animation != null) { + armature.defaultAnimation = animation; + } + break; + } + } + + // Clear helper. + this._rawBones.clear(); + this._armature = null; + this._meshs.clear(); + this._cacheBones.clear(); + this._slotChildActions.clear(); + this._weightSlotPose.clear(); + this._weightBonePoses.clear(); + this._weightBoneIndices.clear(); + return armature; + } + + /** + * @private + */ + protected BoneData _parseBone(Object rawData) { + BoneData bone = BaseObject.borrowObject(BoneData.class); + bone.inheritTranslation = getBool(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = getBool(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = getBool(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = getBool(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = getFloat(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = getString(rawData, ObjectDataParser.NAME, ""); + + if (in(rawData, ObjectDataParser.TRANSFORM)) { + this._parseTransform(get(rawData, ObjectDataParser.TRANSFORM), bone.transform, this._armature.scale); + } + + return bone; + } + + /** + * @private + */ + protected void _parseIKConstraint(Object rawData) { + BoneData bone = this._armature.getBone(getString(rawData, (in(rawData, ObjectDataParser.BONE)) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone == null) { + return; + } + + BoneData target = this._armature.getBone(getString(rawData, ObjectDataParser.TARGET, "")); + if (target == null) { + return; + } + + IKConstraintData constraint = BaseObject.borrowObject(IKConstraintData.class); + constraint.bendPositive = getBool(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = getBool(rawData, ObjectDataParser.SCALE, false); + constraint.weight = getFloat(rawData, ObjectDataParser.WEIGHT, 1f); + constraint.bone = bone; + constraint.target = target; + + float chain = getFloat(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + bone.constraints.add(constraint); + } + + /** + * @private + */ + protected SlotData _parseSlot(Object rawData) + + { + SlotData slot = BaseObject.borrowObject(SlotData.class); + slot.displayIndex = getInt(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = this._armature.sortedSlots.size(); + slot.name = getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(getString(rawData, ObjectDataParser.PARENT, "")); // + + if (in(rawData, ObjectDataParser.BLEND_MODE) && get(rawData, ObjectDataParser.BLEND_MODE) instanceof String) { + slot.blendMode = ObjectDataParser._getBlendMode(Objects.toString(get(rawData, ObjectDataParser.BLEND_MODE))); + } else { + slot.blendMode = BlendMode.values[getInt(rawData, ObjectDataParser.BLEND_MODE, BlendMode.Normal.v)]; + } + + if (in(rawData, ObjectDataParser.COLOR)) { + // slot.color = SlotData.createColor(); + slot.color = SlotData.createColor(); + this._parseColorTransform(get(rawData, ObjectDataParser.COLOR), slot.color); + } else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = SlotData.DEFAULT_COLOR; + } + + if (in(rawData, ObjectDataParser.ACTIONS)) { + Array actions = new Array<>(); + this._slotChildActions.put(slot.name, actions); + this._parseActionData(get(rawData, ObjectDataParser.ACTIONS), actions, ActionType.Play, null, null); + } + + return slot; + } + + /** + * @private + */ + protected SkinData _parseSkin(Object rawData) + + { + SkinData skin = BaseObject.borrowObject(SkinData.class); + skin.name = getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length() == 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + + if (in(rawData, ObjectDataParser.SLOT)) { + this._skin = skin; + + Array rawSlots = getArray(rawData, ObjectDataParser.SLOT); + for (Object rawSlot : rawSlots) { + String slotName = getString(rawSlot, ObjectDataParser.NAME, ""); + SlotData slot = this._armature.getSlot(slotName); + if (slot != null) { + this._slot = slot; + + if (in(rawSlot, ObjectDataParser.DISPLAY)) { + Array rawDisplays = getArray(rawSlot, ObjectDataParser.DISPLAY); + for (Object rawDisplay : rawDisplays) { + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + + this._slot = null; // + } + } + + this._skin = null; // + } + + return skin; + } + + /** + * @private + */ + @Nullable + protected DisplayData _parseDisplay(Object rawData) { + DisplayData display = null; + String name = getString(rawData, ObjectDataParser.NAME, ""); + String path = getString(rawData, ObjectDataParser.PATH, ""); + DisplayType type = DisplayType.Image; + if (in(rawData, ObjectDataParser.TYPE) && get(rawData, ObjectDataParser.TYPE) instanceof String) { + type = ObjectDataParser._getDisplayType(getString(rawData, ObjectDataParser.TYPE, "")); + } else { + type = DisplayType.values[getInt(rawData, ObjectDataParser.TYPE, type.v)]; + } + + switch (type) { + case Image: + ImageDisplayData imageDisplay = BaseObject.borrowObject(ImageDisplayData.class); + display = imageDisplay; + imageDisplay.name = name; + imageDisplay.path = path.length() > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + + case Armature: + ArmatureDisplayData armatureDisplay = BaseObject.borrowObject(ArmatureDisplayData.class); + display = armatureDisplay; + armatureDisplay.name = name; + armatureDisplay.path = path.length() > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + + if (in(rawData, ObjectDataParser.ACTIONS)) { + this._parseActionData(get(rawData, ObjectDataParser.ACTIONS), armatureDisplay.actions, ActionType.Play, null, null); + } else if (in(this._slotChildActions, this._slot.name)) { + Array displays = this._skin.getDisplays(this._slot.name); + if (displays == null ? this._slot.displayIndex == 0 : this._slot.displayIndex == displays.getLength()) { + for (ActionData action : this._slotChildActions.get(this._slot.name)) { + armatureDisplay.actions.push(action); + } + + this._slotChildActions.remove(this._slot.name); + } + } + break; + + case Mesh: + MeshDisplayData meshDisplay = BaseObject.borrowObject(MeshDisplayData.class); + display = meshDisplay; + meshDisplay.name = name; + meshDisplay.path = path.length() > 0 ? path : name; + meshDisplay.inheritAnimation = getBool(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + + String shareName = getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length() > 0) { + MeshDisplayData shareMesh = this._meshs.get(shareName); + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } else { + this._parseMesh(rawData, meshDisplay); + this._meshs.put(meshDisplay.name, meshDisplay); + } + break; + + case BoundingBox: + BoundingBoxData boundingBox = this._parseBoundingBox(rawData); + if (boundingBox != null) { + BoundingBoxDisplayData boundingBoxDisplay = BaseObject.borrowObject(BoundingBoxDisplayData.class); + display = boundingBoxDisplay; + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length() > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + + if (display != null) { + display.parent = this._armature; + if (in(rawData, ObjectDataParser.TRANSFORM)) { + this._parseTransform(get(rawData, ObjectDataParser.TRANSFORM), display.transform, this._armature.scale); + } + } + + return display; + } + + /** + * @private + */ + protected void _parsePivot(Object rawData, ImageDisplayData display) { + if (in(rawData, ObjectDataParser.PIVOT)) { + Object rawPivot = get(rawData, ObjectDataParser.PIVOT); + display.pivot.x = getFloat(rawPivot, ObjectDataParser.X, 0f); + display.pivot.y = getFloat(rawPivot, ObjectDataParser.Y, 0f); + } else { + display.pivot.x = 0.5f; + display.pivot.y = 0.5f; + } + } + + /** + * @private + */ + protected void _parseMesh(Object rawData, MeshDisplayData mesh) { + FloatArray rawVertices = getFloatArray(rawData, ObjectDataParser.VERTICES); + FloatArray rawUVs = getFloatArray(rawData, ObjectDataParser.UVS); + IntArray rawTriangles = getIntArray(rawData, ObjectDataParser.TRIANGLES); + ShortArray intArray = this._data.intArray; + FloatArray floatArray = this._data.floatArray; + int vertexCount = (int) Math.floor(rawVertices.size() / 2); // uint + int triangleCount = (int) Math.floor(rawTriangles.size() / 3); // uint + int vertexOffset = floatArray.length(); + int uvOffset = vertexOffset + vertexCount * 2; + + mesh.offset = intArray.length(); + intArray.incrementLength(1 + 1 + 1 + 1 + triangleCount * 3); + intArray.set(mesh.offset + BinaryOffset.MeshVertexCount.v, vertexCount); + intArray.set(mesh.offset + BinaryOffset.MeshTriangleCount.v, triangleCount); + intArray.set(mesh.offset + BinaryOffset.MeshFloatOffset.v, vertexOffset); + for (int i = 0, l = triangleCount * 3; i < l; ++i) { + intArray.set(mesh.offset + BinaryOffset.MeshVertexIndices.v + i, rawTriangles.get(i)); + } + + floatArray.incrementLength(vertexCount * 2 + vertexCount * 2); + for (int i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray.set(vertexOffset + i, rawVertices.get(i)); + floatArray.set(uvOffset + i, rawUVs.get(i)); + } + + if (in(rawData, ObjectDataParser.WEIGHTS)) { + + IntArray rawWeights = getIntArray(rawData, ObjectDataParser.WEIGHTS); + FloatArray rawSlotPose = getFloatArray(rawData, ObjectDataParser.SLOT_POSE); + // @TODO: Java: Used as int and as float? + FloatArray rawBonePoses = getFloatArray(rawData, ObjectDataParser.BONE_POSE); + IntArray weightBoneIndices = new IntArray(); + int weightBoneCount = (int) Math.floor(rawBonePoses.size() / 7); // uint + int floatOffset = floatArray.length(); + WeightData weight = BaseObject.borrowObject(WeightData.class); + + weight.count = (rawWeights.size() - vertexCount) / 2; + weight.offset = intArray.length(); + weight.bones.setLength(weightBoneCount); + weightBoneIndices.setLength(weightBoneCount); + intArray.incrementLength(1 + 1 + weightBoneCount + vertexCount + weight.count); + intArray.set(weight.offset + BinaryOffset.WeigthFloatOffset.v, floatOffset); + + for (int i = 0; i < weightBoneCount; ++i) { + int rawBoneIndex = (int) rawBonePoses.get(i * 7); // uint + BoneData bone = this._rawBones.get(rawBoneIndex); + weight.bones.set(i, bone); + weightBoneIndices.set(i, rawBoneIndex); + + intArray.set(weight.offset + BinaryOffset.WeigthBoneIndices.v + i, this._armature.sortedBones.indexOf(bone)); + } + + floatArray.incrementLength(weight.count * 3); + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + + for (int i = 0, iW = 0, iB = weight.offset + BinaryOffset.WeigthBoneIndices.v + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + int iD = i * 2; + int vertexBoneCount = rawWeights.get(iW++); // uint + intArray.set(iB++, vertexBoneCount); + + float x = floatArray.get(vertexOffset + iD); + float y = floatArray.get(vertexOffset + iD + 1); + this._helpMatrixA.transformPoint(x, y, this._helpPoint); + x = this._helpPoint.x; + y = this._helpPoint.y; + + for (int j = 0; j < vertexBoneCount; ++j) { + int rawBoneIndex = rawWeights.get(iW++); // uint + BoneData bone = this._rawBones.get(rawBoneIndex); + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray.set(iB++, weight.bones.indexOf(bone)); + floatArray.set(iV++, rawWeights.get(iW++)); + floatArray.set(iV++, this._helpPoint.x); + floatArray.set(iV++, this._helpPoint.y); + } + } + + mesh.weight = weight; + + // + this._weightSlotPose.put(mesh.name, rawSlotPose); + this._weightBonePoses.put(mesh.name, rawBonePoses); + this._weightBoneIndices.put(mesh.name, weightBoneIndices); + } + } + + /** + * @private + */ + @Nullable + protected BoundingBoxData _parseBoundingBox(Object rawData) { + BoundingBoxData boundingBox = null; + BoundingBoxType type = BoundingBoxType.Rectangle; + if (in(rawData, ObjectDataParser.SUB_TYPE) && get(rawData, ObjectDataParser.SUB_TYPE) instanceof String) { + type = ObjectDataParser._getBoundingBoxType(getString(rawData, ObjectDataParser.SUB_TYPE)); + } else { + type = BoundingBoxType.values[getInt(rawData, ObjectDataParser.SUB_TYPE, type.v)]; + } + + switch (type) { + case Rectangle: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData.class); + break; + + case Ellipse: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData.class); + break; + + case Polygon: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + + if (boundingBox != null) { + boundingBox.color = getInt(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type == BoundingBoxType.Rectangle || boundingBox.type == BoundingBoxType.Ellipse) { + boundingBox.width = getFloat(rawData, ObjectDataParser.WIDTH, 0f); + boundingBox.height = getFloat(rawData, ObjectDataParser.HEIGHT, 0f); + } + } + + return boundingBox; + } + + /** + * @private + */ + protected PolygonBoundingBoxData _parsePolygonBoundingBox(Object rawData) + + { + FloatArray rawVertices = getFloatArray(rawData, ObjectDataParser.VERTICES); + FloatArray floatArray = this._data.floatArray; + PolygonBoundingBoxData polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData.class); + + polygonBoundingBox.offset = floatArray.length(); + polygonBoundingBox.count = rawVertices.size(); + polygonBoundingBox.vertices = floatArray; + floatArray.incrementLength(polygonBoundingBox.count); + + for (int i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + int iN = i + 1; + float x = rawVertices.get(i); + float y = rawVertices.get(iN); + floatArray.set(polygonBoundingBox.offset + i, x); + floatArray.set(polygonBoundingBox.offset + iN, 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; + } + } + } + + return polygonBoundingBox; + } + + /** + * @private + */ + protected AnimationData _parseAnimation(Object rawData) + + { + // const animation = BaseObject.borrowObject(AnimationData); + AnimationData animation = BaseObject.borrowObject(AnimationData.class); + animation.frameCount = Math.max(getInt(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = getInt(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = getFloat(rawData, ObjectDataParser.FADE_IN_TIME, 0f); + animation.scale = getFloat(rawData, ObjectDataParser.SCALE, 1f); + animation.name = getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length() < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + animation.frameIntOffset = this._data.frameIntArray.length(); + animation.frameFloatOffset = this._data.frameFloatArray.length(); + animation.frameOffset = this._data.frameArray.length(); + + this._animation = animation; + + if (in(rawData, ObjectDataParser.FRAME)) { + Array rawFrames = getArray(rawData, ObjectDataParser.FRAME); + int keyFrameCount = rawFrames.size(); + if (keyFrameCount > 0) { + for (int i = 0, frameStart = 0; i < keyFrameCount; ++i) { + Object rawFrame = rawFrames.get(i); + this._parseActionDataInFrame(rawFrame, frameStart, null, null); + frameStart += getFloat(rawFrame, ObjectDataParser.DURATION, 1); + } + } + } + + if (in(rawData, ObjectDataParser.Z_ORDER)) { + this._animation.zOrderTimeline = this._parseTimeline( + get(rawData, ObjectDataParser.Z_ORDER), TimelineType.ZOrder, + false, false, 0, + this::_parseZOrderFrame + ); + } + + if (in(rawData, ObjectDataParser.BONE)) { + Array rawTimelines = getArray(rawData, ObjectDataParser.BONE); + for (Object rawTimeline : rawTimelines) { + this._parseBoneTimeline(rawTimeline); + } + } + + if (in(rawData, ObjectDataParser.SLOT)) { + Array rawTimelines = getArray(rawData, ObjectDataParser.SLOT); + for (Object rawTimeline : rawTimelines) { + this._parseSlotTimeline(rawTimeline); + } + } + + if (in(rawData, ObjectDataParser.FFD)) { + Array rawTimelines = getArray(rawData, ObjectDataParser.FFD); + for (Object rawTimeline : rawTimelines) { + String slotName = getString(rawTimeline, ObjectDataParser.SLOT, ""); + String displayName = getString(rawTimeline, ObjectDataParser.NAME, ""); + SlotData slot = this._armature.getSlot(slotName); + if (slot == null) { + continue; + } + + this._slot = slot; + this._mesh = this._meshs.get(displayName); + + TimelineData timelineFFD = this._parseTimeline(rawTimeline, TimelineType.SlotFFD, false, true, 0, this::_parseSlotFFDFrame); + if (timelineFFD != null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + + this._slot = null; // + this._mesh = null; // + } + } + + if (this._actionFrames.size() > 0) { + this._actionFrames.sort(this::_sortActionFrame); + + TimelineData timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData.class); + CharArray timelineArray = this._data.timelineArray; + int keyFrameCount = this._actionFrames.size(); + timeline.type = TimelineType.Action; + timeline.offset = timelineArray.length(); + timelineArray.incrementLength(1 + 1 + 1 + 1 + 1 + keyFrameCount); + timelineArray.set(timeline.offset + BinaryOffset.TimelineScale.v, 100); + timelineArray.set(timeline.offset + BinaryOffset.TimelineOffset.v, 0); + timelineArray.set(timeline.offset + BinaryOffset.TimelineKeyFrameCount.v, keyFrameCount); + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameValueCount.v, 0); + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameValueOffset.v, 0); + + this._timeline = timeline; + + if (keyFrameCount == 1) { + timeline.frameIndicesOffset = -1; + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameOffset.v + 0, this._parseCacheActionFrame(this._actionFrames.get(0)) - this._animation.frameOffset); + } else { + int totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + IntArray frameIndices = this._data.frameIndices; + timeline.frameIndicesOffset = frameIndices.length(); + frameIndices.incrementLength(totalFrameCount); + + for ( + int i = 0, iK = 0, frameStart = 0, frameCount = 0; + i < totalFrameCount; + ++i + ) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + ActionFrame frame = this._actionFrames.get(iK); + frameStart = frame.frameStart; + if (iK == keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } else { + frameCount = this._actionFrames.get(iK + 1).frameStart - frameStart; + } + + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameOffset.v + iK, this._parseCacheActionFrame(frame) - this._animation.frameOffset); + iK++; + } + + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + } + + this._timeline = null; // + this._actionFrames.clear(); + } + + this._animation = null; // + + return animation; + } + + interface FrameParser { + int parse(Object rawData, int frameStart, int frameCount); + } + + /** + * @private + */ + @Nullable + protected TimelineData _parseTimeline( + Object rawData, TimelineType type, + boolean addIntOffset, boolean addFloatOffset, int frameValueCount, + FrameParser frameParser + ) + + { + if (!(in(rawData, ObjectDataParser.FRAME))) { + return null; + } + + Array rawFrames = getArray(rawData, ObjectDataParser.FRAME); + int keyFrameCount = rawFrames.size(); + if (keyFrameCount == 0) { + return null; + } + + CharArray timelineArray = this._data.timelineArray; + int frameIntArrayLength = this._data.frameIntArray.length(); + int frameFloatArrayLength = this._data.frameFloatArray.length(); + TimelineData timeline = BaseObject.borrowObject(TimelineData.class); + timeline.type = type; + timeline.offset = timelineArray.length(); + timelineArray.incrementLength(1 + 1 + 1 + 1 + 1 + keyFrameCount); + timelineArray.set(timeline.offset + BinaryOffset.TimelineScale.v, (int) Math.round(getFloat(rawData, ObjectDataParser.SCALE, 1f) * 100)); + timelineArray.set(timeline.offset + BinaryOffset.TimelineOffset.v, (int) Math.round(getFloat(rawData, ObjectDataParser.OFFSET, 0f) * 100)); + timelineArray.set(timeline.offset + BinaryOffset.TimelineKeyFrameCount.v, keyFrameCount); + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameValueCount.v, frameValueCount); + if (addIntOffset) { + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameValueOffset.v, frameIntArrayLength - this._animation.frameIntOffset); + } else if (addFloatOffset) { + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameValueOffset.v, frameFloatArrayLength - this._animation.frameFloatOffset); + } else { + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameValueOffset.v, 0); + } + + this._timeline = timeline; + + if (keyFrameCount == 1) { // Only one frame. + timeline.frameIndicesOffset = -1; + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameOffset.v + 0, frameParser.parse(rawFrames.get(0), 0, 0) - this._animation.frameOffset); + } else { + IntArray frameIndices = this._data.frameIndices; + int totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + timeline.frameIndicesOffset = frameIndices.size(); + frameIndices.incrementLength(totalFrameCount); + + for (int i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + Object rawFrame = rawFrames.get(iK); + frameStart = i; + frameCount = getInt(rawFrame, ObjectDataParser.DURATION, 1); + if (iK == keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + + timelineArray.set(timeline.offset + BinaryOffset.TimelineFrameOffset.v + iK, frameParser.parse(rawFrame, frameStart, frameCount) - this._animation.frameOffset); + iK++; + } + + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + } + + this._timeline = null; // + + return timeline; + } + + /** + * @private + */ + protected void _parseBoneTimeline(Object rawData) + + { + BoneData bone = this._armature.getBone(getString(rawData, ObjectDataParser.NAME, "")); + if (bone == null) { + return; + } + + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + + TimelineData timeline = this._parseTimeline( + rawData, TimelineType.BoneAll, + false, true, 6, + this::_parseBoneFrame + ); + if (timeline != null) { + this._animation.addBoneTimeline(bone, timeline); + } + + this._bone = null; // + this._slot = null; // + } + + /** + * @private + */ + protected void _parseSlotTimeline(Object rawData) + + { + SlotData slot = this._armature.getSlot(getString(rawData, ObjectDataParser.NAME, "")); + if (slot == null) { + return; + } + + this._slot = slot; + + TimelineData displayIndexTimeline = this._parseTimeline(rawData, TimelineType.SlotDisplay, false, false, 0, this::_parseSlotDisplayIndexFrame); + if (displayIndexTimeline != null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + + TimelineData colorTimeline = this._parseTimeline(rawData, TimelineType.SlotColor, true, false, 1, this::_parseSlotColorFrame); + if (colorTimeline != null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + + this._slot = null; // + } + + /** + * @private + */ + protected int _parseFrame(Object rawData, int frameStart, int frameCount, IntArray frameArray) + + { + int frameOffset = frameArray.size(); + frameArray.incrementLength(1); + frameArray.set(frameOffset + BinaryOffset.FramePosition.v, frameStart); + + return frameOffset; + } + + /** + * @private + */ + protected int _parseTweenFrame(Object rawData, int frameStart, int frameCount, IntArray frameArray) + + { + int frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + + if (frameCount > 0) { + if (in(rawData, ObjectDataParser.CURVE)) { + int sampleCount = frameCount + 1; + this._helpArray.setLength(sampleCount); + this._samplingEasingCurve(getFloatArray(rawData, ObjectDataParser.CURVE), this._helpArray); + + frameArray.incrementLength(1 + 1 + this._helpArray.getLength()); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.Curve.v); + frameArray.set(frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount.v, sampleCount); + for (int i = 0; i < sampleCount; ++i) { + frameArray.set(frameOffset + BinaryOffset.FrameCurveSamples.v + i, (int) Math.round(this._helpArray.get(i) * 10000.0)); + } + } else { + float noTween = -2.0f; + float tweenEasing = noTween; + if (in(rawData, ObjectDataParser.TWEEN_EASING)) { + tweenEasing = getFloat(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + + if (tweenEasing == noTween) { + frameArray.incrementLength(1); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.None.v); + } else if (tweenEasing == 0f) { + frameArray.incrementLength(1); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.Line.v); + } else if (tweenEasing < 0f) { + frameArray.incrementLength(1 + 1); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.QuadIn.v); + frameArray.set(frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount.v, (int) Math.round(-tweenEasing * 100.0)); + } else if (tweenEasing <= 1f) { + frameArray.incrementLength(1 + 1); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.QuadOut.v); + frameArray.set(frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount.v, (int) Math.round(tweenEasing * 100.0)); + } else { + frameArray.incrementLength(1 + 1); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.QuadInOut.v); + frameArray.set(frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount.v, (int) Math.round(tweenEasing * 100.0 - 100.0)); + } + } + } else { + frameArray.incrementLength(1); + frameArray.set(frameOffset + BinaryOffset.FrameTweenType.v, TweenType.None.v); + } + + return frameOffset; + } + + /** + * @private + */ + protected int _parseZOrderFrame(Object rawData, int frameStart, int frameCount) + + { + ShortArray frameArray = this._data.frameArray; + int frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + + if (in(rawData, ObjectDataParser.Z_ORDER)) { + IntArray rawZOrder = getIntArray(rawData, ObjectDataParser.Z_ORDER); + if (rawZOrder.length() > 0) { + int slotCount = this._armature.sortedSlots.length(); + IntArray unchanged = new IntArray(slotCount - rawZOrder.length() / 2); + IntArray zOrders = new IntArray(slotCount); + + for (int i = 0; i < slotCount; ++i) { + zOrders.set(i, -1); + } + + int originalIndex = 0; + int unchangedIndex = 0; + for (int i = 0, l = rawZOrder.length(); i < l; i += 2) { + int slotIndex = rawZOrder.get(i); + int zOrderOffset = rawZOrder.get(i + 1); + + while (originalIndex != slotIndex) { + unchanged.set(unchangedIndex++, originalIndex++); + } + + zOrders.set(originalIndex + zOrderOffset, originalIndex++); + } + + while (originalIndex < slotCount) { + unchanged.set(unchangedIndex++, originalIndex++); + } + + frameArray.incrementLength(1 + slotCount); + frameArray.set(frameOffset + 1, slotCount); + + int i = slotCount; + while (i-- > 0) { + if (zOrders.get(i) == -1) { + frameArray.set(frameOffset + 2 + i, unchanged.get(--unchangedIndex)); + } else { + frameArray.set(frameOffset + 2 + i, zOrders.get(i)); + } + } + + return frameOffset; + } + } + + frameArray.incrementLength(1); + frameArray.set(frameOffset + 1, 0); + + return frameOffset; + } + + /** + * @private + */ + protected int _parseBoneFrame(Object rawData, int frameStart, int frameCount) + + { + FloatArray frameFloatArray = this._data.frameFloatArray; + ShortArray frameArray = this._data.frameArray; + int frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + + this._helpTransform.identity(); + if (in(rawData, ObjectDataParser.TRANSFORM)) { + this._parseTransform(get(rawData, ObjectDataParser.TRANSFORM), this._helpTransform, 1f); + } + + // Modify rotation. + float rotation = this._helpTransform.rotation; + if (frameStart != 0) { + if (this._prevTweenRotate == 0) { + rotation = this._prevRotation + Transform.normalizeRadian(rotation - this._prevRotation); + } else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + + rotation = this._prevRotation + rotation - this._prevRotation + Transform.PI_D * this._prevTweenRotate; + } + } + + this._prevTweenRotate = getFloat(rawData, ObjectDataParser.TWEEN_ROTATE, 0f); + this._prevRotation = rotation; + + int frameFloatOffset = frameFloatArray.length(); + frameFloatArray.incrementLength(6); + frameFloatArray.set(frameFloatOffset++, this._helpTransform.x); + frameFloatArray.set(frameFloatOffset++, this._helpTransform.y); + frameFloatArray.set(frameFloatOffset++, rotation); + frameFloatArray.set(frameFloatOffset++, this._helpTransform.skew); + frameFloatArray.set(frameFloatOffset++, this._helpTransform.scaleX); + frameFloatArray.set(frameFloatOffset++, this._helpTransform.scaleY); + + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + + return frameOffset; + } + + /** + * @private + */ + protected int _parseSlotDisplayIndexFrame(Object rawData, int frameStart, int frameCount) + + { + ShortArray frameArray = this._data.frameArray; + int frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + + frameArray.incrementLength(1); + frameArray.set(frameOffset + 1, getInt(rawData, ObjectDataParser.DISPLAY_INDEX, 0)); + + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + + return frameOffset; + } + + /** + * @private + */ + protected int _parseSlotColorFrame(Object rawData, int frameStart, int frameCount) + + { + ShortArray intArray = this._data.intArray; + ShortArray frameIntArray = this._data.frameIntArray; + ShortArray frameArray = this._data.frameArray; + int frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + + int colorOffset = -1; + if (in(rawData, ObjectDataParser.COLOR)) { + Array rawColor = getArray(rawData, ObjectDataParser.COLOR); + for (int k = 0; k < rawColor.length(); k++) { + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length(); + intArray.incrementLength(8); + intArray.set(colorOffset++, (int) Math.round(this._helpColorTransform.alphaMultiplier * 100)); + intArray.set(colorOffset++, (int) Math.round(this._helpColorTransform.redMultiplier * 100)); + intArray.set(colorOffset++, (int) Math.round(this._helpColorTransform.greenMultiplier * 100)); + intArray.set(colorOffset++, (int) Math.round(this._helpColorTransform.blueMultiplier * 100)); + intArray.set(colorOffset++, Math.round(this._helpColorTransform.alphaOffset)); + intArray.set(colorOffset++, Math.round(this._helpColorTransform.redOffset)); + intArray.set(colorOffset++, Math.round(this._helpColorTransform.greenOffset)); + intArray.set(colorOffset++, Math.round(this._helpColorTransform.blueOffset)); + colorOffset -= 8; + break; + } + } + + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length(); + intArray.incrementLength(8); + intArray.set(colorOffset++, 100); + intArray.set(colorOffset++, 100); + intArray.set(colorOffset++, 100); + intArray.set(colorOffset++, 100); + intArray.set(colorOffset++, 0); + intArray.set(colorOffset++, 0); + intArray.set(colorOffset++, 0); + intArray.set(colorOffset++, 0); + } + + colorOffset = this._defalultColorOffset; + } + + int frameIntOffset = frameIntArray.length(); + frameIntArray.incrementLength(1); + frameIntArray.set(frameIntOffset, colorOffset); + + return frameOffset; + } + + /** + * @private + */ + protected int _parseSlotFFDFrame(Object rawData, int frameStart, int frameCount) + + { + IntArray intArray = this._data.intArray; + FloatArray frameFloatArray = this._data.frameFloatArray; + ShortArray frameArray = this._data.frameArray; + int frameFloatOffset = frameFloatArray.length(); + int frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + FloatArray rawVertices = in(rawData, ObjectDataParser.VERTICES) ? getFloatArray(rawData, ObjectDataParser.VERTICES) : null; + int offset = getInt(rawData, ObjectDataParser.OFFSET, 0); // uint + int vertexCount = intArray.get(this._mesh.offset + BinaryOffset.MeshVertexCount.v); + + float x = 0f; + float y = 0f; + int iB = 0; + int iV = 0; + if (this._mesh.weight != null) { + FloatArray rawSlotPose = this._weightSlotPose.get(this._mesh.name); + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.incrementLength(this._mesh.weight.count * 2); + iB = this._mesh.weight.offset + BinaryOffset.WeigthBoneIndices.v + this._mesh.weight.bones.length(); + } else { + frameFloatArray.incrementLength(vertexCount * 2); + } + + for ( + int i = 0; + i < vertexCount * 2; + i += 2 + ) { + if (rawVertices == null) { // Fill 0. + x = 0f; + y = 0f; + } else { + if (i < offset || i - offset >= rawVertices.length()) { + x = 0f; + } else { + x = rawVertices.get(i - offset); + } + + if (i + 1 < offset || i + 1 - offset >= rawVertices.length()) { + y = 0f; + } else { + y = rawVertices.get(i + 1 - offset); + } + } + + if (this._mesh.weight != null) { // If mesh is skinned, transform point by bone bind pose. + FloatArray rawBonePoses = this._weightBonePoses.get(this._mesh.name); + IntArray weightBoneIndices = this._weightBoneIndices.get(this._mesh.name); + int vertexBoneCount = intArray.get(iB++); + + this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + + for (int j = 0; j < vertexBoneCount; ++j) { + int boneIndex = intArray.get(iB++); + BoneData bone = this._mesh.weight.bones.get(boneIndex); + int rawBoneIndex = this._rawBones.indexOf(bone); + + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + + frameFloatArray.set(frameFloatOffset + iV++, this._helpPoint.x); + frameFloatArray.set(frameFloatOffset + iV++, this._helpPoint.y); + } + } else { + frameFloatArray.set(frameFloatOffset + i, x); + frameFloatArray.set(frameFloatOffset + i + 1, y); + } + } + + if (frameStart == 0) { + ShortArray frameIntArray = this._data.frameIntArray; + CharArray timelineArray = this._data.timelineArray; + int frameIntOffset = frameIntArray.length(); + frameIntArray.incrementLength(1 + 1 + 1 + 1 + 1); + frameIntArray.set(frameIntOffset + BinaryOffset.FFDTimelineMeshOffset.v, this._mesh.offset); + frameIntArray.set(frameIntOffset + BinaryOffset.FFDTimelineFFDCount.v, frameFloatArray.length() - frameFloatOffset); + frameIntArray.set(frameIntOffset + BinaryOffset.FFDTimelineValueCount.v, frameFloatArray.length() - frameFloatOffset); + frameIntArray.set(frameIntOffset + BinaryOffset.FFDTimelineValueOffset.v, 0); + frameIntArray.set(frameIntOffset + BinaryOffset.FFDTimelineFloatOffset.v, frameFloatOffset); + timelineArray.set(this._timeline.offset + BinaryOffset.TimelineFrameValueCount.v, frameIntOffset - this._animation.frameIntOffset); + } + + return frameOffset; + } + + /** + * @private + */ + protected int _parseActionData(Object rawData, Array actions, ActionType type, @Nullable BoneData bone, @Nullable SlotData slot) + + { + int actionCount = 0; + + if (rawData instanceof String) { + ActionData action = BaseObject.borrowObject(ActionData.class); + action.type = type; + action.name = (String) rawData; + action.bone = bone; + action.slot = slot; + actions.push(action); + actionCount++; + } else if (rawData instanceof ArrayBase) { + for (Object rawAction : (ArrayBase) rawData) { + ActionData action = BaseObject.borrowObject(ActionData.class); + if (in(rawAction, ObjectDataParser.GOTO_AND_PLAY)) { + action.type = ActionType.Play; + action.name = getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } else { + if (in(rawAction, ObjectDataParser.TYPE) && get(rawAction, ObjectDataParser.TYPE) instanceof String) { + action.type = ObjectDataParser._getActionType(getString(rawAction, ObjectDataParser.TYPE)); + } else { + action.type = ActionType.values[getInt(rawAction, ObjectDataParser.TYPE, type.v)]; + } + + action.name = getString(rawAction, ObjectDataParser.NAME, ""); + } + + if (in(rawAction, ObjectDataParser.BONE)) { + String boneName = getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } else { + action.bone = bone; + } + + if (in(rawAction, ObjectDataParser.SLOT)) { + String slotName = getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } else { + action.slot = slot; + } + + if (in(rawAction, ObjectDataParser.INTS)) { + if (action.data == null) { + action.data = BaseObject.borrowObject(UserData.class); + } + + IntArray rawInts = getIntArray(rawAction, ObjectDataParser.INTS); + for (int rawValue : rawInts) { + action.data.ints.push(rawValue); + } + } + + if (in(rawAction, ObjectDataParser.FLOATS)) { + if (action.data == null) { + action.data = BaseObject.borrowObject(UserData.class); + } + + FloatArray rawFloats = getFloatArray(rawAction, ObjectDataParser.FLOATS); + for (float rawValue : rawFloats) { + action.data.floats.push(rawValue); + } + } + + if (in(rawAction, ObjectDataParser.STRINGS)) { + if (action.data == null) { + action.data = BaseObject.borrowObject(UserData.class); + } + + Array rawStrings = getArray(rawAction, ObjectDataParser.STRINGS); + for (String rawValue : rawStrings) { + action.data.strings.push(rawValue); + } + } + + actions.push(action); + actionCount++; + } + } + + return actionCount; + } + + /** + * @private + */ + protected void _parseTransform(Object rawData, Transform transform, float scale) + + { + transform.x = getFloat(rawData, ObjectDataParser.X, 0f) * scale; + transform.y = getFloat(rawData, ObjectDataParser.Y, 0f) * scale; + + if (in(rawData, ObjectDataParser.ROTATE) || in(rawData, ObjectDataParser.SKEW)) { + transform.rotation = Transform.normalizeRadian(getFloat(rawData, ObjectDataParser.ROTATE, 0f) * Transform.DEG_RAD); + transform.skew = Transform.normalizeRadian(getFloat(rawData, ObjectDataParser.SKEW, 0f) * Transform.DEG_RAD); + } else if (in(rawData, ObjectDataParser.SKEW_X) || in(rawData, ObjectDataParser.SKEW_Y)) { + transform.rotation = Transform.normalizeRadian(getFloat(rawData, ObjectDataParser.SKEW_Y, 0f) * Transform.DEG_RAD); + transform.skew = Transform.normalizeRadian(getFloat(rawData, ObjectDataParser.SKEW_X, 0f) * Transform.DEG_RAD) - transform.rotation; + } + + transform.scaleX = getFloat(rawData, ObjectDataParser.SCALE_X, 1f); + transform.scaleY = getFloat(rawData, ObjectDataParser.SCALE_Y, 1f); + } + + /** + * @private + */ + protected void _parseColorTransform(Object rawData, ColorTransform color) + + { + color.alphaMultiplier = getFloat(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01f; + color.redMultiplier = getFloat(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01f; + color.greenMultiplier = getFloat(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01f; + color.blueMultiplier = getFloat(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01f; + color.alphaOffset = getInt(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = getInt(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = getInt(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = getInt(rawData, ObjectDataParser.BLUE_OFFSET, 0); + } + + /** + * @private + */ + protected void _parseArray(Object rawData) { + this._data.intArray = new ShortArray(); + this._data.floatArray = new FloatArray(); + this._data.frameIntArray = new ShortArray(); + this._data.frameFloatArray = new FloatArray(); + this._data.frameArray = new ShortArray(); + this._data.timelineArray = new CharArray(); + } + + @Nullable + public DragonBonesData parseDragonBonesDataInstance(@NotNull Object rawData) { + return parseDragonBonesData(rawData, 1f); + } + + /** + * @inheritDoc + */ + @Nullable + public DragonBonesData parseDragonBonesData(@NotNull Object rawData, float scale) { + String version = getString(rawData, ObjectDataParser.VERSION, ""); + String compatibleVersion = getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + + if ( + Arrays.asList(ObjectDataParser.DATA_VERSIONS).indexOf(version) >= 0 || + Arrays.asList(ObjectDataParser.DATA_VERSIONS).indexOf(compatibleVersion) >= 0 + ) { + DragonBonesData data = BaseObject.borrowObject(DragonBonesData.class); + data.version = version; + data.name = getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = getFloat(rawData, ObjectDataParser.FRAME_RATE, 24); + + if (data.frameRate == 0) { // Data error. + data.frameRate = 24; + } + + if (in(rawData, ObjectDataParser.ARMATURE)) { + this._defalultColorOffset = -1; + this._data = data; + + this._parseArray(rawData); + + Array rawArmatures = getArray(rawData, ObjectDataParser.ARMATURE); + for (Object rawArmature : rawArmatures) { + data.addArmature(this._parseArmature(rawArmature, scale)); + } + + if (this._intArrayJson.length() > 0) { + //this._parseWASMArray(); + throw new RuntimeException("this._parseWASMArray() not ported"); + } + + this._data = null; + } + + this._rawTextureAtlasIndex = 0; + if (in(rawData, ObjectDataParser.TEXTURE_ATLAS)) { + this._rawTextureAtlases = getArray(rawData, ObjectDataParser.TEXTURE_ATLAS); + } else { + this._rawTextureAtlases = null; + } + + return data; + } else { + Console._assert(false, "Nonsupport data version."); + } + + return null; + } + + public boolean parseTextureAtlasData(Object rawData, TextureAtlasData textureAtlasData) { + return parseTextureAtlasData(rawData, textureAtlasData, 0f); + } + + /** + * @inheritDoc + */ + public boolean parseTextureAtlasData(Object rawData, TextureAtlasData textureAtlasData, float scale) { + if (rawData == null) { + if (this._rawTextureAtlases == null) { + return false; + } + + Object rawTextureAtlas = this._rawTextureAtlases.get(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 = getFloat(rawData, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = getFloat(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + + if (scale > 0f) { // Use params scale. + textureAtlasData.scale = scale; + } else { // Use data scale. + scale = textureAtlasData.scale = getFloat(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + + scale = 1f / scale; // + + if (in(rawData, ObjectDataParser.SUB_TEXTURE)) { + ArrayBase rawTextures = getArray(rawData, ObjectDataParser.SUB_TEXTURE); + for (int i = 0, l = rawTextures.length(); i < l; ++i) { + Object rawTexture = rawTextures.getObject(i); + TextureData textureData = textureAtlasData.createTexture(); + textureData.rotated = getBool(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = getFloat(rawTexture, ObjectDataParser.X, 0f) * scale; + textureData.region.y = getFloat(rawTexture, ObjectDataParser.Y, 0f) * scale; + textureData.region.width = getFloat(rawTexture, ObjectDataParser.WIDTH, 0f) * scale; + textureData.region.height = getFloat(rawTexture, ObjectDataParser.HEIGHT, 0f) * scale; + + float frameWidth = getFloat(rawTexture, ObjectDataParser.FRAME_WIDTH, -1f); + float frameHeight = getFloat(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1f); + if (frameWidth > 0f && frameHeight > 0f) { + textureData.frame = TextureData.createRectangle(); + textureData.frame.x = getFloat(rawTexture, ObjectDataParser.FRAME_X, 0f) * scale; + textureData.frame.y = getFloat(rawTexture, ObjectDataParser.FRAME_Y, 0f) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + + textureAtlasData.addTexture(textureData); + } + } + + return true; + } + + /** + * @private + */ + private static ObjectDataParser _objectDataParserInstance = null; + + /** + * @see BaseFactory#parseDragonBonesData(Object, String, float) + * @deprecated 已废弃,请参考 @see + */ + public static ObjectDataParser getInstance() { + if (ObjectDataParser._objectDataParserInstance == null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + + return ObjectDataParser._objectDataParserInstance; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/Array.java b/dragonbones-core/src/main/java/com/dragonbones/util/Array.java new file mode 100644 index 0000000..240f411 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/Array.java @@ -0,0 +1,87 @@ +package com.dragonbones.util; + +import java.util.Arrays; +import java.util.Comparator; + +final public class Array extends ArrayBase { + private int length; + private T[] data = (T[]) new Object[0]; + + public Array() { + this((T[]) new Object[16], 0); + } + + public Array(int length) { + this((T[]) new Object[length], length); + } + + public Array(T[] data) { + this(data, data.length); + } + + public Array(T[] data, int length) { + this.data = data; + this.length = length; + } + + @Override + public ArrayBase create(int count) { + return new Array<>(count); + } + + private void ensureCapacity(int minLength) { + if (data.length < minLength) { + data = Arrays.copyOf(data, Math.max(minLength, data.length * 3)); + } + } + + public T get(int index) { + return data[index]; + } + + public void set(int index, T value) { + data[index] = value; + } + + @Override + public T getObject(int index) { + return get(index); + } + + @Override + public void setObject(int index, T value) { + set(index, value); + } + + //@Deprecated + public void add(T value) { + pushObject(value); + } + + public void push(T value) { + pushObject(value); + } + + @Override + public int getLength() { + return length; + } + + @Override + public void setLength(int length) { + this.length = length; + ensureCapacity(length); + } + + public Array copy() { + Array out = new Array<>(); + out.length = length; + out.data = Arrays.copyOf(data, data.length); + return out; + } + + @Override + public void sort(Comparator comparator, int start, int end) { + Arrays.sort(data, start, end, comparator); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/ArrayBase.java b/dragonbones-core/src/main/java/com/dragonbones/util/ArrayBase.java new file mode 100644 index 0000000..ffb84e0 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/ArrayBase.java @@ -0,0 +1,140 @@ +package com.dragonbones.util; + +import org.jetbrains.annotations.NotNull; + +import java.util.Comparator; +import java.util.Iterator; +import java.util.Objects; + +public abstract class ArrayBase implements Iterable { + abstract public int getLength(); + + abstract public void setLength(int length); + + abstract public T getObject(int index); + + abstract public void setObject(int index, T value); + + abstract public ArrayBase create(int count); + + final public int length() { + return getLength(); + } + + final public int size() { + return getLength(); + } + + final public void clear() { + setLength(0); + } + + final public void incrementLength(int delta) { + setLength(getLength() + delta); + } + + // @TODO: Optimize this! + public int indexOf(T value) { + return indexOfObject(value); + } + + public int indexOfObject(T value) { + for (int n = 0; n < length(); n++) { + if (Objects.equals(getObject(n), value)) { + return n; + } + } + return -1; + } + + public void pushObject(T value) { + incrementLength(1); + setObject(getLength() - 1, value); + } + + public T popObject() { + T out = getObject(getLength() - 1); + incrementLength(-1); + return out; + } + + public void unshiftObject(T item) { + setLength(getLength() + 1); + for (int n = 1; n < getLength(); n++) { + setObject(n - 1, getObject(n)); + } + setObject(0, item); + } + + @NotNull + @Override + public Iterator iterator() { + final int[] pos = {0}; + return new Iterator() { + @Override + public boolean hasNext() { + return pos[0] < getLength(); + } + + @Override + public T next() { + return getObject(pos[0]++); + } + }; + } + + static private Object[] EMPTY_ARRAY = new Object[0]; + + public void splice(int index, int removeCount, T... addItems) { + ArrayBase ref = copy(); + if (addItems == null) addItems = (T[]) EMPTY_ARRAY; + setLength(getLength() - removeCount + addItems.length); + for (int n = 0; n < index; n++) { + this.setObject(n, ref.getObject(n)); + } + for (int n = 0; n < addItems.length; n++) { + this.setObject(index + n, addItems[n]); + } + for (int n = 0; n < ref.length() - removeCount; n++) { + this.setObject(index + addItems.length + n, ref.getObject(index + removeCount + n)); + } + } + + public ArrayBase copy() { + return slice(); + } + + public ArrayBase slice() { + return slice(0, getLength()); + } + + public ArrayBase slice(int start) { + return slice(start, getLength()); + } + + public ArrayBase slice(int start, int end) { + int count = end - start; + ArrayBase out = create(count); + for (int n = 0; n < count; n++) { + out.setObject(n, this.getObject(start + n)); + } + return out; + } + + public ArrayBase concat(T... items) { + ArrayBase out = create(this.length() + items.length); + for (int n = 0; n < this.length(); n++) { + out.setObject(n, this.getObject(n)); + } + for (int n = 0; n < items.length; n++) { + out.setObject(this.length() + n, items[n]); + } + return out; + } + + public void sort(Comparator comparator) { + sort(comparator, 0, getLength()); + } + + abstract public void sort(Comparator comparator, int start, int end); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/BoolArray.java b/dragonbones-core/src/main/java/com/dragonbones/util/BoolArray.java new file mode 100644 index 0000000..0a716d1 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/BoolArray.java @@ -0,0 +1,16 @@ +package com.dragonbones.util; + +final public class BoolArray extends IntArray { + @Override + protected IntArray createInstance() { + return new BoolArray(); + } + + public boolean getBool(int index) { + return get(index) != 0; + } + + public void setBool(int index, boolean value) { + set(index, value ? 1 : 0); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/CharArray.java b/dragonbones-core/src/main/java/com/dragonbones/util/CharArray.java new file mode 100644 index 0000000..d62c4c3 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/CharArray.java @@ -0,0 +1,27 @@ +package com.dragonbones.util; + +public class CharArray extends IntArray { + public CharArray(boolean none) { + super(none); + } + + public CharArray() { + } + + public CharArray(int length) { + super(length); + } + + public CharArray(int[] data) { + super(data); + } + + public CharArray(int[] data, int length) { + super(data, length); + } + + @Override + protected IntArray createInstance() { + return new CharArray(); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/Console.java b/dragonbones-core/src/main/java/com/dragonbones/util/Console.java new file mode 100644 index 0000000..ceb6bdd --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/Console.java @@ -0,0 +1,13 @@ +package com.dragonbones.util; + +public class Console { + static public void _assert(boolean bool) { + } + + static public void _assert(boolean bool, String msg) { + } + + static public void warn(String msg) { + System.err.println(msg); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/Dynamic.java b/dragonbones-core/src/main/java/com/dragonbones/util/Dynamic.java new file mode 100644 index 0000000..7eabf43 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/Dynamic.java @@ -0,0 +1,151 @@ +package com.dragonbones.util; + +import java.util.List; +import java.util.Map; +import java.util.Objects; + +// @TODO: Implement using reflection getter methods, or fields +public class Dynamic { + static public Object get(Object rawData, String key) { + return get(rawData, key, null); + } + + static public Object get(Object rawData, String key, Object defaultValue) { + Object out = defaultValue; + try { + if (rawData instanceof Map) { + out = ((Map) rawData).get(key); + if (out != null) return out; + } else if (rawData instanceof List) { + out = ((List) rawData).get(Integer.parseInt(key)); + if (out != null) return out; + } else if (rawData instanceof ArrayBase) { + out = ((ArrayBase) rawData).getObject(Integer.parseInt(key)); + if (out != null) return out; + } + } catch (Throwable e) { + } + return out; + } + + static public boolean in(Object rawData, String key) { + return get(rawData, key, null) != null; + } + + static public IntArray getIntArray(Object rawData, String key) { + Object obj = get(rawData, key); + if (obj instanceof IntArray) { + return (IntArray) obj; + } else if (obj instanceof Iterable) { + IntArray out = new IntArray(); + for (Object o : (Iterable) obj) out.push(castInt(o, 0)); + return out; + } else { + return null; + } + } + + static public FloatArray getFloatArray(Object rawData, String key) { + Object obj = get(rawData, key); + if (obj instanceof FloatArray) { + return (FloatArray) obj; + } else if (obj instanceof Iterable) { + FloatArray out = new FloatArray(); + for (Object o : (Iterable) obj) out.push(castFloat(o, 0f)); + return out; + } else { + return null; + } + } + + static public Array getArray(Object rawData, String key) { + return castArray(get(rawData, key)); + } + + static public boolean getBool(Object rawData, String key) { + return getBool(rawData, key, false); + } + + static public boolean getBool(Object rawData, String key, boolean defaultValue) { + return castBool(get(rawData, key), defaultValue); + } + + static public int getInt(Object rawData, String key) { + return getInt(rawData, key, 0); + } + + static public int getInt(Object rawData, String key, int defaultValue) { + return (int) getDouble(rawData, key, defaultValue); + } + + static public float getFloat(Object rawData, String key) { + return getFloat(rawData, key, 0f); + } + + static public float getFloat(Object rawData, String key, float defaultValue) { + return (float) getDouble(rawData, key, defaultValue); + } + + static public double getDouble(Object rawData, String key) { + return getDouble(rawData, key, 0.0); + } + + static public double getDouble(Object rawData, String key, double defaultValue) { + return castDouble(get(rawData, key), defaultValue); + } + + static public String getString(Object rawData, String key) { + return getString(rawData, key, null); + } + + static public String getString(Object rawData, String key, String defaultValue) { + Object out = get(rawData, key); + if (out == null) return defaultValue; + return Objects.toString(out); + } + + static public Array castArray(Object obj) { + try { + if (obj instanceof Array) { + return (Array) obj; + } else if (obj instanceof Iterable) { + Array out = new Array<>(); + for (T o : (Iterable) obj) out.push(o); + return out; + } else { + return null; + } + } catch (Throwable e) { + return null; + } + } + + static public int castInt(Object obj, int defaultValue) { + return (int) castDouble(obj, defaultValue); + } + + static public float castFloat(Object obj, float defaultValue) { + return (float) castDouble(obj, defaultValue); + } + + static public boolean castBool(Object obj, boolean defaultValue) { + if (Objects.equals(obj, "true")) return true; + if (Objects.equals(obj, "false")) return false; + return ((int) castDouble(obj, defaultValue ? 1 : 0)) != 0; + } + + static public double castDouble(Object obj, double defaultValue) { + try { + if (obj == null) return defaultValue; + if (obj instanceof Number) { + return ((Number) obj).doubleValue(); + } + if (obj instanceof Boolean) { + return ((Boolean) obj) ? 1 : 0; + } + return Double.parseDouble(Objects.toString(obj)); + } catch (Throwable e) { + return defaultValue; + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/FloatArray.java b/dragonbones-core/src/main/java/com/dragonbones/util/FloatArray.java new file mode 100644 index 0000000..720f25b --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/FloatArray.java @@ -0,0 +1,92 @@ +package com.dragonbones.util; + +import java.util.Arrays; +import java.util.Comparator; + +public class FloatArray extends NumberArray { + static private final float[] EMPTY = new float[0]; + private int length; + private float[] data; + + protected FloatArray(boolean none) { + } + + public FloatArray() { + this(EMPTY, 0); + } + + public FloatArray(int length) { + this(new float[length], length); + } + + public FloatArray(float[] data) { + this(data, data.length); + } + + public FloatArray(float[] data, int length) { + this.data = data; + this.length = length; + } + + private void ensureCapacity(int minLength) { + if (data.length < minLength) { + data = Arrays.copyOf(data, Math.max(16, Math.max(minLength, data.length * 3))); + } + } + + public float get(int index) { + return data[index]; + } + + public void set(int index, float value) { + data[index] = value; + } + + @Override + public Float getObject(int index) { + return get(index); + } + + @Override + public void setObject(int index, Float value) { + set(index, value); + } + + @Override + public ArrayBase create(int count) { + return new FloatArray(count); + } + + public void push(float value) { + int pos = getLength(); + setLength(pos + 1); + data[pos] = value; + } + + @Override + public int getLength() { + return length; + } + + @Override + public void setLength(int length) { + this.length = length; + ensureCapacity(length); + } + + public FloatArray copy() { + FloatArray out = new FloatArray(); + out.length = length; + out.data = Arrays.copyOf(data, data.length); + return out; + } + + public void sort(int start, int end) { + Arrays.sort(data, start, end); + } + + @Override + public void sort(Comparator comparator, int start, int end) { + throw new RuntimeException("Not implemented"); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/Function.java b/dragonbones-core/src/main/java/com/dragonbones/util/Function.java new file mode 100644 index 0000000..bca047f --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/Function.java @@ -0,0 +1,5 @@ +package com.dragonbones.util; + +public interface Function { + void invoke(); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/IntArray.java b/dragonbones-core/src/main/java/com/dragonbones/util/IntArray.java new file mode 100644 index 0000000..f4b3c24 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/IntArray.java @@ -0,0 +1,95 @@ +package com.dragonbones.util; + +import java.util.Arrays; +import java.util.Comparator; + +public class IntArray extends NumberArray { + static private final int[] EMPTY = new int[0]; + private int length; + private int[] data; + + protected IntArray(boolean none) { + } + + public IntArray() { + this(EMPTY, 0); + } + + public IntArray(int length) { + this(new int[length], length); + } + + public IntArray(int[] data) { + this(data, data.length); + } + + public IntArray(int[] data, int length) { + this.data = data; + this.length = length; + } + + private void ensureCapacity(int minLength) { + if (data.length < minLength) { + data = Arrays.copyOf(data, Math.max(16, Math.max(minLength, data.length * 3))); + } + } + + public int get(int index) { + return data[index]; + } + + public void set(int index, int value) { + data[index] = value; + } + + @Override + public Integer getObject(int index) { + return get(index); + } + + @Override + public void setObject(int index, Integer value) { + set(index, (Integer) value); + } + + @Override + public ArrayBase create(int count) { + return new IntArray(count); + } + + public void push(int value) { + int pos = getLength(); + setLength(pos + 1); + data[pos] = value; + } + + @Override + public int getLength() { + return length; + } + + @Override + public void setLength(int length) { + this.length = length; + ensureCapacity(length); + } + + protected IntArray createInstance() { + return new IntArray(); + } + + public IntArray copy() { + IntArray out = createInstance(); + out.length = length; + out.data = Arrays.copyOf(data, data.length); + return out; + } + + public void sort(int start, int end) { + Arrays.sort(data, start, end); + } + + public void sort(Comparator comparator, int start, int end) { + throw new RuntimeException("Not implemented"); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/NumberArray.java b/dragonbones-core/src/main/java/com/dragonbones/util/NumberArray.java new file mode 100644 index 0000000..04a0e0c --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/NumberArray.java @@ -0,0 +1,6 @@ +package com.dragonbones.util; + +public abstract class NumberArray extends ArrayBase { + //abstract public int getInt(int index); + //abstract public void setInt(int index, int value); +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/ShortArray.java b/dragonbones-core/src/main/java/com/dragonbones/util/ShortArray.java new file mode 100644 index 0000000..f606b32 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/ShortArray.java @@ -0,0 +1,27 @@ +package com.dragonbones.util; + +public class ShortArray extends IntArray { + public ShortArray(boolean none) { + super(none); + } + + public ShortArray() { + } + + public ShortArray(int length) { + super(length); + } + + public ShortArray(int[] data) { + super(data); + } + + public ShortArray(int[] data, int length) { + super(data, length); + } + + @Override + protected IntArray createInstance() { + return new ShortArray(); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/StrReader.java b/dragonbones-core/src/main/java/com/dragonbones/util/StrReader.java new file mode 100644 index 0000000..bfa5949 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/StrReader.java @@ -0,0 +1,138 @@ +package com.dragonbones.util; + +import org.jetbrains.annotations.NotNull; + +import java.util.Arrays; +import java.util.Objects; + +public class StrReader { + private int offset; + private String str; + + public StrReader(String str) { + this(str, 0); + } + + public StrReader(String str, int offset) { + this.str = str; + this.offset = offset; + } + + public boolean hasMore() { + return offset() < length(); + } + + public boolean eof() { + return offset() >= length(); + } + + public char peek() { + return str.charAt(offset); + } + + public char read() { + return str.charAt(offset++); + } + + public int offset() { + return offset; + } + + public int length() { + return str.length(); + } + + public int available() { + return length() - offset(); + } + + public String peek(int count) { + return str.substring(offset, offset + Math.min(count, available())); + } + + public String read(int count) { + String out = peek(count); + skip(out.length()); + return out; + } + + public void skip(int count) { + offset += Math.min(count, available()); + } + + public void skip() { + skip(1); + } + + public boolean tryRead(char c) { + if (peek() == c) { + skip(); + return true; + } else { + return false; + } + } + + public String tryRead(String value) { + String read = peek(value.length()); + if (Objects.equals(read, value)) { + skip(read.length()); + return read; + } else { + return null; + } + } + + public String tryRead(String... values) { + for (String value : values) { + String out = tryRead(value); + if (out != null) return out; + } + return null; + } + + public char expect(char expect) { + char value = peek(); + if (value != expect) throw new ParseException("Expected " + expect); + skip(); + return value; + } + + @NotNull + public String expect(@NotNull String expect) { + String value = tryRead(expect); + if (value == null) throw new ParseException("Expected " + expect); + return value; + } + + @NotNull + public String expect(@NotNull String... expect) { + final int offset = this.offset(); + final String value = tryRead(expect); + if (value == null) { + throw new ParseException("Expected " + Arrays.asList(expect) + " at " + offset); + } + return value; + } + + public void skipSpaces() { + while (hasMore()) { + char c = peek(); + if (c == ' ' || c == '\n' || c == '\r' || c == '\t') { + skip(1); + } else { + break; + } + } + } + + static public class ParseException extends RuntimeException { + public ParseException() { + super(); + } + + public ParseException(String s) { + super(s); + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/StreamUtil.java b/dragonbones-core/src/main/java/com/dragonbones/util/StreamUtil.java new file mode 100644 index 0000000..beb6deb --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/StreamUtil.java @@ -0,0 +1,45 @@ +package com.dragonbones.util; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.nio.charset.Charset; + +public class StreamUtil { + static public byte[] readAll(InputStream s) { + byte[] temp = new byte[1024]; + ByteArrayOutputStream os = new ByteArrayOutputStream(); + try { + while (true) { + int read = s.read(temp, 0, temp.length); + if (read <= 0) break; + os.write(temp, 0, read); + } + } catch (IOException e) { + e.printStackTrace(); + } + return os.toByteArray(); + } + + static public String getResourceString(String path, Charset charset) { + try { + return new String(getResourceBytes(path), charset.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + } + + static public byte[] getResourceBytes(String path) { + InputStream s = ClassLoader.getSystemClassLoader().getResourceAsStream(path); + try { + return readAll(s); + } finally { + try { + s.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/StringUtil.java b/dragonbones-core/src/main/java/com/dragonbones/util/StringUtil.java new file mode 100644 index 0000000..b6f92f0 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/StringUtil.java @@ -0,0 +1,11 @@ +package com.dragonbones.util; + +public class StringUtil { + static public String fromCharCode(int cc) { + return new String(new int[]{cc}, 0, 1); + } + + static public String fromCodePoint(int cp) { + return new String(new int[]{cp}, 0, 1); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/ArrayBuffer.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/ArrayBuffer.java new file mode 100644 index 0000000..9acdeea --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/ArrayBuffer.java @@ -0,0 +1,56 @@ +package com.dragonbones.util.buffer; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class ArrayBuffer { + public ByteBuffer data; + + public ArrayBuffer(byte[] data) { + this.data = ByteBuffer.wrap(data).order(ByteOrder.nativeOrder()); + } + + public ArrayBuffer(int length) { + this.data = ByteBuffer.allocate(length).order(ByteOrder.nativeOrder()); + } + + public int getU8(int i) { + return data.get(i); + } + + public int getU32(int i) { + return data.getInt(i); + } + + public float getF32(int i) { + return data.getFloat(i); + } + + public int getU16(int i) { + return data.getChar(i); + } + + public int getS16(int i) { + return data.getShort(i); + } + + public void setS16(int i, int v) { + data.putShort(i, (short) v); + } + + public void setF32(int i, float value) { + data.putFloat(i, value); + } + + public void setU16(int i, int value) { + data.putChar(i, (char)value); + } + + public byte[] getBytes(int i, int count) { + byte[] bytes = new byte[count]; + for (int n = 0; n < count; n++) { + bytes[n] = (byte) getU8(i + n); + } + return bytes; + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/ArrayBufferView.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/ArrayBufferView.java new file mode 100644 index 0000000..8ea5554 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/ArrayBufferView.java @@ -0,0 +1,4 @@ +package com.dragonbones.util.buffer; + +public interface ArrayBufferView { +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Float32Array.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Float32Array.java new file mode 100644 index 0000000..6b3b266 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Float32Array.java @@ -0,0 +1,27 @@ +package com.dragonbones.util.buffer; + +import com.dragonbones.util.FloatArray; + +public class Float32Array extends FloatArray { + static public final int BYTES_PER_ELEMENT = 4; + private final ArrayBuffer buffer; + private final int offset; + private final int count; + private final int byteOffset; + + public Float32Array(ArrayBuffer buffer, int offset, int count) { + super(false); + this.buffer = buffer; + this.offset = offset; + this.count = count; + this.byteOffset = offset * BYTES_PER_ELEMENT; + } + + public float get(int index) { + return buffer.getF32(byteOffset + index * BYTES_PER_ELEMENT); + } + + public void set(int index, float value) { + buffer.setF32(byteOffset + index * BYTES_PER_ELEMENT, value); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Int16Array.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Int16Array.java new file mode 100644 index 0000000..1a6eb84 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Int16Array.java @@ -0,0 +1,28 @@ +package com.dragonbones.util.buffer; + +import com.dragonbones.util.ShortArray; + +public class Int16Array extends ShortArray implements ArrayBufferView { + static public final int BYTES_PER_ELEMENT = 2; + private final ArrayBuffer buffer; + private final int offset; + private final int count; + private final int byteOffset; + + public Int16Array(ArrayBuffer buffer, int offset, int count) { + super(false); + this.buffer = buffer; + this.offset = offset; + this.count = count; + this.byteOffset = offset * BYTES_PER_ELEMENT; + } + + public int get(int index) { + return buffer.getS16(byteOffset + index * BYTES_PER_ELEMENT); + } + + @Override + public void set(int i, int v) { + buffer.setS16(byteOffset + i * BYTES_PER_ELEMENT, v); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint16Array.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint16Array.java new file mode 100644 index 0000000..2a515f1 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint16Array.java @@ -0,0 +1,37 @@ +package com.dragonbones.util.buffer; + +import com.dragonbones.util.CharArray; + +public class Uint16Array extends CharArray implements ArrayBufferView { + static public final int BYTES_PER_ELEMENT = 2; + private final ArrayBuffer buffer; + private final int offset; + private final int count; + private final int byteOffset; + + public Uint16Array(ArrayBuffer buffer, int offset, int count) { + super(false); + this.buffer = buffer; + this.offset = offset; + this.count = count; + this.byteOffset = offset * BYTES_PER_ELEMENT; + } + + @Override + public int getLength() { + return count; + } + + @Override + public void setLength(int length) { + } + + public int get(int index) { + return buffer.getU16(byteOffset + index * BYTES_PER_ELEMENT); + } + + @Override + public void set(int index, int value) { + buffer.setU16(byteOffset + index * BYTES_PER_ELEMENT, value); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint32Array.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint32Array.java new file mode 100644 index 0000000..78d2294 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint32Array.java @@ -0,0 +1,23 @@ +package com.dragonbones.util.buffer; + +import com.dragonbones.util.IntArray; + +public class Uint32Array extends IntArray implements ArrayBufferView { + static public final int BYTES_PER_ELEMENT = 4; + private final ArrayBuffer buffer; + private final int offset; + private final int count; + private final int byteOffset; + + public Uint32Array(ArrayBuffer buffer, int offset, int count) { + super(false); + this.buffer = buffer; + this.offset = offset; + this.count = count; + this.byteOffset = offset * BYTES_PER_ELEMENT; + } + + public int get(int index) { + return buffer.getU32(byteOffset + index * BYTES_PER_ELEMENT); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint8Array.java b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint8Array.java new file mode 100644 index 0000000..6702cd1 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/buffer/Uint8Array.java @@ -0,0 +1,24 @@ +package com.dragonbones.util.buffer; + +public class Uint8Array implements ArrayBufferView { + static public final int BYTES_PER_ELEMENT = 1; + private final ArrayBuffer buffer; + private final int offset; + private final int count; + private final int byteOffset; + + public Uint8Array(ArrayBuffer buffer, int offset, int count) { + this.buffer = buffer; + this.offset = offset; + this.byteOffset = offset; + this.count = count; + } + + public int length() { + return count; + } + + public int get(int index) { + return buffer.getU8(byteOffset + index); + } +} diff --git a/dragonbones-core/src/main/java/com/dragonbones/util/json/JSON.java b/dragonbones-core/src/main/java/com/dragonbones/util/json/JSON.java new file mode 100644 index 0000000..5ce3705 --- /dev/null +++ b/dragonbones-core/src/main/java/com/dragonbones/util/json/JSON.java @@ -0,0 +1,198 @@ +package com.dragonbones.util.json; + +import com.dragonbones.util.Array; +import com.dragonbones.util.StrReader; + +import java.util.HashMap; +import java.util.Objects; + +public class JSON { + static public Object parse(String json) { + return parse(new StrReader(json)); + } + + static public Object parse(StrReader s) { + s.skipSpaces(); + switch (s.peek()) { + case '{': + return parseObject(s); + case '[': + return parseArray(s); + case '"': + return parseString(s); + case 't': + case 'f': + return parseBool(s); + case 'n': + return parseNull(s); + case '.': + case '+': + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'e': + case 'E': + return parseNumber(s); + } + throw new StrReader.ParseException("Unexpected character " + s.peek()); + } + + static public Object parseObject(StrReader s) { + HashMap out = new HashMap<>(); + s.skipSpaces(); + s.expect('{'); + s.skipSpaces(); + if (s.peek() != '}') { + while (s.hasMore()) { + s.skipSpaces(); + String key = Objects.toString(parse(s)); + s.skipSpaces(); + s.expect(':'); + s.skipSpaces(); + Object value = parse(s); + out.put(key, value); + s.skipSpaces(); + char c = s.peek(); + if (c == ',') { + s.skip(); + continue; + } + if (c == '}') break; + throw new StrReader.ParseException(); + } + } + s.skipSpaces(); + s.expect('}'); + + return out; + } + + static public Array parseArray(StrReader s) { + Array out = new Array<>(); + s.skipSpaces(); + s.expect('['); + s.skipSpaces(); + if (s.peek() != ']') { + while (s.hasMore()) { + s.skipSpaces(); + out.push(parse(s)); + s.skipSpaces(); + char c = s.peek(); + if (c == ',') { + s.skip(); + continue; + } + if (c == ']') break; + throw new StrReader.ParseException(); + } + } + s.skipSpaces(); + s.expect(']'); + s.skipSpaces(); + return out; + } + + static public String parseString(StrReader s) { + StringBuilder sb = new StringBuilder(); + s.skipSpaces(); + s.expect('"'); + while (s.hasMore()) { + char c = s.peek(); + if (c == '"') { + break; + } else if (c == '\\') { + s.skip(); + char cc = s.read(); + switch (cc) { + case 'n': + sb.append('\n'); + break; + case 'r': + sb.append('\r'); + break; + case 't': + sb.append('\t'); + break; + case 'b': + sb.append('\b'); + break; + case 'f': + sb.append('\f'); + break; + case '\\': + sb.append('\\'); + break; + case '/': + sb.append('/'); + break; + case 'u': + sb.appendCodePoint(Integer.parseInt(s.read(4), 16)); + break; + default: + throw new StrReader.ParseException("Invalid " + cc); + } + } else { + sb.append(c); + s.skip(); + } + } + s.expect('"'); + s.skipSpaces(); + return sb.toString(); + } + + static public double parseNumber(StrReader s) { + StringBuilder sb = new StringBuilder(); + s.skipSpaces(); + loop: + while (s.hasMore()) { + char c = s.peek(); + switch (c) { + case '.': + case '+': + case '-': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'e': + case 'E': + sb.append(c); + s.skip(); + break; + default: + break loop; + } + } + s.skipSpaces(); + return Double.parseDouble(sb.toString()); + } + + static public boolean parseBool(StrReader s) { + s.skipSpaces(); + String v = s.expect("true", "false"); + s.skipSpaces(); + return Objects.equals(v, "true"); + } + + static public Object parseNull(StrReader s) { + s.skipSpaces(); + s.expect("null"); + s.skipSpaces(); + return null; + } +} diff --git a/dragonbones-core/src/test/java/com/dragonbones/parser/DataParserTest.java b/dragonbones-core/src/test/java/com/dragonbones/parser/DataParserTest.java new file mode 100644 index 0000000..0082a80 --- /dev/null +++ b/dragonbones-core/src/test/java/com/dragonbones/parser/DataParserTest.java @@ -0,0 +1,17 @@ +package com.dragonbones.parser; + +import com.dragonbones.model.DragonBonesData; +import com.dragonbones.util.StreamUtil; +import org.junit.Test; + +import java.nio.charset.StandardCharsets; + +public class DataParserTest { + @Test + public void name() throws Exception { + DragonBonesData data = DataParser.parseDragonBonesDataJson( + StreamUtil.getResourceString("Dragon/Dragon_ske.json", StandardCharsets.UTF_8) + ); + System.out.println(data); + } +} \ No newline at end of file diff --git a/dragonbones-core/src/test/java/com/dragonbones/util/IntArrayTest.java b/dragonbones-core/src/test/java/com/dragonbones/util/IntArrayTest.java new file mode 100644 index 0000000..c3431bf --- /dev/null +++ b/dragonbones-core/src/test/java/com/dragonbones/util/IntArrayTest.java @@ -0,0 +1,22 @@ +package com.dragonbones.util; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.ArrayList; + +import static org.junit.Assert.*; + +public class IntArrayTest { + @Test + public void name() throws Exception { + ArrayList out = new ArrayList<>(); + for (int v : new IntArray(new int[]{1, 2, 3})) { + out.add(v); + } + Assert.assertEquals(3, out.size()); + Assert.assertEquals(1, (int)out.get(0)); + Assert.assertEquals(2, (int)out.get(1)); + Assert.assertEquals(3, (int)out.get(2)); + } +} \ No newline at end of file diff --git a/dragonbones-core/src/test/java/com/dragonbones/util/json/JSONTest.java b/dragonbones-core/src/test/java/com/dragonbones/util/json/JSONTest.java new file mode 100644 index 0000000..d4e1f47 --- /dev/null +++ b/dragonbones-core/src/test/java/com/dragonbones/util/json/JSONTest.java @@ -0,0 +1,31 @@ +package com.dragonbones.util.json; + +import com.dragonbones.util.StreamUtil; +import org.junit.Test; + +import java.nio.charset.StandardCharsets; + +public class JSONTest { + @Test + public void name() throws Exception { + JSON.parse("[true,false]"); + JSON.parse("{}"); + JSON.parse("{\"a\":1}"); + JSON.parse("1"); + JSON.parse("\"abc\""); + JSON.parse("true"); + JSON.parse("false"); + JSON.parse("null"); + JSON.parse("[1,2,3,4]"); + JSON.parse("true"); + JSON.parse("false"); + JSON.parse("[]"); + JSON.parse("[[]]"); + JSON.parse("[[[]],[]]"); + JSON.parse("[ [ true, false ], 1, 2, { \"a\" : true } ]"); + JSON.parse("[ [ true, false ] , 1 , 2 , { \"a\" : true } ]"); + + JSON.parse(StreamUtil.getResourceString("NewDragon/NewDragon.json", StandardCharsets.UTF_8)); + //System.out.println(); + } +} \ No newline at end of file diff --git a/dragonbones-core/src/test/resources/Dragon/Dragon.dbproj b/dragonbones-core/src/test/resources/Dragon/Dragon.dbproj new file mode 100644 index 0000000..af0761b Binary files /dev/null and b/dragonbones-core/src/test/resources/Dragon/Dragon.dbproj differ diff --git a/dragonbones-core/src/test/resources/Dragon/Dragon_ske.dbbin b/dragonbones-core/src/test/resources/Dragon/Dragon_ske.dbbin new file mode 100644 index 0000000..302cfa6 Binary files /dev/null and b/dragonbones-core/src/test/resources/Dragon/Dragon_ske.dbbin differ diff --git a/dragonbones-core/src/test/resources/Dragon/Dragon_ske.json b/dragonbones-core/src/test/resources/Dragon/Dragon_ske.json new file mode 100644 index 0000000..f86776c --- /dev/null +++ b/dragonbones-core/src/test/resources/Dragon/Dragon_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"version":"5.0","armature":[{"frameRate":24,"aabb":{"x":-234.40908264561412,"y":-431.81395140042207,"width":693.2805749826739,"height":769.5863484320666},"skin":[{"name":"","slot":[{"display":[{"type":"image","transform":{"y":4.3217,"skX":-148.2623,"skY":-148.2623,"x":27.8984},"name":"parts/armUpperL","path":"parts/armUpperL"}],"name":"armUpperL"},{"display":[{"type":"image","transform":{"y":-0.3072,"skX":45.2229,"skY":45.2229,"x":120.9881},"name":"parts/tail","path":"parts/tail"}],"name":"tail"},{"display":[{"type":"image","transform":{"y":-0.5,"x":1.5},"name":"parts/eyeR","path":"parts/eyeR"}],"name":"eyeR"},{"display":[{"type":"image","transform":{"y":-4.3543,"skX":-174.0434,"skY":-174.0434,"x":49.9847},"name":"parts/beardL","path":"parts/beardL"}],"name":"beardL"},{"display":[{"type":"image","transform":{"y":-6.446,"skX":-146.9135,"skY":-146.9135,"x":101.115},"name":"parts/legL","path":"parts/legL"}],"name":"legL"},{"display":[{"type":"image","transform":{"y":-10.5387,"skX":80.4531,"skY":80.4531,"x":122.955},"name":"parts/head","path":"parts/head"}],"name":"head"},{"display":[{"type":"image","transform":{"y":2.7905,"skX":-85.2356,"skY":-85.2356,"x":14.2173},"name":"parts/armR","path":"parts/armR"}],"name":"armR"},{"display":[{"type":"image","transform":{"y":-2.8771,"skX":98.2989,"skY":98.2989,"x":26.6948},"name":"parts/armL","path":"parts/armL"}],"name":"armL"},{"display":[{"type":"image","transform":{"y":16.0499,"skX":132.4995,"skY":132.4995,"x":32.3981},"name":"parts/clothes1","path":"parts/clothes1"}],"name":"clothes"},{"display":[{"type":"image","transform":{"y":-6.0098,"skX":-94.0239,"skY":-94.0239,"x":82.5819},"name":"parts/legR","path":"parts/legR"}],"name":"legR"},{"display":[{"type":"image","transform":{"y":0.2,"x":61.6},"name":"parts/beardR","path":"parts/beardR"}],"name":"beardR"},{"display":[{"type":"image","transform":{"y":-0.8219,"skX":82.7421,"skY":82.7421,"x":81.6504},"name":"parts/tailTip","path":"parts/tailTip"}],"name":"tailTip"},{"display":[{"type":"image","transform":{"y":0.6195,"skX":94.9653,"skY":94.9653,"x":-0.9572},"name":"parts/body","path":"parts/body"}],"name":"body"},{"display":[{"type":"image","transform":{"y":0.4,"x":0.3},"name":"parts/eyeL","path":"parts/eyeL"}],"name":"eyeL"},{"display":[{"type":"image","transform":{"y":5.0626,"skX":-88.1106,"skY":-88.1106,"x":23.0456},"name":"parts/handR","path":"parts/handR"}],"name":"handR"},{"display":[{"type":"image","transform":{"y":-1.4511,"skX":146.6156,"skY":146.6156,"x":34.7325},"name":"parts/handL","path":"parts/handL"}],"name":"handL"},{"display":[{"type":"image","transform":{"y":0.3975,"skX":-4.9086,"skY":-4.9086,"x":0.045},"name":"parts/hair","path":"parts/hair"}],"name":"hair"},{"display":[{"type":"image","transform":{"y":4.7392,"skX":13.9232,"skY":13.9232,"x":56.5203},"name":"parts/armUpperR","path":"parts/armUpperR"}],"name":"armUpperR"}]}],"animation":[{"bone":[{"frame":[{"tweenEasing":null,"transform":{},"duration":30}],"name":"root"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"transform":{},"duration":8},{"tweenEasing":0,"transform":{"skX":4.95,"skY":4.95,"x":-4},"duration":22},{"tweenEasing":null,"transform":{},"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"transform":{},"duration":12},{"tweenEasing":0,"transform":{"y":-2,"x":-2},"duration":18},{"tweenEasing":null,"transform":{},"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"transform":{},"duration":8},{"tweenEasing":0,"transform":{"y":-2},"duration":22},{"tweenEasing":null,"transform":{},"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":8},{"tweenEasing":0,"transform":{"y":-8.0574,"skX":-12.64,"skY":-12.64,"x":5.1348},"duration":22},{"tweenEasing":null,"transform":{},"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"transform":{},"duration":8},{"tweenEasing":0,"transform":{"y":-2},"duration":22},{"tweenEasing":null,"transform":{},"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"transform":{"skX":9.6205,"skY":9.6205},"duration":15},{"tweenEasing":0,"transform":{"skX":-1.4848,"skY":-1.4848},"duration":15},{"tweenEasing":null,"transform":{"skX":9.6205,"skY":9.6205},"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":15},{"tweenEasing":0,"transform":{"skX":5.44,"skY":5.44},"duration":15},{"tweenEasing":null,"transform":{},"duration":0}],"name":"beardR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":12},{"tweenEasing":0,"transform":{"y":-4,"x":2},"duration":18},{"tweenEasing":null,"transform":{},"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":30},{"tweenEasing":null,"transform":{},"duration":0}],"name":"handL"}],"frame":[],"ffd":[],"playTimes":0,"slot":[{"name":"armUpperL","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"handL","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"legL","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"body","frame":[{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}]},{"name":"clothes","frame":[{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":17},{"tweenEasing":null,"duration":1},{"tweenEasing":null,"duration":0}]},{"name":"hair","frame":[{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}]},{"name":"head","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"eyeL","frame":[{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}]},{"name":"legR","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"armUpperR","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"armR","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"handR","frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}]},{"name":"beardL","frame":[{"tweenEasing":0,"duration":7},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":1},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}]},{"name":"beardR","frame":[{"tweenEasing":0,"duration":7},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":1},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}]}],"name":"stand","duration":30},{"bone":[{"frame":[{"tweenEasing":null,"transform":{},"duration":20},{"tweenEasing":null,"transform":{},"duration":0}],"name":"root"},{"frame":[{"tweenEasing":0,"transform":{"y":-4},"duration":10},{"tweenEasing":0,"transform":{"y":-2},"duration":10},{"tweenEasing":null,"transform":{"y":-4},"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"transform":{"y":-14,"skX":-30,"skY":-30,"x":-6},"duration":10},{"tweenEasing":0,"transform":{"y":-2,"skX":30,"skY":30,"x":-3.9},"duration":10},{"tweenEasing":null,"transform":{"y":-14,"skX":-30,"skY":-30,"x":-6},"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"transform":{"y":14,"skX":45.5,"skY":45.5,"x":-6},"duration":10},{"tweenEasing":0,"transform":{"y":2,"skX":-22.15,"skY":-22.15},"duration":10},{"tweenEasing":null,"transform":{"y":14,"skX":45.5,"skY":45.5,"x":-6},"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"transform":{"y":28.4011,"skX":49.67,"skY":49.67,"x":-40.3442},"duration":10},{"tweenEasing":0,"transform":{"y":-8.9278,"skX":-19.23,"skY":-19.23,"x":-22.5206},"duration":10},{"tweenEasing":null,"transform":{"y":28.4011,"skX":49.67,"skY":49.67,"x":-40.3442},"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"transform":{"y":4},"duration":10},{"tweenEasing":0,"transform":{"y":2,"skX":2.95,"skY":2.95},"duration":10},{"tweenEasing":null,"transform":{"y":4},"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"transform":{"y":4,"skX":-21.2,"skY":-21.2},"duration":10},{"tweenEasing":0,"transform":{"y":2,"skX":30,"skY":30},"duration":10},{"tweenEasing":null,"transform":{"y":4,"skX":-21.2,"skY":-21.2},"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"transform":{"x":-8},"duration":10},{"tweenEasing":0,"transform":{"y":-6,"skX":-8.7,"skY":-8.7,"x":-12},"duration":10},{"tweenEasing":null,"transform":{"x":-8},"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"transform":{},"duration":5},{"tweenEasing":0,"transform":{"y":-2,"x":-2},"duration":5},{"tweenEasing":0,"transform":{},"duration":5},{"tweenEasing":0,"transform":{"y":-2,"x":-2},"duration":5},{"tweenEasing":null,"transform":{},"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"transform":{"y":-2.2012,"skX":-38.8,"skY":-38.8,"x":-13.0387},"duration":10},{"tweenEasing":0,"transform":{"y":-5.8451,"skX":38.55,"skY":38.55,"x":3.9043},"duration":10},{"tweenEasing":null,"transform":{"y":-2.2012,"skX":-38.8,"skY":-38.8,"x":-13.0387},"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"transform":{"y":0.5,"x":1.7},"duration":10},{"tweenEasing":0,"transform":{"y":-0.2773,"skX":-2.95,"skY":-2.95,"x":-4.1136},"duration":10},{"tweenEasing":null,"transform":{"y":0.5,"x":1.7},"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"transform":{"y":-0.5359,"x":8.9282},"duration":10},{"tweenEasing":0,"transform":{"y":10.0761,"skX":17.93,"skY":17.93,"x":-2.9969},"duration":10},{"tweenEasing":null,"transform":{"y":-0.5359,"x":8.9282},"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"transform":{},"duration":10},{"tweenEasing":0,"transform":{"y":4.1907,"skX":-2.95,"skY":-2.95,"x":-7.5499},"duration":10},{"tweenEasing":null,"transform":{},"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"transform":{},"duration":10},{"tweenEasing":0,"transform":{"y":-5.5174,"skX":6.04,"skY":6.04,"x":-3.5187},"duration":10},{"tweenEasing":null,"transform":{},"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"transform":{"y":9.9555,"skX":21.72,"skY":21.72,"x":-2.5742},"duration":5},{"tweenEasing":0,"transform":{"y":4.9989,"skX":31.7897,"skY":31.7897,"x":-2.7325},"duration":5},{"tweenEasing":0,"transform":{"y":0.0424,"skX":-15.63,"skY":-15.63,"x":-2.8907},"duration":5},{"tweenEasing":0,"transform":{"y":-5.611,"skX":-19.6672,"skY":-19.6672,"x":-0.2247},"duration":5},{"tweenEasing":null,"transform":{"y":9.9555,"skX":21.72,"skY":21.72,"x":-2.5742},"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":10},{"tweenEasing":0,"transform":{"y":1.6594,"skX":-10.45,"skY":-10.45,"x":-1.4456},"duration":10},{"tweenEasing":null,"transform":{},"duration":0}],"name":"beardR"},{"frame":[{"tweenEasing":0,"transform":{},"duration":10},{"tweenEasing":0,"transform":{"y":-7.1738,"skX":-2.95,"skY":-2.95,"x":1.1289},"duration":10},{"tweenEasing":null,"transform":{},"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"transform":{"y":2.0245,"skX":-45.48,"skY":-45.48,"x":-16.2659},"duration":10},{"tweenEasing":0,"transform":{"y":2.1665,"skX":-0.48,"skY":-0.48,"x":1.4963},"duration":10},{"tweenEasing":null,"transform":{"y":2.0245,"skX":-45.48,"skY":-45.48,"x":-16.2659},"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"transform":{"y":0.9027,"skX":15,"skY":15,"x":-1.6657},"duration":10},{"tweenEasing":0,"transform":{"y":3.3992,"skX":6.45,"skY":6.45,"x":-2.7762},"duration":10},{"tweenEasing":null,"transform":{"y":0.9027,"skX":15,"skY":15,"x":-1.6657},"duration":0}],"name":"handL"}],"frame":[],"ffd":[],"playTimes":0,"slot":[{"name":"tailTip","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"armUpperL","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"armL","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"handL","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"legL","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"body","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"tail","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"clothes","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"hair","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"head","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"eyeL","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"eyeR","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"legR","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"armUpperR","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"armR","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"handR","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"beardL","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]},{"name":"beardR","frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}]}],"name":"walk","duration":20},{"bone":[{"frame":[{"tweenEasing":null,"transform":{},"duration":5}],"name":"root"},{"frame":[{"tweenEasing":0,"transform":{"y":-66},"duration":5},{"tweenEasing":null,"transform":{"y":-66},"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"transform":{"y":1.0328,"skX":-27.69,"skY":-27.69,"x":1.1757},"duration":2},{"tweenEasing":0,"transform":{"y":0.6594,"skX":-27.69,"skY":-27.69,"x":-3.122},"duration":3},{"tweenEasing":null,"transform":{"y":1.0328,"skX":-27.69,"skY":-27.69,"x":1.1757},"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"transform":{"y":10,"skX":-24.65,"skY":-24.65},"duration":2},{"tweenEasing":0,"transform":{"y":9.7511,"skX":-23.1904,"skY":-23.1904,"x":-2.8651},"duration":3},{"tweenEasing":null,"transform":{"y":10,"skX":-24.65,"skY":-24.65},"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"transform":{"y":38.2873,"skX":-15.2954,"skY":-15.2954,"x":-20.6204},"duration":2},{"tweenEasing":0,"transform":{"y":37.7894,"skX":-15.2954,"skY":-15.2954,"x":-26.3507},"duration":3},{"tweenEasing":null,"transform":{"y":38.2873,"skX":-15.2954,"skY":-15.2954,"x":-20.6204},"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"transform":{"y":1.9,"skX":10,"skY":10,"x":3.6},"duration":5},{"tweenEasing":null,"transform":{"y":1.9,"skX":10,"skY":10,"x":3.6},"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"transform":{"y":4,"skX":15,"skY":15},"duration":2},{"tweenEasing":0,"transform":{"y":3.6266,"skX":15,"skY":15,"x":-4.2977},"duration":3},{"tweenEasing":null,"transform":{"y":4,"skX":15,"skY":15},"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"transform":{"y":-10,"skX":9.3457,"skY":9.3457,"x":-24},"duration":2},{"tweenEasing":0,"transform":{"y":-10,"skX":13.7283,"skY":13.7283,"x":-24},"duration":3},{"tweenEasing":null,"transform":{"y":-10,"skX":9.3457,"skY":9.3457,"x":-24},"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"transform":{"y":-4.5108,"x":-4.7682},"duration":2},{"tweenEasing":0,"transform":{"y":-4.8842,"x":-9.0659},"duration":3},{"tweenEasing":null,"transform":{"y":-4.5108,"x":-4.7682},"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"transform":{"y":2.5528,"skX":8.55,"skY":8.55,"x":-0.5979},"duration":5},{"tweenEasing":null,"transform":{"y":2.5528,"skX":8.55,"skY":8.55,"x":-0.5979},"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"transform":{"y":-8.7028,"skX":-10,"skY":-10,"x":8.8815},"duration":2},{"tweenEasing":0,"transform":{"y":-9.0585,"skX":-10,"skY":-10,"x":8.1208},"duration":3},{"tweenEasing":null,"transform":{"y":-7.7261,"skX":-10,"skY":-10,"x":9.013},"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"transform":{"y":6.3001,"skX":2.89,"skY":2.89,"x":2.1698},"duration":2},{"tweenEasing":0,"transform":{"y":-0.896,"skX":8.91,"skY":8.91,"x":0.6375},"duration":3},{"tweenEasing":null,"transform":{"y":6.3001,"skX":2.89,"skY":2.89,"x":2.1698},"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"transform":{"y":-6.3014,"skX":-10,"skY":-10,"x":8.9391},"duration":2},{"tweenEasing":0,"transform":{"y":-9.0585,"skX":-10,"skY":-10,"x":8.1208},"duration":3},{"tweenEasing":null,"transform":{"y":-6.3014,"skX":-10,"skY":-10,"x":8.9391},"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"transform":{"y":19.2267,"skX":-50.29,"skY":-50.29,"x":-19.7777},"duration":2},{"tweenEasing":0,"transform":{"y":19.2267,"skX":-58.5649,"skY":-58.5649,"x":-19.7777},"duration":3},{"tweenEasing":null,"transform":{"y":19.2267,"skX":-50.29,"skY":-50.29,"x":-19.7777},"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"transform":{"y":1.1591,"skX":-13.13,"skY":-13.13,"x":-8.0809},"duration":5},{"tweenEasing":null,"transform":{"y":1.1591,"skX":-13.13,"skY":-13.13,"x":-8.0809},"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"transform":{"y":6.7484,"skX":42.5,"skY":42.5,"x":-8.1489},"duration":2},{"tweenEasing":0,"transform":{"y":6.8295,"skX":50.23,"skY":50.23,"x":-8.0331},"duration":3},{"tweenEasing":null,"transform":{"y":6.7484,"skX":42.5,"skY":42.5,"x":-8.1489},"duration":0}],"name":"beardR"},{"frame":[{"tweenEasing":0,"transform":{"y":-6.0436,"skX":-10,"skY":-10,"x":-0.8181},"duration":2},{"tweenEasing":0,"transform":{"y":-2.7989,"skX":-10,"skY":-10,"x":3.8157},"duration":3},{"tweenEasing":null,"transform":{"y":-6.0436,"skX":-10,"skY":-10,"x":-0.8181},"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"transform":{"y":2.1665,"skX":-0.48,"skY":-0.48,"x":1.4963},"duration":5},{"tweenEasing":null,"transform":{"y":2.1665,"skX":-0.48,"skY":-0.48,"x":1.4963},"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"transform":{"y":-3.8513,"skX":-8.55,"skY":-8.55,"x":-14.1093},"duration":5},{"tweenEasing":null,"transform":{"y":-3.8513,"skX":-8.55,"skY":-8.55,"x":-14.1093},"duration":0}],"name":"handL"}],"frame":[],"ffd":[],"playTimes":0,"slot":[{"name":"tailTip","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armUpperL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armL","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"handL","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"legL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"body","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"tail","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"clothes","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"hair","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"head","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"eyeL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"eyeR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"legR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armUpperR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armR","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"handR","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"beardL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"beardR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]}],"name":"jump","duration":5},{"bone":[{"frame":[{"tweenEasing":null,"transform":{},"duration":5}],"name":"root"},{"frame":[{"tweenEasing":0,"transform":{"y":-66},"duration":5},{"tweenEasing":null,"transform":{"y":-66},"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"transform":{"y":8.9644,"skX":27.76,"skY":27.76,"x":6.1797},"duration":2},{"tweenEasing":0,"transform":{"y":8.576,"skX":27.76,"skY":27.76,"x":1.7095},"duration":3},{"tweenEasing":null,"transform":{"y":8.9644,"skX":27.76,"skY":27.76,"x":6.1797},"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"transform":{"y":10,"skX":-69.64,"skY":-69.64},"duration":2},{"tweenEasing":0,"transform":{"y":9.8705,"skX":-66.683,"skY":-66.683,"x":-1.49},"duration":3},{"tweenEasing":null,"transform":{"y":10,"skX":-69.64,"skY":-69.64},"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"transform":{"y":7.9,"skX":50.73,"skY":50.73,"x":22.6},"duration":2},{"tweenEasing":0,"transform":{"y":7.6411,"skX":50.73,"skY":50.73,"x":19.6199},"duration":3},{"tweenEasing":null,"transform":{"y":7.9,"skX":50.73,"skY":50.73,"x":22.6},"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"transform":{"y":-3.4,"skX":-8.73,"skY":-8.73,"x":11},"duration":5},{"tweenEasing":null,"transform":{"y":-3.4,"skX":-8.73,"skY":-8.73,"x":11},"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"transform":{"y":4,"skX":92.45,"skY":92.45},"duration":2},{"tweenEasing":0,"transform":{"y":4.2589,"skX":89.9735,"skY":89.9735,"x":2.9801},"duration":3},{"tweenEasing":null,"transform":{"y":4,"skX":92.45,"skY":92.45},"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"transform":{"y":-6.1,"skX":-18.47,"skY":-18.47,"x":-3.9},"duration":2},{"tweenEasing":0,"transform":{"y":-6.1,"skX":-22.44,"skY":-22.44,"x":-3.9},"duration":3},{"tweenEasing":null,"transform":{"y":-6.1,"skX":-18.47,"skY":-18.47,"x":-3.9},"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"transform":{"y":-4.8621,"x":-6.0066},"duration":2},{"tweenEasing":0,"transform":{"y":-4.4737,"x":-1.5365},"duration":3},{"tweenEasing":null,"transform":{"y":-4.8621,"x":-6.0066},"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"transform":{"y":5.8138,"skX":-53.9,"skY":-53.9,"x":4.3491},"duration":5},{"tweenEasing":null,"transform":{"y":5.8138,"skX":-53.9,"skY":-53.9,"x":4.3491},"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"transform":{"y":-4.6145,"skX":8.73,"skY":8.73,"x":-17.7606},"duration":2},{"tweenEasing":0,"transform":{"y":-3.0052,"skX":8.73,"skY":8.73,"x":-14.8289},"duration":3},{"tweenEasing":null,"transform":{"y":-4.6145,"skX":8.73,"skY":8.73,"x":-17.7606},"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"transform":{"y":-1.156,"skX":0.14,"skY":0.14,"x":2.7983},"duration":2},{"tweenEasing":0,"transform":{"y":1.7886,"skX":-0.83,"skY":-0.83,"x":1.817},"duration":3},{"tweenEasing":null,"transform":{"y":-1.156,"skX":0.14,"skY":0.14,"x":2.7983},"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"transform":{"y":-8.1532,"skX":8.73,"skY":8.73,"x":-13.0014},"duration":2},{"tweenEasing":0,"transform":{"y":-5.9369,"skX":8.73,"skY":8.73,"x":-13.2195},"duration":3},{"tweenEasing":null,"transform":{"y":-8.1532,"skX":8.73,"skY":8.73,"x":-13.0014},"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"transform":{"y":7.7817,"skX":-2.54,"skY":-2.54,"x":0.3247},"duration":2},{"tweenEasing":0,"transform":{"y":7.7817,"skX":25.1339,"skY":25.1339,"x":0.3247},"duration":3},{"tweenEasing":null,"transform":{"y":7.7817,"skX":-2.54,"skY":-2.54,"x":0.3247},"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"transform":{"y":-3.1965,"skX":-13.14,"skY":-13.14,"x":-11.2069},"duration":5},{"tweenEasing":null,"transform":{"y":-3.1965,"skX":-13.14,"skY":-13.14,"x":-11.2069},"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"transform":{"y":5.251,"skX":8.96,"skY":8.96,"x":-7.8667},"duration":2},{"tweenEasing":0,"transform":{"y":5.251,"skX":-6.04,"skY":-6.04,"x":-7.8667},"duration":3},{"tweenEasing":null,"transform":{"y":5.251,"skX":8.96,"skY":8.96,"x":-7.8667},"duration":0}],"name":"beardR"},{"frame":[{"tweenEasing":0,"transform":{"y":7.2382,"skX":-6.27,"skY":-6.27,"x":0.5909},"duration":2},{"tweenEasing":0,"transform":{"y":0.2075,"skX":-7.09,"skY":-7.09,"x":-6.3221},"duration":3},{"tweenEasing":null,"transform":{"y":7.2382,"skX":-6.27,"skY":-6.27,"x":0.5909},"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"transform":{"y":-1.3692,"skX":29.52,"skY":29.52,"x":-3.9387},"duration":5},{"tweenEasing":null,"transform":{"y":-1.3692,"skX":29.52,"skY":29.52,"x":-3.9387},"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"transform":{"y":1.4681,"skX":21.45,"skY":21.45,"x":-3.5985},"duration":5},{"tweenEasing":null,"transform":{"y":1.4681,"skX":21.45,"skY":21.45,"x":-3.5985},"duration":0}],"name":"handL"}],"frame":[],"ffd":[],"playTimes":0,"slot":[{"name":"tailTip","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armUpperL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armL","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"handL","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"legL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"body","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"tail","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"clothes","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"hair","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"head","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"eyeL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"eyeR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"legR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armUpperR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"armR","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"handR","frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}]},{"name":"beardL","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]},{"name":"beardR","frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}]}],"name":"fall","duration":5}],"defaultActions":[{"gotoAndPlay":"stand"}],"ik":[],"type":"Armature","slot":[{"color":{},"name":"tailTip","parent":"tailTip"},{"z":1,"color":{},"name":"armUpperL","parent":"armUpperL"},{"z":2,"color":{},"name":"armL","parent":"armL"},{"z":3,"color":{},"name":"handL","parent":"handL"},{"z":4,"color":{},"name":"legL","parent":"legL"},{"z":5,"color":{},"name":"body","parent":"body"},{"z":6,"color":{},"name":"tail","parent":"tail"},{"z":7,"color":{},"name":"clothes","parent":"clothes"},{"z":8,"color":{},"name":"hair","parent":"hair"},{"z":9,"color":{},"name":"head","parent":"head"},{"z":10,"color":{},"name":"eyeL","parent":"eyeL"},{"z":11,"color":{},"name":"eyeR","parent":"eyeR"},{"z":12,"color":{},"name":"legR","parent":"legR"},{"z":13,"color":{},"name":"armUpperR","parent":"armUpperR"},{"z":14,"color":{},"name":"armR","parent":"armR"},{"z":15,"color":{},"name":"handR","parent":"handR"},{"z":16,"color":{},"name":"beardL","parent":"beardL"},{"z":17,"color":{},"name":"beardR","parent":"beardR"}],"bone":[{"transform":{},"name":"root"},{"length":150,"parent":"root","transform":{"y":50.5419,"skX":-94.9653,"skY":-94.9653,"x":26.0941},"name":"body"},{"length":120,"parent":"body","transform":{"y":46.9,"skX":-156.0107,"skY":-156.0107,"x":-95.6182},"name":"legR"},{"length":150,"parent":"body","transform":{"y":31.3927,"skX":159.9921,"skY":159.9921,"x":80.5853},"name":"armUpperR"},{"length":150,"parent":"body","transform":{"y":-60.2758,"skX":-154.3312,"skY":-154.3312,"x":-71.0496},"name":"legL"},{"length":150,"parent":"body","transform":{"y":-5.8037,"skX":11.4957,"skY":11.4957,"x":163.1145},"name":"head"},{"length":70,"parent":"body","transform":{"y":-93.6047,"skX":-171.7742,"skY":-171.7742,"x":74.4813},"name":"armUpperL"},{"length":250,"parent":"body","transform":{"y":70.127,"skX":79.7425,"skY":79.7425,"x":-117.1092},"name":"tail"},{"length":80,"parent":"body","transform":{"y":-31.7416,"skX":-37.5342,"skY":-37.5342,"x":1.423},"name":"clothes"},{"length":60,"parent":"armUpperL","transform":{"y":2.2256,"skX":30.7088,"skY":30.7088,"x":66.7632},"name":"armL"},{"transform":{"y":-23.9957,"skX":80.4531,"skY":80.4531,"x":140.2628},"name":"eyeR","parent":"head"},{"length":150,"parent":"tail","transform":{"y":-3.1008,"skX":-37.5192,"skY":-37.5192,"x":257.8621},"name":"tailTip"},{"transform":{"y":-101.188,"skX":80.4531,"skY":80.4531,"x":133.7701},"name":"eyeL","parent":"head"},{"length":80,"parent":"head","transform":{"y":-133.6248,"skX":-105.5036,"skY":-105.5036,"x":7.4588},"name":"beardL"},{"length":50,"parent":"armUpperR","transform":{"y":0.5285,"skX":35.2088,"skY":35.2088,"x":138.7492},"name":"armR"},{"length":80,"parent":"head","transform":{"y":-35.857,"skX":80.4531,"skY":80.4531,"x":23.2753},"name":"beardR"},{"length":50,"parent":"head","transform":{"y":80.6309,"skX":86.9099,"skY":86.9099,"x":104.8249},"name":"hair"},{"length":40,"parent":"armR","transform":{"y":1.1079,"skX":17.875,"skY":17.875,"x":43.3874},"name":"handR"},{"length":80,"parent":"armL","transform":{"y":-0.4273,"skX":4.4133,"skY":4.4133,"x":66.6309},"name":"handL"}],"name":"Dragon"}],"name":"Dragon","isGlobal":0} \ No newline at end of file diff --git a/dragonbones-core/src/test/resources/Dragon/Dragon_tex.json b/dragonbones-core/src/test/resources/Dragon/Dragon_tex.json new file mode 100644 index 0000000..07cc681 --- /dev/null +++ b/dragonbones-core/src/test/resources/Dragon/Dragon_tex.json @@ -0,0 +1 @@ +{"SubTexture":[{"height":209,"y":234,"frameWidth":112,"frameX":0,"frameHeight":210,"frameY":0,"width":111,"name":"parts/tailTip","x":456},{"x":340,"y":234,"width":112,"name":"parts/armUpperL","height":86},{"x":373,"y":859,"width":48,"name":"parts/armL","height":80},{"x":1,"y":922,"width":96,"name":"parts/handL","height":78},{"height":180,"y":677,"frameWidth":204,"frameX":0,"frameHeight":180,"frameY":0,"width":203,"name":"parts/legL","x":238},{"height":347,"y":397,"frameWidth":236,"frameX":0,"frameHeight":348,"frameY":0,"width":235,"name":"parts/body","x":1},{"x":238,"y":397,"width":216,"name":"parts/tail","height":278},{"x":1,"y":746,"width":208,"name":"parts/clothes1","height":174},{"x":443,"y":677,"width":124,"name":"parts/hair","height":282},{"height":394,"y":1,"frameWidth":338,"frameX":0,"frameHeight":394,"frameY":0,"width":337,"name":"parts/head","x":1},{"x":459,"y":961,"width":28,"name":"parts/eyeL","height":46},{"height":58,"y":961,"frameWidth":38,"frameX":0,"frameHeight":58,"frameY":0,"width":37,"name":"parts/eyeR","x":420},{"height":231,"y":1,"frameWidth":180,"frameX":0,"frameHeight":232,"frameY":0,"width":180,"name":"parts/legR","x":340},{"x":211,"y":859,"width":160,"name":"parts/armUpperR","height":94},{"height":77,"y":941,"frameWidth":46,"frameX":0,"frameHeight":78,"frameY":0,"width":45,"name":"parts/armR","x":373},{"x":340,"y":322,"width":98,"name":"parts/handR","height":58},{"height":36,"y":955,"frameWidth":120,"frameX":0,"frameHeight":36,"frameY":0,"width":119,"name":"parts/beardL","x":237},{"x":99,"y":955,"width":136,"name":"parts/beardR","height":36}],"width":1024,"name":"Dragon","imagePath":"Dragon_tex.png","height":1024} \ No newline at end of file diff --git a/dragonbones-core/src/test/resources/Dragon/Dragon_tex.png b/dragonbones-core/src/test/resources/Dragon/Dragon_tex.png new file mode 100644 index 0000000..02cc390 Binary files /dev/null and b/dragonbones-core/src/test/resources/Dragon/Dragon_tex.png differ diff --git a/dragonbones-core/src/test/resources/Dragon/library/texture.json b/dragonbones-core/src/test/resources/Dragon/library/texture.json new file mode 100644 index 0000000..c65cedf --- /dev/null +++ b/dragonbones-core/src/test/resources/Dragon/library/texture.json @@ -0,0 +1 @@ +{"imagePath":"texture.png","name":"Dragon","SubTexture":[{"height":209,"y":234,"frameHeight":210,"frameY":0,"frameX":0,"frameWidth":112,"width":111,"name":"parts/tailTip","x":456},{"x":340,"y":234,"width":112,"name":"parts/armUpperL","height":86},{"x":373,"y":859,"width":48,"name":"parts/armL","height":80},{"x":1,"y":922,"width":96,"name":"parts/handL","height":78},{"height":180,"y":677,"frameHeight":180,"frameY":0,"frameX":0,"frameWidth":204,"width":203,"name":"parts/legL","x":238},{"height":347,"y":397,"frameHeight":348,"frameY":0,"frameX":0,"frameWidth":236,"width":235,"name":"parts/body","x":1},{"x":238,"y":397,"width":216,"name":"parts/tail","height":278},{"x":1,"y":746,"width":208,"name":"parts/clothes1","height":174},{"x":443,"y":677,"width":124,"name":"parts/hair","height":282},{"height":394,"y":1,"frameHeight":394,"frameY":0,"frameX":0,"frameWidth":338,"width":337,"name":"parts/head","x":1},{"x":459,"y":961,"width":28,"name":"parts/eyeL","height":46},{"height":58,"y":961,"frameHeight":58,"frameY":0,"frameX":0,"frameWidth":38,"width":37,"name":"parts/eyeR","x":420},{"height":231,"y":1,"frameHeight":232,"frameY":0,"frameX":0,"frameWidth":180,"width":180,"name":"parts/legR","x":340},{"x":211,"y":859,"width":160,"name":"parts/armUpperR","height":94},{"height":77,"y":941,"frameHeight":78,"frameY":0,"frameX":0,"frameWidth":46,"width":45,"name":"parts/armR","x":373},{"x":340,"y":322,"width":98,"name":"parts/handR","height":58},{"height":36,"y":955,"frameHeight":36,"frameY":0,"frameX":0,"frameWidth":120,"width":119,"name":"parts/beardL","x":237},{"x":99,"y":955,"width":136,"name":"parts/beardR","height":36}]} \ No newline at end of file diff --git a/dragonbones-core/src/test/resources/Dragon/library/texture.png b/dragonbones-core/src/test/resources/Dragon/library/texture.png new file mode 100644 index 0000000..709960c Binary files /dev/null and b/dragonbones-core/src/test/resources/Dragon/library/texture.png differ diff --git a/dragonbones-core/src/test/resources/NewDragon/NewDragon.atlas b/dragonbones-core/src/test/resources/NewDragon/NewDragon.atlas new file mode 100644 index 0000000..53ba7c1 --- /dev/null +++ b/dragonbones-core/src/test/resources/NewDragon/NewDragon.atlas @@ -0,0 +1,209 @@ + +NewDragon.png +size: 1024,1024 +format: RGBA8888 +filter: Linear,Linear +repeat: none +author + rotate: true + xy: 195, 309 + size: 372, 56 + orig: 372, 56 + offset: 0, 0 + index: -1 +bozishang + rotate: false + xy: 2, 2 + size: 301, 230 + orig: 301, 230 + offset: 0, 0 + index: -1 +bozixia + rotate: true + xy: 253, 418 + size: 263, 194 + orig: 263, 194 + offset: 0, 0 + index: -1 +chibangL1 + rotate: false + xy: 455, 240 + size: 95, 62 + orig: 95, 62 + offset: 0, 0 + index: -1 +chibangL2 + rotate: false + xy: 327, 749 + size: 270, 273 + orig: 270, 273 + offset: 0, 0 + index: -1 +chibangR1 + rotate: true + xy: 575, 638 + size: 109, 73 + orig: 109, 73 + offset: 0, 0 + index: -1 +chibangR2 + rotate: false + xy: 2, 683 + size: 323, 339 + orig: 323, 339 + offset: 0, 0 + index: -1 +chujiao + rotate: true + xy: 449, 419 + size: 106, 112 + orig: 106, 112 + offset: 0, 0 + index: -1 +dabiL + rotate: false + xy: 392, 2 + size: 62, 68 + orig: 62, 68 + offset: 0, 0 + index: -1 +dabiR + rotate: true + xy: 456, 2 + size: 87, 55 + orig: 87, 55 + offset: 0, 0 + index: -1 +datuiL + rotate: false + xy: 305, 2 + size: 85, 68 + orig: 85, 68 + offset: 0, 0 + index: -1 +datuiR + rotate: false + xy: 455, 304 + size: 86, 113 + orig: 86, 113 + offset: 0, 0 + index: -1 +er + rotate: true + xy: 451, 629 + size: 118, 122 + orig: 118, 122 + offset: 0, 0 + index: -1 +jianbang + rotate: false + xy: 449, 527 + size: 119, 100 + orig: 119, 100 + offset: 0, 0 + index: -1 +jiaoL + rotate: false + xy: 447, 169 + size: 97, 69 + orig: 97, 69 + offset: 0, 0 + index: -1 +jiaoR + rotate: false + xy: 746, 648 + size: 91, 105 + orig: 91, 105 + offset: 0, 0 + index: -1 +shenti + rotate: false + xy: 599, 755 + size: 239, 267 + orig: 239, 267 + offset: 0, 0 + index: -1 +shouL + rotate: false + xy: 447, 91 + size: 75, 76 + orig: 75, 76 + offset: 0, 0 + index: -1 +shouR + rotate: false + xy: 650, 650 + size: 94, 103 + orig: 94, 103 + offset: 0, 0 + index: -1 +tail + rotate: true + xy: 2, 234 + size: 447, 191 + orig: 447, 191 + offset: 0, 0 + index: -1 +tou + rotate: false + xy: 840, 809 + size: 176, 213 + orig: 176, 213 + offset: 0, 0 + index: -1 +tou1 + rotate: true + xy: 195, 236 + size: 71, 46 + orig: 71, 46 + offset: 0, 0 + index: -1 +toujiaoL + rotate: true + xy: 840, 700 + size: 107, 153 + orig: 107, 153 + offset: 0, 0 + index: -1 +toujiaoR + rotate: false + xy: 253, 260 + size: 200, 156 + orig: 200, 156 + offset: 0, 0 + index: -1 +xiaobiL + rotate: false + xy: 839, 653 + size: 104, 45 + orig: 104, 45 + offset: 0, 0 + index: -1 +xiaobiR + rotate: false + xy: 327, 686 + size: 122, 61 + orig: 122, 61 + offset: 0, 0 + index: -1 +xiaotuiL + rotate: true + xy: 524, 100 + size: 67, 31 + orig: 67, 31 + offset: 0, 0 + index: -1 +xiaotuiR + rotate: false + xy: 945, 633 + size: 61, 65 + orig: 61, 65 + offset: 0, 0 + index: -1 +zui + rotate: true + xy: 305, 72 + size: 186, 140 + orig: 186, 140 + offset: 0, 0 + index: -1 diff --git a/dragonbones-core/src/test/resources/NewDragon/NewDragon.json b/dragonbones-core/src/test/resources/NewDragon/NewDragon.json new file mode 100644 index 0000000..e6e90d9 --- /dev/null +++ b/dragonbones-core/src/test/resources/NewDragon/NewDragon.json @@ -0,0 +1 @@ +{"skeleton":{"hash":"SInqWiGuNCBY0iY6UU64SzuOo5w","spine":"3.2.01","width":648.36,"height":676.96,"images":"./image/"},"bones":[{"name":"root"},{"name":"IK_Lhand","parent":"root","x":144.22,"y":158.18,"color":"ff3f00ff"},{"name":"IK_Rhand","parent":"root","x":-13.64,"y":169.81,"color":"ff3f00ff"},{"name":"bone","parent":"root","x":45.23,"y":95.63},{"name":"shenti","parent":"bone","length":209.27,"rotation":106.65,"y":4.69},{"name":"chibangR1","parent":"shenti","length":76.33,"rotation":93.15,"x":166.51,"y":34.93},{"name":"bone2","parent":"chibangR1","length":148.46,"rotation":-85.15,"x":58.47,"y":-8.06},{"name":"bone3","parent":"bone2","length":95.22,"rotation":-26.5,"x":148.48,"y":0.57},{"name":"bone4","parent":"bone3","length":123,"rotation":74.86,"x":95.08,"y":1.15},{"name":"bone5","parent":"bone4","length":142.68,"rotation":50.1,"x":123,"y":0.09},{"name":"bone6","parent":"bone3","length":79.56,"rotation":127.12,"x":75.77,"y":20.28},{"name":"bone7","parent":"bone6","length":93.07,"rotation":35.04,"x":79.56,"y":-0.34},{"name":"bone8","parent":"bone3","length":62.03,"rotation":147.55,"x":54.96,"y":14.64},{"name":"bone9","parent":"bone8","length":60.68,"rotation":31.02,"x":62.03,"y":0.29},{"name":"bone10","parent":"bone9","length":82.09,"rotation":22.38,"x":60.68,"y":-0.28},{"name":"weiba1","parent":"bone","length":137.24,"rotation":-165.01,"x":-2.34,"y":1.16},{"name":"bone11","parent":"weiba1","length":47.48,"rotation":-24.37,"x":51.86,"y":-57.38},{"name":"bone12","parent":"weiba1","length":32.41,"rotation":-52.31,"x":100.31,"y":-46.38},{"name":"bone13","parent":"weiba1","length":26.78,"rotation":-62.99,"x":128.5,"y":-45.26},{"name":"weiba2","parent":"weiba1","length":66.37,"rotation":-27.7,"x":141.22,"y":-0.91},{"name":"bone14","parent":"weiba2","length":21.16,"rotation":-52.56,"x":37.58,"y":-33.74},{"name":"bone26","parent":"weiba2","length":62.39,"rotation":-22.66,"x":67.21},{"name":"bone15","parent":"bone26","length":14.13,"rotation":-64.01,"x":19.07,"y":-26.6},{"name":"bone16","parent":"bone26","length":17.04,"rotation":-111.95,"x":42.55,"y":-24.63},{"name":"weiba3","parent":"bone26","length":56.85,"rotation":-81.13,"x":63.75,"y":-1.25},{"name":"bone17","parent":"weiba3","length":12.36,"rotation":-60.23,"x":32.65,"y":-18.49},{"name":"bone18","parent":"weiba3","length":14.54,"rotation":-48.63,"x":48.15,"y":-18.65},{"name":"weiba4","parent":"weiba3","length":52.76,"rotation":65.44,"x":50.54,"y":-0.9},{"name":"bone19","parent":"weiba4","length":11.04,"rotation":-97.79,"x":-5.44,"y":-20.7},{"name":"bone20","parent":"weiba4","length":9.59,"rotation":-88.32,"x":14.2,"y":-26.57},{"name":"bone21","parent":"weiba4","length":10.62,"rotation":-1.16,"x":40.58,"y":-18.03},{"name":"weiba5","parent":"weiba4","length":50.66,"rotation":65.02,"x":54.11,"y":2.34},{"name":"bone22","parent":"weiba5","length":36.48,"rotation":46.24,"x":41.93,"y":15.26},{"name":"bone23","parent":"weiba5","length":24.3,"rotation":31.92,"x":71.69,"y":8.06},{"name":"bone24","parent":"bone23","length":34.97,"rotation":33.88,"x":25.26,"y":0.07},{"name":"bone25","parent":"weiba5","length":35.92,"rotation":-7.73,"x":78.32,"y":-6.5},{"name":"bozixia","parent":"shenti","length":96.53,"rotation":-54.16,"x":203.63,"y":2.93},{"name":"bozishang","parent":"bozixia","length":62.92,"rotation":-35.23,"x":86.13,"y":3.76},{"name":"chibangL1","parent":"shenti","length":60.7,"rotation":54.67,"x":116.89,"y":-56.72},{"name":"chibangL3","parent":"chibangL1","length":270.66,"rotation":-43.37,"x":56.91,"y":0.22},{"name":"chujiao","parent":"bozishang","length":86.22,"rotation":130.37,"x":25.11,"y":-26.29},{"name":"dabiL","parent":"shenti","length":41.18,"rotation":-165.85,"x":103.87,"y":-47.07},{"name":"xiaobiL","parent":"dabiL","length":62.83,"rotation":46.38,"x":46.85,"y":-1.88},{"name":"jianbang","parent":"shenti","length":25.92,"rotation":112.65,"x":140.03,"y":-0.14},{"name":"dabiR","parent":"jianbang","length":74.82,"rotation":-15.05,"x":24.35,"y":7.44},{"name":"xiaobiR","parent":"dabiR","length":62.25,"rotation":140.33,"x":70.15,"y":-1.98},{"name":"datuiL","parent":"bone","length":65.8,"rotation":-41.71,"x":3.53,"y":-3.53},{"name":"datuiR","parent":"bone","length":76.81,"rotation":-104.57,"x":-40.02,"y":16.48},{"name":"er","parent":"bozishang","length":110.18,"rotation":109.1,"x":46.71,"y":-8.35},{"name":"jiaoL","parent":"root","length":45.47,"rotation":-73.82,"x":42.81,"y":49.74},{"name":"jiaoR","parent":"root","length":63.84,"rotation":-101.43,"x":-53.15,"y":75.74},{"name":"shouL","parent":"xiaobiL","length":44.79,"rotation":15.4,"x":61.41,"y":0.67},{"name":"shouR","parent":"xiaobiR","length":83.18,"rotation":-35,"x":61.96,"y":0.1},{"name":"tou","parent":"bozishang","length":84.76,"rotation":-17.89,"x":55.05,"y":2.61},{"name":"tou1","parent":"tou","length":64.76,"rotation":162.1,"x":14.79,"y":36.22},{"name":"toujiaoL","parent":"tou","length":129.94,"rotation":124.1,"x":70.29,"y":32.52},{"name":"toujiaoR","parent":"tou","length":205.58,"rotation":131.51,"x":41.95,"y":40.46},{"name":"xiaotuiL","parent":"datuiL","length":53.81,"rotation":-141.04,"x":65.75,"y":-1.86},{"name":"xiaotuiR","parent":"datuiR","length":52.5,"rotation":-119.99,"x":75.98,"y":-1.61},{"name":"zui","parent":"bozishang","length":160.13,"rotation":-66.19,"x":57.56,"y":-28.97}],"ik":[{"name":"IK_L","bones":["dabiL","xiaobiL"],"target":"IK_Lhand","mix":0},{"name":"IK_R","bones":["dabiR","xiaobiR"],"target":"IK_Rhand","mix":0}],"slots":[{"name":"tail","bone":"weiba1","attachment":"tail"},{"name":"chibangL2","bone":"chibangL3","attachment":"chibangL2"},{"name":"chibangL1","bone":"chibangL1","attachment":"chibangL1"},{"name":"dabiL","bone":"dabiL","attachment":"dabiL"},{"name":"xiaobiL","bone":"xiaobiL","attachment":"xiaobiL"},{"name":"shouL","bone":"shouL","attachment":"shouL"},{"name":"jiaoL","bone":"jiaoL","attachment":"jiaoL"},{"name":"xiaotuiL","bone":"xiaotuiL","attachment":"xiaotuiL"},{"name":"datuiL","bone":"datuiL","attachment":"datuiL"},{"name":"shenti","bone":"shenti","attachment":"shenti"},{"name":"bozixia","bone":"bozixia","attachment":"bozixia"},{"name":"bozishang","bone":"bozishang","attachment":"bozishang"},{"name":"toujiaoL","bone":"toujiaoL","attachment":"toujiaoL"},{"name":"tou1","bone":"tou1","attachment":"tou1"},{"name":"chujiao","bone":"chujiao","attachment":"chujiao"},{"name":"er","bone":"er","attachment":"er"},{"name":"zui","bone":"zui","attachment":"zui"},{"name":"toujiaoR","bone":"toujiaoR","attachment":"toujiaoR"},{"name":"tou","bone":"tou","attachment":"tou"},{"name":"jiaoR","bone":"jiaoR","attachment":"jiaoR"},{"name":"xiaotuiR","bone":"xiaotuiR","attachment":"xiaotuiR"},{"name":"datuiR","bone":"datuiR","attachment":"datuiR"},{"name":"chibangR2","bone":"bone2","attachment":"chibangR2"},{"name":"chibangR1","bone":"chibangR1","attachment":"chibangR1"},{"name":"jianbang","bone":"jianbang","attachment":"jianbang"},{"name":"dabiR","bone":"dabiR","attachment":"dabiR"},{"name":"xiaobiR","bone":"xiaobiR","attachment":"xiaobiR"},{"name":"shouR","bone":"shouR","attachment":"shouR"},{"name":"author","bone":"root","attachment":"author"}],"skins":{"default":{"author":{"author":{"x":3.27,"y":-61.59,"width":372,"height":56}},"bozishang":{"bozishang":{"type":"mesh","uvs":[0.48093,0.53756,0.40112,0.5215,0.32131,0.48936,0.23024,0.42642,0.15861,0.3983,0.05731,0.37553,0,0.37955,0,0.35678,0.05628,0.32464,0.14838,0.30723,0.26298,0.30188,0.36326,0.31527,0.26503,0.26304,0.17396,0.22287,0.10244,0.2058,0.12893,0.17466,0.24047,0.15457,0.33768,0.1452,0.27117,0.0903,0.19545,0.03807,0.17498,0.022,0.18624,0.00325,0.308,0.00861,0.40112,0.0461,0.52084,0.14118,0.47966,0.09482,0.42635,0.04892,0.35347,0.0021,0.43965,0,0.50889,0.01844,0.57927,0.0456,0.64568,0.10503,0.59247,0.02334,0.61128,0.01626,0.75836,0.11461,0.85,0.19883,0.92963,0.31161,1,0.47063,1,0.81729,0.84241,1,0.79396,1,0.80641,0.80932,0.58408,0.6915,0.43385,0.59966,0.53881,0.40723,0.45097,0.17942,0.61547,0.28392,0.45539,0.36353,0.53383,0.23206,0.56338,0.20534,0.70018,0.17506],"triangles":[19,21,22,20,21,19,28,26,27,18,19,22,29,26,28,25,29,30,25,26,29,34,31,33,33,31,32,24,25,30,24,30,31,23,18,22,45,17,23,17,18,23,50,31,34,24,45,23,49,24,31,49,31,50,13,15,16,14,15,13,48,24,49,45,24,48,12,16,17,13,16,12,46,49,50,48,49,46,11,17,45,12,17,11,47,45,48,44,47,48,11,45,47,5,8,9,7,8,5,6,7,5,4,9,10,5,9,4,46,44,48,3,4,10,11,3,10,2,11,47,2,3,11,1,2,47,0,1,47,44,0,47,37,42,44,0,44,42,43,0,42,50,34,35,46,50,35,46,35,36,37,44,36,36,44,46,41,42,37,41,37,38,39,41,38,40,41,39],"vertices":[-32.75999,58.56,-54.61,69.21,-75.36,83.39,-97.25,105.33,-115.93,117.9,-143.5,131.94,-160.25,136.17,-158.69,141.17,-140.32,143.21,-112.66,138.82,-79.35,129.77,-51.43,117.89,-76.11,138.12,-99.56,155.07,-116.33,165.43,-109.21,169.67,-75.78,164.14,-47.2,157.53,-62.58,175.52,-80.78,193.75,-85.57,199.1,-81.06,202.22,-46.42,190.18,-22.2,173.64,5.72,142.07,-2.56,154.61,-13.58,171.28,-29.06,184.79,-6.71,179.93,10.25,169.43,28.18,158.32,44.08,138.88,34.34999,161.57,40.24,161.45,74.86,125.72,94.14,96.86,105.48,71.37999,121.02,26.96,98.03,-47.12,84.94,-89.31,25.71,-70.94,6.35,-40.46,-24.82,8.64,-50.52,49.12,-7.23,82.01999,-16.95999,139.9,23.2,102.28,-28.24,99.07,3.26,120.95,13.58,124.18,54.97,118.63],"hull":44,"edges":[0,2,2,4,4,6,6,8,8,10,10,12,12,14,14,16,16,18,18,20,20,22,22,24,24,26,26,28,28,30,30,32,32,34,34,36,36,38,38,40,40,42,42,44,44,46,46,48,52,54,54,56,60,62,62,64,64,66,66,68,68,70,70,72,72,74,78,80,0,86,88,0,34,90,88,92,22,94,94,88,2,94,90,96,96,92,94,96,48,98,98,92,96,98,62,100,22,4,20,6,18,8,16,10,32,26,34,24,90,22,44,36,46,34,56,52,60,48,62,98,100,92,68,100,84,86,80,82,82,84,74,76,76,78,48,50,50,52,56,58,58,60,50,58],"width":301,"height":230}},"bozixia":{"bozixia":{"type":"mesh","uvs":[0.43834,0.72029,0.38736,0.79202,0.31233,0.84027,0.26327,0.90026,0.22575,0.99938,0.20747,0.99677,0.2017,0.93939,0.21228,0.82593,0.23922,0.73334,0.27,0.67335,0.30271,0.63422,0.23825,0.68508,0.18727,0.75159,0.14302,0.86114,0.1257,0.85592,0.14206,0.70986,0.18631,0.57815,0.23248,0.51164,0.17476,0.54685,0.10839,0.63813,0.07087,0.74507,0.05644,0.72029,0.07472,0.54815,0.1132,0.45165,0.14783,0.39035,0.18535,0.35514,0.11608,0.40209,0.06895,0.44512,0.0093,0.54293,0,0.54163,0.00546,0.41904,0.05163,0.3121,0.09973,0.23647,0.16514,0.18561,0.20939,0.16474,0.13821,0.17517,0.07087,0.20647,6.5E-4,0.25342,6.5E-4,0.21299,0.04297,0.13866,0.10165,0.08649,0.16611,0.04346,0.24884,0.01607,0.31329,0,0.523,0,0.64806,0.03824,0.76926,0.10475,0.82217,0.15561,1,0.26907,1,0.85462,0.43738,0.77507],"triangles":[34,41,42,40,41,34,35,40,34,39,40,35,36,39,35,38,39,36,37,38,36,25,33,34,32,33,25,31,32,25,25,26,31,30,31,26,27,30,26,43,17,34,25,34,17,24,25,17,23,24,17,28,29,30,27,28,30,18,23,17,22,23,18,42,43,34,44,10,17,16,17,10,19,22,18,10,11,16,11,15,16,22,19,21,20,21,19,43,44,17,45,10,44,46,10,45,47,10,46,0,10,47,12,15,11,0,9,10,0,1,9,1,8,9,0,47,48,2,7,8,1,2,8,0,48,49,50,0,49,15,12,14,13,14,12,3,7,2,6,7,3,4,5,6,3,4,6],"vertices":[-37.2,33.3,-56.4,35.46,-75.83999,45.41,-92.93,48.56,-114.19,44.68,-116.72,48.8,-108.81,56.78,-89.66,67.98,-71.1,73.3,-56.94,73.97,-45.68,71.76,-63.83,79.19999,-82.23,81.98,-106.17,78.26999,-108.14,82.49,-83.05,96.34,-55.69,102.67,-38.06,100.9,-52.73,108.78,-77.4,111.84,-99.87,107.03,-98.37,112.97,-68.94999,129.49,-47.94,132.87,-32.96,132.89,-21.53,129.22,-39.84999,138.12,-54.02,142.87,-78.62999,143.75,-79.92,145.85,-60.18,159.19,-36.33,162.2,-16.98,161.1,1.30999,153.46,11.61,146.7,-1.39,160.32,-16.99,170.66,-35.46,179.77,-29.24,184.54,-11.03,184.5,6.39,178.42,23.34,170.06,40.8,156.04,53.6,144.49,87.19,100.74,101.33,70.14,110.51,37,111.16,19.95,122.18,-30.54,32.08,-99.72,-45.78,27.03],"hull":51,"edges":[0,2,2,4,4,6,6,8,8,10,10,12,12,14,14,16,16,18,18,20,20,22,22,24,24,26,26,28,28,30,30,32,32,34,34,36,36,38,38,40,40,42,42,44,44,46,46,48,48,50,50,52,52,54,54,56,56,58,58,60,60,62,62,64,64,66,66,68,68,70,70,72,72,74,74,76,76,78,78,80,80,82,82,84,84,86,86,88,88,90,90,92,92,94,94,96,96,98,98,100,0,100],"width":263,"height":194}},"chibangL1":{"chibangL1":{"x":31.02,"y":1.53,"rotation":-161.33,"width":95,"height":62}},"chibangL2":{"chibangL2":{"x":130.75,"y":-1.03,"rotation":-117.95,"width":270,"height":273}},"chibangR1":{"chibangR1":{"x":36.43,"y":-7.51,"rotation":160.17,"width":109,"height":73}},"chibangR2":{"chibangR2":{"type":"weightedmesh","uvs":[0,0.40391,0,0.30686,0.08034,0.13778,0.19389,0.08185,0.29847,0.03034,0.43156,0.01273,0.53323,0.08318,0.61885,0.10006,0.69406,0.11488,0.74951,0.09198,0.74397,0.04267,0.72918,0,0.80682,0,0.89185,0.06556,0.91958,0.18357,0.89555,0.24874,0.83187,0.32677,0.7935,0.37379,0.78348,0.49741,0.80703,0.60679,0.83548,0.68339,0.87978,0.71579,0.94623,0.71645,1,0.76561,1,0.85227,0.91325,0.90881,0.84786,0.89993,0.79599,0.92257,0.74027,0.84934,0.62566,0.86343,0.63675,0.94445,0.66448,1,0.60717,1,0.53878,0.93564,0.53844,0.87724,0.53809,0.81754,0.45312,0.68447,0.38621,0.63988,0.36388,0.66957,0.33729,0.70491,0.30217,0.79122,0.2652,0.77889,0.24856,0.69082,0.26704,0.58867,0.33938,0.56399,0.34243,0.44449,0.28362,0.36141,0.19261,0.32872,0.10278,0.32911,0.0489,0.4074,0.03043,0.4918,0,0.49708,0.36241,0.52773,0.433,0.39962,0.47496,0.35601,0.66949,0.25607,0.61799,0.22518,0.54838,0.21519,0.48926,0.15977,0.42633,0.11888,0.34909,0.11525,0.23848,0.16885,0.1641,0.22246,0.41554,0.55583,0.47253,0.42184,0.50378,0.38506,0.59017,0.33427,0.68301,0.30449,0.70415,0.30975,0.68301,0.32814,0.63797,0.34741,0.59845,0.41221,0.55341,0.45162,0.51297,0.63553,0.59891,0.7905,0.57481,0.6385,0.61728,0.47885,0.63334,0.43073,0.66892,0.38262,0.7045,0.36293,0.66663,0.50618,0.72172,0.67896,0.72172,0.7227,0.75615,0.74676,0.7814,0.78175,0.77566,0.81893,0.5719,0.30621,0.70483,0.626,0.40205,0.21656,0.31258,0.32028,0.4397,0.28856,0.37562,0.36182,0.22996,0.26585,0.37465,0.16413,0.29613,0.21933,0.352,0.27459,0.40862,0.32409,0.55931,0.40099,0.51935,0.43908,0.47455,0.6041],"triangles":[32,30,31,32,33,30,33,29,30,33,34,29,34,35,29,35,74,29,29,74,28,74,35,73,74,73,75,36,73,35,81,74,75,36,99,73,72,73,99,73,72,75,76,75,72,99,98,72,72,71,76,72,98,97,80,78,79,80,77,78,76,71,77,72,97,71,77,71,78,71,70,78,71,97,70,78,69,79,78,70,69,69,68,79,17,79,68,69,70,67,69,67,68,98,65,97,65,64,54,97,66,70,97,65,66,65,86,66,65,54,86,96,90,54,54,90,86,67,70,66,67,66,55,90,57,86,66,86,55,86,56,55,55,68,67,40,41,39,41,42,39,39,42,38,42,43,38,36,37,99,43,44,38,38,44,37,37,44,63,37,63,99,63,44,52,99,63,98,98,63,64,44,45,52,63,52,64,52,53,64,52,45,53,45,46,91,45,91,53,91,46,89,64,65,98,91,96,53,64,53,54,53,96,54,96,91,95,91,89,95,96,95,90,95,88,90,51,0,50,50,0,49,48,49,1,49,0,1,89,46,92,47,48,62,48,1,62,46,47,92,47,62,92,92,94,89,89,94,95,1,2,62,95,94,88,92,61,94,92,62,61,62,3,61,62,2,3,94,93,88,94,60,93,94,61,60,88,59,58,88,93,59,61,4,60,61,3,4,93,60,59,59,5,6,59,60,5,60,4,5,86,57,56,90,58,57,90,88,58,55,56,8,56,7,8,56,57,7,58,6,57,57,6,7,58,59,6,75,76,80,87,80,18,18,80,79,76,77,80,18,79,17,16,17,68,9,15,16,55,16,68,9,16,55,55,8,9,15,9,14,14,9,13,9,12,13,9,10,12,10,11,12,28,85,27,27,85,26,24,25,21,23,24,21,21,25,26,85,84,26,26,84,21,21,22,23,74,82,28,28,83,85,28,82,83,85,83,84,82,74,81,84,20,21,84,83,20,20,83,81,81,75,87,83,82,81,81,19,20,81,87,19,75,80,87,87,18,19],"vertices":[1,9,174.14,48.06,1,1,9,160.71,18.02,1,1,9,113.63,-23.71,1,1,9,72.41,-26.05,1,1,9,34.45,-28.21,1,1,9,-7.22,-16.12,1,2,6,300.89,21.22,0.00799,8,90.75,-8.74,0.992,3,6,287.95,-3.86,0.00374,7,126.81,58.24,0.00425,8,63.39,-15.73,0.992,3,6,276.58,-25.9,0,7,126.47,33.43999,0.00799,8,39.36,-21.87,0.992,1,7,137.48,17.32,1,1,7,153.56,22.24,1,1,7,166.86,29.67,1,1,7,171.6,5.04,1,1,7,154.97,-26.12,1,1,7,117.38,-42.48,1,1,7,94.22,-39.03,1,1,7,65.35,-29.03,1,1,7,47.96,-23.01,1,1,7,1.78,-29.47,1,1,6,106.6,-27.34,1,1,6,83.89,-27.9,1,1,6,70.94,-39.78,1,1,6,60.57,-49.29,1,1,6,48.2,-64.74,1,1,6,-0.09,-51.26,1,1,6,-7.16,-21.08,1,1,6,-5.88,10.16,1,1,6,7.11,30.08,1,1,6,32.8,26.63,1,1,14,79.25,14.9,1,1,14,106.92,13.63,1,1,14,127.03,19.15,1,1,14,123.79,0.93,1,1,14,98.44,-17,1,1,14,75.37,-13.01,1,1,14,51.79,-8.93999,1,2,11,105.6,44.06,0.51049,14,17.04,-33.18,0.4895,1,11,98.14,18.54999,1,1,11,108.85,16.02,1,1,11,121.6,13.02,1,1,11,152.71,17.14,1,1,11,154.78,4.66,1,1,11,131.19,-14.39,1,1,11,97.96,-25.81,1,1,11,75.82,-12.75,1,1,11,58.86,-32.11,1,2,9,102.06,79.32,0.51199,11,45.98,-63.09,0.488,1,9,124.63,54.31,1,1,9,142.15,45.94,1,1,9,163.15,60.75,1,1,9,177.32,79.26999,1,1,9,187.02,76.89,1,1,11,64.87999,-8.45,1,1,11,16,-9.62,1,1,10,79.5,-6.31,1,1,10,8.16,-8.93999,1,2,8,45.03,22.5,0.992,10,18.45,-25.68,0.00799,4,8,66.72,29.32,0.992,9,-13.67,61.93,3.9E-4,11,-56.73,-7.01,4.2E-4,10,37.13,-38.66,0.00718,4,8,92.12,20.81,0.992,9,-3.9,36.98,5.1E-4,11,-64.03,-32.79,4.7E-4,10,45.95,-63.95,0.007,1,9,8.99,16.03,1,1,9,31.27,4.73,1,1,9,71.3,6.74,1,1,9,100.65,13.53,1,1,11,65.14,10.88,1,1,11,16.45999,5.17999,1,1,10,75.5,6.62,1,1,10,42.85,3.51,1,1,10,11.5,7.7,1,1,12,-4.44999,-6.52,1,1,12,4.76,-7.2,1,1,12,19.49,-13.3,1,1,12,44.23,-7.51,1,1,13,-3.12,-8.88,1,1,14,-3.17,-7.41,1,1,14,53.4,10.72,1,1,14,1.29999,12.07,1,1,13,1.49,13.24,1,1,12,41.06,4.98999,1,1,12,21.31,2.15,1,1,12,8.57,5.93,1,1,7,-5.45,17.06,1,1,6,90.03,16.87999,1,1,6,75.75,20.86,1,1,6,64.91,12.35,1,1,6,51.29,7.68,1,1,6,39.65,12.85,1,1,10,43.95,-7.62,1,1,6,108.78,17.31,1,2,9,29.66,43.06,0.51199,11,-33.59999,-48.23,0.488,2,9,70.39,63.38,0.51199,11,11.12,-56.66,0.488,2,11,-18.04999,-25.83,0.48,10,79.61,-31.86,0.51999,1,11,13.67,-32.04,1,1,9,87.23,35.64,1,1,9,30.49,23.23,1,1,9,61.28,29.96,1,2,9,52.45,54.43,0.51199,11,-8.58,-52.94,0.488,1,11,-2.66,-28.84,1,2,10,61.79,19.39,0.50399,12,50.14,-19.31,0.496,2,11,14.31,21.25,0.54103,13,-4.92,-20.53,0.45896,2,11,70.32,35.46,0.53831,14,-15.83,-17.76,0.46168],"hull":52,"edges":[2,4,8,10,10,12,16,18,18,20,20,22,22,24,24,26,26,28,28,30,34,36,44,46,46,48,48,50,50,52,52,54,54,56,58,60,60,62,62,64,64,66,78,80,80,82,82,84,84,86,86,88,96,98,98,100,100,102,88,104,104,106,106,108,110,112,112,114,114,116,116,118,118,120,120,122,122,124,74,126,126,128,128,130,130,132,132,134,134,136,136,138,138,140,140,142,142,144,144,146,146,70,58,148,148,150,150,152,152,154,154,156,156,158,158,160,162,164,164,166,166,168,168,170,170,56,106,128,108,130,144,152,142,154,140,156,138,158,146,150,70,148,108,172,172,110,132,172,152,160,160,174,174,162,150,174,36,38,38,40,174,38,40,42,42,44,56,58,124,96,2,0,0,102,98,0,96,2,124,4,4,6,6,8,122,6,120,8,118,10,116,12,12,14,14,16,114,14,112,16,20,24,18,26,104,126,88,74,84,78,74,76,76,78,86,76,160,36,158,34,110,134,162,40,66,60,66,68,68,70,58,68,132,140,166,40,168,42,30,32,32,34,136,32,18,110,18,32,116,176,178,92,108,180,180,176,114,180,106,182,182,178,88,90,90,92,182,90,92,94,94,96,124,184,184,178,94,184,120,186,186,176,186,118,184,188,188,186,122,188,176,190,190,178,188,190,180,192,192,182,190,192,192,106,104,90,130,194,194,142,140,194,128,196,196,144,194,196,126,198,198,146,196,198,70,72,72,74,198,72],"width":323,"height":339}},"chujiao":{"chujiao":{"x":47,"y":-3.97,"rotation":-147.63,"width":106,"height":112}},"dabiL":{"dabiL":{"x":20.03,"y":-0.15,"rotation":59.19,"width":62,"height":68}},"dabiR":{"dabiR":{"x":22.26,"y":-1.51,"rotation":155.67,"width":87,"height":55}},"datuiL":{"datuiL":{"x":39.21,"y":-0.64,"rotation":42.65,"width":85,"height":68}},"datuiR":{"datuiR":{"x":40.73,"y":-3.12,"rotation":104.98,"width":86,"height":113}},"er":{"er":{"x":44.31,"y":-0.49,"rotation":-126.36,"width":118,"height":122}},"jianbang":{"jianbang":{"x":12.5,"y":-0.58,"rotation":140.69,"width":119,"height":100}},"jiaoL":{"jiaoL":{"x":34.66,"y":23.29,"rotation":70.67,"width":97,"height":69}},"jiaoR":{"jiaoR":{"x":49.85,"y":-10.76,"rotation":95.27,"width":91,"height":105}},"shenti":{"shenti":{"x":104.83,"y":-6.26,"rotation":-106.65,"width":239,"height":267}},"shouL":{"shouL":{"x":19.15,"y":-2,"rotation":-2.59,"width":75,"height":76}},"shouR":{"shouR":{"x":54.61,"y":0.78,"rotation":50.26,"width":94,"height":103}},"tail":{"tail":{"type":"weightedmesh","uvs":[0.43539,0.33299,0.43522,0.3471,0.4213,0.39349,0.39882,0.41862,0.41694,0.43746,0.38942,0.4728,0.4166,0.45945,0.41703,0.47413,0.4005,0.52621,0.40251,0.54034,0.42969,0.49008,0.45689,0.57742,0.47432,0.57647,0.47947,0.50202,0.48459,0.49678,0.54054,0.54915,0.52338,0.47222,0.52858,0.46292,0.56841,0.5017,0.59526,0.52553,0.56554,0.43593,0.57797,0.41652,0.6303,0.46773,0.68056,0.46622,0.61975,0.3858,0.62545,0.36614,0.72072,0.33266,0.83533,0.17391,0.88595,0.20616,0.95813,0.25213,0.99027,0.49033,0.97526,0.71846,0.89142,0.89232,0.78614,0.96143,0.63256,0.98798,0.53772,0.97332,0.41793,0.91358,0.33172,0.77172,0.30164,0.72222,0.25737,0.58129,0.28533,0.42438,0.30898,0.34513,0.31877,0.31231,0.31899,0.28185,0.31919,0.25456,0.30332,0.20368,0.27631,0.18235,0.24022,0.26417,0.20599,0.31054,0.18139,0.36444,0.15605,0.42458,0.15408,0.35797,0.1572,0.29262,0.12609,0.34472,0.09616,0.4578,0.07752,0.5715,0.06497,0.56479,0.06636,0.44341,0.06488,0.30863,0.07912,0.23668,0.04888,0.21829,0.00791,0.19157,0.05127,0.16139,0.10835,0.09246,0.09703,0.05932,0.10924,0.05193,0.15055,0.06843,0.20215,0.03444,0.27482,0.03871,0.30202,0.05475,0.32498,0.08432,0.31017,0.03019,0.31644,0.02207,0.34738,0.07369,0.38485,0.13341,0.41115,0.13059,0.41056,0.16676,0.41023,0.21993,0.43351,0.24353,0.41838,0.30444,0.53966,0.68156,0.60656,0.66559,0.70628,0.58685,0.77236,0.41092,0.44944,0.64165,0.38786,0.58822,0.37811,0.57059,0.35845,0.52574,0.39259,0.30939,0.38471,0.19457,0.33571,0.10632,0.12584,0.19016,0.173,0.159,0.19242,0.19536,0.59887,0.57023,0.68725,0.49763,0.73088,0.34806,0.54028,0.58806,0.45324,0.6089,0.39449,0.56657,0.38757,0.55183,0.37112,0.5174,0.3721,0.48119,0.38482,0.40768,0.40232,0.30752,0.3929,0.49539,0.39343,0.24347,0.39978,0.23942,0.39544,0.18303,0.38089,0.16245,0.37796,0.4021,0.36319,0.4812,0.40946,0.35652,0.39355,0.35769,0.38542,0.35479],"triangles":[73,70,71,71,72,73,82,95,83,95,19,23,83,95,96,26,96,23,95,23,96,25,26,24,23,24,26,83,28,29,83,96,28,28,26,27,28,96,26,15,19,94,95,94,19,19,22,23,22,19,20,20,21,22,97,94,81,97,15,94,97,12,15,15,18,19,15,16,18,16,17,18,15,13,14,15,12,13,98,12,97,98,11,12,11,98,99,11,99,9,10,11,9,100,8,9,100,101,8,101,105,8,101,102,105,101,111,102,102,5,105,8,105,7,105,5,7,102,103,5,5,6,7,5,103,3,4,5,3,103,112,3,112,2,3,103,110,113,112,103,113,2,112,1,104,112,113,113,114,88,113,88,104,1,112,0,79,0,112,79,112,104,107,78,79,104,107,79,107,104,106,107,77,78,106,89,107,77,107,108,107,89,108,77,108,76,108,109,76,109,74,76,76,74,75,63,91,59,59,60,62,60,61,62,63,59,62,63,65,66,63,64,65,55,56,54,56,57,54,57,53,54,57,58,53,53,58,52,58,59,52,59,91,52,50,51,49,49,51,48,51,52,48,48,52,47,52,93,47,52,91,93,47,93,46,91,92,93,68,46,67,67,46,93,93,92,67,92,91,63,46,68,69,63,66,92,92,66,67,42,43,88,43,44,106,44,89,106,44,45,89,89,45,90,89,90,109,89,109,108,90,45,46,46,70,90,46,69,70,109,90,74,74,90,73,90,70,73,110,114,113,103,102,111,103,111,110,87,40,111,39,40,87,40,41,110,41,42,114,104,88,106,106,88,43,110,111,40,110,41,114,87,111,101,114,42,88,87,101,100,86,87,100,86,100,99,99,98,85,84,37,85,37,38,85,86,38,39,86,85,38,85,86,99,99,100,9,39,87,86,84,36,37,97,84,98,84,80,36,34,35,80,35,36,80,80,84,97,84,85,98,80,97,81,81,94,82,33,34,81,80,81,34,32,33,82,33,81,82,32,82,31,30,31,83,83,31,82,83,29,30,94,95,82],"vertices":[1,26,18.9,2.07,1,1,26,18.12999,-0.5,1,2,26,9.82,-7.46,0.86422,25,18.95999,8.04,0.13576,2,26,-1.12,-9.5,0.19289,25,8.64,3.84,0.8071,1,25,16.52,-0.22,1,2,25,3.84,-6.24,0.18894,23,8.18,4.44,0.81105,1,23,19.78,0,1,3,25,16.15,-7.22,0.01096,23,18.42,-2.45,0.98779,22,19.03,6.64,0.00124,3,21,33.68,-28.41,0.0211,23,6.82,-6.81,0.73113,22,8.02,12.33,0.24775,3,21,31.39,-26.72,0.05835,23,6.11,-9.57,0.50368,22,5.5,11.01,0.43796,1,22,16.94,0.56,1,3,19,60.62,-35.15,0.02092,22,2.43,-14.12,0.78367,20,15.12,17.44,0.19539,3,19,53.05,-37.03,0.03313,22,3.86,-21.79,0.30362,20,12.01,10.29,0.66323,4,15,165.08,-71.47,0,21,7.51,-52.57,0,20,23.96,2.23,0.98965,18,39.97,20.68,0.01034,3,15,162.61,-71.83999,0,21,6.22,-54.71,0,20,23.91,-0.26,0.99999,2,20,4.32,-18.76,0.21424,18,14.99,6.45,0.78575,4,15,144.65,-71.87,1.0E-5,19,36,-61.25,1.6E-4,18,31.04,2.29,0.99845,17,47.28,19.49,0.00136,3,15,141.94,-72.98,0,19,34.12,-63.49,2.0E-5,18,30.8,-0.61,0.99996,2,18,13.36,-8.87,0.93322,17,27.84,11.79,0.06677,3,15,116.27,-53.69,1.6E-4,18,1.94,-14.72,0.28786,17,15.53,8.16,0.71197,2,15,124.65,-73.66,1.0E-4,17,36.47,2.57,0.99989,2,15,118.32,-75.8,1.0E-5,17,34.29,-3.74,0.99998,2,17,9.74,-10.1,0.98468,16,43.48,16.5,0.01531,3,15,76.51,-54.72,0.03447,17,-7.96,-23.93,0.29275,16,21.35,12.59,0.67277,3,15,98.76,-76.61,1.0E-5,17,22.97,-19.70999,1.3E-4,16,50.67,1.82,0.99985,1,16,48.76,-2.29,1,1,16,7.76,-15.48,1,2,15,-4.8,-90.65,0.25929,16,-37.9,-53.69,0.7407,2,15,-25.05,-78.82,0.38649,16,-61.23,-51.27,0.6135,2,15,-53.92,-61.96,0.56992,16,-94.49,-47.81,0.43007,2,15,-55.97,-14.29,0.84896,16,-116.02,-5.23,0.15103,3,15,-38.16999,26.03,0.99936,20,-106.63,-181.62,0,16,-116.44,38.84999,6.3E-4,3,15,6.64,48.35,0.99999,20,-121.04,-133.64,0,16,-84.82,77.68,0,3,15,55.51,48.87,0.99999,20,-113.27,-85.37,0,16,-40.5,98.32,0,2,15,123.12,35.93,0.83565,19,-33.14,24.22,0.16434,1,19,8.83,30.75,1,1,19,63.59,31.31,1,4,15,242.24,-38.89,6.0E-5,19,107.12,13.29,0.02908,21,31.71,27.64,0.97085,18,46,104.23,0,4,15,252.77,-51.52,2.0E-5,21,48.15,27.68,0.93617,24,-31,-10.95,0.0638,18,62.03,107.87,0,1,21,79.86,17.12,1,1,24,16.73,20.87,1,2,24,34.99,18.12999,0.74658,27,10.85,22.04,0.25341,2,24,42.56,17,0.50258,27,12.96,14.69,0.49741,3,24,47.81,19.5,0.33702,27,17.42,10.95,0.66297,25,-25.45,32.03,0,3,24,52.52,21.74,0.21685,27,21.41,7.6,0.78314,25,-25.06,37.23,0,3,27,33.43,6.98,0.86154,31,-4.52,20.7,0.12647,32,-28.2,37.31,0.01198,3,27,44.21,13.8,0.4182,31,6.2,13.81,0.48472,32,-25.76,24.8,0.09707,3,27,42.23,36.18,0.02573,31,25.65,25.04,0.3134,32,-4.19,18.52,0.66085,1,32,11.08,9.60999,1,5,27,43.93,68.67,0,31,55.83,37.23,4.0E-5,32,25.47,5.16,0.99995,29,-94.34,32.5,0,25,-87.81,19.89,0,3,32,41.07,1,1,29,-110.42,31.18,0,25,-99.8,9.09,0,6,32,30.45,-6.05,0.98231,33,9.54,23.5,0.01748,34,0,28.21,5.0E-5,35,-16.17,37.74,1.4E-4,29,-102.79,41.4,0,25,-99.93,21.84,0,4,32,18.91,-11.03,0.50422,33,-0.4,15.83,0.48779,34,-12.52,27.38,0.00796,25,-97.81,34.23,0,5,32,34.45,-18.18,0.06208,33,16.42,12.74,0.7257,34,-0.28,15.44,0.21221,29,-110.62,51.49,0,25,-112.28,25.11,0,3,34,23.34,6.07,1,29,-134.86,43.85,0,25,-126.91,4.32,0,3,34,46.19,1.69,1,29,-155.35,32.82,0,25,-136.51,-16.87,0,5,32,84.51,-21.11,1.0E-5,33,65.65,22.29,5.0E-5,34,45.92,-4.06,0.99993,29,-158.77,37.46,0,25,-142.04,-15.26,0,3,34,22.98,-7.52,1,29,-143.17,54.63,0,25,-140.06,7.85,0,5,33,30.47,-11.73,0.34676,34,-2.25,-12.71,0.5478,35,22.43,23.96,0.10542,29,-126.86,74.57,0,25,-139.2,33.59999,0,4,33,16.16,-16.7,0.29248,34,-16.9,-8.85999,0.05717,35,14.58,11,0.65033,25,-132.04,46.95,0,6,31,106.51,-4.26,2.0E-4,32,30.56,-60.14,0,33,23.03,-28.87,0.00206,35,27.63,6.01,0.99773,29,-121.02,92.32,0,25,-145.33,51.26,0,3,34,-19.78,-41.72,1.4E-4,35,45.27,-1.08,0.99985,25,-163.32,57.43,0,2,35,25.36,-4.67,1,25,-143.63,62.05,0,5,31,74.87,-21.11,0.13544,32,-3.49,-48.94,0.00137,35,-1.46,-14.93,0.86317,29,-85.18,93.19,1.0E-5,25,-117.37,73.69999,0,5,31,78.24,-28.48,0.14617,32,-6.49,-56.48,0.00151,35,2.86,-21.79,0.85229,29,-84.89,101.29,1.0E-5,25,-122.05,80.32,0,5,31,72.6,-28.53,0.15994,32,-10.42,-52.43,0.00145,35,-2.71,-22.59,0.83858,29,-79.83,98.8,1.0E-5,25,-116.52,81.41,0,5,31,55.45,-20.96999,0.63112,33,-29.14,-16.06,0.06527,35,-20.71999,-17.41,0.30352,29,-67.89,84.36,5.0E-5,25,-98.26,77.17,0,4,31,31.49,-21.66,0.99317,35,-44.37,-21.31,0.00639,29,-46.16,74.22,4.3E-4,25,-74.83999,82.3,0,3,27,65.94,-2.97,0.28793,31,0.16,-12.97,0.71206,25,-42.44,79.57,0,3,27,55.67,-9.47,0.69421,31,-10.05,-6.4,0.30578,25,-31.17,75.01999,0,1,27,47.94,-14.35,1,1,30,16.62,2.08,1,1,30,16.12,-1.07,1,1,30,-0.15,-5.93,1,1,29,3.4,6.59,1,3,24,92.02,-4.56,2.4E-4,29,12.66,-0.67,0.99975,25,17.37999,58.46,0,3,29,7.95,-5.73,0.87183,28,11.94,15.91,0.12816,25,16.70999,51.58,0,3,24,76.55,-11.78,0.01222,29,1.21,-13.33,0.04525,28,6.54,7.3,0.94252,2,28,13.09,-1.95,0.99999,25,26.09,36.33,0,3,27,-13.92,-20.84,9.0E-4,28,1.27,-8.38,0.60508,26,12.96,9.31,0.39401,1,19,20.16,-23.81,1,1,15,118.34,-26.54,1,1,15,71.39,-29.48,1,2,15,34.13,-54.25,0.08198,16,-17.43,-4.46,0.91801,1,19,61.19,-22.44,1,1,21,31.45,-15.47,1,1,21,36.96,-15.7,1,1,24,13.92,-17.02,1,4,24,57.73,-12.31,0.16985,27,-7.39,-11.28,0.09623,28,-9.07,-3.2,0.32506,26,1.57,11.37,0.40884,1,27,11.86,-22.37,1,1,27,39.04,-16.26,1,4,31,71.82,-1.1,0.36321,33,-4.73,-7.85,0.37803,35,-7.16,4.48,0.25874,25,-110.66,54.6,0,1,31,49.92,-1.75,1,3,31,43.18,7.09,0.69398,32,-5.03,-6.55,0.30598,29,-69.51999,53.76,2.0E-5,3,15,116.93,-45.02,1.6E-4,18,-5.47,-10.2,0.28786,17,9.08,13.98,0.71197,3,15,75.17,-48.15,0.03447,17,-13.98,-20.95999,0.29275,16,17.43,18.02,0.67277,1,16,2.8,-13.31,1,2,20,-2.36999,-15.54,0.21424,18,9.55,11.52,0.78575,3,19,60.9,-28.92,0.02092,22,-3.76,-13.48,0.78367,20,10.35,21.45,0.19539,1,21,31.42,-20.56,1,1,21,35.57,-21.07,1,1,23,-3.3,1.71,1,1,23,0.8,7.29,1,2,26,-6.63,-5.86,0.19289,25,2.51,6.29,0.8071,4,24,59.98,-16.04999,0.16985,27,-9.85,-14.89,0.09623,28,-5.16,-5.16,0.32506,26,5.87,10.59,0.40884,1,23,7.15,-0.02,1,3,24,69.18,-7.05,0.57899,29,-7.41,-11.84,0.17047,28,-2.21,7.36,0.25053,3,24,71.12999,-9.25,0.01222,29,-4.75,-13.11,0.04525,28,0.61,6.54,0.94252,1,29,0.8,-3.68,1,1,27,17.7,-24.91,1,1,24,38.95,-14.33,1,1,24,22.48,-15.13,1,1,26,6.53,0.72,1,1,26,-0.39,2.34999,1,1,24,48.54,-13.3,1],"hull":80,"edges":[88,90,90,92,48,46,66,68,40,42,42,44,44,46,48,50,50,52,52,54,34,36,36,38,32,34,32,30,68,70,70,72,40,38,26,28,24,22,20,18,18,16,16,14,14,12,12,10,10,8,8,6,6,4,4,2,2,0,158,156,156,154,154,152,152,150,150,148,148,146,146,144,142,144,142,140,92,136,136,134,134,132,128,126,126,124,124,122,122,120,120,118,118,116,116,114,114,112,112,110,110,108,108,106,106,104,158,0,64,66,64,62,58,60,62,60,28,30,24,26,20,22,114,108,116,106,104,96,72,74,74,76,76,78,160,70,162,68,160,162,164,66,162,164,166,62,164,166,54,56,56,58,166,56,168,72,160,168,170,74,168,170,172,76,170,172,174,78,172,174,84,176,88,178,90,180,180,146,178,180,180,140,124,120,128,130,130,132,96,98,98,100,100,102,102,104,98,102,92,94,94,96,118,104,126,132,126,118,78,80,118,182,182,184,184,186,186,104,186,94,184,132,186,134,186,92,38,188,188,162,46,190,190,164,188,190,52,192,192,166,190,192,52,46,46,38,38,30,30,24,30,194,194,160,188,194,22,196,196,168,194,196,18,198,198,170,196,198,16,200,200,172,198,200,202,174,200,202,202,204,204,206,158,208,208,176,10,204,6,206,22,18,14,210,210,202,16,210,210,10,6,10,176,212,212,178,84,86,86,88,212,86,154,214,214,212,208,214,152,216,216,178,214,216,216,218,218,180,148,218,218,178,206,220,80,82,82,84,220,82,174,222,222,220,204,222,222,80,6,224,224,158,2,224,206,226,226,208,224,226,176,228,228,220,226,228,136,138,138,140],"width":447,"height":191}},"tou":{"tou":{"type":"mesh","uvs":[1,1,0,1,0,0,1,0,0.30764,0.29612,0.37783,0.28012,0.47868,0.29745,0.53596,0.36345,0.58357,0.42145,0.58921,0.48945,0.60616,0.55745,0.51499,0.56812,0.40445,0.52745,0.34717,0.47879,0.33587,0.38612,0.31369,0.31542,0.41575,0.33012,0.49724,0.35812,0.54161,0.39145,0.57227,0.44812,0.57711,0.52745,0.57066,0.55079],"triangles":[5,2,3,4,2,5,6,5,3,15,4,5,16,5,6,15,5,16,7,17,6,16,6,17,3,7,6,14,15,16,8,18,7,17,7,18,3,8,7,19,18,8,13,14,16,9,8,3,19,8,9,17,12,13,17,13,16,12,17,18,12,18,19,19,11,12,9,20,19,19,20,11,10,9,3,20,9,10,21,20,10,21,11,20,11,21,10,15,1,2,15,2,4,13,1,15,13,15,14,1,13,12,10,3,0,11,10,0,1,12,11,0,1,11],"vertices":[168.1,-156.16,-7.88,-158.1,-10.22,54.88,165.76,56.82,44.6,-7.58,56.92,-4.04,74.71,-7.54,84.95,-21.48,93.46,-33.74,94.61,-48.22,97.75,-62.67,81.73,-65.11,62.19,-56.67,51.99,-46.41,49.78,-26.7,45.72,-11.68,63.71,-14.62,78.12,-20.42,86,-27.44,91.53,-39.45,92.57,-56.33,91.49,-61.32],"hull":4,"edges":[0,2,2,4,4,6,0,6,8,10,10,12,12,14,14,16,16,18,18,20,20,22,22,24,24,26,26,28,8,30,30,28,30,32,32,34,34,36,36,38,38,40,40,42],"width":176,"height":213}},"tou1":{"tou1":{"x":26.8,"y":-0.45,"rotation":-161.47,"width":71,"height":46}},"toujiaoL":{"toujiaoL":{"x":57.58,"y":2.34,"rotation":-134.25,"width":107,"height":153}},"toujiaoR":{"toujiaoR":{"x":101.02,"y":9.72,"rotation":-140.32,"width":200,"height":156}},"xiaobiL":{"xiaobiL":{"x":26.27,"y":-3.85,"rotation":12.81,"width":104,"height":45}},"xiaobiR":{"xiaobiR":{"x":19.01,"y":-3.84,"rotation":15.26,"width":122,"height":61}},"xiaotuiL":{"xiaotuiL":{"x":19.79,"y":1.04,"rotation":-170.08,"width":67,"height":31}},"xiaotuiR":{"xiaotuiR":{"x":16.5,"y":-0.4,"rotation":-132.48,"width":61,"height":65}},"zui":{"zui":{"x":69.9,"y":-4.34,"rotation":48.94,"width":186,"height":140}}}},"animations":{"stand":{"bones":{"bone":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":-1.73},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0},{"time":0.2666,"x":7.11,"y":10.67},{"time":0.5,"x":0,"y":20.01},{"time":0.7666,"x":-8.54,"y":9.33},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"jiaoL":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"jiaoR":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"datuiL":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":-7.4},{"time":0.5,"angle":-0.78},{"time":0.7666,"angle":9.84},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"datuiR":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":1.61},{"time":0.5,"angle":10.44},{"time":0.7666,"angle":11.68},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"shenti":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"weiba1":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":-1.36},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bozixia":{"rotate":[{"time":0,"angle":0},{"time":0.2333,"angle":-0.58},{"time":0.5,"angle":3.22},{"time":0.7333,"angle":3.12},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"chibangR1":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":-8.28},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"dabiL":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":-9.16},{"time":0.5,"angle":-0.28},{"time":0.7666,"angle":5.24},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"jianbang":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"weiba2":{"rotate":[{"time":0,"angle":0.09},{"time":0.0666,"angle":1.97},{"time":0.5666,"angle":-2.22},{"time":1,"angle":0.09}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.0666,"x":0,"y":0,"curve":"stepped"},{"time":0.5666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.0666,"x":1,"y":1,"curve":"stepped"},{"time":0.5666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"xiaotuiL":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":12.32},{"time":0.5,"angle":21.51},{"time":0.7666,"angle":9.22},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"xiaotuiR":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":14.51},{"time":0.5,"angle":15.92},{"time":0.7666,"angle":-0.55},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bozishang":{"rotate":[{"time":0,"angle":0},{"time":0.2333,"angle":-1.16},{"time":0.5,"angle":1.98},{"time":0.7333,"angle":2.46},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"dabiR":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":13.11},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"weiba3":{"rotate":[{"time":0,"angle":0.6},{"time":0.2,"angle":3.95},{"time":0.7,"angle":0.03},{"time":1,"angle":0.6}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.2,"x":0,"y":0,"curve":"stepped"},{"time":0.7,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.2,"x":1,"y":1,"curve":"stepped"},{"time":0.7,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"xiaobiL":{"rotate":[{"time":0,"angle":0},{"time":0.2333,"angle":-0.38},{"time":0.5,"angle":-6.49},{"time":0.7666,"angle":-2.52},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"chujiao":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"er":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"shouL":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":5.73},{"time":0.5,"angle":-4.28},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"tou":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"weiba4":{"rotate":[{"time":0,"angle":-1.6},{"time":0.2666,"angle":5.94},{"time":0.7666,"angle":-8.21},{"time":1,"angle":-1.6}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.2666,"x":0,"y":0,"curve":"stepped"},{"time":0.7666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.2666,"x":1,"y":1,"curve":"stepped"},{"time":0.7666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"xiaobiR":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":-14.43},{"time":0.5,"angle":-13.08},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"zui":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.1666,"angle":0},{"time":0.5,"angle":-5.24},{"time":0.8333,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.1666,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":0.8333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.1666,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":0.8333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"shouR":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":3.32},{"time":0.5,"angle":-3.46},{"time":0.7333,"angle":6.13},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"toujiaoL":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":3.57},{"time":0.5,"angle":0},{"time":0.7666,"angle":-2.7},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"toujiaoR":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":3.48},{"time":0.5,"angle":0},{"time":0.7666,"angle":-0.5},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"weiba5":{"rotate":[{"time":0,"angle":-1.51},{"time":0.3333,"angle":7.93},{"time":0.8333,"angle":-6.23},{"time":1,"angle":-1.51}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.8333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.8333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"chibangL1":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"chibangL3":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"tou1":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":0.5,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone2":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone3":{"rotate":[{"time":0,"angle":0,"curve":"stepped"},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone4":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":20.19},{"time":0.7666,"angle":12.57},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone5":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":-11.08},{"time":0.5,"angle":-5.23},{"time":0.7666,"angle":6.26},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone6":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":18.2},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone7":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":-6.66},{"time":0.5,"angle":0},{"time":0.7666,"angle":6.77},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone8":{"rotate":[{"time":0,"angle":0},{"time":0.5,"angle":9.19},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone9":{"rotate":[{"time":0,"angle":0},{"time":0.2666,"angle":-7.35},{"time":0.5,"angle":0},{"time":0.7666,"angle":3.63},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.5,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.5,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone10":{"rotate":[{"time":0,"angle":0},{"time":0.1666,"angle":-2.78},{"time":0.3333,"angle":-7.66},{"time":0.5,"angle":-6.46},{"time":0.7,"angle":1.1},{"time":0.8333,"angle":1.23},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone23":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":7.19},{"time":0.7333,"angle":1.21},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.7333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.7333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone24":{"rotate":[{"time":0,"angle":0},{"time":0.2,"angle":9},{"time":0.4666,"angle":3.11},{"time":0.7666,"angle":-21.64},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.2,"x":0,"y":0,"curve":"stepped"},{"time":0.4666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.2,"x":1,"y":1,"curve":"stepped"},{"time":0.4666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone25":{"rotate":[{"time":0,"angle":0},{"time":0.2333,"angle":18.5},{"time":0.4333,"angle":12.09},{"time":0.8333,"angle":0.1},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.4333,"x":0,"y":0,"curve":"stepped"},{"time":0.8333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.4333,"x":1,"y":1,"curve":"stepped"},{"time":0.8333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone22":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":3.46},{"time":0.8333,"angle":-12.88},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.8333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.8333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone21":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":-21.8},{"time":0.6666,"angle":18.27},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone20":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":-14.4},{"time":0.6666,"angle":31.8},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone19":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":17.43},{"time":0.6666,"angle":-38.51},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone18":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":24.63},{"time":0.6666,"angle":-19.23},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone17":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":39.99},{"time":0.6666,"angle":-16.69},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone16":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":17.8},{"time":0.6666,"angle":-32.46},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone15":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":12.56},{"time":0.6666,"angle":-22.2},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone14":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":-5.93},{"time":0.6666,"angle":-11.63},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone13":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":5.76},{"time":0.6666,"angle":-4.04},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone12":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":9.53},{"time":0.6666,"angle":-1.93},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone11":{"rotate":[{"time":0,"angle":0},{"time":0.3333,"angle":3.7},{"time":0.6666,"angle":-3.62},{"time":1,"angle":0}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.3333,"x":0,"y":0,"curve":"stepped"},{"time":0.6666,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.3333,"x":1,"y":1,"curve":"stepped"},{"time":0.6666,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]},"bone26":{"rotate":[{"time":0,"angle":4.79},{"time":0.1333,"angle":0},{"time":0.6333,"angle":-4.37},{"time":1,"angle":4.79}],"translate":[{"time":0,"x":0,"y":0,"curve":"stepped"},{"time":0.1333,"x":0,"y":0,"curve":"stepped"},{"time":0.6333,"x":0,"y":0,"curve":"stepped"},{"time":1,"x":0,"y":0}],"scale":[{"time":0,"x":1,"y":1,"curve":"stepped"},{"time":0.1333,"x":1,"y":1,"curve":"stepped"},{"time":0.6333,"x":1,"y":1,"curve":"stepped"},{"time":1,"x":1,"y":1}]}},"ffd":{"default":{"bozishang":{"bozishang":[{"time":0,"offset":6,"vertices":[-0.54631,0.16979,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.66614,2.18981,0,0,0,0,0,0,1.66614,2.18981]},{"time":0.5,"offset":2,"vertices":[0.39909,-0.15237,-0.76017,-2.81369,-4.76631,-10.08128,-11.67932,-16.11244,-12.87498,-24.64079,-26.08101,-27.19285,-11.69793,-23.18663,-7.10708,-15.5899,-5.63208,-11.07275,-1.18116,-9.16714,1.39007,-5.60423,-3.23986,-4.04275,-8.67079,-12.96566,-16.84547,-21.14059,-6.57843,-14.39357,-4.02623,-7.4048,1.96569,-7.56994,-8.99745,-9.374,-15.71865,-15.71713,-25.49047,-21.09736,-23.43983,-15.56904,-19.69587,-9.45701,-9.13946,-7.0227,2.98738,0.39505,0,0,-5.6336,-6.26731,-16.11631,-9.15596,-7.77491,-4.34162,0,0,-4.96264,0.92071,0,0,-6.26344,-1.55409,-2.99334,-2.13903,0,0,4.42803,-0.42726,10.55395,1.42237,8.31709,-2.13948,0,0,0,0,0,0,0,0,0,0,-0.3366,0.85484]},{"time":1,"offset":6,"vertices":[-0.54631,0.16979,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1.66614,2.18981,0,0,0,0,0,0,1.66614,2.18981]}]},"bozixia":{"bozixia":[{"time":0,"offset":8,"vertices":[1.10426,0.21304]},{"time":0.5,"vertices":[-8.58589,-11.87962,-8.58589,-11.87962,-8.58589,-11.87962,-8.58589,-11.87962,-7.48162,-11.66658,4.06758,-6.14323,4.89106,-6.73164,3.24205,-9.90687,2.0182,-10.40029,2.55815,-12.77673,9.22341,-8.27536,7.43252,-1.43287,1.38748,-1.90908,1.38748,-1.90908,-3.3168,-3.86715,-0.7987,-4.71955,-2.82904,-7.51142,3.98394,-9.40925,2.54252,-10.17247,1.26657,-8.66304,-3.54208,-3.96939,-0.52188,-0.37893,-2.72117,-6.75529,-4.03936,-8.25877,-0.48744,-12.24523,4.31379,-13.04454,1.77854,-9.20007,-4.56512,-7.17195,3.40151,-12.20761,15.45115,-4.94531,7.50912,-11.24177,-0.37512,-14.17028,-6.63336,-15.99578,-7.31326,-12.93998,-2.37908,-11.1842,-2.18479,-12.07969,-6.69622,-12.09716,-8.03213,-13.5662,-4.74479,-12.75979,-10.09953,-10.11999,-12.88264,-6.91882,-11.56013,-4.35638,-2.77673,-3.65936,0.20387,-5.00454]},{"time":1,"offset":8,"vertices":[1.10426,0.21304]}]},"chibangR2":{"chibangR2":[{"time":0}]},"tou":{"tou":[{"time":0.6666,"offset":24,"vertices":[0.01285,0.20153]},{"time":0.7333,"offset":24,"vertices":[0.01285,0.20153,0,0,0,0,0,0,-12.78933,-11.95648,-25.18135,-25.46112,-23.14934,-28.2377,-14.56987,-22.86676,-10.98754,-7.93289]},{"time":0.8,"offset":24,"vertices":[0.01285,0.20153]}]}}}}}} \ No newline at end of file diff --git a/dragonbones-core/src/test/resources/NewDragon/NewDragon.png b/dragonbones-core/src/test/resources/NewDragon/NewDragon.png new file mode 100644 index 0000000..21ec3fd Binary files /dev/null and b/dragonbones-core/src/test/resources/NewDragon/NewDragon.png differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..c981446 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Sep 02 17:00:25 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..4453cce --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save ( ) { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/reference/.gitignore b/reference/.gitignore new file mode 100644 index 0000000..f879a6d --- /dev/null +++ b/reference/.gitignore @@ -0,0 +1,20 @@ +# Build and Release Folders +bin-debug/ +bin-release/ +bin/ +libs/ +node_modules/ +modules/ + +pids +logs +results + +lib-cov +*.seed +*.log +*.csv +*.dat +*.out +*.pid +*.gz \ No newline at end of file diff --git a/reference/@base.url b/reference/@base.url new file mode 100644 index 0000000..09eb622 --- /dev/null +++ b/reference/@base.url @@ -0,0 +1,2 @@ +[InternetShortcut] +URL=https://github.com/DragonBones/DragonBonesJS/commit/1fe868947b6a9f652d474e6ac5b94333cea97e72 diff --git a/reference/DragonBones/README.md b/reference/DragonBones/README.md new file mode 100644 index 0000000..569a556 --- /dev/null +++ b/reference/DragonBones/README.md @@ -0,0 +1,7 @@ +# DragonBones common library + +## How to build +``` +$npm install +$npm run build +``` \ No newline at end of file diff --git a/reference/DragonBones/out/dragonBones.d.ts b/reference/DragonBones/out/dragonBones.d.ts new file mode 100644 index 0000000..1c52caa --- /dev/null +++ b/reference/DragonBones/out/dragonBones.d.ts @@ -0,0 +1,4384 @@ +declare const Module: any; +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + FFDTimelineMeshOffset = 0, + FFDTimelineFFDCount = 1, + FFDTimelineValueCount = 2, + FFDTimelineValueOffset = 3, + FFDTimelineFloatOffset = 4, + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * @language zh_CN + * 包围盒类型。 + * @version DragonBones 5.0 + */ + 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, + BoneT = 11, + BoneR = 12, + BoneS = 13, + BoneX = 14, + BoneY = 15, + BoneRotate = 16, + BoneSkew = 17, + BoneScaleX = 18, + BoneScaleY = 19, + SlotVisible = 23, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * @private + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * @language zh_CN + * 动画混合的淡出方式。 + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + None = 0, + /** + * 淡出同层的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer = 1, + /** + * 淡出同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup = 2, + /** + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * 淡出所有动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + All = 4, + /** + * 不替换同名动画。 + * @version DragonBones 5.1 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + static readonly VERSION: string; + 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 namespace 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); + /** + * @private + */ + static toString(): string; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * 对象的唯一标识。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +declare namespace dragonBones { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * 转换为单位矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: 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; + constructor( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x?: number, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y?: number, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew?: number, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation?: number, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX?: number, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fromMatrix(matrix: Matrix): Transform; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + toMatrix(matrix: Matrix): Transform; + } +} +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; + } +} +declare namespace dragonBones { + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * 自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * 获取自定义字符串。 + * @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; + } +} +declare namespace dragonBones { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly frameIndices: Array; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatures: Map; + /** + * @private + */ + intArray: Array | Int16Array; + /** + * @private + */ + floatArray: Array | Float32Array; + /** + * @private + */ + frameIntArray: Array | Int16Array; + /** + * @private + */ + frameFloatArray: Array | Float32Array; + /** + * @private + */ + frameArray: Array | Int16Array; + /** + * @private + */ + timelineArray: Array | Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addArmature(value: ArmatureData): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + /** + * @private + */ + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * 所有动画数据名称。 + * @see #armatures + * @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; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly bones: Map; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly slots: Map; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly skins: Map; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animations: Map; + /** + * 获取默认皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * 获取默认动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的龙骨数据。 + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parent: DragonBonesData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + sortBones(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @private + */ + addBone(value: BoneData): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + length: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + readonly constraints: Array; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static createColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + target: BoneData; + bone: BoneData; + root: BoneData | null; + protected _onClear(): void; + } + /** + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: ArmatureData; + 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 + */ + class MeshDisplayData extends ImageDisplayData { + static toString(): string; + inheritAnimation: boolean; + offset: number; + weight: WeightData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * 边界框颜色。 + * @version DragonBones 5.0 + * @language zh_CN + */ + color: number; + /** + * 边界框宽。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + width: number; + /** + * 边界框高。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * 是否包含点。 + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * 是否与线段相交。 + * @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; + } + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 多边形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array | Float32Array, offset: number, count: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + count: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + vertices: Array | Float32Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } +} +declare namespace dragonBones { + /** + * 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + frameIntOffset: number; + /** + * @private + */ + frameFloatOffset: number; + /** + * @private + */ + frameOffset: number; + /** + * 持续的帧数。 ([1~N]) + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * 淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimeline(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * 是否暂停淡出的动画。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeOut: boolean; + /** + * 淡出模式。 + * @default dragonBones.AnimationFadeOutMode.All + * @see dragonBones.AnimationFadeOutMode + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * 淡出缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTweenType: TweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTime: number; + /** + * 否能触发行为。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 是否以增加的方式混合。 + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeIn: boolean; + /** + * 是否将没有动画的对象重置为初始值。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 淡入缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTweenType: TweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + playTimes: number; + /** + * 混合图层,图层高会优先获取混合权重。 + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * 开始时间。 (以秒为单位) + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * 混合权重。 + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * 动画状态名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * 动画数据名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + clear(): void; + copyFrom(value: AnimationConfig): void; + containsBoneMask(name: string): boolean; + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * 贴图集缩放系数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scale: number; + /** + * 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + abstract createTexture(): TextureData; + /** + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: 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; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架代理接口。 + * @version DragonBones 5.0 + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + init(armature: Armature): void; + /** + * @private + */ + clear(): void; + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + dispose(disposeProxy: boolean): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @language zh_CN + * 获取骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + readonly armature: Armature; + /** + * @language zh_CN + * 获取动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + readonly animation: Animation; + } +} +declare namespace dragonBones { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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); + /** + * 是否继承父骨架的动画状态。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + debugDraw: boolean; + /** + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + */ + armatureData: ArmatureData; + /** + * 用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + private _debugDraw; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + /** + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlotDisplay?: boolean): void; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string | null): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + flipX: boolean; + flipY: boolean; + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * @pivate + */ + readonly eventDispatcher: IEventDispatcher; + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + replaceTexture(texture: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + hasEventListener(type: EventStringType): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + enableAnimationCache(frameRate: number): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + } +} +declare namespace dragonBones { + /** + * 基础变换对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * 对象的名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + */ + origin: Transform; + /** + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * @private + */ + updateGlobalTransform(): void; + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +declare namespace dragonBones { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * @private + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + readonly constraints: Array; + /** + * @readonly + */ + boneData: BoneData; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + /** + * @internal + * @private + */ + _blendDirty: boolean; + private _localDirty; + private _visible; + private _cachedFrameIndex; + /** + * @internal + * @private + */ + _blendLayer: number; + /** + * @internal + * @private + */ + _blendLeftWeight: number; + /** + * @internal + * @private + */ + _blendLayerWeight: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(isCache); + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * @internal + * @private + */ + addConstraint(constraint: Constraint): void; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(child: TransformObject): boolean; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + readonly length: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + readonly slot: Slot | null; + } +} +declare namespace dragonBones { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 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; + /** + * @readonly + */ + slotData: SlotData; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + _colorDirty: boolean; + /** + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @private + */ + readonly _ffdVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @internal + * @private + */ + _rawDisplayDatas: Array; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @private + */ + init(slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + * @internal + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + target: Bone; + bone: Bone; + root: Bone | null; + protected _onClear(): void; + abstract update(): void; + } + /** + * @private + * @internal + */ + class IKConstraint extends Constraint { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + update(): void; + } +} +declare namespace dragonBones { + /** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * 更新时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 当前所属的 WordClock 实例。 + * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * 添加 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * 移除 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _animationDirty; + /** + * @internal + * @private + */ + _timelineDirty: boolean; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * 清除所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 上一个正在播放的动画状态名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationList: Array; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 是否以增加的方式混合。 + * @version DragonBones 3.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否能触发行为。 + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 混合图层。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + layer: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 混合权重。 + * @version DragonBones 3.0 + * @language zh_CN + */ + weight: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * @version DragonBones 3.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * 动画名称。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + name: string; + /** + * 混合组。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + group: string; + /** + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + animationData: AnimationData; + private _timelineDirty; + /** + * @internal + * @private + * xx: Play Enabled, Fade Play Enabled + */ + _playheadState: number; + /** + * @internal + * @private + * -1: Fade in, 0: Fade complete, 1: Fade out; + */ + _fadeState: number; + /** + * @internal + * @private + * -1: Fade start, 0: Fading, 1: Fade complete; + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + private _weightResult; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _slotTimelines; + private readonly _bonePoses; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @private + */ + protected _onClear(): void; + private _isDisabled(slot); + private _advanceFadeTime(passedTime); + private _blendBoneTimline(timeline); + /** + * @private + * @internal + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @private + * @internal + */ + updateTimelines(): void; + /** + * @private + * @internal + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + readonly clip: AnimationData; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class SlotDislayIndexTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _ffdCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } +} +declare namespace dragonBones { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + time: number; + /** + * 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * 发出事件的骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * 发出事件的骨骼。 + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * 发出事件的插槽。 + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * 发出事件的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * 自定义数据 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * 事件接口。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } +} +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: 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 BONE: string; + protected static readonly IK: string; + protected static readonly SLOT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly VISIBLE_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 CANVAS: 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 SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_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_FFD: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: 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_TYPE: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: 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_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 GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + private _intArrayJson; + private _floatArrayJson; + private _frameIntArrayJson; + private _frameFloatArrayJson; + private _frameArrayJson; + private _timelineArrayJson; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + 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 _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defalultColorOffset; + private _prevTweenRotate; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _weightBoneIndices; + private readonly _cacheBones; + private readonly _meshs; + private readonly _slotChildActions; + /** + * @private + */ + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + /** + * @private + */ + private _samplingEasingCurve(curve, samples); + private _sortActionFrame(a, b); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + private _parseCacheActionFrame(frame); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIKConstraint(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData | null; + /** + * @private + */ + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseTimeline(rawData: any, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): void; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): void; + /** + * @private + */ + protected _parseFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseBoneFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotDisplayIndexFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, type: ActionType, bone: BoneData | null, slot: SlotData | null): number; + /** + * @private + */ + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + /** + * @private + */ + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @private + */ + protected _parseWASMArray(): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + /** + * @private + */ + private static _objectDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binary; + private _binaryOffset; + private _intArray; + private _floatArray; + private _frameIntArray; + private _frameFloatArray; + private _frameArray; + private _timelineArray; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @private + */ + private static _binaryDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): BinaryDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * 清除所有的数据。 + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): Armature | null; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string | null, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): void; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): void; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string | null, fromDragonBonesDataName?: string | null, replaceOriginalAnimation?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} diff --git a/reference/DragonBones/out/dragonBones.js b/reference/DragonBones/out/dragonBones.js new file mode 100644 index 0000000..6794493 --- /dev/null +++ b/reference/DragonBones/out/dragonBones.js @@ -0,0 +1,10537 @@ +"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 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; + } + 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; + armature.eventDispatcher._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(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.yDown = true; + DragonBones.debug = false; + DragonBones.debugDraw = false; + DragonBones.webAssembly = false; + DragonBones.VERSION = "5.1.0"; + return DragonBones; + }()); + dragonBones.DragonBones = DragonBones; + if (!console.warn) { + console.warn = function () { }; + } + if (!console.assert) { + console.assert = function () { }; + } +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var BaseObject = (function () { + function BaseObject() { + /** + * 对象的唯一标识。 + * @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._defaultMaxCount : BaseObject._maxCountMap[classType]; + var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.push(object); + } + else { + console.assert(false, "The object is already in the pool."); + } + } + else { + } + }; + /** + * @private + */ + BaseObject.toString = function () { + throw new Error(); + }; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @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) { + if (classType in BaseObject._maxCountMap) { + continue; + } + var pool = BaseObject._poolsMap[classType]; + if (pool.length > maxCount) { + pool.length = maxCount; + } + BaseObject._maxCountMap[classType] = maxCount; + } + } + }; + /** + * 清除对象池缓存的对象。 + * @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; + } + } + }; + /** + * 从对象池中创建指定对象。 + * @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; + }; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseObject.prototype.returnToPool = function () { + this._onClear(); + BaseObject._returnObject(this); + }; + BaseObject._hashCode = 0; + BaseObject._defaultMaxCount = 1000; + BaseObject._maxCountMap = {}; + BaseObject._poolsMap = {}; + return BaseObject; + }()); + dragonBones.BaseObject = BaseObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Matrix = (function () { + 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; + } + /** + * @private + */ + 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; + }; + /** + * 转换为单位矩阵。 + * @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; + }; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @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; + }; + /** + * 转换为逆矩阵。 + * @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; + }; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params 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; + } + }; + return Matrix; + }()); + dragonBones.Matrix = Matrix; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Transform = (function () { + function Transform( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Transform.prototype.toMatrix = function (matrix) { + if (this.skew !== 0.0 || this.rotation !== 0.0) { + 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; + } + } + else { + matrix.a = this.scaleX; + matrix.b = 0.0; + matrix.c = 0.0; + matrix.d = this.scaleY; + } + matrix.tx = this.x; + matrix.ty = this.y; + return this; + }; + /** + * @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 = {})); +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 = {})); +var dragonBones; +(function (dragonBones) { + var Point = (function () { + function Point(x, y) { + if (x === void 0) { x = 0.0; } + if (y === void 0) { y = 0.0; } + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function () { + this.x = this.y = 0.0; + }; + return Point; + }()); + dragonBones.Point = Point; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + var Rectangle = (function () { + 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; + } + Rectangle.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function () { + this.x = this.y = 0.0; + this.width = this.height = 0.0; + }; + return Rectangle; + }()); + dragonBones.Rectangle = Rectangle; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 自定义数据。 + * @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; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.ints = []; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.floats = []; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.strings = []; + return _this; + } + /** + * @private + */ + UserData.toString = function () { + return "[class dragonBones.UserData]"; + }; + /** + * @private + */ + UserData.prototype._onClear = function () { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + /** + * 获取自定义整数。 + * @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; + }; + /** + * 获取自定义浮点数。 + * @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; + }; + /** + * 获取自定义字符串。 + * @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 = {})); +var dragonBones; +(function (dragonBones) { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @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; + /** + * @private + */ + _this.frameIndices = []; + /** + * @private + */ + _this.cachedFrames = []; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatureNames = []; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatures = {}; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + DragonBonesData.toString = function () { + return "[class dragonBones.DragonBonesData]"; + }; + /** + * @private + */ + 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.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + //this.armatures.clear(); + this.intArray = null; // + this.floatArray = null; // + this.frameIntArray = null; // + this.frameFloatArray = null; // + this.frameArray = null; // + this.timelineArray = null; // + this.userData = null; + }; + /** + * @private + */ + DragonBonesData.prototype.addArmature = function (value) { + if (value.name in this.armatures) { + console.warn("Replace armature: " + value.name); + this.armatures[value.name].returnToPool(); + } + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + DragonBonesData.prototype.getArmature = function (name) { + return name in this.armatures ? this.armatures[name] : null; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + DragonBonesData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + return DragonBonesData; + }(dragonBones.BaseObject)); + dragonBones.DragonBonesData = DragonBonesData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var CanvasData = (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + /** + * @private + */ + 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; + /** + * 骨架数据。 + * @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(); + /** + * 所有动画数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.bones = {}; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.slots = {}; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.skins = {}; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + /** + * @private + */ + 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.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.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + 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; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @private + */ + 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); + } + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Replace bone: " + value.name); + this.bones[value.name].returnToPool(); + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Replace slot: " + value.name); + this.slots[value.name].returnToPool(); + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Replace skin: " + value.name); + this.skins[value.name].returnToPool(); + } + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + }; + /** + * @private + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Replace animation: " + value.name); + this.animations[value.name].returnToPool(); + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (name) { + return name in this.bones ? this.bones[name] : null; + }; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (name) { + return name in this.slots ? this.slots[name] : null; + }; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (name) { + return name in this.skins ? this.skins[name] : null; + }; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (name) { + return name in this.animations ? this.animations[name] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * 骨骼数据。 + * @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.constraints = []; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + /** + * @private + */ + BoneData.prototype._onClear = function () { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0.0; + this.name = ""; + this.transform.identity(); + this.constraints.length = 0; + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * 插槽数据。 + * @see dragonBones.Slot + * @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; + } + /** + * @private + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + /** + * @private + */ + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + /** + * @private + */ + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @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]"; + }; + /** + * @private + */ + 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(); + }; + /** + * @private + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + 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 = {})); +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.target = null; // + this.bone = null; // + this.root = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @private + */ + 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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @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; + }; + 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.weight = null; // Initial value. + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Mesh */; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + }; + return MeshDisplayData; + }(ImageDisplayData)); + 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 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; + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 边界框数据基类。 + * @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; + } + /** + * @private + */ + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 多边形边界框。 + * @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; + /** + * @private + */ + _this.weight = null; // Initial value. + return _this; + } + /** + * @private + */ + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, offset, count, 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 dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[offset + count - 2]; + var yC = vertices[offset + 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[offset + i]; + var yD = vertices[offset + 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; + }; + /** + * @private + */ + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Polygon */; + this.count = 0; + this.offset = 0; + this.x = 0.0; + this.y = 0.0; + this.vertices = null; // + this.weight = null; + }; + /** + * @inherDoc + */ + 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.count, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[this.offset + iP + 1]; + var yB = this.vertices[this.offset + i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[this.offset + iP]; + var xB = this.vertices[this.offset + i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inherDoc + */ + 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.width, this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, this.offset, this.count, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画数据。 + * @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.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + /** + * @private + */ + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var kA in this.boneTimelines[k]) { + this.boneTimelines[k][kA].returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var kA in this.slotTimelines[k]) { + this.slotTimelines[k][kA].returnToPool(); + } + delete this.slotTimelines[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.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.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @private + */ + 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 (bone, timeline) { + var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (slot, timeline) { + var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (name) { + return name in this.boneTimelines ? this.boneTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimeline = function (name) { + return name in this.slotTimelines ? this.slotTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (name) { + return name in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (name) { + return name in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[name] : 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; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + var AnimationConfig = (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + /** + * @private + */ + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additiveBlending = 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.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.weight = 1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + 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.additiveBlending = value.additiveBlending; + 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]; + } + }; + AnimationConfig.prototype.containsBoneMask = function (name) { + return this.boneMask.length === 0 || this.boneMask.indexOf(name) >= 0; + }; + AnimationConfig.prototype.addBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = armature.getBone(name); + if (currentBone === null) { + return; + } + if (this.boneMask.indexOf(name) < 0) { + this.boneMask.push(name); + } + if (recursive) { + for (var _i = 0, _a = 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); + } + } + } + }; + AnimationConfig.prototype.removeBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this.boneMask.indexOf(name); + if (index >= 0) { + this.boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = armature.getBone(name); + if (currentBone !== null) { + if (this.boneMask.length > 0) { + for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_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 _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 贴图集数据。 + * @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; + } + /** + * @private + */ + 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; + } + }; + /** + * @private + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Replace texture: " + value.name); + this.textures[value.name].returnToPool(); + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (name) { + return name in this.textures ? this.textures[name] : 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 = {})); +var dragonBones; +(function (dragonBones_1) { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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 = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @private + */ + _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._zOrder > b._zOrder ? 1 : -1; + }; + /** + * @private + */ + 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._actions; _d < _e.length; _d++) { + var action = _e[_d]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.clear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null; // + this.userData = null; + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._actions.length = 0; + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + Armature.prototype._sortBones = function () { + var total = this._bones.length; + if (total <= 0) { + return; + } + var sortHelper = this._bones.concat(); + var index = 0; + var count = 0; + this._bones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this._bones.indexOf(bone) >= 0) { + continue; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this._bones.indexOf(bone.parent) < 0) { + continue; + } + this._bones.push(bone); + count++; + } + }; + Armature.prototype._sortSlots = function () { + this._slots.sort(Armature._onSortSlots); + }; + /** + * @internal + * @private + */ + 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 + * @private + */ + Armature.prototype._addBoneToBoneList = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeBoneFromBoneList = function (value) { + var index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._addSlotToSlotList = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeSlotFromSlotList = function (value) { + var index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this.armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @private + */ + 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.init(this); + this._animation.init(this); + this._animation.animations = this.armatureData.animations; + }; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + if (this.armatureData === null) { + console.assert(false, "The armature has been disposed."); + return; + } + else if (this.armatureData.parent === null) { + console.assert(false, "The armature data has been disposed."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update nimation. + this._animation.advanceTime(passedTime); + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + // 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); + } + } + if (this._actions.length > 0) { + this._lockUpdate = true; + for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { + var action = _a[_i]; + if (action.type === 0 /* Play */) { + this._animation.fadeIn(action.name); + } + } + this._actions.length = 0; + this._lockUpdate = false; + } + // + var drawed = this.debugDraw || dragonBones_1.DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + }; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlotDisplay) { + 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 (updateSlotDisplay) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @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; + }; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + }; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @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; + }; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @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; + }; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @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; + }; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @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; + }; + /** + * @deprecated + */ + Armature.prototype.addBone = function (value, parentName) { + if (parentName === void 0) { parentName = null; } + console.assert(value !== null); + value._setArmature(this); + value._setParent(parentName !== null ? this.getBone(parentName) : null); + }; + /** + * @deprecated + */ + Armature.prototype.removeBone = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * @deprecated + */ + Armature.prototype.addSlot = function (value, parentName) { + var bone = this.getBone(parentName); + console.assert(value !== null && bone !== null); + value._setArmature(this); + value._setParent(bone); + }; + /** + * @deprecated + */ + Armature.prototype.removeSlot = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + 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", { + 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", { + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @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", { + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this.armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * 获得动画控制器。 + * @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", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + 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", { + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + Armature.prototype.replaceTexture = function (texture) { + this.replacedTexture = texture; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.hasEventListener = function (type) { + return this._proxy.hasEvent(type); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.addEventListener = function (type, listener, target) { + this._proxy.addEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.removeEventListener = function (type, listener, target) { + this._proxy.removeEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + Armature.prototype.enableAnimationCache = function (frameRate) { + this.cacheFrameRate = frameRate; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础变换对象。 + * @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; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + * @private + */ + TransformObject.prototype._onClear = function () { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; // + this.userData = null; + this._globalDirty = false; + this._armature = null; // + this._parent = null; // + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setArmature = function (value) { + this._armature = value; + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setParent = function (value) { + this._parent = value; + }; + /** + * @private + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransformObject.prototype, "parent", { + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + TransformObject._helpMatrix = new dragonBones.Matrix(); + /** + * @private + */ + TransformObject._helpTransform = new dragonBones.Transform(); + /** + * @private + */ + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @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 + * @private + */ + _this.animationPose = new dragonBones.Transform(); + /** + * @internal + * @private + */ + _this.constraints = []; + _this._bones = []; + _this._slots = []; + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + /** + * @private + */ + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this.constraints.length = 0; + this.boneData = null; // + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1.0; + this._blendLayerWeight = 0.0; + this._bones.length = 0; + this._slots.length = 0; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var inherit = this._parent !== null; + var dR = 0.0; + if (this.offsetMode === 1 /* Additive */) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } + else if (this.offsetMode === 0 /* None */) { + global.copyFrom(this.origin).add(this.animationPose); + } + else { + inherit = false; + global.copyFrom(this.offset); + } + if (inherit) { + var parentMatrix = this._parent.globalTransformMatrix; + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (this.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 (this.boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + if (this._parent.global.scaleX < 0.0) { + dR += Math.PI; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + dR -= global.rotation * 2.0; + if (flipX !== flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + global.rotation += dR; + } + else if (flipX || flipY) { + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + * @private + */ + Bone.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + var oldSlots = null; + var oldBones = null; + if (this._armature !== null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + this._armature = value; // + if (this._armature !== null) { + this._armature._addBoneToBoneList(this); + } + if (oldSlots !== null) { + for (var _i = 0, oldSlots_1 = oldSlots; _i < oldSlots_1.length; _i++) { + var slot = oldSlots_1[_i]; + if (slot.parent === this) { + slot._setArmature(this._armature); + } + } + } + if (oldBones !== null) { + for (var _a = 0, oldBones_1 = oldBones; _a < oldBones_1.length; _a++) { + var bone = oldBones_1[_a]; + if (bone.parent === this) { + bone._setArmature(this._armature); + } + } + } + }; + /** + * @internal + * @private + */ + Bone.prototype.init = function (boneData) { + if (this.boneData !== null) { + return; + } + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + }; + /** + * @internal + * @private + */ + Bone.prototype.update = function (cacheFrameIndex) { + this._blendDirty = false; + 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.constraints.length > 0) { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + 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.constraints.length > 0) { + for (var _b = 0, _c = this.constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + 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 + * @private + */ + 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; + } + }; + /** + * @internal + * @private + */ + Bone.prototype.addConstraint = function (constraint) { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.push(constraint); + } + }; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (child) { + if (child === this) { + return false; + } + var ancestor = child; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getBones = function () { + this._bones.length = 0; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.parent === this) { + this._bones.push(bone); + } + } + return this._bones; + }; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getSlots = function () { + this._slots.length = 0; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + this._slots.push(slot); + } + } + return this._slots; + }; + Object.defineProperty(Bone.prototype, "visible", { + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @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, "length", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + get: function () { + return this.boneData.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + get: function () { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + return slot; + } + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @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; + /** + * @private + */ + _this._localMatrix = new dragonBones.Matrix(); + /** + * @private + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @private + */ + _this._ffdVertices = []; + /** + * @private + */ + _this._displayDatas = []; + /** + * @private + */ + _this._displayList = []; + /** + * @private + */ + _this._meshBones = []; + /** + * @private + */ + _this._rawDisplay = null; // Initial value. + /** + * @private + */ + _this._meshDisplay = null; // Initial value. + return _this; + } + /** + * @private + */ + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { + var eachDisplay = _a[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + 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); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { + this._disposeDisplay(this._meshDisplay); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay); + } + this.displayController = null; + this.slotData = null; // + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.length = 0; + this._displayList.length = 0; + this._displayDatas.length = 0; + this._meshBones.length = 0; + this._rawDisplayDatas = null; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Slot.prototype._updateDisplayData = function () { + var prevDisplayData = this._displayData; + var prevTextureData = this._textureData; + var prevMeshData = this._meshData; + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.length) { + this._displayData = this._displayDatas[this._displayIndex]; + } + else { + this._displayData = null; + } + // Update texture and mesh data. + if (this._displayData !== null) { + if (this._displayData.type === 0 /* Image */ || this._displayData.type === 2 /* Mesh */) { + this._textureData = this._displayData.texture; + if (this._displayData.type === 2 /* Mesh */) { + this._meshData = this._displayData; + } + else if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */) { + this._meshData = rawDisplayData; + } + else { + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + // Update bounding box data. + if (this._displayData !== null && this._displayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = this._displayData.boundingBox; + } + else if (rawDisplayData !== null && rawDisplayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = rawDisplayData.boundingBox; + } + else { + this._boundingBoxData = null; + } + if (this._displayData !== prevDisplayData || this._textureData !== prevTextureData || this._meshData !== prevMeshData) { + // Update pivot offset. + if (this._meshData !== null) { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + else if (this._textureData !== null) { + var imageDisplayData = this._displayData; + var 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 * scale; + var height = rect.height * scale; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width; + this._pivotY *= height; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update mesh bones and ffd vertices. + if (this._meshData !== prevMeshData) { + if (this._meshData !== null) { + if (this._meshData.weight !== null) { + this._ffdVertices.length = this._meshData.weight.count * 2; + this._meshBones.length = this._meshData.weight.bones.length; + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.weight.bones[i].name); + } + } + else { + var vertexCount = this._meshData.parent.parent.intArray[this._meshData.offset + 0 /* MeshVertexCount */]; + this._ffdVertices.length = vertexCount * 2; + this._meshBones.length = 0; + } + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0.0; + } + this._meshDirty = true; + } + else { + this._ffdVertices.length = 0; + this._meshBones.length = 0; + } + } + else if (this._meshData !== null && this._textureData !== prevTextureData) { + this._meshDirty = true; + } + if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData && this._meshData === null) { + 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; + this._displayData.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; + } + // Update original transform. + if (rawDisplayData !== null) { + this.origin = rawDisplayData.transform; + } + else if (this._displayData !== null) { + this.origin = this._displayData.transform; + } + this._displayDirty = true; + this._transformDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + 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._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + // Update frame. + if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { + this._updateFrame(); + } + // 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. + var actions = null; + if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { + actions = this._displayData.actions; + } + else { + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { + actions = rawDisplayData.actions; + } + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + }; + /** + * @private + */ + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._isMeshBonesUpdate = function () { + for (var _i = 0, _a = this._meshBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + * @private + */ + Slot.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + if (this._armature !== null) { + this._armature._removeSlotFromSlotList(this); + } + this._armature = value; // + this._onUpdateDisplay(); + if (this._armature !== null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); + } + }; + /** + * @internal + * @private + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return false; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return false; + } + this._displayIndex = value; + this._displayDirty = true; + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setZorder = function (value) { + if (this._zOrder === value) { + //return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return this._colorDirty; + }; + /** + * @private + */ + Slot.prototype._setDisplayList = function (value) { + if (value !== null && value.length > 0) { + if (this._displayList.length !== value.length) { + this._displayList.length = value.length; + } + for (var i = 0, l = value.length; i < l; ++i) { + var eachDisplay = value[i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { + this._initDisplay(eachDisplay); + } + this._displayList[i] = eachDisplay; + } + } + else if (this._displayList.length > 0) { + this._displayList.length = 0; + } + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display !== this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display !== null; + } + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @private + */ + Slot.prototype.init = function (slotData, displayDatas, rawDisplay, meshDisplay) { + if (this.slotData !== null) { + return; + } + this.slotData = slotData; + this.name = this.slotData.name; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._displayDatas.length = this._rawDisplayDatas.length; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) { + this._displayDatas[i] = this._rawDisplayDatas[i]; + } + }; + /** + * @internal + * @private + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + if (this._transformDirty) { + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + 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._display === null) { + return; + } + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + if (this._meshData !== null && this._display === this._meshDisplay) { + var isSkinned = this._meshData.weight !== null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + return; + } + } + if (this._transformDirty) { + this._transformDirty = false; + 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(false); + } + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + }; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @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); + }; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + }; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDirty = true; + this._transformDirty = true; + }; + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._displayList.concat(); + }, + set: function (value) { + var backupDisplayList = this._displayList.concat(); // Copy. + var disposeDisplayList = new Array(); + if (this._setDisplayList(value)) { + this.update(-1); + } + // Release replaced displays. + for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { + var eachDisplay = backupDisplayList_1[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { + var eachDisplay = disposeDisplayList_2[_a]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + 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", { + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + var displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength === 0) { + this._displayIndex = 0; + } + if (this._displayIndex < 0) { + return; + } + else { + var replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @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 + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + * @internal + */ + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this.target = null; // + this.bone = null; // + this.root = null; // + }; + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @private + * @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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this.target.global; + var global = this.bone.global; + var globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + var ikRadian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadian += Math.PI; + } + global.rotation += (ikRadian - 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 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 ikRadianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + ikRadianA += 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; + if (parent._parent !== null) { + var parentParentMatrix = parent._parent.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; + } + ikRadianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + var parentRadian = rawRadianA + dR; + global.x = parentGlobal.x + Math.cos(parentRadian) * lP; + global.y = parentGlobal.y + Math.sin(parentRadian) * lP; + var ikRadianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadianB += Math.PI; + } + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.update = function () { + if (this.root === null) { + this.bone.updateByConstraint(); + this._computeA(); + } + else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = (function () { + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = -1.0; } + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._animatebles = []; + this._clock = null; + if (time < 0.0) { + this.time = new Date().getTime() * 0.001; + } + else { + this.time = time; + } + } + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + if (passedTime < 0.0) { + passedTime = new Date().getTime() * 0.001 - this.time; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + if (passedTime === 0.0) { + return; + } + 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; + } + }; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + return this._animatebles.indexOf(value) >= 0; + }; + /** + * 添加 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; + } + }; + /** + * 移除 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; + } + }; + /** + * 清除所有的 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 + }); + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.clock = new WorldClock(); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @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._animationConfig = null; // Initial value. + return _this; + } + /** + * @private + */ + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + /** + * @private + */ + 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]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._timelineDirty = false; + 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.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.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.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]; + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 0 /* None */: + case 5 /* Single */: + default: + break; + } + }; + /** + * @internal + * @private + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + * @private + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { + passedTime *= this._armature._parent._armature.animation.timeScale; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + 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]; + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + this._timelineDirty = false; + }; + /** + * 清除所有动画状态。 + * @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._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * 暂停播放动画。 + * @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(); + } + } + }; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @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.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 > 1) { + 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) { + } + else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + // Child armature play same name animation. + 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); // + } + } + if (animationConfig.fadeInTime <= 0.0) { + this._armature.advanceTime(0.0); + } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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.duration * frame / animationData.frameCount; + } + return this.playConfig(this._animationConfig); + }; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName) { + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName) { + return animationState; + } + } + return null; + }; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * 动画是否处于播放状态。 + * @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", { + /** + * 所有动画状态是否均已播放完毕。 + * @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", { + /** + * 上一个正在播放的动画状态名称。 + * @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", { + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @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._animations[k] = value[k]; + this._animationNames.push(k); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * 一个可以快速使用的动画配置实例。 + * @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", { + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (duration === void 0) { duration = -1; } + 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 */; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + var animationData = this._animations[animationName]; + if (animationData && duration > 0.0) { + this._animationConfig.timeScale = animationData.duration / duration; + } + return this.playConfig(this._animationConfig); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + Animation.prototype.gotoAndStop = function (animationName, time) { + if (time === void 0) { time = 0; } + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); + } + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var BonePose = (function (_super) { + __extends(BonePose, _super); + function BonePose() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.current = new dragonBones.Transform(); + _this.delta = new dragonBones.Transform(); + _this.result = new dragonBones.Transform(); + return _this; + } + BonePose.toString = function () { + return "[class dragonBones.BonePose]"; + }; + BonePose.prototype._onClear = function () { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return BonePose; + }(dragonBones.BaseObject)); + dragonBones.BonePose = BonePose; + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @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._slotTimelines = []; + _this._bonePoses = {}; + /** + * @internal + * @private + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + /** + * @private + */ + 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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1.0; + this.weight = 1.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this.animationData = null; // + this._timelineDirty = true; + 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._slotTimelines.length = 0; + // this._bonePoses.clear(); + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + }; + AnimationState.prototype._isDisabled = function (slot) { + if (this.displayControl) { + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + return false; + } + } + return true; + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasEvent(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 eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + }; + AnimationState.prototype._blendBoneTimline = function (timeline) { + var bone = timeline.bone; + var bonePose = timeline.bonePose.result; + var animationPose = bone.animationPose; + var boneWeight = this._weightResult > 0.0 ? this._weightResult : -this._weightResult; + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1.0; + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1.0) * boneWeight + 1.0; + animationPose.scaleY = (bonePose.scaleY - 1.0) * boneWeight + 1.0; + } + else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1.0) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1.0) * boneWeight; + } + if (this._fadeState !== 0 || this._subFadeState !== 0) { + bone._transformDirty = true; + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + 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); + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.updateTimelines = function () { + var boneTimelines = {}; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.bone.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + var timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (timelineName in boneTimelines) { + delete boneTimelines[timelineName]; + } + else { + var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); + if (timelineDatas !== null) { + for (var _d = 0, timelineDatas_1 = timelineDatas; _d < timelineDatas_1.length; _d++) { + var timelineData = timelineDatas_1[_d]; + switch (timelineData.type) { + case 10 /* BoneAll */: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + case 11 /* BoneT */: + case 12 /* BoneR */: + case 13 /* BoneS */: + // TODO + break; + case 14 /* BoneX */: + case 15 /* BoneY */: + case 16 /* BoneRotate */: + case 17 /* BoneSkew */: + case 18 /* BoneScaleX */: + case 19 /* BoneScaleY */: + // TODO + break; + } + } + } + else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + for (var k in boneTimelines) { + for (var _e = 0, _f = boneTimelines[k]; _e < _f.length; _e++) { + var timeline = _f[_e]; + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + var slotTimelines = {}; + var ffdFlags = []; + for (var _g = 0, _h = this._slotTimelines; _g < _h.length; _g++) { + var timeline = _h[_g]; + var timelineName = timeline.slot.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _j = 0, _k = this._armature.getSlots(); _j < _k.length; _j++) { + var slot = _k[_j]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + var timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (timelineName in slotTimelines) { + delete slotTimelines[timelineName]; + } + else { + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + if (timelineDatas !== null) { + for (var _l = 0, timelineDatas_2 = timelineDatas; _l < timelineDatas_2.length; _l++) { + var timelineData = timelineDatas_2[_l]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 21 /* SlotColor */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotFFD */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + if (this.resetToPose) { + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + for (var _m = 0, _o = slot._rawDisplayDatas; _m < _o.length; _m++) { + var displayData = _o[_m]; + if (displayData !== null && displayData.type === 2 /* Mesh */ && ffdFlags.indexOf(displayData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { + for (var _p = 0, _q = slotTimelines[k]; _p < _q.length; _p++) { + var timeline = _q[_p]; + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + }; + /** + * @private + * @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; + } + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + if (this.weight === 0.0) { + return; + } + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this.weight * this._fadeProgress; + this._actionTimeline.update(time); // Update main timeline. + if (isCacheEnabled) { + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null) { + 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) { + if (isUpdateBoneTimeline) { + var bone = null; + var prevTimeline = null; // + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (bone !== timeline.bone) { + if (bone !== null) { + this._blendBoneTimline(prevTimeline); + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0.0) { + if (bone._blendLayer !== this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0.0; + bone = null; + } + else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0.0; + } + } + } + else { + bone = null; + } + } + } + bone = timeline.bone; + } + if (bone !== null) { + timeline.update(time); + if (i === l - 1) { + this._blendBoneTimline(timeline); + } + else { + prevTimeline = timeline; + } + } + } + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (this._isDisabled(timeline.slot)) { + continue; + } + timeline.update(time); + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * 淡出动画。 + * @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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (name) { + return this._boneMask.length === 0 || this._boneMask.indexOf(name) >= 0; + }; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(name); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(name) < 0) { + this._boneMask.push(name); + } + 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 = true; + }; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(name); + if (index >= 0) { + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(name); + 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_2 = this._boneMask.indexOf(bone.name); + if (index_2 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_2, 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 = true; + }; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = true; + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * 是否正在播放。 + * @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", { + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * 当前播放的时间。 (以秒为单位) + * @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) { + 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, "clip", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + get: function () { + return this.animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var TimelineState = (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this._tweenState = 0 /* None */; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 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._dragonBonesData = null; // + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._frameIntArray = null; // + this._frameFloatArray = 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._duration; + } + } + 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._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + if (this._timelineData !== null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._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 () { }; + TimelineState.prototype.update = function (passedTime) { + if (this.playState <= 0 && 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._tweenState !== 0 /* None */) { + this._onUpdateFrame(); + } + } + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + * @private + */ + 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 segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : 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._tweenProgress = 0.0; + this._tweenEasing = 0.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 */]; // TODO recode ture tween type. + this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; + 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; + } + 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]; + this._frameDurationR = 1.0 / (this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition); + } + } + else { + this._tweenState = 1 /* Once */; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._tweenState === 2 /* Always */) { + 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); + } + } + else { + this._tweenProgress = 0.0; + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + * @private + */ + var BoneTimelineState = (function (_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.bone = null; // + this.bonePose = null; // + }; + return BoneTimelineState; + }(TweenTimelineState)); + dragonBones.BoneTimelineState = BoneTimelineState; + /** + * @internal + * @private + */ + var SlotTimelineState = (function (_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.slot = null; // + }; + return SlotTimelineState; + }(TweenTimelineState)); + dragonBones.SlotTimelineState = SlotTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + 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._armature.armatureData.actions; + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + if (action.slot !== null) { + var slot = this._armature.getSlot(action.slot.name); + if (slot !== null) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature._bufferAction(action, true); + } + } + } + else if (action.bone !== null) { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null && slot.parent.boneData === action.bone) { + childArmature._bufferAction(action, true); + } + } + } + else { + this._armature._bufferAction(action, true); + } + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasEvent(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.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + if (action.bone !== null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + if (action.slot !== null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + 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.playState <= 0 && this._setCurrentTime(passedTime)) { + 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 (eventDispatcher.hasEvent(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 (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasEvent(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.hasEvent(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 + * @private + */ + 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 + * @private + */ + 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._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + current.x = frameFloatArray[valueOffset++]; + current.y = frameFloatArray[valueOffset++]; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + delta.x = frameFloatArray[valueOffset++] - current.x; + delta.y = frameFloatArray[valueOffset++] - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } + // else { + // delta.x = 0.0; + // delta.y = 0.0; + // delta.rotation = 0.0; + // delta.skew = 0.0; + // delta.scaleX = 0.0; + // delta.scaleY = 0.0; + // } + } + else { + var current = this.bonePose.current; + current.x = 0.0; + current.y = 0.0; + current.rotation = 0.0; + current.skew = 0.0; + current.scaleX = 1.0; + current.scaleY = 1.0; + } + }; + BoneAllTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + var scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneAllTimelineState; + }(dragonBones.BoneTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + * @private + */ + var SlotDislayIndexTimelineState = (function (_super) { + __extends(SlotDislayIndexTimelineState, _super); + function SlotDislayIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDislayIndexTimelineState.toString = function () { + return "[class dragonBones.SlotDislayIndexTimelineState]"; + }; + SlotDislayIndexTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot.slotData.displayIndex; + if (this.slot.displayIndex !== displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + }; + return SlotDislayIndexTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotDislayIndexTimelineState = SlotDislayIndexTimelineState; + /** + * @internal + * @private + */ + 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._delta = [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._onClear = function () { + _super.prototype._onClear.call(this); + this._dirty = false; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var intArray = this._dragonBonesData.intArray; + var frameIntArray = this._dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + var colorOffset = frameIntArray[valueOffset]; + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1 * 1]; + } + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } + else { + var color = this.slot.slotData.color; + this._current[0] = color.alphaMultiplier * 100.0; + this._current[1] = color.redMultiplier * 100.0; + this._current[2] = color.greenMultiplier * 100.0; + this._current[3] = color.blueMultiplier * 100.0; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.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; + this.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]; + this.slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + * @private + */ + var SlotFFDTimelineState = (function (_super) { + __extends(SlotFFDTimelineState, _super); + function SlotFFDTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + SlotFFDTimelineState.toString = function () { + return "[class dragonBones.SlotFFDTimelineState]"; + }; + SlotFFDTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.meshOffset = 0; + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + SlotFFDTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var isTween = this._tweenState === 2 /* Always */; + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + if (isTween) { + var nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex === this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = frameFloatArray[nextValueOffset + i] - (this._current[i] = frameFloatArray[valueOffset + i]); + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = frameFloatArray[valueOffset + i]; + } + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = 0.0; + } + } + }; + SlotFFDTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + for (var i = 0; i < this._valueCount; ++i) { + this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + } + }; + SlotFFDTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntArray = this._dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this.meshOffset = frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */]; + this._ffdCount = frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */]; + this._valueOffset = frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */]; + this._frameFloatOffset = frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] + this._animationData.frameFloatOffset; + } + else { + this._valueCount = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = 0.0; + } + }; + SlotFFDTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotFFDTimelineState.prototype.update = function (passedTime) { + if (this.slot._meshData === null || (this._timelineData !== null && this.slot._meshData.offset !== this.meshOffset)) { + return; + } + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.slot._ffdVertices; + if (this._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] += (frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; + } + else { + result[i] += (frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + } + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] = frameFloatArray[this._frameFloatOffset + i]; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] = this._result[i - this._valueOffset]; + } + else { + result[i] = frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + } + } + this.slot._meshDirty = true; + } + } + else { + this._ffdCount = result.length; // + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + result[i] += (0.0 - result[i]) * fadeProgress; + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + result[i] = 0.0; + } + this.slot._meshDirty = true; + } + } + } + }; + return SlotFFDTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotFFDTimelineState = SlotFFDTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + /** + * @private + */ + 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.data = null; + }; + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(dragonBones || (dragonBones = {})); +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._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 */; + 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._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._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 */; + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + DataParser.parseDragonBonesData = function (rawData) { + if (rawData instanceof ArrayBuffer) { + return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); + } + else { + return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + DataParser.parseTextureAtlasData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.warn("已废弃,请参考 @see"); + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + } + return textureAtlasData; + }; + 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 = DataParser.DATA_VERSION_5_0; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + ]; + 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.BONE = "bone"; + DataParser.IK = "ik"; + DataParser.SLOT = "slot"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.Z_ORDER = "zOrder"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.VISIBLE_FRAME = "visibleFrame"; + 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.CANVAS = "canvas"; + 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.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + 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_FFD = "inheritFFD"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_TYPE = "tweenType"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + 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_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.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var ObjectDataParser = (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + /** + * @private + */ + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._intArrayJson = []; + _this._floatArrayJson = []; + _this._frameIntArrayJson = []; + _this._frameFloatArrayJson = []; + _this._frameArrayJson = []; + _this._timelineArrayJson = []; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._defalultColorOffset = -1; + _this._prevTweenRotate = 0; + _this._prevRotation = 0.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._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._weightBoneIndices = {}; + _this._cacheBones = {}; + _this._meshs = {}; + _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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + if (dragonBones.DragonBones.webAssembly) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + } + return value; + } + return String(value); + } + return defaultValue; + }; + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); + 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; + } + }; + ObjectDataParser.prototype._sortActionFrame = function (a, b) { + return a.frameStart > b.frameStart ? 1 : -1; + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (ObjectDataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (ObjectDataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (ObjectDataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + var frame = null; + if (this._actionFrames.length === 0) { + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _i = 0, _a = this._actionFrames; _i < _a.length; _i++) { + var eachFrame = _a[_i]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + } + if (frame === null) { + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.push(frame); + } + for (var i = 0; i < actionCount; ++i) { + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseCacheActionFrame = function (frame) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = frameArray.length; + var actionCount = frame.actions.length; + frameArray.length += 1 + 1 + actionCount; + frameArray[frameOffset + 0 /* FramePosition */] = frame.frameStart; + frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { + frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + // const armature = BaseObject.borrowObject(ArmatureData); + var armature = dragonBones.DragonBones.webAssembly ? new Module["ArmatureData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { + armature.frameRate = 24; + } + this._armature = armature; + if (ObjectDataParser.AABB in rawData) { + var rawAABB = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.X, 0.0); + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.Y, 0.0); + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.WIDTH, 0.0); + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.HEIGHT, 0.0); + } + if (ObjectDataParser.CANVAS in rawData) { + var rawCanvas = rawData[ObjectDataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (ObjectDataParser.COLOR in rawCanvas) { + ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.X, 0); + canvas.y = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.HEIGHT, 0); + armature.canvas = canvas; + } + if (ObjectDataParser.BONE in rawData) { + var rawBones = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, ObjectDataParser.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 { + (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); // Raw bone sort. + } + } + if (ObjectDataParser.IK in rawData) { + var rawIKS = rawData[ObjectDataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + this._parseIKConstraint(rawIK); + } + } + armature.sortBones(); + if (ObjectDataParser.SLOT in rawData) { + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot)); + } + } + if (ObjectDataParser.SKIN in rawData) { + var rawSkins = rawData[ObjectDataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (ObjectDataParser.ANIMATION in rawData) { + var rawAnimations = rawData[ObjectDataParser.ANIMATION]; + for (var _f = 0, rawAnimations_1 = rawAnimations; _f < rawAnimations_1.length; _f++) { + var rawAnimation = rawAnimations_1[_f]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (ObjectDataParser.DEFAULT_ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.DEFAULT_ACTIONS], armature.defaultActions, 0 /* Play */, null, null); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armature.actions, 0 /* Play */, null, null); + } + // for (const action of armature.defaultActions) { // Set default animation from default action. + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? armature.defaultActions.size() : armature.defaultActions.length); ++i) { + var action = dragonBones.DragonBones.webAssembly ? armature.defaultActions.get(i) : armature.defaultActions[i]; + if (action.type === 0 /* Play */) { + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + break; + } + } + // Clear helper. + this._rawBones.length = 0; + this._armature = null; + for (var k in this._meshs) { + delete this._meshs[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + 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._weightBoneIndices) { + delete this._weightBoneIndices[k]; + } + return armature; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBone = function (rawData) { + // const bone = BaseObject.borrowObject(BoneData); + var bone = dragonBones.DragonBones.webAssembly ? new Module["BoneData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform, this._armature.scale); + } + return bone; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, "")); + if (target === null) { + return; + } + // const constraint = BaseObject.borrowObject(IKConstraintData); + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraintData"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, ObjectDataParser.SCALE, false); + constraint.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1.0); + constraint.bone = bone; + constraint.target = target; + var chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + if (dragonBones.DragonBones.webAssembly) { + bone.constraints.push_back(constraint); + } + else { + bone.constraints.push(constraint); + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlot = function (rawData) { + // const slot = BaseObject.borrowObject(SlotData); + var slot = dragonBones.DragonBones.webAssembly ? new Module["SlotData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = dragonBones.DragonBones.webAssembly ? this._armature.sortedSlots.size() : this._armature.sortedSlots.length; + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, "")); // + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] === "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); + } + if (ObjectDataParser.COLOR in rawData) { + // slot.color = SlotData.createColor(); + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].createColor() : dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].DEFAULT_COLOR : dragonBones.SlotData.DEFAULT_COLOR; + } + if (ObjectDataParser.ACTIONS in rawData) { + var actions = this._slotChildActions[slot.name] = []; + this._parseActionData(rawData[ObjectDataParser.ACTIONS], actions, 0 /* Play */, null, null); + } + return slot; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSkin = function (rawData) { + // const skin = BaseObject.borrowObject(SkinData); + var skin = dragonBones.DragonBones.webAssembly ? new Module["SkinData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (ObjectDataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[ObjectDataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var display = null; + var name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, ObjectDataParser.PATH, ""); + var type = 0 /* Image */; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: + // const imageDisplay = display = BaseObject.borrowObject(ImageDisplayData); + var imageDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ImageDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + case 1 /* Armature */: + // const armatureDisplay = display = BaseObject.borrowObject(ArmatureDisplayData); + var armatureDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ArmatureDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armatureDisplay.actions, 0 /* Play */, null, null); + } + 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 _i = 0, _a = this._slotChildActions[this._slot.name]; _i < _a.length; _i++) { + var action = _a[_i]; + if (dragonBones.DragonBones.webAssembly) { + armatureDisplay.actions.push_back(action); + } + else { + armatureDisplay.actions.push(action); + } + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + case 2 /* Mesh */: + // const meshDisplay = display = BaseObject.borrowObject(MeshDisplayData); + var meshDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["MeshDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.inheritAnimation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + var shareName = ObjectDataParser._getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length > 0) { + var shareMesh = this._meshs[shareName]; + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } + else { + this._parseMesh(rawData, meshDisplay); + this._meshs[meshDisplay.name] = meshDisplay; + } + break; + case 3 /* BoundingBox */: + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + // const boundingBoxDisplay = display = BaseObject.borrowObject(BoundingBoxDisplayData); + var boundingBoxDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["BoundingBoxDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + if (display !== null) { + display.parent = this._armature; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform, this._armature.scale); + } + } + return display; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (ObjectDataParser.PIVOT in rawData) { + var rawPivot = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var rawUVs = rawData[ObjectDataParser.UVS]; + var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = Math.floor(rawTriangles.length / 3); // uint + var vertexOffset = floatArray.length; + var uvOffset = vertexOffset + vertexCount * 2; + mesh.offset = intArray.length; + intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; + intArray[mesh.offset + 0 /* MeshVertexCount */] = vertexCount; + intArray[mesh.offset + 1 /* MeshTriangleCount */] = triangleCount; + intArray[mesh.offset + 2 /* MeshFloatOffset */] = vertexOffset; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + intArray[mesh.offset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; + } + floatArray.length += vertexCount * 2 + vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray[vertexOffset + i] = rawVertices[i]; + floatArray[uvOffset + i] = rawUVs[i]; + } + if (ObjectDataParser.WEIGHTS in rawData) { + var rawWeights = rawData[ObjectDataParser.WEIGHTS]; + var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; + var rawBonePoses = rawData[ObjectDataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + var floatOffset = floatArray.length; + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = (rawWeights.length - vertexCount) / 2; + weight.offset = intArray.length; + weight.bones.length = weightBoneCount; + weightBoneIndices.length = weightBoneCount; + intArray.length += 1 + 1 + weightBoneCount + vertexCount + weight.count; + intArray[weight.offset + 1 /* WeigthFloatOffset */] = floatOffset; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.bones[i] = bone; + weightBoneIndices[i] = rawBoneIndex; + if (dragonBones.DragonBones.webAssembly) { + for (var j = 0; j < this._armature.sortedBones.size(); j++) { + if (this._armature.sortedBones.get(j) === bone) { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = j; + } + } + } + else { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = this._armature.sortedBones.indexOf(bone); + } + } + floatArray.length += weight.count * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = intArray[iB++] = rawWeights[iW++]; // uint + var x = floatArray[vertexOffset + iD]; + var y = floatArray[vertexOffset + 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 bone = this._rawBones[rawBoneIndex]; + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray[iB++] = weight.bones.indexOf(bone); + floatArray[iV++] = rawWeights[iW++]; + floatArray[iV++] = this._helpPoint.x; + floatArray[iV++] = this._helpPoint.y; + } + } + mesh.weight = weight; + // + this._weightSlotPose[mesh.name] = rawSlotPose; + this._weightBonePoses[mesh.name] = rawBonePoses; + this._weightBoneIndices[mesh.name] = weightBoneIndices; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (ObjectDataParser.SUB_TYPE in rawData && typeof rawData[ObjectDataParser.SUB_TYPE] === "string") { + type = ObjectDataParser._getBoundingBoxType(rawData[ObjectDataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["RectangleBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["EllipseBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, ObjectDataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = floatArray.length; + polygonBoundingBox.count = rawVertices.length; + polygonBoundingBox.vertices = floatArray; + floatArray.length += polygonBoundingBox.count; + for (var i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + var iN = i + 1; + var x = rawVertices[i]; + var y = rawVertices[iN]; + floatArray[polygonBoundingBox.offset + i] = x; + floatArray[polygonBoundingBox.offset + iN] = 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; + } + } + } + return polygonBoundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + if (dragonBones.DragonBones.webAssembly) { + animation.frameIntOffset = this._frameIntArrayJson.length; + animation.frameFloatOffset = this._frameFloatArrayJson.length; + animation.frameOffset = this._frameArrayJson.length; + } + else { + animation.frameIntOffset = this._data.frameIntArray.length; + animation.frameFloatOffset = this._data.frameFloatArray.length; + animation.frameOffset = this._data.frameArray.length; + } + this._animation = animation; + if (ObjectDataParser.FRAME in rawData) { + var rawFrames = rawData[ObjectDataParser.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, ObjectDataParser.DURATION, 1); + } + } + } + if (ObjectDataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[ObjectDataParser.Z_ORDER], 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); + } + if (ObjectDataParser.BONE in rawData) { + var rawTimelines = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (ObjectDataParser.SLOT in rawData) { + var rawTimelines = rawData[ObjectDataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (ObjectDataParser.FFD in rawData) { + var rawTimelines = rawData[ObjectDataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var slotName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot === null) { + continue; + } + this._slot = slot; + this._mesh = this._meshs[displayName]; + var timelineFFD = this._parseTimeline(rawTimeline, 22 /* SlotFFD */, false, true, 0, this._parseSlotFFDFrame); + if (timelineFFD !== null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + this._slot = null; // + this._mesh = null; // + } + } + if (this._actionFrames.length > 0) { + this._actionFrames.sort(this._sortActionFrame); + // const timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData); + var timeline = this._animation.actionTimeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var keyFrameCount = this._actionFrames.length; + timeline.type = 0 /* Action */; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = 100; + timelineArray[timeline.offset + 1 /* TimelineOffset */] = 0; + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = 0; + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = this._parseCacheActionFrame(this._actionFrames[0]) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + //(frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var frame = this._actionFrames[iK]; + frameStart = frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = this._parseCacheActionFrame(frame) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + this._actionFrames.length = 0; + } + this._animation = null; // + return animation; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTimeline = function (rawData, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { + if (!(ObjectDataParser.FRAME in rawData)) { + return null; + } + var rawFrames = rawData[ObjectDataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntArrayLength = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson.length : this._data.frameIntArray.length; + var frameFloatArrayLength = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson.length : this._data.frameFloatArray.length; + // const timeline = BaseObject.borrowObject(TimelineData); + var timeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0) * 100); + timelineArray[timeline.offset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0.0) * 100); + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = frameValueCount; + if (addIntOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + } + else if (addFloatOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + } + else { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + } + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var frameIndices = this._data.frameIndices; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // frameIndices.resize( frameIndices.size() + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + 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; + frameCount = ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + var timeline = this._parseTimeline(rawData, 10 /* BoneAll */, false, true, 6, this._parseBoneFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone, timeline); + } + this._bone = null; // + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (slot === null) { + return; + } + this._slot = slot; + var displayIndexTimeline = this._parseTimeline(rawData, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayIndexFrame); + if (displayIndexTimeline !== null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + var colorTimeline = this._parseTimeline(rawData, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount, frameArray) { + rawData; + frameCount; + var frameOffset = frameArray.length; + frameArray.length += 1; + frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount, frameArray) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (frameCount > 0) { + if (ObjectDataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[ObjectDataParser.CURVE], this._helpArray); + frameArray.length += 1 + 1 + this._helpArray.length; + frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; + for (var i = 0; i < sampleCount; ++i) { + frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (ObjectDataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (ObjectDataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[ObjectDataParser.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 < slotCount; ++i_1) { + zOrders[i_1] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_2 = 0, l = rawZOrder.length; i_2 < l; i_2 += 2) { + var slotIndex = rawZOrder[i_2]; + var zOrderOffset = rawZOrder[i_2 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + zOrders[originalIndex + zOrderOffset] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + frameArray.length += 1 + slotCount; + frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex]; + } + else { + frameArray[frameOffset + 2 + i] = zOrders[i]; + } + } + return frameOffset; + } + } + frameArray.length += 1; + frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneFrame = function (rawData, frameStart, frameCount) { + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + this._helpTransform.identity(); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevTweenRotate === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevTweenRotate; + } + } + this._prevTweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + var frameFloatOffset = frameFloatArray.length; + frameFloatArray.length += 6; + frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + frameFloatArray[frameFloatOffset++] = rotation; + frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotDisplayIndexFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + frameArray.length += 1; + frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var colorOffset = -1; + if (ObjectDataParser.COLOR in rawData) { + var rawColor = rawData[ObjectDataParser.COLOR]; + for (var k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + } + colorOffset = this._defalultColorOffset; + } + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1; + frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameFloatOffset = frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var rawVertices = ObjectDataParser.VERTICES in rawData ? rawData[ObjectDataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); // uint + var vertexCount = intArray[this._mesh.offset + 0 /* MeshVertexCount */]; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (this._mesh.weight !== null) { + var rawSlotPose = this._weightSlotPose[this._mesh.name]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.length += this._mesh.weight.count * 2; + iB = this._mesh.weight.offset + 2 /* WeigthBoneIndices */ + this._mesh.weight.bones.length; + } + else { + 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 (this._mesh.weight !== null) { + var rawBonePoses = this._weightBonePoses[this._mesh.name]; + var weightBoneIndices = this._weightBoneIndices[this._mesh.name]; + var vertexBoneCount = 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 = intArray[iB++]; + var bone = this._mesh.weight.bones[boneIndex]; + var rawBoneIndex = this._rawBones.indexOf(bone); + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + frameFloatArray[frameFloatOffset + i] = x; + frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1 + 1 + 1 + 1 + 1; + frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */] = this._mesh.offset; + frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */] = 0; + frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] = frameFloatOffset; + timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseActionData = function (rawData, actions, type, bone, slot) { + var actionCount = 0; + if (typeof rawData === "string") { + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_1 = rawData; _i < rawData_1.length; _i++) { + var rawAction = rawData_1[_i]; + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (ObjectDataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } + else { + if (ObjectDataParser.TYPE in rawAction && typeof rawAction[ObjectDataParser.TYPE] === "string") { + action.type = ObjectDataParser._getActionType(rawAction[ObjectDataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, ObjectDataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.NAME, ""); + } + if (ObjectDataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (ObjectDataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + if (ObjectDataParser.INTS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[ObjectDataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + dragonBones.DragonBones.webAssembly ? action.data.ints.push_back(rawValue) : action.data.ints.push(rawValue); + } + } + if (ObjectDataParser.FLOATS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[ObjectDataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + dragonBones.DragonBones.webAssembly ? action.data.floats.push_back(rawValue) : action.data.floats.push(rawValue); + } + } + if (ObjectDataParser.STRINGS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[ObjectDataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + dragonBones.DragonBones.webAssembly ? action.data.strings.push_back(rawValue) : action.data.strings.push(rawValue); + } + } + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + } + return actionCount; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0.0) * scale; + if (ObjectDataParser.ROTATE in rawData || ObjectDataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (ObjectDataParser.SKEW_X in rawData || ObjectDataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1.0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArray = function (rawData) { + rawData; + if (dragonBones.DragonBones.webAssembly) { + return; + } + this._data.intArray = []; + this._data.floatArray = []; + this._data.frameIntArray = []; + this._data.frameFloatArray = []; + this._data.frameArray = []; + this._data.timelineArray = []; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseWASMArray = function () { + var intArrayBuf = Module._malloc(this._intArrayJson.length * 2); + this._intArrayBuffer = new Int16Array(Module.HEAP16.buffer, intArrayBuf, this._intArrayJson.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + for (var i1 = 0; i1 < this._intArrayJson.length; ++i1) { + this._intArrayBuffer[i1] = this._intArrayJson[i1]; + } + var floatArrayBuf = Module._malloc(this._floatArrayJson.length * 4); + // Module.HEAPF32.set(this._floatArrayJson, floatArrayBuf); + this._floatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, this._floatArrayJson.length); + for (var i2 = 0; i2 < this._floatArrayJson.length; ++i2) { + this._floatArrayBuffer[i2] = this._floatArrayJson[i2]; + } + var frameIntArrayBuf = Module._malloc(this._frameIntArrayJson.length * 2); + // Module.HEAP16.set(this._frameIntArrayJson, frameIntArrayBuf); + this._frameIntArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, this._frameIntArrayJson.length); + for (var i3 = 0; i3 < this._frameIntArrayJson.length; ++i3) { + this._frameIntArrayBuffer[i3] = this._frameIntArrayJson[i3]; + } + var frameFloatArrayBuf = Module._malloc(this._frameFloatArrayJson.length * 4); + // Module.HEAPF32.set(this._frameFloatArrayJson, frameFloatArrayBuf); + this._frameFloatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, this._frameFloatArrayJson.length); + for (var i4 = 0; i4 < this._frameFloatArrayJson.length; ++i4) { + this._frameFloatArrayBuffer[i4] = this._frameFloatArrayJson[i4]; + } + var frameArrayBuf = Module._malloc(this._frameArrayJson.length * 2); + // Module.HEAP16.set(this._frameArrayJson, frameArrayBuf); + this._frameArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, this._frameArrayJson.length); + for (var i5 = 0; i5 < this._frameArrayJson.length; ++i5) { + this._frameArrayBuffer[i5] = this._frameArrayJson[i5]; + } + var timelineArrayBuf = Module._malloc(this._timelineArrayJson.length * 2); + // Module.HEAPU16.set(this._timelineArrayJson, timelineArrayBuf); + this._timelineArrayBuffer = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, this._timelineArrayJson.length); + for (var i6 = 0; i6 < this._timelineArrayJson.length; ++i6) { + this._timelineArrayBuffer[i6] = this._timelineArrayJson[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined); + var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + if (ObjectDataParser.DATA_VERSIONS.indexOf(version) >= 0 || + ObjectDataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + // const data = BaseObject.borrowObject(DragonBonesData); + var data = dragonBones.DragonBones.webAssembly ? new Module["DragonBonesData"]() : dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { + data.frameRate = 24; + } + if (ObjectDataParser.ARMATURE in rawData) { + this._defalultColorOffset = -1; + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[ObjectDataParser.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._intArrayJson.length > 0) { + this._parseWASMArray(); + } + this._data = null; + } + this._rawTextureAtlasIndex = 0; + if (ObjectDataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[ObjectDataParser.TEXTURE_ATLAS]; + } + else { + this._rawTextureAtlases = null; + } + return data; + } + else { + console.assert(false, "Nonsupport data version."); + } + return null; + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 0.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null) { + 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, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + if (scale > 0.0) { + textureAtlasData.scale = scale; + } + else { + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + scale = 1.0 / scale; // + if (ObjectDataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[ObjectDataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.X, 0.0) * scale; + textureData.region.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.Y, 0.0) * scale; + textureData.region.width = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.WIDTH, 0.0) * scale; + textureData.region.height = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.HEIGHT, 0.0) * scale; + var frameWidth = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.DragonBones.webAssembly ? Module["TextureData"].createRectangle() : dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_X, 0.0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_Y, 0.0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + /** + * @private + */ + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + var ActionFrame = (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); +})(dragonBones || (dragonBones = {})); +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._getUTF16Key = function (value) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + return value; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + // const timeline = timelineData !== null ? timelineData : BaseObject.borrowObject(TimelineData); + var timeline = timelineData !== null ? timelineData : (dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData)); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // (frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { + mesh.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + var weightOffset = this._intArray[mesh.offset + 3 /* MeshWeightOffset */]; + if (weightOffset >= 0) { + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArray[mesh.offset + 0 /* MeshVertexCount */]; + var boneCount = this._intArray[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + if (dragonBones.DragonBones.webAssembly) { + weight.bones.resize(boneCount, null); + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones.set(i, this._rawBones[boneIndex]); + } + } + else { + weight.bones.length = boneCount; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones[i] = this._rawBones[boneIndex]; + } + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArray[boneIndicesOffset++]; + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + mesh.weight = weight; + } + }; + /** + * @private + */ + BinaryDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + polygonBoundingBox.vertices = this._floatArray; + return polygonBoundingBox; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.DURATION, 1), 1); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.ObjectDataParser.NAME, dragonBones.ObjectDataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.ObjectDataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.ObjectDataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.ObjectDataParser.ACTION]); + } + if (dragonBones.ObjectDataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.ObjectDataParser.Z_ORDER]); + } + if (dragonBones.ObjectDataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + if (dragonBones.ObjectDataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + this._animation = null; + return animation; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + if (dragonBones.DragonBones.webAssembly) { + var tmpIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + var tmpFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + var tmpFrameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + var tmpTimelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + var intArrayBuf = Module._malloc(tmpIntArray.length * tmpIntArray.BYTES_PER_ELEMENT); + var floatArrayBuf = Module._malloc(tmpFloatArray.length * tmpFloatArray.BYTES_PER_ELEMENT); + var frameIntArrayBuf = Module._malloc(tmpFrameIntArray.length * tmpFrameIntArray.BYTES_PER_ELEMENT); + var frameFloatArrayBuf = Module._malloc(tmpFrameFloatArray.length * tmpFrameFloatArray.BYTES_PER_ELEMENT); + var frameArrayBuf = Module._malloc(tmpFrameArray.length * tmpFrameArray.BYTES_PER_ELEMENT); + var timelineArrayBuf = Module._malloc(tmpTimelineArray.length * tmpTimelineArray.BYTES_PER_ELEMENT); + this._intArray = new Int16Array(Module.HEAP16.buffer, intArrayBuf, tmpIntArray.length); + this._floatArray = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, tmpFloatArray.length); + this._frameIntArray = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, tmpFrameIntArray.length); + this._frameFloatArray = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, tmpFrameFloatArray.length); + this._frameArray = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, tmpFrameArray.length); + this._timelineArray = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, tmpTimelineArray.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + // Module.HEAPF32.set(tmpFloatArray, floatArrayBuf); + // Module.HEAP16.set(tmpFrameIntArray, frameIntArrayBuf); + // Module.HEAPF32.set(tmpFrameFloatArray, frameFloatArrayBuf); + // Module.HEAP16.set(tmpFrameArray, frameArrayBuf); + // Module.HEAPU16.set(tmpTimelineArray, timelineArrayBuf); + for (var i1 = 0; i1 < tmpIntArray.length; ++i1) { + this._intArray[i1] = tmpIntArray[i1]; + } + for (var i2 = 0; i2 < tmpFloatArray.length; ++i2) { + this._floatArray[i2] = tmpFloatArray[i2]; + } + for (var i3 = 0; i3 < tmpFrameIntArray.length; ++i3) { + this._frameIntArray[i3] = tmpFrameIntArray[i3]; + } + for (var i4 = 0; i4 < tmpFrameFloatArray.length; ++i4) { + this._frameFloatArray[i4] = tmpFrameFloatArray[i4]; + } + for (var i5 = 0; i5 < tmpFrameArray.length; ++i5) { + this._frameArray[i5] = tmpFrameArray[i5]; + } + for (var i6 = 0; i6 < tmpTimelineArray.length; ++i6) { + this._timelineArray[i6] = tmpTimelineArray[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + } + else { + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + } + }; + /** + * @inheritDoc + */ + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer); + 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._binary = rawData; + this._binaryOffset = 8 + 4 + headerLength; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + /** + * @private + */ + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var BuildArmaturePackage = (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = (function () { + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + this.autoSearch = false; + /** + * @private + */ + this._dragonBonesDataMap = {}; + /** + * @private + */ + this._textureAtlasDataMap = {}; + /** + * @private + */ + this._dragonBones = null; + /** + * @private + */ + 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; + } + /** + * @private + */ + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + var bones = dataPackage.armature.sortedBones; + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? bones.size() : bones.length); ++i) { + var boneData = dragonBones.DragonBones.webAssembly ? bones.get(i) : bones[i]; + var bone = dragonBones.DragonBones.webAssembly ? new Module["Bone"]() : dragonBones.BaseObject.borrowObject(dragonBones.Bone); + bone.init(boneData); + if (boneData.parent !== null) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + var constraints = boneData.constraints; + for (var j = 0; j < (dragonBones.DragonBones.webAssembly ? constraints.size() : constraints.length); ++j) { + var constraintData = dragonBones.DragonBones.webAssembly ? constraints.get(j) : constraints[j]; + var target = armature.getBone(constraintData.target.name); + if (target === null) { + continue; + } + // TODO more constraint type. + var ikConstraintData = constraintData; + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraint"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + var root = ikConstraintData.root !== null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + if (root !== null) { + root.addConstraint(constraint); + } + else { + bone.addConstraint(constraint); + } + } + } + }; + /** + * @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.displays[k]; + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.displays[k]; + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + if (!(slotData.name in skinSlots)) { + continue; + } + var displays = skinSlots[slotData.name]; + var slot = this._buildSlot(dataPackage, slotData, displays, armature); + var displayList = new Array(); + for (var _b = 0, displays_1 = displays; _b < displays_1.length; _b++) { + var displayData = displays_1[_b]; + if (displayData !== null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.push(null); + } + } + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + /** + * @private + */ + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.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); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 2 /* Mesh */: + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 1 /* Armature */: + var armatureDisplayData = displayData; + var childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + 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_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + childArmature._bufferAction(action, true); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + return display; + }; + /** + * @private + */ + BaseFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + var displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + for (var i = 0, l = displayList.length; i < l; ++i) { + if (!displayList[i]) { + displayList[i] = null; + } + } + } + if (slot._displayDatas.length <= displayIndex) { + slot._displayDatas.length = displayIndex + 1; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + if (!slot._displayDatas[i]) { + slot._displayDatas[i] = null; + } + } + } + slot._displayDatas[displayIndex] = displayData; + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay(dataPackage, displayData, displayIndex < slot._rawDisplayDatas.length ? slot._rawDisplayDatas[displayIndex] : null, slot); + } + else { + displayList[displayIndex] = null; + } + slot.displayList = displayList; + }; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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 dragonBonesData = null; + if (rawData instanceof ArrayBuffer) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } + else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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 = 0.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { + 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]); + } + } + } + }; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @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; + }; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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("Replace data: " + name); + this._dragonBonesDataMap[name].returnToPool(); + } + this._dragonBonesDataMap[name] = data; + }; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @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]; + } + }; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @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; + }; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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); + } + }; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @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]; + } + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @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; + }; + /** + * 清除所有的数据。 + * @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]; + } + }; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + 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); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + for (var _i = 0, displays_2 = displays; _i < displays_2.length; _i++) { + var display = displays_2[_i]; + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + }; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + var displayIndex = 0; + for (var _i = 0, displays_3 = displays; _i < displays_3.length; _i++) { + var displayData = displays_3[_i]; + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + }; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { + if (exclude === void 0) { exclude = null; } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (!(slot.name in skin.displays) || (exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + var displays = skin.displays[slot.name]; + var displayList = slot.displayList; // Copy. + displayList.length = displays.length; // Modify displayList length. + for (var i = 0, l = displays.length; i < l; ++i) { + var displayData = displays[i]; + if (displayData !== null) { + displayList[i] = this._getSlotDisplay(null, displayData, null, slot); + } + else { + displayList[i] = null; + } + } + slot._rawDisplayDatas = displays; + slot._displayDatas.length = displays.length; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + slot._displayDatas[i] = displays[i]; + } + slot.displayList = displayList; + } + }; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { + if (fromSkinName === void 0) { fromSkinName = null; } + if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } + if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } + var dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage(dataPackage, fromDragonBonesDataName || "", fromArmatreName, fromSkinName || "", "")) { + var fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.animation.animations = fromArmatureData.animations; + } + else { + var animations = {}; + for (var animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + for (var animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + toArmature.animation.animations = animations; + } + if (dataPackage.skin) { + var slots = toArmature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var toSlot = slots[i]; + var toSlotDisplayList = toSlot.displayList; + for (var j = 0, lJ = toSlotDisplayList.length; j < lJ; ++j) { + var toDisplayObject = toSlotDisplayList[j]; + if (toDisplayObject instanceof dragonBones.Armature) { + var displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays !== null && j < displays.length) { + var fromDisplayData = displays[j]; + if (fromDisplayData !== null && fromDisplayData.type === 1 /* Armature */) { + this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + return true; + } + } + return false; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + /** + * @private + */ + BaseFactory._objectParser = null; + /** + * @private + */ + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; +})(dragonBones || (dragonBones = {})); diff --git a/reference/DragonBones/out/dragonBones.min.js b/reference/DragonBones/out/dragonBones.min.js new file mode 100644 index 0000000..1261237 --- /dev/null +++ b/reference/DragonBones/out/dragonBones.min.js @@ -0,0 +1 @@ +"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]};return function(e,i){t(e,i);function a(){this.constructor=e}e.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}}();var dragonBones;(function(t){var e=function(){function e(e){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=e}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var i=0,a=this._objects;i0){for(var n=0;ni){r.length=i}t._maxCountMap[a]=i}else{t._defaultMaxCount=i;for(var a in t._poolsMap){if(a in t._maxCountMap){continue}var r=t._poolsMap[a];if(r.length>i){r.length=i}t._maxCountMap[a]=i}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in t._poolsMap){var a=t._poolsMap[r];a.length=0}}};t.borrowObject=function(e){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=1e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=1}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=1}if(r===void 0){r=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=i;this.d=a;this.tx=r;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 i=0;var a=0;var r=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;i+=this.b*t.d;a+=this.c*t.a;r+=this.c*t.b}if(t.b!==0||t.c!==0){i+=this.a*t.b;a+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=i;this.c=a;this.d=r;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var i=this.c;var a=this.d;var r=this.tx;var n=this.ty;if(e===0&&i===0){this.b=this.c=0;if(t===0||a===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;a=this.d=1/a;this.tx=-t*r;this.ty=-a*n}return this}var s=t*a-e*i;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=a*s;e=this.b=-e*s;i=this.c=-i*s;a=this.d=t*s;this.tx=-(o*r+i*n);this.ty=-(e*r+a*n);return this};t.prototype.transformPoint=function(t,e,i,a){if(a===void 0){a=false}i.x=this.a*t+this.c*e;i.y=this.b*t+this.d*e;if(!a){i.x+=this.tx;i.y+=this.ty}};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}if(r===void 0){r=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=i;this.rotation=a;this.scaleX=r;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.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};t.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};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.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};t.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};t.prototype.fromMatrix=function(e){var i=this.scaleX,a=this.scaleY;var r=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-r&&this.rotation-r&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.skew!==0||this.rotation!==0){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}}else{t.a=this.scaleX;t.b=0;t.c=0;t.d=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(i===void 0){i=1}if(a===void 0){a=1}if(r===void 0){r=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=i;this.blueMultiplier=a;this.alphaOffset=r;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,i,a){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}this.x=t;this.y=e;this.width=i;this.height=a}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(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){i=0}if(this.sortedBones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames;var a=i.length;i.length+=10;i[a]=t.a;i[a+1]=t.b;i[a+2]=t.c;i[a+3]=t.d;i[a+4]=t.tx;i[a+5]=t.ty;i[a+6]=e.rotation;i[a+7]=e.skew;i[a+8]=e.scaleX;i[a+9]=e.scaleY;return a};i.prototype.getCacheFrame=function(t,e,i){var a=this.parent.cachedFrames;t.a=a[i];t.b=a[i+1];t.c=a[i+2];t.d=a[i+3];t.tx=a[i+4];t.ty=a[i+5];e.rotation=a[i+6];e.skew=a[i+7];e.scaleX=a[i+8];e.scaleY=a[i+9];e.x=t.tx;e.y=t.ty};i.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Replace bone: "+t.name);this.bones[t.name].returnToPool()}this.bones[t.name]=t;this.sortedBones.push(t)};i.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Replace slot: "+t.name);this.slots[t.name].returnToPool()}this.slots[t.name]=t;this.sortedSlots.push(t)};i.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Replace skin: "+t.name);this.skins[t.name].returnToPool()}this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}};i.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Replace animation: "+t.name);this.animations[t.name].returnToPool()}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return i}(t.BaseObject);t.ArmatureData=i;var a=function(e){__extends(i,e);function i(){var i=e!==null&&e.apply(this,arguments)||this;i.transform=new t.Transform;i.constraints=[];i.userData=null;return i}i.toString=function(){return"[class dragonBones.BoneData]"};i.prototype._onClear=function(){for(var t=0,e=this.constraints;tr){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,i,a,r,n,s,o,l,h,f,u){if(h===void 0){h=null}if(f===void 0){f=null}if(u===void 0){u=null}var _=t>n&&ts&&in&&as&&r=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){return true}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var f=e.rectangleIntersectsSegment(t,i,a,r,-l,-h,l,h,n,s,o);return f};return e}(e);t.RectangleBoundingBoxData=i;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,i,a,r,n,s,o,l,h,f){if(l===void 0){l=null}if(h===void 0){h=null}if(f===void 0){f=null}var u=s/o;var _=u*u;e*=u;a*=u;var m=i-t;var c=a-e;var p=Math.sqrt(m*m+c*c);var d=m/p;var y=c/p;var g=(r-t)*d+(n-e)*y;var v=g*g;var b=t*t+e*e;var D=s*s;var T=D-b+v;var A=0;if(T>=0){var O=Math.sqrt(T);var B=g-O;var S=g+O;var x=B<0?-1:B<=p?0:1;var M=S<0?-1:S<=p?0:1;var w=x*M;if(w<0){return-1}else if(w===0){if(x===-1){A=2;i=t+S*d;a=(e+S*y)/u;if(l!==null){l.x=i;l.y=a}if(h!==null){h.x=i;h.y=a}if(f!==null){f.x=Math.atan2(a/D*_,i/D);f.y=f.x+Math.PI}}else if(M===1){A=1;t=t+B*d;e=(e+B*y)/u;if(l!==null){l.x=t;l.y=e}if(h!==null){h.x=t;h.y=e}if(f!==null){f.x=Math.atan2(e/D*_,t/D);f.y=f.x+Math.PI}}else{A=3;if(l!==null){l.x=t+B*d;l.y=(e+B*y)/u;if(f!==null){f.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+S*d;h.y=(e+S*y)/u;if(f!==null){f.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var i=this.width*.5;if(t>=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){e*=i/a;return Math.sqrt(t*t+e*e)<=i}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,i,a,r,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.weight=null;return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,i,a,r,n,s,o,l,h){if(o===void 0){o=null}if(l===void 0){l=null}if(h===void 0){h=null}if(t===i){t=i+1e-6}if(e===a){e=a+1e-6}var f=t-i;var u=e-a;var _=t*a-e*i;var m=0;var c=r[n+s-2];var p=r[n+s-1];var d=0;var y=0;var g=0;var v=0;var b=0;var D=0;for(var T=0;T=c&&w<=A||w>=A&&w<=c)&&(f===0||w>=t&&w<=i||w>=i&&w<=t)){var E=(_*S-u*x)/M;if((E>=p&&E<=O||E>=O&&E<=p)&&(u===0||E>=e&&E<=a||E>=a&&E<=e)){if(l!==null){var P=w-t;if(P<0){P=-P}if(m===0){d=P;y=P;g=w;v=E;b=w;D=E;if(h!==null){h.x=Math.atan2(O-p,A-c)-Math.PI*.5;h.y=h.x}}else{if(Py){y=P;b=w;D=E;if(h!==null){h.y=Math.atan2(O-p,A-c)-Math.PI*.5}}}m++}else{g=w;v=E;b=w;D=E;m++;if(h!==null){h.x=Math.atan2(O-p,A-c)-Math.PI*.5;h.y=h.x}break}}}c=A;p=O}if(m===1){if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=g;l.y=v}if(h!==null){h.y=h.x+Math.PI}}else if(m>1){m++;if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=b;l.y=D}}return m};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.weight!==null){this.weight.returnToPool()}this.type=2;this.count=0;this.offset=0;this.x=0;this.y=0;this.vertices=null;this.weight=null};e.prototype.containsPoint=function(t,e){var i=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var a=0,r=this.count,n=r-2;a=e||s=e){var l=this.vertices[this.offset+n];var h=this.vertices[this.offset+a];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 i=0,a=this.cacheFrames.length;i=0};e.prototype.addBoneMask=function(t,e,i){if(i===void 0){i=true}var a=t.getBone(e);if(a===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(i){for(var r=0,n=t.getBones();r=0){this.boneMask.splice(a,1)}if(i){var r=t.getBone(e);if(r!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&r.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,f=t.getBones();he._zOrder?1:-1};i.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=t){i=0}if(this._bones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s=n){continue}var o=i[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(r)}}this._slotsDirty=true;this._zOrderDirty=!a}};i.prototype._addBoneToBoneList=function(t){if(this._bones.indexOf(t)<0){this._bonesDirty=true;this._bones.push(t);this._animation._timelineDirty=true}};i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);if(e>=0){this._bones.splice(e,1);this._animation._timelineDirty=true}};i.prototype._addSlotToSlotList=function(t){if(this._slots.indexOf(t)<0){this._slotsDirty=true;this._slots.push(t);this._animation._timelineDirty=true}};i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);if(e>=0){this._slots.splice(e,1);this._animation._timelineDirty=true}};i.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};i.prototype.dispose=function(){if(this.armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};i.prototype.init=function(e,i,a,r){if(this.armatureData!==null){return}this.armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=i;this._display=a;this._dragonBones=r;this._proxy.init(this);this._animation.init(this);this._animation.animations=this.armatureData.animations};i.prototype.advanceTime=function(e){if(this._lockUpdate){return}if(this.armatureData===null){console.assert(false,"The armature has been disposed.");return}else if(this.armatureData.parent===null){console.assert(false,"The armature data has been disposed.");return}var i=this._cacheFrameIndex;this._animation.advanceTime(e);if(this._bonesDirty){this._bonesDirty=false;this._sortBones()}if(this._slotsDirty){this._slotsDirty=false;this._sortSlots()}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==i){var a=0,r=0;for(a=0,r=this._bones.length;a0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var i=this.getBone(t);if(i!==null){i.invalidUpdate();if(e){for(var a=0,r=this._slots;a0){if(r!==null||n!==null){if(r!==null){var T=o?r.y-e:r.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;m=n.y;y=b;if(s!==null){p=s.y}}}}else{d=b;break}}}if(d!==null&&r!==null){r.x=f;r.y=u;if(s!==null){s.x=c}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=p}}return d};i.prototype.getBone=function(t){for(var e=0,i=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.constraints.length>0){for(var i=0,a=this.constraints;i=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this.constraints.length>0){for(var n=0,s=this.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};i.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};i.prototype.addConstraint=function(t){if(this.constraints.indexOf(t)<0){this.constraints.push(t)}};i.prototype.invalidUpdate=function(){this._transformDirty=true};i.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};i.prototype.getBones=function(){this._bones.length=0;for(var t=0,e=this._armature.getBones();t=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var i=0,a=e.length;i0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=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._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._display===null){return}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._meshData!==null&&this._display===this._meshDisplay){var i=this._meshData.weight!==null;if(this._meshDirty||i&&this._isMeshBonesUpdate()){this._meshDirty=false;this._updateMesh()}if(i){if(this._transformDirty){this._transformDirty=false;this._updateTransform(true)}return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var a=t>=0;this._updateGlobalTransformMatrix(a);if(a&&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(false)}};i.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};i.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);return this._boundingBoxData.containsPoint(i._helpPoint.x,i._helpPoint.y)};i.prototype.intersectsSegment=function(t,e,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);t=i._helpPoint.x;e=i._helpPoint.y;i._helpMatrix.transformPoint(a,r,i._helpPoint);a=i._helpPoint.x;r=i._helpPoint.y;var l=this._boundingBoxData.intersectsSegment(t,e,a,r,n,s,o);if(l>0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,true);o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,true);o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x)}}return l};i.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat();var a=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var r=0,n=i;r0){this._animatebles[e-i]=r;this._animatebles[e]=null}r.advanceTime(t)}else{i++}}if(i>0){a=this._animatebles.length;for(;e=0};t.prototype.add=function(t){if(this._animatebles.indexOf(t)<0){this._animatebles.push(t);t.clock=this}};t.prototype.remove=function(t){var e=this._animatebles.indexOf(t);if(e>=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&i._subFadeState>0){this._armature._dragonBones.bufferObject(i);this._animationStates.length=0;this._lastAnimationState=null}else{var a=i.animationData;var r=a.cacheFrameRate;if(this._animationDirty&&r>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n1){for(var u=0,_=0;u0&&i._subFadeState>0){_++;this._armature._dragonBones.bufferObject(i);this._animationDirty=true;if(this._lastAnimationState===i){this._lastAnimationState=null}}else{if(_>0){this._animationStates[u-_]=i}if(this._timelineDirty){i.updateTimelines()}i.advanceTime(t,0)}if(u===e-1&&_>0){this._animationStates.length-=_;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}this._timelineDirty=false};i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=a.duration;e.position=a.duration-e.position}else if(e.position===a.duration){e.position-=1e-6}else if(e.position>a.duration){e.position%=a.duration}if(e.duration>0&&e.position+e.duration>a.duration){e.duration=a.duration-e.position}if(e.playTimes<0){e.playTimes=a.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,a,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,f=this._animationStates.length;h=this._animationStates[h].layer){}else{l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var u=0,_=this._armature.getSlots();u<_.length;u++){var m=_[u];var c=m.childArmature;if(c!==null&&c.inheritAnimation&&c.animation.hasAnimation(i)&&c.animation.getState(i)===null){c.animation.fadeIn(i)}}if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o;return o};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var i=this._armature.armatureData.defaultAnimation;if(i!==null){this._animationConfig.animation=i.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};i.prototype.fadeIn=function(t,e,i,a,r,n){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=0}if(r===void 0){r=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=i;this._animationConfig.layer=a;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=r!==null?r:"";return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByTime=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByFrame=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*e/a.frameCount}return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByProgress=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByTime(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByFrame(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByProgress(t,e,1);if(i!==null){i.stop()}return i};i.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var i=this._animationStates[e];if(i.name===t){return i}}return null};i.prototype.hasAnimation=function(t){return t in this._animations};i.prototype.getStates=function(){return this._animationStates};Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.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._animations[e]=t[e];this._animationNames.push(e)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});i.prototype.gotoAndPlay=function(t,e,i,a,r,n,s,o,l){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&i>0){this._animationConfig.timeScale=h.duration/i}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}return this.gotoAndStopByTime(t,e)};Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationDataList",{get:function(){var t=[];for(var e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var a=i?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=i?0:1}else if(this._fadeTime>0){this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=i?1:0}if(this._subFadeState>0){if(!i){this._playheadState|=1;this._fadeState=0}var a=i?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}};a.prototype._blendBoneTimline=function(t){var e=t.bone;var i=t.bonePose.result;var a=e.animationPose;var r=this._weightResult>0?this._weightResult:-this._weightResult;if(!e._blendDirty){e._blendDirty=true;e._blendLayer=this.layer;e._blendLayerWeight=r;e._blendLeftWeight=1;a.x=i.x*r;a.y=i.y*r;a.rotation=i.rotation*r;a.skew=i.skew*r;a.scaleX=(i.scaleX-1)*r+1;a.scaleY=(i.scaleY-1)*r+1}else{r*=e._blendLeftWeight;e._blendLayerWeight+=r;a.x+=i.x*r;a.y+=i.y*r;a.rotation+=i.rotation*r;a.skew+=i.skew*r;a.scaleX+=(i.scaleX-1)*r;a.scaleY+=(i.scaleY-1)*r}if(this._fadeState!==0||this._subFadeState!==0){e._transformDirty=true}};a.prototype.init=function(e,i,a){if(this._armature!==null){return}this._armature=e;this.animationData=i;this.resetToPose=a.resetToPose;this.additiveBlending=a.additiveBlending;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.weight=a.weight;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;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,n=this._boneMask.length;r0;var a=true;var r=true;var n=this._time;this._weightResult=this.weight*this._fadeProgress;this._actionTimeline.update(n);if(i){var s=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*s)/s}if(this._zOrderTimeline!==null){this._zOrderTimeline.update(n)}if(i){var o=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===o){a=false;r=false}else{this._armature._cacheFrameIndex=o;if(this.animationData.cachedFrames[o]){r=false}else{this.animationData.cachedFrames[o]=true}}}if(a){if(r){var l=null;var h=null;for(var f=0,u=this._boneTimelines.length;f0){if(l._blendLayer!==this.layer){if(l._blendLayerWeight>=l._blendLeftWeight){l._blendLeftWeight=0;l=null}else{l._blendLayer=this.layer;l._blendLeftWeight-=l._blendLayerWeight;l._blendLayerWeight=0}}}else{l=null}}}l=_.bone}if(l!==null){_.update(n);if(f===u-1){this._blendBoneTimline(_)}else{h=_}}}}for(var f=0,u=this._slotTimelines.length;f0){this._subFadeState=0}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};a.prototype.play=function(){this._playheadState=3};a.prototype.stop=function(){this._playheadState&=1};a.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 i=0,a=this._boneTimelines;i1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};a.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};a.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var i=this._armature.getBone(t);if(i===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var a=0,r=this._armature.getBones();a=0){this._boneMask.splice(i,1)}if(e){var a=this._armature.getBone(t);if(a!==null){var r=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=r;n=0&&a.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,f=r;h0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(a.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){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 i=0,a=this._boneTimelines;i=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var r=this._animationState.playTimes;var n=r*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(r>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=r;if(t<0){this.currentTime=0}else{this.currentTime=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===i&&this.currentTime===a){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i){this._frameIndex=-1}return true};e.prototype.init=function(t,e,i){this._armature=t;this._animationState=e;this._timelineData=i;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._frameRate=this._armature.armatureData.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._armature.armatureData.parent;this._animationData=this._animationState.animationData;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.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(){};e.prototype.update=function(t){if(this.playState<=0&&this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var i=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==i){this._frameIndex=i;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._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,i){var a=e;switch(t){case 3:a=Math.pow(e,2);break;case 4:a=1-Math.pow(1-e,2);break;case 5:a=.5*(1-Math.cos(e*Math.PI));break}return(a-e)*i+e};e._getEasingCurveValue=function(t,e,i,a){if(t<=0){return 0}else if(t>=1){return 1}var r=i+1;var n=Math.floor(t*r);var s=n===0?0:e[a+n-1];var o=n===r-1?1e4:e[a+n];return(s+(o-s)*(t*r-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){if(n.hasEvent(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.EventObject.COMPLETE;h.armature=this._armature;h.animationState=this._animationState}}}if(this._frameCount>1){var f=this._timelineData;var u=Math.floor(this.currentTime*this._frameRate);var _=this._frameIndices[f.frameIndicesOffset+u];if(this._frameIndex!==_){var m=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[f.offset+5+this._frameIndex];if(o){if(m<0){var c=Math.floor(r*this._frameRate);m=this._frameIndices[f.frameIndicesOffset+c];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var p=this._animationData.frameOffset+this._timelineArray[f.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[f.frameIndicesOffset+c];var p=this._animationData.frameOffset+this._timelineArray[f.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}(t.TimelineState);t.ZOrderTimelineState=i;var a=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};i.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._dragonBonesData.frameFloatArray;var i=this.bonePose.current;var a=this.bonePose.delta;var r=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;i.x=t[r++];i.y=t[r++];i.rotation=t[r++];i.skew=t[r++];i.scaleX=t[r++];i.scaleY=t[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}a.x=t[r++]-i.x;a.y=t[r++]-i.y;a.rotation=t[r++]-i.rotation;a.skew=t[r++]-i.skew;a.scaleX=t[r++]-i.scaleX;a.scaleY=t[r++]-i.scaleY}}else{var i=this.bonePose.current;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1}};i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var i=this.bonePose.delta;var a=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}var r=this._armature.armatureData.scale;a.x=(t.x+i.x*this._tweenProgress)*r;a.y=(t.y+i.y*this._tweenProgress)*r;a.rotation=t.rotation+i.rotation*this._tweenProgress;a.skew=t.skew+i.skew*this._tweenProgress;a.scaleX=t.scaleX+i.scaleX*this._tweenProgress;a.scaleY=t.scaleY+i.scaleY*this._tweenProgress};i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return i}(t.BoneTimelineState);t.BoneAllTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDislayIndexTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot.slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayIndexTimelineState=r;var n=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var i=this._dragonBonesData.frameIntArray;var a=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var r=i[a];this._current[0]=e[r++];this._current[1]=e[r++];this._current[2]=e[r++];this._current[3]=e[r++];this._current[4]=e[r++];this._current[5]=e[r++];this._current[6]=e[r++];this._current[7]=e[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=i[this._animationData.frameIntOffset+this._frameValueOffset]}else{r=i[a+1*1]}this._delta[0]=e[r++]-this._current[0];this._delta[1]=e[r++]-this._current[1];this._delta[2]=e[r++]-this._current[2];this._delta[3]=e[r++]-this._current[3];this._delta[4]=e[r++]-this._current[4];this._delta[5]=e[r++]-this._current[5];this._delta[6]=e[r++]-this._current[6];this._delta[7]=e[r++]-this._current[7]}}else{var n=this.slot.slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var i=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var a=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*a;i.redMultiplier+=(this._result[1]-i.redMultiplier)*a;i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*a;i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*a;i.alphaOffset+=(this._result[4]-i.alphaOffset)*a;i.redOffset+=(this._result[5]-i.redOffset)*a;i.greenOffset+=(this._result[6]-i.greenOffset)*a;i.blueOffset+=(this._result[7]-i.blueOffset)*a;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){i.alphaMultiplier=this._result[0];i.redMultiplier=this._result[1];i.greenMultiplier=this._result[2];i.blueMultiplier=this._result[3];i.alphaOffset=this._result[4];i.redOffset=this._result[5];i.greenOffset=this._result[6];i.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=n;var s=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SlotFFDTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.meshOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._ffdCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._tweenState===2;var i=this._dragonBonesData.frameFloatArray;var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;if(e){var r=a+this._valueCount;if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n255){return encodeURI(r)}}}return r}return String(r)}return a};a.prototype._getCurvePoint=function(t,e,i,a,r,n,s,o,l,h){var f=1-l;var u=f*f;var _=l*l;var m=f*u;var c=3*l*u;var p=3*f*_;var d=l*_;h.x=m*t+c*i+p*r+d*s;h.y=m*e+c*a+p*n+d*o};a.prototype._samplingEasingCurve=function(t,e){var i=t.length;var a=-2;for(var r=0,n=e.length;r=0&&a+61e-4){var g=(y+d)*.5;this._getCurvePoint(l,h,f,u,_,m,c,p,g,this._helpPoint);if(s-this._helpPoint.x>0){d=g}else{y=g}}e[r]=this._helpPoint.y}};a.prototype._sortActionFrame=function(t,e){return t.frameStart>e.frameStart?1:-1};a.prototype._parseActionDataInFrame=function(t,e,i,r){if(a.EVENT in t){this._mergeActionFrame(t[a.EVENT],e,10,i,r)}if(a.SOUND in t){this._mergeActionFrame(t[a.SOUND],e,11,i,r)}if(a.ACTION in t){this._mergeActionFrame(t[a.ACTION],e,0,i,r)}if(a.EVENTS in t){this._mergeActionFrame(t[a.EVENTS],e,10,i,r)}if(a.ACTIONS in t){this._mergeActionFrame(t[a.ACTIONS],e,0,i,r)}};a.prototype._mergeActionFrame=function(e,a,r,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,this._armature.actions,r,n,s);var h=null;if(this._actionFrames.length===0){h=new i;h.frameStart=0;this._actionFrames.push(h);h=null}for(var f=0,u=this._actionFrames;f0){var c=r.getBone(_);if(c!==null){m.parent=c}else{(this._cacheBones[_]=this._cacheBones[_]||[]).push(m)}}if(m.name in this._cacheBones){for(var p=0,d=this._cacheBones[m.name];p0){n.root=i.parent}if(t.DragonBones.webAssembly){i.constraints.push_back(n)}else{i.constraints.push(n)}};a.prototype._parseSlot=function(e){var i=t.DragonBones.webAssembly?new Module["SlotData"]:t.BaseObject.borrowObject(t.SlotData);i.displayIndex=a._getNumber(e,a.DISPLAY_INDEX,0);i.zOrder=t.DragonBones.webAssembly?this._armature.sortedSlots.size():this._armature.sortedSlots.length;i.name=a._getString(e,a.NAME,"");i.parent=this._armature.getBone(a._getString(e,a.PARENT,""));if(a.BLEND_MODE in e&&typeof e[a.BLEND_MODE]==="string"){i.blendMode=a._getBlendMode(e[a.BLEND_MODE])}else{i.blendMode=a._getNumber(e,a.BLEND_MODE,0)}if(a.COLOR in e){i.color=t.DragonBones.webAssembly?Module["SlotData"].createColor():t.SlotData.createColor();this._parseColorTransform(e[a.COLOR],i.color)}else{i.color=t.DragonBones.webAssembly?Module["SlotData"].DEFAULT_COLOR:t.SlotData.DEFAULT_COLOR}if(a.ACTIONS in e){var r=this._slotChildActions[i.name]=[];this._parseActionData(e[a.ACTIONS],r,0,null,null)}return i};a.prototype._parseSkin=function(e){var i=t.DragonBones.webAssembly?new Module["SkinData"]:t.BaseObject.borrowObject(t.SkinData);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length===0){i.name=a.DEFAULT_NAME}if(a.SLOT in e){this._skin=i;var r=e[a.SLOT];for(var n=0,s=r;n0?n:r;this._parsePivot(e,o);break;case 1:var l=i=t.DragonBones.webAssembly?new Module["ArmatureDisplayData"]:t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=r;l.path=n.length>0?n:r;l.inheritAnimation=true;if(a.ACTIONS in e){this._parseActionData(e[a.ACTIONS],l.actions,0,null,null)}else if(this._slot.name in this._slotChildActions){var h=this._skin.getDisplays(this._slot.name);if(h===null?this._slot.displayIndex===0:this._slot.displayIndex===h.length){for(var f=0,u=this._slotChildActions[this._slot.name];f0?n:r;m.inheritAnimation=a._getBoolean(e,a.INHERIT_FFD,true);this._parsePivot(e,m);var c=a._getString(e,a.SHARE,"");if(c.length>0){var p=this._meshs[c];m.offset=p.offset;m.weight=p.weight}else{this._parseMesh(e,m);this._meshs[m.name]=m}break;case 3:var d=this._parseBoundingBox(e);if(d!==null){var y=i=t.DragonBones.webAssembly?new Module["BoundingBoxDisplayData"]:t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=r;y.path=n.length>0?n:r;y.boundingBox=d}break}if(i!==null){i.parent=this._armature;if(a.TRANSFORM in e){this._parseTransform(e[a.TRANSFORM],i.transform,this._armature.scale)}}return i};a.prototype._parsePivot=function(t,e){if(a.PIVOT in t){var i=t[a.PIVOT];e.pivot.x=a._getNumber(i,a.X,0);e.pivot.y=a._getNumber(i,a.Y,0)}else{e.pivot.x=.5;e.pivot.y=.5}};a.prototype._parseMesh=function(e,i){var r=e[a.VERTICES];var n=e[a.UVS];var s=e[a.TRIANGLES];var o=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var l=t.DragonBones.webAssembly?this._floatArrayJson:this._data.floatArray;var h=Math.floor(r.length/2);var f=Math.floor(s.length/3);var u=l.length;var _=u+h*2;i.offset=o.length;o.length+=1+1+1+1+f*3;o[i.offset+0]=h;o[i.offset+1]=f;o[i.offset+2]=u;for(var m=0,c=f*3;mn.width){n.width=h}if(fn.height){n.height=f}}}return n};a.prototype._parseAnimation=function(e){var i=t.DragonBones.webAssembly?new Module["AnimationData"]:t.BaseObject.borrowObject(t.AnimationData);i.frameCount=Math.max(a._getNumber(e,a.DURATION,1),1);i.playTimes=a._getNumber(e,a.PLAY_TIMES,1);i.duration=i.frameCount/this._armature.frameRate;i.fadeInTime=a._getNumber(e,a.FADE_IN_TIME,0);i.scale=a._getNumber(e,a.SCALE,1);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length<1){i.name=a.DEFAULT_NAME}if(t.DragonBones.webAssembly){i.frameIntOffset=this._frameIntArrayJson.length;i.frameFloatOffset=this._frameFloatArrayJson.length;i.frameOffset=this._frameArrayJson.length}else{i.frameIntOffset=this._data.frameIntArray.length;i.frameFloatOffset=this._data.frameFloatArray.length;i.frameOffset=this._data.frameArray.length}this._animation=i;if(a.FRAME in e){var r=e[a.FRAME];var n=r.length;if(n>0){for(var s=0,o=0;s0){this._actionFrames.sort(this._sortActionFrame);var D=this._animation.actionTimeline=t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);var T=t.DragonBones.webAssembly?this._timelineArrayJson:this._data.timelineArray;var n=this._actionFrames.length;D.type=0;D.offset=T.length;T.length+=1+1+1+1+1+n;T[D.offset+0]=100;T[D.offset+1]=0;T[D.offset+2]=n;T[D.offset+3]=0;T[D.offset+4]=0;this._timeline=D;if(n===1){D.frameIndicesOffset=-1;T[D.offset+5+0]=this._parseCacheActionFrame(this._actionFrames[0])-this._animation.frameOffset}else{var A=this._animation.frameCount+1;var O=this._data.frameIndices;if(t.DragonBones.webAssembly){D.frameIndicesOffset=O.size();for(var B=0;B0){if(a.CURVE in t){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(t[a.CURVE],this._helpArray);r.length+=1+1+this._helpArray.length;r[n+1]=2;r[n+2]=s;for(var o=0;o0){var l=this._armature.sortedSlots.length;var h=new Array(l-o.length/2);var f=new Array(l);for(var u=0;u0?l>=this._prevRotation:l<=this._prevRotation){this._prevTweenRotate=this._prevTweenRotate>0?this._prevTweenRotate-1:this._prevTweenRotate+1}l=this._prevRotation+l-this._prevRotation+t.Transform.PI_D*this._prevTweenRotate}}this._prevTweenRotate=a._getNumber(e,a.TWEEN_ROTATE,0);this._prevRotation=l;var h=n.length;n.length+=6;n[h++]=this._helpTransform.x;n[h++]=this._helpTransform.y;n[h++]=l;n[h++]=this._helpTransform.skew;n[h++]=this._helpTransform.scaleX;n[h++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,i,this._bone,this._slot);return o};a.prototype._parseSlotDisplayIndexFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var s=this._parseFrame(e,i,r,n);n.length+=1;n[s+1]=a._getNumber(e,a.DISPLAY_INDEX,0);this._parseActionDataInFrame(e,i,this._slot.parent,this._slot);return s};a.prototype._parseSlotColorFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameIntArrayJson:this._data.frameIntArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=this._parseTweenFrame(e,i,r,o);var h=-1;if(a.COLOR in e){var f=e[a.COLOR];for(var u in f){u;this._parseColorTransform(f,this._helpColorTransform);h=n.length;n.length+=8;n[h++]=Math.round(this._helpColorTransform.alphaMultiplier*100);n[h++]=Math.round(this._helpColorTransform.redMultiplier*100);n[h++]=Math.round(this._helpColorTransform.greenMultiplier*100);n[h++]=Math.round(this._helpColorTransform.blueMultiplier*100);n[h++]=Math.round(this._helpColorTransform.alphaOffset);n[h++]=Math.round(this._helpColorTransform.redOffset);n[h++]=Math.round(this._helpColorTransform.greenOffset);n[h++]=Math.round(this._helpColorTransform.blueOffset);h-=8;break}}if(h<0){if(this._defalultColorOffset<0){this._defalultColorOffset=h=n.length;n.length+=8;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=0;n[h++]=0;n[h++]=0;n[h++]=0}h=this._defalultColorOffset}var _=s.length;s.length+=1;s[_]=h;return l};a.prototype._parseSlotFFDFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameFloatArrayJson:this._data.frameFloatArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=s.length;var h=this._parseTweenFrame(e,i,r,o);var f=a.VERTICES in e?e[a.VERTICES]:null;var u=a._getNumber(e,a.OFFSET,0);var _=n[this._mesh.offset+0];var m=0;var c=0;var p=0;var d=0;if(this._mesh.weight!==null){var y=this._weightSlotPose[this._mesh.name];this._helpMatrixA.copyFromArray(y,0);s.length+=this._mesh.weight.count*2;p=this._mesh.weight.offset+2+this._mesh.weight.bones.length}else{s.length+=_*2}for(var g=0;g<_*2;g+=2){if(f===null){m=0;c=0}else{if(g=f.length){m=0}else{m=f[g-u]}if(g+1=f.length){c=0}else{c=f[g+1-u]}}if(this._mesh.weight!==null){var v=this._weightBonePoses[this._mesh.name];var b=this._weightBoneIndices[this._mesh.name];var D=n[p++];this._helpMatrixA.transformPoint(m,c,this._helpPoint,true);m=this._helpPoint.x;c=this._helpPoint.y;for(var T=0;T=0||a.DATA_VERSIONS.indexOf(n)>=0){var s=t.DragonBones.webAssembly?new Module["DragonBonesData"]:t.BaseObject.borrowObject(t.DragonBonesData);s.version=r;s.name=a._getString(e,a.NAME,"");s.frameRate=a._getNumber(e,a.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(a.ARMATURE in e){this._defalultColorOffset=-1;this._data=s;this._parseArray(e);var o=e[a.ARMATURE];for(var l=0,h=o;l0){this._parseWASMArray()}this._data=null}this._rawTextureAtlasIndex=0;if(a.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[a.TEXTURE_ATLAS]}else{this._rawTextureAtlases=null}return s}else{console.assert(false,"Nonsupport data version.")}return null};a.prototype.parseTextureAtlasData=function(e,i,r){if(r===void 0){r=0}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,i,r);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}i.width=a._getNumber(e,a.WIDTH,0);i.height=a._getNumber(e,a.HEIGHT,0);i.name=a._getString(e,a.NAME,"");i.imagePath=a._getString(e,a.IMAGE_PATH,"");if(r>0){i.scale=r}else{r=i.scale=a._getNumber(e,a.SCALE,i.scale)}r=1/r;if(a.SUB_TEXTURE in e){var s=e[a.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){f.frame=t.DragonBones.webAssembly?Module["TextureData"].createRectangle():t.TextureData.createRectangle();f.frame.x=a._getNumber(h,a.FRAME_X,0)*r;f.frame.y=a._getNumber(h,a.FRAME_Y,0)*r;f.frame.width=u*r;f.frame.height=_*r}i.addTexture(f)}}return true};a.getInstance=function(){if(a._objectDataParserInstance===null){a._objectDataParserInstance=new a}return a._objectDataParserInstance};a._objectDataParserInstance=null;return a}(t.DataParser);t.ObjectDataParser=e;var i=function(){function t(){this.frameStart=0;this.actions=[]}return t}()})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.prototype._inRange=function(t,e,i){return e<=t&&t<=i};i.prototype._decodeUTF8=function(t){var e=-1;var i=-1;var a=65533;var r=0;var n="";var s;var o=0;var l=0;var h=0;var f=0;while(t.length>r){var u=t[r++];if(u===e){if(l!==0){s=a}else{s=i}}else{if(l===0){if(this._inRange(u,0,127)){s=u}else{if(this._inRange(u,194,223)){l=1;f=128;o=u-192}else if(this._inRange(u,224,239)){l=2;f=2048;o=u-224}else if(this._inRange(u,240,244)){l=3;f=65536;o=u-240}else{}o=o*Math.pow(64,l);s=null}}else if(!this._inRange(u,128,191)){o=0;l=0;h=0;f=0;r--;s=u}else{h+=1;o=o+(u-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var m=f;o=0;l=0;h=0;f=0;if(this._inRange(_,m,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=u}}}}if(s!==null&&s!==i){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};i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255){return encodeURI(t)}}return t};i.prototype._parseBinaryTimeline=function(e,i,a){if(a===void 0){a=null}var r=a!==null?a:t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);r.type=e;r.offset=i;this._timeline=r;var n=this._timelineArray[r.offset+2];if(n===1){r.frameIndicesOffset=-1}else{var s=this._animation.frameCount+1;var o=this._data.frameIndices;if(t.DragonBones.webAssembly){r.frameIndicesOffset=o.size();for(var l=0;l=0){var r=t.DragonBones.webAssembly?new Module["WeightData"]:t.BaseObject.borrowObject(t.WeightData);var n=this._intArray[i.offset+0];var s=this._intArray[a+0];r.offset=a;if(t.DragonBones.webAssembly){r.bones.resize(s,null);for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(i)}}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(i);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=r;t.data=n;t.armature=s;t.skin=null;if(a.length>0){t.skin=s.getSkin(a);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(a);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};i.prototype._buildBones=function(e,i){var a=e.armature.sortedBones;for(var r=0;r<(t.DragonBones.webAssembly?a.size():a.length);++r){var n=t.DragonBones.webAssembly?a.get(r):a[r];var s=t.DragonBones.webAssembly?new Module["Bone"]:t.BaseObject.borrowObject(t.Bone);s.init(n);if(n.parent!==null){i.addBone(s,n.parent.name)}else{i.addBone(s)}var o=n.constraints;for(var l=0;l<(t.DragonBones.webAssembly?o.size():o.length);++l){var h=t.DragonBones.webAssembly?o.get(l):o[l];var f=i.getBone(h.target.name);if(f===null){continue}var u=h;var _=t.DragonBones.webAssembly?new Module["IKConstraint"]:t.BaseObject.borrowObject(t.IKConstraint);var m=u.root!==null?i.getBone(u.root.name):null;_.target=f;_.bone=s;_.root=m;_.bendPositive=u.bendPositive;_.scaleEnabled=u.scaleEnabled;_.weight=u.weight;if(m!==null){m.addConstraint(_)}else{s.addConstraint(_)}}}};i.prototype._buildSlots=function(t,e){var i=t.skin;var a=t.armature.defaultSkin;if(i===null||a===null){return}var r={};for(var n in a.displays){var s=a.displays[n];r[n]=s}if(i!==a){for(var n in i.displays){var s=i.displays[n];r[n]=s}}for(var o=0,l=t.armature.sortedSlots;o0){s.texture=this._getTextureData(t.textureAtlasName,e.path)}if(i!==null&&i.type===2&&this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 2:var o=e;if(o.texture===null){o.texture=this._getTextureData(r,o.path)}else if(t!==null&&t.textureAtlasName.length>0){o.texture=this._getTextureData(t.textureAtlasName,o.path)}if(this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 1:var l=e;var h=this.buildArmature(l.path,r,null,t!==null?t.textureAtlasName:null);if(h!==null){h.inheritAnimation=l.inheritAnimation;if(!h.inheritAnimation){var f=l.actions.length>0?l.actions:h.armatureData.defaultActions;if(f.length>0){for(var u=0,_=f;u<_.length;u++){var m=_[u];h._bufferAction(m,true)}}else{h.animation.play()}}l.armature=h.armatureData}n=h;break}return n};i.prototype._replaceSlotDisplay=function(t,e,i,a){if(a<0){a=i.displayIndex}if(a<0){a=0}var r=i.displayList;if(r.length<=a){r.length=a+1;for(var n=0,s=r.length;n=0){continue}var s=e.displays[n.name];var o=n.displayList;o.length=s.length;for(var l=0,h=s.length;l = []; + private readonly _animationStates: Array = []; + private readonly _animations: Map = {}; + private _armature: Armature; + private _animationConfig: AnimationConfig = null as any; // Initial value. + private _lastAnimationState: AnimationState | null; + /** + * @private + */ + protected _onClear(): void { + for (const animationState of this._animationStates) { + animationState.returnToPool(); + } + + for (let k in this._animations) { + delete this._animations[k]; + } + + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + + this.timeScale = 1.0; + + this._animationDirty = false; + this._timelineDirty = false; + this._animationNames.length = 0; + this._animationStates.length = 0; + //this._animations.clear(); + this._armature = null as any; // + this._animationConfig = null as any; // + this._lastAnimationState = null; + } + + private _fadeOut(animationConfig: AnimationConfig): void { + switch (animationConfig.fadeOutMode) { + case AnimationFadeOutMode.SameLayer: + for (const animationState of this._animationStates) { + if (animationState.layer === animationConfig.layer) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + + case AnimationFadeOutMode.SameGroup: + for (const animationState of this._animationStates) { + if (animationState.group === animationConfig.group) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + + case AnimationFadeOutMode.SameLayerAndGroup: + for (const animationState of this._animationStates) { + if ( + animationState.layer === animationConfig.layer && + animationState.group === animationConfig.group + ) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + } + break; + + case AnimationFadeOutMode.All: + for (const animationState of this._animationStates) { + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + + case AnimationFadeOutMode.None: + case AnimationFadeOutMode.Single: + default: + break; + } + } + /** + * @internal + * @private + */ + public init(armature: Armature): void { + if (this._armature !== null) { + return; + } + + this._armature = armature; + this._animationConfig = BaseObject.borrowObject(AnimationConfig); + } + /** + * @internal + * @private + */ + public advanceTime(passedTime: number): void { + if (passedTime < 0.0) { // Only animationState can reverse play. + passedTime = -passedTime; + } + + if (this._armature.inheritAnimation && this._armature._parent !== null) { // Inherit parent animation timeScale. + passedTime *= this._armature._parent._armature.animation.timeScale; + } + + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + + const animationStateCount = this._animationStates.length; + if (animationStateCount === 1) { + const animationState = this._animationStates[0]; + if (animationState._fadeState > 0 && animationState._subFadeState > 0) { + this._armature._dragonBones.bufferObject(animationState); + this._animationStates.length = 0; + this._lastAnimationState = null; + } + else { + const animationData = animationState.animationData; + const cacheFrameRate = animationData.cacheFrameRate; + if (this._animationDirty && cacheFrameRate > 0.0) { // Update cachedFrameIndices. + this._animationDirty = false; + for (const bone of this._armature.getBones()) { + bone._cachedFrameIndices = animationData.getBoneCachedFrameIndices(bone.name); + } + + for (const slot of this._armature.getSlots()) { + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + + if (this._timelineDirty) { + animationState.updateTimelines(); + } + + animationState.advanceTime(passedTime, cacheFrameRate); + } + } + else if (animationStateCount > 1) { + for (let i = 0, r = 0; i < animationStateCount; ++i) { + const 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; + } + + if (this._timelineDirty) { + animationState.updateTimelines(); + } + + 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; + } + + this._timelineDirty = false; + } + /** + * 清除所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public reset(): void { + for (const animationState of this._animationStates) { + animationState.returnToPool(); + } + + this._animationDirty = false; + this._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + } + /** + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + public stop(animationName: string | null = null): void { + if (animationName !== null) { + const animationState = this.getState(animationName); + if (animationState !== null) { + animationState.stop(); + } + } + else { + for (const animationState of this._animationStates) { + animationState.stop(); + } + } + } + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + public playConfig(animationConfig: AnimationConfig): AnimationState | null { + const 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; + } + + const animationData = this._animations[animationName]; + + if (animationConfig.fadeOutMode === AnimationFadeOutMode.Single) { + for (const animationState of this._animationStates) { + if (animationState.animationData === animationData) { + return animationState; + } + } + } + + 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 > 1) { + 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); + + const animationState = BaseObject.borrowObject(AnimationState); + animationState.init(this._armature, animationData, animationConfig); + this._animationDirty = true; + this._armature._cacheFrameIndex = -1; + + if (this._animationStates.length > 0) { + let added = false; + for (let i = 0, l = this._animationStates.length; i < l; ++i) { + if (animationState.layer >= this._animationStates[i].layer) { + } + else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + + // Child armature play same name animation. + for (const slot of this._armature.getSlots()) { + const childArmature = slot.childArmature; + if ( + childArmature !== null && childArmature.inheritAnimation && + childArmature.animation.hasAnimation(animationName) && + childArmature.animation.getState(animationName) === null + ) { + childArmature.animation.fadeIn(animationName); // + } + } + + if (animationConfig.fadeInTime <= 0.0) { // Blend animation state, update armature. + this._armature.advanceTime(0.0); + } + + this._lastAnimationState = animationState; + + return animationState; + } + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + public play(animationName: string | null = null, playTimes: number = -1): AnimationState | null { + 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) { + const 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; + } + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public fadeIn( + animationName: string, fadeInTime: number = -1.0, playTimes: number = -1, + layer: number = 0, group: string | null = null, fadeOutMode: AnimationFadeOutMode = AnimationFadeOutMode.SameLayerAndGroup + ): AnimationState | null { + 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); + } + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public gotoAndPlayByTime(animationName: string, time: number = 0.0, playTimes: number = -1): AnimationState | null { + 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); + } + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public gotoAndPlayByFrame(animationName: string, frame: number = 0, playTimes: number = -1): AnimationState | null { + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + + const animationData = animationName in this._animations ? this._animations[animationName] : null; + if (animationData !== null) { + this._animationConfig.position = animationData.duration * frame / animationData.frameCount; + } + + return this.playConfig(this._animationConfig); + } + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public gotoAndPlayByProgress(animationName: string, progress: number = 0.0, playTimes: number = -1): AnimationState | null { + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + this._animationConfig.playTimes = playTimes; + this._animationConfig.fadeInTime = 0.0; + this._animationConfig.animation = animationName; + + const 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); + } + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public gotoAndStopByTime(animationName: string, time: number = 0.0): AnimationState | null { + const animationState = this.gotoAndPlayByTime(animationName, time, 1); + if (animationState !== null) { + animationState.stop(); + } + + return animationState; + } + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public gotoAndStopByFrame(animationName: string, frame: number = 0): AnimationState | null { + const animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + if (animationState !== null) { + animationState.stop(); + } + + return animationState; + } + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + public gotoAndStopByProgress(animationName: string, progress: number = 0.0): AnimationState | null { + const animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + if (animationState !== null) { + animationState.stop(); + } + + return animationState; + } + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + public getState(animationName: string): AnimationState | null { + let i = this._animationStates.length; + while (i--) { + const animationState = this._animationStates[i]; + if (animationState.name === animationName) { + return animationState; + } + } + + return null; + } + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + public hasAnimation(animationName: string): boolean { + return animationName in this._animations; + } + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + public getStates(): Array { + return this._animationStates; + } + /** + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get isPlaying(): boolean { + for (const animationState of this._animationStates) { + if (animationState.isPlaying) { + return true; + } + } + + return false; + } + /** + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + public get isCompleted(): boolean { + for (const animationState of this._animationStates) { + if (!animationState.isCompleted) { + return false; + } + } + + return this._animationStates.length > 0; + } + /** + * 上一个正在播放的动画状态名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + public get lastAnimationName(): string { + return this._lastAnimationState !== null ? this._lastAnimationState.name : ""; + } + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + public get animationNames(): Array { + return this._animationNames; + } + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + public get animations(): Map { + return this._animations; + } + public set animations(value: Map) { + if (this._animations === value) { + return; + } + + this._animationNames.length = 0; + + for (let k in this._animations) { + delete this._animations[k]; + } + + for (let k in value) { + this._animations[k] = value[k]; + this._animationNames.push(k); + } + } + /** + * 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + public get animationConfig(): AnimationConfig { + this._animationConfig.clear(); + return this._animationConfig; + } + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + public get lastAnimationState(): AnimationState | null { + return this._lastAnimationState; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + public gotoAndPlay( + animationName: string, fadeInTime: number = -1, duration: number = -1, playTimes: number = -1, + layer: number = 0, group: string | null = null, fadeOutMode: AnimationFadeOutMode = AnimationFadeOutMode.SameLayerAndGroup, + pauseFadeOut: boolean = true, pauseFadeIn: boolean = true + ): AnimationState | null { + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + + const animationData = this._animations[animationName]; + if (animationData && duration > 0.0) { + this._animationConfig.timeScale = animationData.duration / duration; + } + + return this.playConfig(this._animationConfig); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + public gotoAndStop(animationName: string, time: number = 0): AnimationState | null { + return this.gotoAndStopByTime(animationName, time); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + public get animationList(): Array { + return this._animationNames; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + public get animationDataList(): Array { + const list: AnimationData[] = []; + for (let i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); + } + + return list; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/animation/AnimationState.ts b/reference/DragonBones/src/dragonBones/animation/AnimationState.ts new file mode 100644 index 0000000..a258c4a --- /dev/null +++ b/reference/DragonBones/src/dragonBones/animation/AnimationState.ts @@ -0,0 +1,953 @@ +namespace dragonBones { + /** + * @internal + * @private + */ + export class BonePose extends BaseObject { + public static toString(): string { + return "[class dragonBones.BonePose]"; + } + + public readonly current: Transform = new Transform(); + public readonly delta: Transform = new Transform(); + public readonly result: Transform = new Transform(); + + protected _onClear(): void { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + } + } + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + export class AnimationState extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.AnimationState]"; + } + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * @version DragonBones 5.1 + * @language zh_CN + */ + public resetToPose: boolean; + /** + * 是否以增加的方式混合。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + * @language zh_CN + */ + public displayControl: boolean; + /** + * 是否能触发行为。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public actionEnabled: boolean; + /** + * 混合图层。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public layer: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + public playTimes: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @version DragonBones 3.0 + * @language zh_CN + */ + public timeScale: number; + /** + * 混合权重。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public weight: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public autoFadeOutTime: number; + /** + * @private + */ + public fadeTotalTime: number; + /** + * 动画名称。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public name: string; + /** + * 混合组。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public group: string; + /** + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + public animationData: AnimationData; + + private _timelineDirty: boolean; + /** + * @internal + * @private + * xx: Play Enabled, Fade Play Enabled + */ + public _playheadState: number; + /** + * @internal + * @private + * -1: Fade in, 0: Fade complete, 1: Fade out; + */ + public _fadeState: number; + /** + * @internal + * @private + * -1: Fade start, 0: Fading, 1: Fade complete; + */ + public _subFadeState: number; + /** + * @internal + * @private + */ + public _position: number; + /** + * @internal + * @private + */ + public _duration: number; + private _fadeTime: number; + private _time: number; + /** + * @internal + * @private + */ + public _fadeProgress: number; + private _weightResult: number; + private readonly _boneMask: Array = []; + private readonly _boneTimelines: Array = []; + private readonly _slotTimelines: Array = []; + private readonly _bonePoses: Map = {}; + private _armature: Armature; + /** + * @internal + * @private + */ + public _actionTimeline: ActionTimelineState = null as any; // Initial value. + private _zOrderTimeline: ZOrderTimelineState | null = null; // Initial value. + /** + * @private + */ + protected _onClear(): void { + for (const timeline of this._boneTimelines) { + timeline.returnToPool(); + } + + for (const timeline of this._slotTimelines) { + timeline.returnToPool(); + } + + for (let k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1.0; + this.weight = 1.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this.animationData = null as any; // + + this._timelineDirty = true; + 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._slotTimelines.length = 0; + // this._bonePoses.clear(); + this._armature = null as any; // + this._actionTimeline = null as any; // + this._zOrderTimeline = null; + } + + private _isDisabled(slot: Slot): boolean { + if (this.displayControl) { + const displayController = slot.displayController; + if ( + displayController === null || + displayController === this.name || + displayController === this.group + ) { + return false; + } + } + + return true; + } + + private _advanceFadeTime(passedTime: number): void { + const isFadeOut = this._fadeState > 0; + + if (this._subFadeState < 0) { // Fade start event. + this._subFadeState = 0; + + const eventType = isFadeOut ? EventObject.FADE_OUT : EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + const eventObject = BaseObject.borrowObject(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; + } + + const eventType = isFadeOut ? EventObject.FADE_OUT_COMPLETE : EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + const eventObject = BaseObject.borrowObject(EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + + private _blendBoneTimline(timeline: BoneTimelineState): void { + const bone = timeline.bone; + const bonePose = timeline.bonePose.result; + const animationPose = bone.animationPose; + let boneWeight = this._weightResult > 0.0 ? this._weightResult : -this._weightResult; + + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1.0; + + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1.0) * boneWeight + 1.0; + animationPose.scaleY = (bonePose.scaleY - 1.0) * boneWeight + 1.0; + } + else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1.0) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1.0) * boneWeight; + } + + if (this._fadeState !== 0 || this._subFadeState !== 0) { + bone._transformDirty = true; + } + } + /** + * @private + * @internal + */ + public init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void { + if (this._armature !== null) { + return; + } + + this._armature = armature; + + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + + 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 (let i = 0, l = this._boneMask.length; i < l; ++i) { + this._boneMask[i] = animationConfig.boneMask[i]; + } + } + + this._actionTimeline = BaseObject.borrowObject(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 = BaseObject.borrowObject(ZOrderTimelineState); + this._zOrderTimeline.init(this._armature, this, this.animationData.zOrderTimeline); + } + } + /** + * @private + * @internal + */ + public updateTimelines(): void { + const boneTimelines: Map> = {}; + for (const timeline of this._boneTimelines) { // Create bone timelines map. + const timelineName = timeline.bone.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + + boneTimelines[timelineName].push(timeline); + } + + for (const bone of this._armature.getBones()) { + const timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + + const timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (timelineName in boneTimelines) { // Remove bone timeline from map. + delete boneTimelines[timelineName]; + } + else { // Create new bone timeline. + const bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = BaseObject.borrowObject(BonePose)); + if (timelineDatas !== null) { + for (const timelineData of timelineDatas) { + switch (timelineData.type) { + case TimelineType.BoneAll: + const timeline = BaseObject.borrowObject(BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + + case TimelineType.BoneT: + case TimelineType.BoneR: + case TimelineType.BoneS: + // TODO + break; + + case TimelineType.BoneX: + case TimelineType.BoneY: + case TimelineType.BoneRotate: + case TimelineType.BoneSkew: + case TimelineType.BoneScaleX: + case TimelineType.BoneScaleY: + // TODO + break; + } + } + } + else if (this.resetToPose) { // Pose timeline. + const timeline = BaseObject.borrowObject(BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + + for (let k in boneTimelines) { // Remove bone timelines. + for (const timeline of boneTimelines[k]) { + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + + const slotTimelines: Map> = {}; + const ffdFlags: Array = []; + for (const timeline of this._slotTimelines) { // Create slot timelines map. + const timelineName = timeline.slot.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + + slotTimelines[timelineName].push(timeline); + } + + for (const slot of this._armature.getSlots()) { + const boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + + const timelineName = slot.name; + const timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (timelineName in slotTimelines) { // Remove slot timeline from map. + delete slotTimelines[timelineName]; + } + else { // Create new slot timeline. + let displayIndexFlag = false; + let colorFlag = false; + ffdFlags.length = 0; + + if (timelineDatas !== null) { + for (const timelineData of timelineDatas) { + switch (timelineData.type) { + case TimelineType.SlotDisplay: + { + const timeline = BaseObject.borrowObject(SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + + case TimelineType.SlotColor: + { + const timeline = BaseObject.borrowObject(SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + + case TimelineType.SlotFFD: + { + const timeline = BaseObject.borrowObject(SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + + if (this.resetToPose) { // Pose timeline. + if (!displayIndexFlag) { + const timeline = BaseObject.borrowObject(SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + + if (!colorFlag) { + const timeline = BaseObject.borrowObject(SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + + for (const displayData of slot._rawDisplayDatas) { + if (displayData !== null && displayData.type === DisplayType.Mesh && ffdFlags.indexOf((displayData as MeshDisplayData).offset) < 0) { + const timeline = BaseObject.borrowObject(SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + + for (let k in slotTimelines) { // Remove slot timelines. + for (const timeline of slotTimelines[k]) { + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + } + /** + * @private + * @internal + */ + public advanceTime(passedTime: number, cacheFrameRate: number): void { + // 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; + } + + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + + if (this.weight === 0.0) { + return; + } + + const isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + let isUpdateTimeline = true; + let isUpdateBoneTimeline = true; + let time = this._time; + this._weightResult = this.weight * this._fadeProgress; + + this._actionTimeline.update(time); // Update main timeline. + + if (isCacheEnabled) { // Cache time internval. + const internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + + if (this._zOrderTimeline !== null) { // Update zOrder timeline. + this._zOrderTimeline.update(time); + } + + if (isCacheEnabled) { // Update cache. + const 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) { + if (isUpdateBoneTimeline) { // Update bone timelines. + let bone: Bone | null = null; + let prevTimeline: BoneTimelineState = null as any; // + for (let i = 0, l = this._boneTimelines.length; i < l; ++i) { + const timeline = this._boneTimelines[i]; + if (bone !== timeline.bone) { // Blend bone pose. + if (bone !== null) { + this._blendBoneTimline(prevTimeline); + + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0.0) { + if (bone._blendLayer !== this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0.0; + bone = null; + } + else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0.0; + } + } + } + else { + bone = null; + } + } + } + + bone = timeline.bone; + } + + if (bone !== null) { + timeline.update(time); + if (i === l - 1) { + this._blendBoneTimline(timeline); + } + else { + prevTimeline = timeline; + } + } + } + } + + for (let i = 0, l = this._slotTimelines.length; i < l; ++i) { + const timeline = this._slotTimelines[i]; + if (this._isDisabled(timeline.slot)) { + continue; + } + + timeline.update(time); + } + } + + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { // Auto fade out. + this.fadeOut(this.autoFadeOutTime); + } + } + } + } + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public play(): void { + this._playheadState = 3; // 11 + } + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public stop(): void { + this._playheadState &= 1; // 0x + } + /** + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public fadeOut(fadeOutTime: number, pausePlayhead: boolean = true): void { + 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 (const timeline of this._boneTimelines) { + timeline.fadeOut(); + } + + for (const timeline of this._slotTimelines) { + timeline.fadeOut(); + } + } + + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + } + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public containsBoneMask(name: string): boolean { + return this._boneMask.length === 0 || this._boneMask.indexOf(name) >= 0; + } + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public addBoneMask(name: string, recursive: boolean = true): void { + const currentBone = this._armature.getBone(name); + if (currentBone === null) { + return; + } + + if (this._boneMask.indexOf(name) < 0) { // Add mixing + this._boneMask.push(name); + } + + if (recursive) { // Add recursive mixing. + for (const bone of this._armature.getBones()) { + if (this._boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + + this._timelineDirty = true; + } + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public removeBoneMask(name: string, recursive: boolean = true): void { + const index = this._boneMask.indexOf(name); + if (index >= 0) { // Remove mixing. + this._boneMask.splice(index, 1); + } + + if (recursive) { + const currentBone = this._armature.getBone(name); + if (currentBone !== null) { + const bones = this._armature.getBones(); + if (this._boneMask.length > 0) { // Remove recursive mixing. + for (const bone of bones) { + const index = this._boneMask.indexOf(bone.name); + if (index >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index, 1); + } + } + } + else { // Add unrecursive mixing. + for (const bone of bones) { + if (bone === currentBone) { + continue; + } + + if (!currentBone.contains(bone)) { + this._boneMask.push(bone.name); + } + } + } + } + } + + this._timelineDirty = true; + } + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public removeAllBoneMask(): void { + this._boneMask.length = 0; + this._timelineDirty = true; + } + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + public get isFadeIn(): boolean { + return this._fadeState < 0; + } + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + public get isFadeOut(): boolean { + return this._fadeState > 0; + } + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + public get isFadeComplete(): boolean { + return this._fadeState === 0; + } + /** + * 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get isPlaying(): boolean { + return (this._playheadState & 2) !== 0 && this._actionTimeline.playState <= 0; + } + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get isCompleted(): boolean { + return this._actionTimeline.playState > 0; + } + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get currentPlayTimes(): number { + return this._actionTimeline.currentPlayTimes; + } + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public get totalTime(): number { + return this._duration; + } + /** + * 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public get currentTime(): number { + return this._actionTimeline.currentTime; + } + public set currentTime(value: number) { + const 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) { + 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 (const timeline of this._boneTimelines) { + timeline.playState = -1; + } + + for (const timeline of this._slotTimelines) { + timeline.playState = -1; + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + public get clip(): AnimationData { + return this.animationData; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/animation/BaseTimelineState.ts b/reference/DragonBones/src/dragonBones/animation/BaseTimelineState.ts new file mode 100644 index 0000000..05632f0 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/animation/BaseTimelineState.ts @@ -0,0 +1,340 @@ +namespace dragonBones { + /** + * @internal + * @private + */ + export const enum TweenState { + None, + Once, + Always + } + /** + * @internal + * @private + */ + export abstract class TimelineState extends BaseObject { + public playState: number; // -1: start, 0: play, 1: complete; + public currentPlayTimes: number; + public currentTime: number; + + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + + protected _onClear(): void { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + + this._tweenState = TweenState.None; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 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._dragonBonesData = null as any; // + this._animationData = null as any; // + this._timelineData = null as any; // + this._armature = null as any; // + this._animationState = null as any; // + this._actionTimeline = null as any; // + this._frameArray = null as any; // + this._frameIntArray = null as any; // + this._frameFloatArray = null as any; // + this._timelineArray = null as any; // + this._frameIndices = null as any; // + } + + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + + protected _setCurrentTime(passedTime: number): boolean { + const prevState = this.playState; + const prevPlayTimes = this.currentPlayTimes; + const 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. + const playTimes = this._animationState.playTimes; + const 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._duration; + } + } + 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; + } + + public init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void { + this._armature = armature; + this._animationState = animationState; + this._timelineData = timelineData; + this._actionTimeline = this._animationState._actionTimeline; + + if (this === this._actionTimeline) { + this._actionTimeline = null as any; // + } + + this._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + + if (this._timelineData !== null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._dragonBonesData.frameIndices; + + this._frameCount = this._timelineArray[this._timelineData.offset + BinaryOffset.TimelineKeyFrameCount]; + this._frameValueOffset = this._timelineArray[this._timelineData.offset + BinaryOffset.TimelineFrameValueOffset]; + this._timeScale = 100.0 / this._timelineArray[this._timelineData.offset + BinaryOffset.TimelineScale]; + this._timeOffset = this._timelineArray[this._timelineData.offset + BinaryOffset.TimelineOffset] * 0.01; + } + } + + public fadeOut(): void { } + + public update(passedTime: number): void { + if (this.playState <= 0 && this._setCurrentTime(passedTime)) { + if (this._frameCount > 1) { + const timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + const frameIndex = this._frameIndices[(this._timelineData as TimelineData).frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { + this._frameIndex = frameIndex; + this._frameOffset = this._animationData.frameOffset + this._timelineArray[(this._timelineData as TimelineData).offset + BinaryOffset.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 + BinaryOffset.TimelineFrameOffset]; + } + + this._onArriveAtFrame(); + } + + if (this._tweenState !== TweenState.None) { + this._onUpdateFrame(); + } + } + } + } + /** + * @internal + * @private + */ + export abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType: TweenType, progress: number, easing: number): number { + let value = progress; + + switch (tweenType) { + case TweenType.QuadIn: + value = Math.pow(progress, 2.0); + break; + + case TweenType.QuadOut: + value = 1.0 - Math.pow(1.0 - progress, 2.0); + break; + + case TweenType.QuadInOut: + value = 0.5 * (1.0 - Math.cos(progress * Math.PI)); + break; + } + + return (value - progress) * easing + progress; + } + + private static _getEasingCurveValue(progress: number, samples: Array | Int16Array, count: number, offset: number): number { + if (progress <= 0.0) { + return 0.0; + } + else if (progress >= 1.0) { + return 1.0; + } + + const segmentCount = count + 1; // + 2 - 1 + const valueIndex = Math.floor(progress * segmentCount); + const fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + const toValue = (valueIndex === segmentCount - 1) ? 10000.0 : samples[offset + valueIndex]; + + return (fromValue + (toValue - fromValue) * (progress * segmentCount - valueIndex)) * 0.0001; + } + + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + + protected _onClear(): void { + super._onClear(); + + this._tweenType = TweenType.None; + this._curveCount = 0; + this._framePosition = 0.0; + this._frameDurationR = 0.0; + this._tweenProgress = 0.0; + this._tweenEasing = 0.0; + } + + protected _onArriveAtFrame(): void { + 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 + BinaryOffset.FrameTweenType]; // TODO recode ture tween type. + this._tweenState = this._tweenType === TweenType.None ? TweenState.Once : TweenState.Always; + if (this._tweenType === TweenType.Curve) { + this._curveCount = this._frameArray[this._frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount]; + } + else if (this._tweenType !== TweenType.None && this._tweenType !== TweenType.Line) { + this._tweenEasing = this._frameArray[this._frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount] * 0.01; + } + + this._framePosition = this._frameArray[this._frameOffset] * this._frameRateR; + if (this._frameIndex === this._frameCount - 1) { + this._frameDurationR = 1.0 / (this._animationData.duration - this._framePosition); + } + else { + const nextFrameOffset = this._animationData.frameOffset + this._timelineArray[(this._timelineData as TimelineData).offset + BinaryOffset.TimelineFrameOffset + this._frameIndex + 1]; + this._frameDurationR = 1.0 / (this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition); + } + } + else { + this._tweenState = TweenState.Once; + } + } + + protected _onUpdateFrame(): void { + if (this._tweenState === TweenState.Always) { + this._tweenProgress = (this.currentTime - this._framePosition) * this._frameDurationR; + if (this._tweenType === TweenType.Curve) { + this._tweenProgress = TweenTimelineState._getEasingCurveValue(this._tweenProgress, this._frameArray, this._curveCount, this._frameOffset + BinaryOffset.FrameCurveSamples); + } + else if (this._tweenType !== TweenType.Line) { + this._tweenProgress = TweenTimelineState._getEasingValue(this._tweenType, this._tweenProgress, this._tweenEasing); + } + } + else { + this._tweenProgress = 0.0; + } + } + } + /** + * @internal + * @private + */ + export abstract class BoneTimelineState extends TweenTimelineState { + public bone: Bone; + public bonePose: BonePose; + + protected _onClear(): void { + super._onClear(); + + this.bone = null as any; // + this.bonePose = null as any; // + } + } + /** + * @internal + * @private + */ + export abstract class SlotTimelineState extends TweenTimelineState { + public slot: Slot; + + protected _onClear(): void { + super._onClear(); + + this.slot = null as any; // + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/animation/IAnimatable.ts b/reference/DragonBones/src/dragonBones/animation/IAnimatable.ts new file mode 100644 index 0000000..adbb9ac --- /dev/null +++ b/reference/DragonBones/src/dragonBones/animation/IAnimatable.ts @@ -0,0 +1,25 @@ +namespace dragonBones { + /** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + export interface IAnimatable { + /** + * 更新时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 当前所属的 WordClock 实例。 + * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/animation/TimelineState.ts b/reference/DragonBones/src/dragonBones/animation/TimelineState.ts new file mode 100644 index 0000000..2b614b9 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/animation/TimelineState.ts @@ -0,0 +1,714 @@ +namespace dragonBones { + /** + * @internal + * @private + */ + export class ActionTimelineState extends TimelineState { + public static toString(): string { + return "[class dragonBones.ActionTimelineState]"; + } + + private _onCrossFrame(frameIndex: number): void { + const eventDispatcher = this._armature.eventDispatcher; + if (this._animationState.actionEnabled) { + const frameOffset = this._animationData.frameOffset + this._timelineArray[(this._timelineData as TimelineData).offset + BinaryOffset.TimelineFrameOffset + frameIndex]; + const actionCount = this._frameArray[frameOffset + 1]; + const actions = this._armature.armatureData.actions; + for (let i = 0; i < actionCount; ++i) { + const actionIndex = this._frameArray[frameOffset + 2 + i]; + const action = actions[actionIndex]; + if (action.type === ActionType.Play) { + if (action.slot !== null) { + const slot = this._armature.getSlot(action.slot.name); + if (slot !== null) { + const childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature._bufferAction(action, true); + } + } + } + else if (action.bone !== null) { + for (const slot of this._armature.getSlots()) { + const childArmature = slot.childArmature; + if (childArmature !== null && slot.parent.boneData === action.bone) { + childArmature._bufferAction(action, true); + } + } + } + else { + this._armature._bufferAction(action, true); + } + } + else { + const eventType = action.type === ActionType.Frame ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT; + if (action.type === ActionType.Sound || eventDispatcher.hasEvent(eventType)) { + const eventObject = BaseObject.borrowObject(EventObject); + // eventObject.time = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + eventObject.time = this._frameArray[frameOffset] / this._frameRate; + eventObject.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + + if (action.bone !== null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + + if (action.slot !== null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + + this._armature._dragonBones.bufferEvent(eventObject); + } + } + } + } + } + + protected _onArriveAtFrame(): void { } + protected _onUpdateFrame(): void { } + + public update(passedTime: number): void { + const prevState = this.playState; + let prevPlayTimes = this.currentPlayTimes; + let prevTime = this.currentTime; + + if (this.playState <= 0 && this._setCurrentTime(passedTime)) { + const 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 (eventDispatcher.hasEvent(EventObject.START)) { + const eventObject = BaseObject.borrowObject(EventObject); + eventObject.type = EventObject.START; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + else { + return; + } + } + + const isReverse = this._animationState.timeScale < 0.0; + let loopCompleteEvent: EventObject | null = null; + let completeEvent: EventObject | null = null; + if (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasEvent(EventObject.LOOP_COMPLETE)) { + loopCompleteEvent = BaseObject.borrowObject(EventObject); + loopCompleteEvent.type = EventObject.LOOP_COMPLETE; + loopCompleteEvent.armature = this._armature; + loopCompleteEvent.animationState = this._animationState; + } + + if (this.playState > 0) { + if (eventDispatcher.hasEvent(EventObject.COMPLETE)) { + completeEvent = BaseObject.borrowObject(EventObject); + completeEvent.type = EventObject.COMPLETE; + completeEvent.armature = this._armature; + completeEvent.animationState = this._animationState; + } + + } + } + + if (this._frameCount > 1) { + const timelineData = this._timelineData as TimelineData; + const timelineFrameIndex = Math.floor(this.currentTime * this._frameRate); // uint + const frameIndex = this._frameIndices[timelineData.frameIndicesOffset + timelineFrameIndex]; + if (this._frameIndex !== frameIndex) { // Arrive at frame. + let crossedFrameIndex = this._frameIndex; + this._frameIndex = frameIndex; + if (this._timelineArray !== null) { + this._frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + BinaryOffset.TimelineFrameOffset + this._frameIndex]; + if (isReverse) { + if (crossedFrameIndex < 0) { + const 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) { + const frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + BinaryOffset.TimelineFrameOffset + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + const 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) { + const prevFrameIndex = Math.floor(prevTime * this._frameRate); + crossedFrameIndex = this._frameIndices[timelineData.frameIndicesOffset + prevFrameIndex]; + const frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + BinaryOffset.TimelineFrameOffset + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + const 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; + } + + const frameOffset = this._animationData.frameOffset + this._timelineArray[timelineData.offset + BinaryOffset.TimelineFrameOffset + crossedFrameIndex]; + // const framePosition = this._frameArray[frameOffset] * this._frameRateR; // Precision problem + const 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 + BinaryOffset.TimelineFrameOffset]; + // Arrive at frame. + const 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); + } + } + } + + public setCurrentTime(value: number): void { + this._setCurrentTime(value); + this._frameIndex = -1; + } + } + /** + * @internal + * @private + */ + export class ZOrderTimelineState extends TimelineState { + public static toString(): string { + return "[class dragonBones.ZOrderTimelineState]"; + } + + protected _onArriveAtFrame(): void { + if (this.playState >= 0) { + const count = this._frameArray[this._frameOffset + 1]; + if (count > 0) { + this._armature._sortZOrder(this._frameArray, this._frameOffset + 2); + } + else { + this._armature._sortZOrder(null, 0); + } + } + } + + protected _onUpdateFrame(): void { } + } + /** + * @internal + * @private + */ + export class BoneAllTimelineState extends BoneTimelineState { + public static toString(): string { + return "[class dragonBones.BoneAllTimelineState]"; + } + + protected _onArriveAtFrame(): void { + super._onArriveAtFrame(); + + if (this._timelineData !== null) { + const frameFloatArray = this._dragonBonesData.frameFloatArray; + const current = this.bonePose.current; + const delta = this.bonePose.delta; + let valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + + current.x = frameFloatArray[valueOffset++]; + current.y = frameFloatArray[valueOffset++]; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + + if (this._tweenState === TweenState.Always) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + + delta.x = frameFloatArray[valueOffset++] - current.x; + delta.y = frameFloatArray[valueOffset++] - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } + // else { + // delta.x = 0.0; + // delta.y = 0.0; + // delta.rotation = 0.0; + // delta.skew = 0.0; + // delta.scaleX = 0.0; + // delta.scaleY = 0.0; + // } + } + else { // Pose. + const current = this.bonePose.current; + current.x = 0.0; + current.y = 0.0; + current.rotation = 0.0; + current.skew = 0.0; + current.scaleX = 1.0; + current.scaleY = 1.0; + } + } + + protected _onUpdateFrame(): void { + super._onUpdateFrame(); + + const current = this.bonePose.current; + const delta = this.bonePose.delta; + const result = this.bonePose.result; + + this.bone._transformDirty = true; + if (this._tweenState !== TweenState.Always) { + this._tweenState = TweenState.None; + } + + const scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + } + + public fadeOut(): void { + const result = this.bonePose.result; + result.rotation = Transform.normalizeRadian(result.rotation); + result.skew = Transform.normalizeRadian(result.skew); + } + } + /** + * @internal + * @private + */ + export class SlotDislayIndexTimelineState extends SlotTimelineState { + public static toString(): string { + return "[class dragonBones.SlotDislayIndexTimelineState]"; + } + + protected _onArriveAtFrame(): void { + if (this.playState >= 0) { + const displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot.slotData.displayIndex; + if (this.slot.displayIndex !== displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + } + } + /** + * @internal + * @private + */ + export class SlotColorTimelineState extends SlotTimelineState { + public static toString(): string { + return "[class dragonBones.SlotColorTimelineState]"; + } + + private _dirty: boolean; + private readonly _current: Array = [0, 0, 0, 0, 0, 0, 0, 0]; + private readonly _delta: Array = [0, 0, 0, 0, 0, 0, 0, 0]; + private readonly _result: Array = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]; + + protected _onClear(): void { + super._onClear(); + + this._dirty = false; + } + + protected _onArriveAtFrame(): void { + super._onArriveAtFrame(); + + if (this._timelineData !== null) { + const intArray = this._dragonBonesData.intArray; + const frameIntArray = this._dragonBonesData.frameIntArray; + const valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + let colorOffset = frameIntArray[valueOffset]; + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + + if (this._tweenState === TweenState.Always) { + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1 * 1]; + } + + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } + else { // Pose. + const color = this.slot.slotData.color; + this._current[0] = color.alphaMultiplier * 100.0; + this._current[1] = color.redMultiplier * 100.0; + this._current[2] = color.greenMultiplier * 100.0; + this._current[3] = color.blueMultiplier * 100.0; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + } + + protected _onUpdateFrame(): void { + super._onUpdateFrame(); + + this._dirty = true; + if (this._tweenState !== TweenState.Always) { + this._tweenState = TweenState.None; + } + + this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + } + + public fadeOut(): void { + this._tweenState = TweenState.None; + this._dirty = false; + } + + public update(passedTime: number): void { + super.update(passedTime); + + // Fade animation. + if (this._tweenState !== TweenState.None || this._dirty) { + const result = this.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] + ) { + const 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; + + this.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]; + + this.slot._colorDirty = true; + } + } + } + } + } + /** + * @internal + * @private + */ + export class SlotFFDTimelineState extends SlotTimelineState { + public static toString(): string { + return "[class dragonBones.SlotFFDTimelineState]"; + } + + public meshOffset: number; + + private _dirty: boolean; + private _frameFloatOffset: number; + private _valueCount: number; + private _ffdCount: number; + private _valueOffset: number; + private readonly _current: Array = []; + private readonly _delta: Array = []; + private readonly _result: Array = []; + + protected _onClear(): void { + super._onClear(); + + this.meshOffset = 0; + + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + } + + protected _onArriveAtFrame(): void { + super._onArriveAtFrame(); + + if (this._timelineData !== null) { + const isTween = this._tweenState === TweenState.Always; + const frameFloatArray = this._dragonBonesData.frameFloatArray; + const valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + + if (isTween) { + let nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex === this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + + for (let i = 0; i < this._valueCount; ++i) { + this._delta[i] = frameFloatArray[nextValueOffset + i] - (this._current[i] = frameFloatArray[valueOffset + i]); + } + } + else { + for (let i = 0; i < this._valueCount; ++i) { + this._current[i] = frameFloatArray[valueOffset + i]; + } + } + } + else { + for (let i = 0; i < this._valueCount; ++i) { + this._current[i] = 0.0; + } + } + } + + protected _onUpdateFrame(): void { + super._onUpdateFrame(); + + this._dirty = true; + if (this._tweenState !== TweenState.Always) { + this._tweenState = TweenState.None; + } + + for (let i = 0; i < this._valueCount; ++i) { + this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + } + } + + public init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void { + super.init(armature, animationState, timelineData); + + if (this._timelineData !== null) { + const frameIntArray = this._dragonBonesData.frameIntArray; + const frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + BinaryOffset.TimelineFrameValueCount]; + this.meshOffset = frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineMeshOffset]; + this._ffdCount = frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineFFDCount]; + this._valueCount = frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineValueCount]; + this._valueOffset = frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineValueOffset]; + this._frameFloatOffset = frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineFloatOffset] + this._animationData.frameFloatOffset; + } + else { + this._valueCount = 0; + } + + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + + for (let i = 0; i < this._valueCount; ++i) { + this._delta[i] = 0.0; + } + } + + public fadeOut(): void { + this._tweenState = TweenState.None; + this._dirty = false; + } + + public update(passedTime: number): void { + if (this.slot._meshData === null || (this._timelineData !== null && this.slot._meshData.offset !== this.meshOffset)) { + return; + } + + super.update(passedTime); + + // Fade animation. + if (this._tweenState !== TweenState.None || this._dirty) { + const result = this.slot._ffdVertices; + if (this._timelineData !== null) { + const frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + const fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + + for (let i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] += (frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; + } + else { + result[i] += (frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + } + } + + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + + for (let i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] = frameFloatArray[this._frameFloatOffset + i]; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] = this._result[i - this._valueOffset]; + } + else { + result[i] = frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + } + } + + this.slot._meshDirty = true; + } + } + else { + this._ffdCount = result.length; // + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + const fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (let i = 0; i < this._ffdCount; ++i) { + result[i] += (0.0 - result[i]) * fadeProgress; + } + + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + + for (let i = 0; i < this._ffdCount; ++i) { + result[i] = 0.0; + } + + this.slot._meshDirty = true; + } + } + } + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/animation/WorldClock.ts b/reference/DragonBones/src/dragonBones/animation/WorldClock.ts new file mode 100644 index 0000000..be10551 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/animation/WorldClock.ts @@ -0,0 +1,175 @@ +namespace dragonBones { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + export class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + public static readonly clock: WorldClock = new WorldClock(); + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public time: number = 0.0; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + public timeScale: number = 1.0; + private readonly _animatebles: Array = []; + private _clock: WorldClock | null = null; + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + public constructor(time: number = -1.0) { + if (time < 0.0) { + this.time = new Date().getTime() * 0.001; + } + else { + this.time = time; + } + } + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + public advanceTime(passedTime: number): void { + if (passedTime !== passedTime) { // isNaN + passedTime = 0.0; + } + + if (passedTime < 0.0) { + passedTime = new Date().getTime() * 0.001 - this.time; + } + + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + + if (passedTime === 0.0) { + return; + } + + let i = 0, r = 0, l = this._animatebles.length; + for (; i < l; ++i) { + const 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) { + const animateble = this._animatebles[i]; + if (animateble !== null) { + this._animatebles[i - r] = animateble; + } + else { + r++; + } + } + + this._animatebles.length -= r; + } + } + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public contains(value: IAnimatable): boolean { + return this._animatebles.indexOf(value) >= 0; + } + /** + * 添加 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public add(value: IAnimatable): void { + if (this._animatebles.indexOf(value) < 0) { + this._animatebles.push(value); + value.clock = this; + } + } + /** + * 移除 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public remove(value: IAnimatable): void { + const index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles[index] = null; + value.clock = null; + } + } + /** + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public clear(): void { + for (const animatable of this._animatebles) { + if (animatable !== null) { + animatable.clock = null; + } + } + } + /** + * @inheritDoc + */ + public get clock(): WorldClock | null { + return this._clock; + } + public set clock(value: WorldClock | null) { + if (this._clock === value) { + return; + } + + if (this._clock !== null) { + this._clock.remove(this); + } + + this._clock = value; + + if (this._clock !== null) { + this._clock.add(this); + } + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/armature/Armature.ts b/reference/DragonBones/src/dragonBones/armature/Armature.ts new file mode 100644 index 0000000..1d259ae --- /dev/null +++ b/reference/DragonBones/src/dragonBones/armature/Armature.ts @@ -0,0 +1,841 @@ +namespace dragonBones { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + export class Armature extends BaseObject implements IAnimatable { + public static toString(): string { + return "[class dragonBones.Armature]"; + } + private static _onSortSlots(a: Slot, b: Slot): number { + return a._zOrder > b._zOrder ? 1 : -1; + } + /** + * 是否继承父骨架的动画状态。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + public inheritAnimation: boolean; + /** + * @private + */ + public debugDraw: boolean; + /** + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + */ + public armatureData: ArmatureData; + /** + * 用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public userData: any; + + private _debugDraw: boolean; + private _lockUpdate: boolean; + private _bonesDirty: boolean; + private _slotsDirty: boolean; + private _zOrderDirty: boolean; + private _flipX: boolean; + private _flipY: boolean; + /** + * @internal + * @private + */ + public _cacheFrameIndex: number; + private readonly _bones: Array = []; + private readonly _slots: Array = []; + private readonly _actions: Array = []; + private _animation: Animation = null as any; // Initial value. + private _proxy: IArmatureProxy = null as any; // Initial value. + private _display: any; + /** + * @private + */ + public _replaceTextureAtlasData: TextureAtlasData | null = null; // Initial value. + private _replacedTexture: any; + /** + * @internal + * @private + */ + public _dragonBones: DragonBones; + private _clock: WorldClock | null = null; // Initial value. + /** + * @internal + * @private + */ + public _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void { + if (this._clock !== null) { // Remove clock first. + this._clock.remove(this); + } + + for (const bone of this._bones) { + bone.returnToPool(); + } + + for (const slot of this._slots) { + slot.returnToPool(); + } + + for (const action of this._actions) { + action.returnToPool(); + } + + if (this._animation !== null) { + this._animation.returnToPool(); + } + + if (this._proxy !== null) { + this._proxy.clear(); + } + + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null as any; // + this.userData = null; + + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._actions.length = 0; + this._animation = null as any; // + this._proxy = null as any; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null as any; // + this._clock = null; + this._parent = null; + } + + private _sortBones(): void { + const total = this._bones.length; + if (total <= 0) { + return; + } + + const sortHelper = this._bones.concat(); + let index = 0; + let count = 0; + + this._bones.length = 0; + while (count < total) { + const bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + + if (this._bones.indexOf(bone) >= 0) { + continue; + } + + if (bone.constraints.length > 0) { // Wait constraint. + let flag = false; + for (const constraint of bone.constraints) { + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + + if (flag) { + continue; + } + } + + if (bone.parent !== null && this._bones.indexOf(bone.parent) < 0) { // Wait parent. + continue; + } + + this._bones.push(bone); + count++; + } + } + + private _sortSlots(): void { + this._slots.sort(Armature._onSortSlots); + } + /** + * @internal + * @private + */ + public _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void { + const slotDatas = this.armatureData.sortedSlots; + const isOriginal = slotIndices === null; + + if (this._zOrderDirty || !isOriginal) { + for (let i = 0, l = slotDatas.length; i < l; ++i) { + const slotIndex = isOriginal ? i : (slotIndices as Array)[offset + i]; + if (slotIndex < 0 || slotIndex >= l) { + continue; + } + + const slotData = slotDatas[slotIndex]; + const slot = this.getSlot(slotData.name); + if (slot !== null) { + slot._setZorder(i); + } + } + + this._slotsDirty = true; + this._zOrderDirty = !isOriginal; + } + } + /** + * @internal + * @private + */ + public _addBoneToBoneList(value: Bone): void { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.push(value); + this._animation._timelineDirty = true; + } + } + /** + * @internal + * @private + */ + public _removeBoneFromBoneList(value: Bone): void { + const index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + } + /** + * @internal + * @private + */ + public _addSlotToSlotList(value: Slot): void { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.push(value); + this._animation._timelineDirty = true; + } + } + /** + * @internal + * @private + */ + public _removeSlotFromSlotList(value: Slot): void { + const index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + } + /** + * @internal + * @private + */ + public _bufferAction(action: ActionData, append: boolean): void { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + } + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + public dispose(): void { + if (this.armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + } + /** + * @private + */ + public init( + armatureData: ArmatureData, + proxy: IArmatureProxy, display: any, dragonBones: DragonBones + ): void { + if (this.armatureData !== null) { + return; + } + + this.armatureData = armatureData; + this._animation = BaseObject.borrowObject(Animation); + this._proxy = proxy; + this._display = display; + this._dragonBones = dragonBones; + + this._proxy.init(this); + this._animation.init(this); + this._animation.animations = this.armatureData.animations; + } + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + public advanceTime(passedTime: number): void { + if (this._lockUpdate) { + return; + } + + if (this.armatureData === null) { + console.assert(false, "The armature has been disposed."); + return; + } + else if (this.armatureData.parent === null) { + console.assert(false, "The armature data has been disposed."); + return; + } + + const prevCacheFrameIndex = this._cacheFrameIndex; + + // Update nimation. + this._animation.advanceTime(passedTime); + + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + + // Update bones and slots. + if (this._cacheFrameIndex < 0 || this._cacheFrameIndex !== prevCacheFrameIndex) { + let 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); + } + } + + if (this._actions.length > 0) { + this._lockUpdate = true; + for (const action of this._actions) { + if (action.type === ActionType.Play) { + this._animation.fadeIn(action.name); + } + } + + this._actions.length = 0; + this._lockUpdate = false; + } + + // + const drawed = this.debugDraw || DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + } + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + public invalidUpdate(boneName: string | null = null, updateSlotDisplay: boolean = false): void { + if (boneName !== null && boneName.length > 0) { + const bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + + if (updateSlotDisplay) { + for (const slot of this._slots) { + if (slot.parent === bone) { + slot.invalidUpdate(); + } + } + } + } + } + else { + for (const bone of this._bones) { + bone.invalidUpdate(); + } + + if (updateSlotDisplay) { + for (const slot of this._slots) { + slot.invalidUpdate(); + } + } + } + } + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + public containsPoint(x: number, y: number): Slot | null { + for (const slot of this._slots) { + if (slot.containsPoint(x, y)) { + return slot; + } + } + + return null; + } + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @param xA 线段起点的水平坐标。(骨架内坐标系) + * @param yA 线段起点的垂直坐标。(骨架内坐标系) + * @param xB 线段终点的水平坐标。(骨架内坐标系) + * @param yB 线段终点的垂直坐标。(骨架内坐标系) + * @param intersectionPointA 线段从起点到终点与包围盒相交的第一个交点。(骨架内坐标系) + * @param intersectionPointB 线段从终点到起点与包围盒相交的第一个交点。(骨架内坐标系) + * @param normalRadians 碰撞点处包围盒切线的法线弧度。 [x: 第一个碰撞点处切线的法线弧度, y: 第二个碰撞点处切线的法线弧度] + * @returns 线段从起点到终点相交的第一个自定义包围盒的插槽。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public intersectsSegment( + xA: number, yA: number, xB: number, yB: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): Slot | null { + const isV = xA === xB; + let dMin = 0.0; + let dMax = 0.0; + let intXA = 0.0; + let intYA = 0.0; + let intXB = 0.0; + let intYB = 0.0; + let intAN = 0.0; + let intBN = 0.0; + let intSlotA: Slot | null = null; + let intSlotB: Slot | null = null; + + for (const slot of this._slots) { + const intersectionCount = slot.intersectsSegment(xA, yA, xB, yB, intersectionPointA, intersectionPointB, normalRadians); + if (intersectionCount > 0) { + if (intersectionPointA !== null || intersectionPointB !== null) { + if (intersectionPointA !== null) { + let 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) { + let 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; + } + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + public getBone(name: string): Bone | null { + for (const bone of this._bones) { + if (bone.name === name) { + return bone; + } + } + + return null; + } + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + public getBoneByDisplay(display: any): Bone | null { + const slot = this.getSlotByDisplay(display); + + return slot !== null ? slot.parent : null; + } + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + public getSlot(name: string): Slot | null { + for (const slot of this._slots) { + if (slot.name === name) { + return slot; + } + } + + return null; + } + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + public getSlotByDisplay(display: any): Slot | null { + if (display !== null) { + for (const slot of this._slots) { + if (slot.display === display) { + return slot; + } + } + } + + return null; + } + /** + * @deprecated + */ + public addBone(value: Bone, parentName: string | null = null): void { + console.assert(value !== null); + + value._setArmature(this); + value._setParent(parentName !== null ? this.getBone(parentName) : null); + } + /** + * @deprecated + */ + public removeBone(value: Bone): void { + console.assert(value !== null && value.armature === this); + + value._setParent(null); + value._setArmature(null); + } + /** + * @deprecated + */ + public addSlot(value: Slot, parentName: string): void { + const bone = this.getBone(parentName); + + console.assert(value !== null && bone !== null); + + value._setArmature(this); + value._setParent(bone); + } + /** + * @deprecated + */ + public removeSlot(value: Slot): void { + console.assert(value !== null && value.armature === this); + + value._setParent(null); + value._setArmature(null); + } + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + public getBones(): Array { + return this._bones; + } + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + public getSlots(): Array { + return this._slots; + } + + public get flipX(): boolean { + return this._flipX; + } + public set flipX(value: boolean) { + if (this._flipX === value) { + return; + } + + this._flipX = value; + this.invalidUpdate(); + } + + public get flipY(): boolean { + return this._flipY; + } + public set flipY(value: boolean) { + if (this._flipY === value) { + return; + } + + this._flipY = value; + this.invalidUpdate(); + } + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + public get cacheFrameRate(): number { + return this.armatureData.cacheFrameRate; + } + public set cacheFrameRate(value: number) { + if (this.armatureData.cacheFrameRate !== value) { + this.armatureData.cacheFrames(value); + + // Set child armature frameRate. + for (const slot of this._slots) { + const childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.cacheFrameRate = value; + } + } + } + } + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + public get name(): string { + return this.armatureData.name; + } + /** + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + public get animation(): Animation { + return this._animation; + } + /** + * @pivate + */ + public get proxy(): IArmatureProxy { + return this._proxy; + } + /** + * @pivate + */ + public get eventDispatcher(): IEventDispatcher { + return this._proxy; + } + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get display(): any { + return this._display; + } + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + public get replacedTexture(): any { + return this._replacedTexture; + } + public set replacedTexture(value: any) { + if (this._replacedTexture === value) { + return; + } + + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + this._replaceTextureAtlasData = null; + } + + this._replacedTexture = value; + + for (const slot of this._slots) { + slot.invalidUpdate(); + slot.update(-1); + } + } + /** + * @inheritDoc + */ + public get clock(): WorldClock | null { + return this._clock; + } + public set clock(value: WorldClock | null) { + 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 (const slot of this._slots) { + const childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature.clock = this._clock; + } + } + } + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + public get parent(): Slot | null { + return this._parent; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + public replaceTexture(texture: any): void { + this.replacedTexture = texture; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + public hasEventListener(type: EventStringType): boolean { + return this._proxy.hasEvent(type); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + public addEventListener(type: EventStringType, listener: Function, target: any): void { + this._proxy.addEvent(type, listener, target); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + public removeEventListener(type: EventStringType, listener: Function, target: any): void { + this._proxy.removeEvent(type, listener, target); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + public enableAnimationCache(frameRate: number): void { + this.cacheFrameRate = frameRate; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + public getDisplay(): any { + return this._display; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/armature/Bone.ts b/reference/DragonBones/src/dragonBones/armature/Bone.ts new file mode 100644 index 0000000..668b513 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/armature/Bone.ts @@ -0,0 +1,503 @@ +namespace dragonBones { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + export class Bone extends TransformObject { + public static toString(): string { + return "[class dragonBones.Bone]"; + } + /** + * @private + */ + public offsetMode: OffsetMode; + /** + * @internal + * @private + */ + public readonly animationPose: Transform = new Transform(); + /** + * @internal + * @private + */ + public readonly constraints: Array = []; + /** + * @readonly + */ + public boneData: BoneData; + /** + * @internal + * @private + */ + public _transformDirty: boolean; + /** + * @internal + * @private + */ + public _childrenTransformDirty: boolean; + /** + * @internal + * @private + */ + public _blendDirty: boolean; + private _localDirty: boolean; + private _visible: boolean; + private _cachedFrameIndex: number; + /** + * @internal + * @private + */ + public _blendLayer: number; + /** + * @internal + * @private + */ + public _blendLeftWeight: number; + /** + * @internal + * @private + */ + public _blendLayerWeight: number; + private readonly _bones: Array = []; + private readonly _slots: Array = []; + /** + * @internal + * @private + */ + public _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + for (const constraint of this.constraints) { + constraint.returnToPool(); + } + + this.offsetMode = OffsetMode.Additive; + this.animationPose.identity(); + this.constraints.length = 0; + this.boneData = null as any; // + + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1.0; + this._blendLayerWeight = 0.0; + this._bones.length = 0; + this._slots.length = 0; + this._cachedFrameIndices = null; + } + /** + * @private + */ + private _updateGlobalTransformMatrix(isCache: boolean): void { + const flipX = this._armature.flipX; + const flipY = this._armature.flipY === DragonBones.yDown; + const global = this.global; + const globalTransformMatrix = this.globalTransformMatrix; + let inherit = this._parent !== null; + let dR = 0.0; + + if (this.offsetMode === OffsetMode.Additive) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } + else if (this.offsetMode === OffsetMode.None) { + global.copyFrom(this.origin).add(this.animationPose); + } + else { + inherit = false; + global.copyFrom(this.offset); + } + + if (inherit) { + const parentMatrix = this._parent.globalTransformMatrix; + + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + + if (this.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 (this.boneData.inheritTranslation) { + const x = global.x; + const y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + + if (flipY) { + global.y = -global.y; + } + } + + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + + if (this._parent.global.scaleX < 0.0) { + dR += Math.PI; + } + + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + dR -= global.rotation * 2.0; + + if (flipX !== flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + + global.rotation += dR; + } + else if (flipX || flipY) { + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + + global.skew += Math.PI; + } + + global.rotation += dR; + } + + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + + if (flipY) { + global.y = -global.y; + } + + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + + global.skew += Math.PI; + } + + global.rotation += dR; + } + + global.toMatrix(globalTransformMatrix); + } + } + /** + * @internal + * @private + */ + public _setArmature(value: Armature | null): void { + if (this._armature === value) { + return; + } + + let oldSlots: Array | null = null; + let oldBones: Array | null = null; + + if (this._armature !== null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + + this._armature = value as any; // + + if (this._armature !== null) { + this._armature._addBoneToBoneList(this); + } + + if (oldSlots !== null) { + for (const slot of oldSlots) { + if (slot.parent === this) { + slot._setArmature(this._armature); + } + } + } + + if (oldBones !== null) { + for (const bone of oldBones) { + if (bone.parent === this) { + bone._setArmature(this._armature); + } + } + } + } + /** + * @internal + * @private + */ + public init(boneData: BoneData): void { + if (this.boneData !== null) { + return; + } + + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + } + /** + * @internal + * @private + */ + public update(cacheFrameIndex: number): void { + this._blendDirty = false; + + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + const 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.constraints.length > 0) { // Update constraints. + for (const constraint of this.constraints) { + 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.constraints.length > 0) { // Update constraints. + for (const constraint of this.constraints) { + 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) { + const 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 + * @private + */ + public updateByConstraint(): void { + if (this._localDirty) { + this._localDirty = false; + if (this._transformDirty || (this._parent !== null && this._parent._childrenTransformDirty)) { + this._updateGlobalTransformMatrix(true); + } + + this._transformDirty = true; + } + } + /** + * @internal + * @private + */ + public addConstraint(constraint: Constraint): void { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.push(constraint); + } + } + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + public invalidUpdate(): void { + this._transformDirty = true; + } + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + public contains(child: TransformObject): boolean { + if (child === this) { + return false; + } + + let ancestor: TransformObject | null = child; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + + return ancestor === this; + } + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public getBones(): Array { + this._bones.length = 0; + + for (const bone of this._armature.getBones()) { + if (bone.parent === this) { + this._bones.push(bone); + } + } + + return this._bones; + } + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + public getSlots(): Array { + this._slots.length = 0; + + for (const slot of this._armature.getSlots()) { + if (slot.parent === this) { + this._slots.push(slot); + } + } + + return this._slots; + } + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + public get visible(): boolean { + return this._visible; + } + public set visible(value: boolean) { + if (this._visible === value) { + return; + } + + this._visible = value; + + for (const slot of this._armature.getSlots()) { + if (slot._parent === this) { + slot._updateVisible(); + } + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + public get length(): number { + return this.boneData.length; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + public get slot(): Slot | null { + for (const slot of this._armature.getSlots()) { + if (slot.parent === this) { + return slot; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/armature/Constraint.ts b/reference/DragonBones/src/dragonBones/armature/Constraint.ts new file mode 100644 index 0000000..7cb84db --- /dev/null +++ b/reference/DragonBones/src/dragonBones/armature/Constraint.ts @@ -0,0 +1,150 @@ +namespace dragonBones { + /** + * @private + * @internal + */ + export abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix = new Matrix(); + protected static readonly _helpTransform: Transform = new Transform(); + protected static readonly _helpPoint: Point = new Point(); + + public target: Bone; + public bone: Bone; + public root: Bone | null; + + protected _onClear(): void { + this.target = null as any; // + this.bone = null as any; // + this.root = null; // + } + + public abstract update(): void; + } + /** + * @private + * @internal + */ + export class IKConstraint extends Constraint { + public static toString(): string { + return "[class dragonBones.IKConstraint]"; + } + + public bendPositive: boolean; + public scaleEnabled: boolean; // TODO + public weight: number; + + protected _onClear(): void { + super._onClear(); + + this.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + } + + private _computeA(): void { + const ikGlobal = this.target.global; + const global = this.bone.global; + const globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + + let ikRadian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadian += Math.PI; + } + + global.rotation += (ikRadian - global.rotation) * this.weight; + global.toMatrix(globalTransformMatrix); + } + + private _computeB(): void { + const boneLength = this.bone.boneData.length; + const parent = this.root as Bone; + const ikGlobal = this.target.global; + const parentGlobal = parent.global; + const global = this.bone.global; + const globalTransformMatrix = this.bone.globalTransformMatrix; + + const x = globalTransformMatrix.a * boneLength; + const y = globalTransformMatrix.b * boneLength; + + const lLL = x * x + y * y; + const lL = Math.sqrt(lLL); + + let dX = global.x - parentGlobal.x; + let dY = global.y - parentGlobal.y; + const lPP = dX * dX + dY * dY; + const lP = Math.sqrt(lPP); + const rawRadianA = Math.atan2(dY, dX); + + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + const lTT = dX * dX + dY * dY; + const lT = Math.sqrt(lTT); + + let ikRadianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + ikRadianA += Math.PI; + } + } + else { + const h = (lPP - lLL + lTT) / (2.0 * lTT); + const r = Math.sqrt(lPP - h * h * lTT) / lT; + const hX = parentGlobal.x + (dX * h); + const hY = parentGlobal.y + (dY * h); + const rX = -dY * r; + const rY = dX * r; + + let isPPR = false; + if (parent._parent !== null) { + const parentParentMatrix = parent._parent.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; + } + + ikRadianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + + let dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + + const parentRadian = rawRadianA + dR; + global.x = parentGlobal.x + Math.cos(parentRadian) * lP; + global.y = parentGlobal.y + Math.sin(parentRadian) * lP; + + let ikRadianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadianB += Math.PI; + } + + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + } + + public update(): void { + if (this.root === null) { + this.bone.updateByConstraint(); + this._computeA(); + } + else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/armature/IArmatureProxy.ts b/reference/DragonBones/src/dragonBones/armature/IArmatureProxy.ts new file mode 100644 index 0000000..d29ae49 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/armature/IArmatureProxy.ts @@ -0,0 +1,41 @@ +namespace dragonBones { + /** + * @language zh_CN + * 骨架代理接口。 + * @version DragonBones 5.0 + */ + export interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + init(armature: Armature): void; + /** + * @private + */ + clear(): void; + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + dispose(disposeProxy: boolean): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @language zh_CN + * 获取骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + readonly armature: Armature; + /** + * @language zh_CN + * 获取动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + readonly animation: Animation; + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/armature/Slot.ts b/reference/DragonBones/src/dragonBones/armature/Slot.ts new file mode 100644 index 0000000..c6b8b29 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/armature/Slot.ts @@ -0,0 +1,1005 @@ +namespace dragonBones { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + export abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 + * @language zh_CN + */ + public displayController: string | null; + /** + * @readonly + */ + public slotData: SlotData; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + public _colorDirty: boolean; + /** + * @private + */ + public _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @private + */ + public _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @private + */ + public _pivotX: number; + /** + * @private + */ + public _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix = new Matrix(); + /** + * @private + */ + public readonly _colorTransform: ColorTransform = new ColorTransform(); + /** + * @private + */ + public readonly _ffdVertices: Array = []; + /** + * @private + */ + public readonly _displayDatas: Array = []; + /** + * @private + */ + protected readonly _displayList: Array = []; + /** + * @private + */ + protected readonly _meshBones: Array = []; + /** + * @internal + * @private + */ + public _rawDisplayDatas: Array; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @private + */ + public _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any = null; // Initial value. + /** + * @private + */ + protected _meshDisplay: any = null; // Initial value. + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + public _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + const disposeDisplayList: Array = []; + for (const eachDisplay of this._displayList) { + if ( + eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0 + ) { + disposeDisplayList.push(eachDisplay); + } + } + + for (const eachDisplay of disposeDisplayList) { + if (eachDisplay instanceof Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { // May be _meshDisplay and _rawDisplay is the same one. + this._disposeDisplay(this._meshDisplay); + } + + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay); + } + + this.displayController = null; + this.slotData = null as any; // + + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = BlendMode.Normal; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.length = 0; + this._displayList.length = 0; + this._displayDatas.length = 0; + this._meshBones.length = 0; + this._rawDisplayDatas = null as any; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + } + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + public abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateDisplayData(): void { + const prevDisplayData = this._displayData; + const prevTextureData = this._textureData; + const prevMeshData = this._meshData; + const rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.length) { + this._displayData = this._displayDatas[this._displayIndex]; + } + else { + this._displayData = null; + } + + // Update texture and mesh data. + if (this._displayData !== null) { + if (this._displayData.type === DisplayType.Image || this._displayData.type === DisplayType.Mesh) { + this._textureData = (this._displayData as ImageDisplayData).texture; + if (this._displayData.type === DisplayType.Mesh) { + this._meshData = this._displayData as MeshDisplayData; + } + else if (rawDisplayData !== null && rawDisplayData.type === DisplayType.Mesh) { + this._meshData = rawDisplayData as MeshDisplayData; + } + else { + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + + // Update bounding box data. + if (this._displayData !== null && this._displayData.type === DisplayType.BoundingBox) { + this._boundingBoxData = (this._displayData as BoundingBoxDisplayData).boundingBox; + } + else if (rawDisplayData !== null && rawDisplayData.type === DisplayType.BoundingBox) { + this._boundingBoxData = (rawDisplayData as BoundingBoxDisplayData).boundingBox; + } + else { + this._boundingBoxData = null; + } + + if (this._displayData !== prevDisplayData || this._textureData !== prevTextureData || this._meshData !== prevMeshData) { + // Update pivot offset. + if (this._meshData !== null) { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + else if (this._textureData !== null) { + const imageDisplayData = this._displayData as ImageDisplayData; + const scale = this._armature.armatureData.scale; + const frame = this._textureData.frame; + + this._pivotX = imageDisplayData.pivot.x; + this._pivotY = imageDisplayData.pivot.y; + + const rect = frame !== null ? frame : this._textureData.region; + let width = rect.width * scale; + let height = rect.height * scale; + + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + + this._pivotX *= width; + this._pivotY *= height; + + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + + // Update mesh bones and ffd vertices. + if (this._meshData !== prevMeshData) { + if (this._meshData !== null) { // && this._meshData === this._displayData + if (this._meshData.weight !== null) { + this._ffdVertices.length = this._meshData.weight.count * 2; + this._meshBones.length = this._meshData.weight.bones.length; + + for (let i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.weight.bones[i].name); + } + } + else { + const vertexCount = this._meshData.parent.parent.intArray[this._meshData.offset + BinaryOffset.MeshVertexCount]; + this._ffdVertices.length = vertexCount * 2; + this._meshBones.length = 0; + } + + for (let i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0.0; + } + + this._meshDirty = true; + } + else { + this._ffdVertices.length = 0; + this._meshBones.length = 0; + } + } + else if (this._meshData !== null && this._textureData !== prevTextureData) { // Update mesh after update frame. + this._meshDirty = true; + } + + if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData && this._meshData === null) { + 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; + + this._displayData.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; + } + + // Update original transform. + if (rawDisplayData !== null) { + this.origin = rawDisplayData.transform; + } + else if (this._displayData !== null) { + this.origin = this._displayData.transform; + } + + this._displayDirty = true; + this._transformDirty = true; + } + } + /** + * @private + */ + protected _updateDisplay(): void { + const prevDisplay = this._display !== null ? this._display : this._rawDisplay; + const prevChildArmature = this._childArmature; + + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + if (this._display !== null && this._display instanceof Armature) { + this._childArmature = this._display as Armature; + this._display = this._childArmature.display; + } + else { + this._childArmature = null; + } + } + else { + this._display = null; + this._childArmature = null; + } + + // Update display. + const currentDisplay = this._display !== null ? this._display : this._rawDisplay; + if (currentDisplay !== prevDisplay) { + this._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + + // Update frame. + if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { + this._updateFrame(); + } + + // 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) { + const cacheFrameRate = this._armature.cacheFrameRate; + if (cacheFrameRate !== 0) { + this._childArmature.cacheFrameRate = cacheFrameRate; + } + } + + // Child armature action. + let actions: Array | null = null; + if (this._displayData !== null && this._displayData.type === DisplayType.Armature) { + actions = (this._displayData as ArmatureDisplayData).actions; + } + else { + const rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (rawDisplayData !== null && rawDisplayData.type === DisplayType.Armature) { + actions = (rawDisplayData as ArmatureDisplayData).actions; + } + } + + if (actions !== null && actions.length > 0) { + for (const action of actions) { + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + } + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + } + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean { + for (const bone of this._meshBones) { + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + + return false; + } + /** + * @internal + * @private + */ + public _setArmature(value: Armature | null): void { + if (this._armature === value) { + return; + } + + if (this._armature !== null) { + this._armature._removeSlotFromSlotList(this); + } + + this._armature = value as any; // + + this._onUpdateDisplay(); + + if (this._armature !== null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); + } + } + /** + * @internal + * @private + */ + public _setDisplayIndex(value: number, isAnimation: boolean = false): boolean { + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return false; + } + + this._animationDisplayIndex = value; + } + + if (this._displayIndex === value) { + return false; + } + + this._displayIndex = value; + this._displayDirty = true; + + this._updateDisplayData(); + + return this._displayDirty; + } + /** + * @internal + * @private + */ + public _setZorder(value: number): boolean { + if (this._zOrder === value) { + //return false; + } + + this._zOrder = value; + this._zOrderDirty = true; + + return this._zOrderDirty; + } + /** + * @internal + * @private + */ + public _setColor(value: ColorTransform): boolean { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + + return this._colorDirty; + } + /** + * @private + */ + public _setDisplayList(value: Array | null): boolean { + if (value !== null && value.length > 0) { + if (this._displayList.length !== value.length) { + this._displayList.length = value.length; + } + + for (let i = 0, l = value.length; i < l; ++i) { // Retain input render displays. + const eachDisplay = value[i]; + if ( + eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + !(eachDisplay instanceof Armature) && this._displayList.indexOf(eachDisplay) < 0 + ) { + this._initDisplay(eachDisplay); + } + + this._displayList[i] = eachDisplay; + } + } + else if (this._displayList.length > 0) { + this._displayList.length = 0; + } + + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display !== this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display !== null; + } + + this._updateDisplayData(); + + return this._displayDirty; + } + /** + * @private + */ + public init(slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void { + if (this.slotData !== null) { + return; + } + + this.slotData = slotData; + this.name = this.slotData.name; + + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + + this._displayDatas.length = this._rawDisplayDatas.length; + for (let i = 0, l = this._displayDatas.length; i < l; ++i) { + this._displayDatas[i] = this._rawDisplayDatas[i]; + } + } + /** + * @internal + * @private + */ + public update(cacheFrameIndex: number): void { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + + if (this._transformDirty) { // Update local matrix. (Only updated when both display and transform are dirty.) + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + + if (cacheFrameIndex >= 0 && this._cachedFrameIndices !== null) { + const 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._display === null) { + return; + } + + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + + if (this._meshData !== null && this._display === this._meshDisplay) { + const isSkinned = this._meshData.weight !== null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + + return; + } + } + + if (this._transformDirty) { + this._transformDirty = false; + + if (this._cachedFrameIndex < 0) { + const 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(false); + } + } + /** + * @private + */ + public updateTransformAndMatrix(): void { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + } + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @version DragonBones 5.0 + * @language zh_CN + */ + public containsPoint(x: number, y: number): boolean { + 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); + } + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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 + */ + public intersectsSegment( + xA: number, yA: number, xB: number, yB: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + 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; + + const 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; + } + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public invalidUpdate(): void { + this._displayDirty = true; + this._transformDirty = true; + } + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public get displayIndex(): number { + return this._displayIndex; + } + public set displayIndex(value: number) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + } + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get displayList(): Array { + return this._displayList.concat(); + } + public set displayList(value: Array) { + const backupDisplayList = this._displayList.concat(); // Copy. + const disposeDisplayList = new Array(); + + if (this._setDisplayList(value)) { + this.update(-1); + } + + // Release replaced displays. + for (const eachDisplay of backupDisplayList) { + if ( + eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0 + ) { + disposeDisplayList.push(eachDisplay); + } + } + + for (const eachDisplay of disposeDisplayList) { + if (eachDisplay instanceof Armature) { + (eachDisplay as Armature).dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + } + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + public get boundingBoxData(): BoundingBoxData | null { + return this._boundingBoxData; + } + /** + * @private + */ + public get rawDisplay(): any { + return this._rawDisplay; + } + /** + * @private + */ + public get meshDisplay(): any { + return this._meshDisplay; + } + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get display(): any { + return this._display; + } + public set display(value: any) { + if (this._display === value) { + return; + } + + const displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength === 0) { // Emprty. + this._displayIndex = 0; + } + + if (this._displayIndex < 0) { + return; + } + else { + const replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + } + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + public get childArmature(): Armature | null { + return this._childArmature; + } + public set childArmature(value: Armature | null) { + if (this._childArmature === value) { + return; + } + + this.display = value; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + public getDisplay(): any { + return this._display; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + public setDisplay(value: any) { + this.display = value; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/armature/TransformObject.ts b/reference/DragonBones/src/dragonBones/armature/TransformObject.ts new file mode 100644 index 0000000..dfb31f4 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/armature/TransformObject.ts @@ -0,0 +1,129 @@ +namespace dragonBones { + /** + * 基础变换对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + export abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix = new Matrix(); + /** + * @private + */ + protected static readonly _helpTransform: Transform = new Transform(); + /** + * @private + */ + protected static readonly _helpPoint: Point = new Point(); + /** + * 对象的名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly globalTransformMatrix: Matrix = new Matrix(); + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly global: Transform = new Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly offset: Transform = new Transform(); + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + */ + public origin: Transform; + /** + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @private + */ + public _armature: Armature; + /** + * @private + */ + public _parent: Bone; + /** + * @private + */ + protected _onClear(): void { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null as any; // + this.userData = null; + + this._globalDirty = false; + this._armature = null as any; // + this._parent = null as any; // + } + /** + * @internal + * @private + */ + public _setArmature(value: Armature | null): void { + this._armature = value as any; + } + /** + * @internal + * @private + */ + public _setParent(value: Bone | null): void { + this._parent = value as any; + } + /** + * @private + */ + public updateGlobalTransform(): void { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + } + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + public get armature(): Armature { + return this._armature; + } + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + public get parent(): Bone { + return this._parent; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/core/BaseObject.ts b/reference/DragonBones/src/dragonBones/core/BaseObject.ts new file mode 100644 index 0000000..e80be0f --- /dev/null +++ b/reference/DragonBones/src/dragonBones/core/BaseObject.ts @@ -0,0 +1,133 @@ +namespace dragonBones { + /** + * 基础对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + export abstract class BaseObject { + private static _hashCode: number = 0; + private static _defaultMaxCount: number = 1000; + private static readonly _maxCountMap: Map = {}; + private static readonly _poolsMap: Map> = {}; + + private static _returnObject(object: BaseObject): void { + const classType = String(object.constructor); + const maxCount = classType in BaseObject._maxCountMap ? BaseObject._defaultMaxCount : BaseObject._maxCountMap[classType]; + const pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.push(object); + } + else { + console.assert(false, "The object is already in the pool."); + } + } + else { + } + } + /** + * @private + */ + public static toString(): string { + throw new Error(); + } + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + public static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void { + if (maxCount < 0 || maxCount !== maxCount) { // isNaN + maxCount = 0; + } + + if (objectConstructor !== null) { + const classType = String(objectConstructor); + const 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 (let classType in BaseObject._poolsMap) { + if (classType in BaseObject._maxCountMap) { + continue; + } + + const pool = BaseObject._poolsMap[classType]; + if (pool.length > maxCount) { + pool.length = maxCount; + } + + BaseObject._maxCountMap[classType] = maxCount; + } + } + } + /** + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + public static clearPool(objectConstructor: (typeof BaseObject) | null = null): void { + if (objectConstructor !== null) { + const classType = String(objectConstructor); + const pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; + if (pool !== null && pool.length > 0) { + pool.length = 0; + } + } + else { + for (let k in BaseObject._poolsMap) { + const pool = BaseObject._poolsMap[k]; + pool.length = 0; + } + } + } + /** + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static borrowObject(objectConstructor: { new (): T; }): T { + const classType = String(objectConstructor); + const pool = classType in BaseObject._poolsMap ? BaseObject._poolsMap[classType] : null; + if (pool !== null && pool.length > 0) { + const object = pool.pop() as T; + object._isInPool = false; + return object; + } + + const object = new objectConstructor(); + object._onClear(); + return object; + } + /** + * 对象的唯一标识。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public readonly hashCode: number = BaseObject._hashCode++; + private _isInPool: boolean = false; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public returnToPool(): void { + this._onClear(); + BaseObject._returnObject(this); + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/core/DragonBones.ts b/reference/DragonBones/src/dragonBones/core/DragonBones.ts new file mode 100644 index 0000000..db2f505 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/core/DragonBones.ts @@ -0,0 +1,259 @@ + + +namespace dragonBones { + /** + * @private + */ + export const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + + FFDTimelineMeshOffset = 0, + FFDTimelineFFDCount = 1, + FFDTimelineValueCount = 2, + FFDTimelineValueOffset = 3, + FFDTimelineFloatOffset = 4 + } + /** + * @private + */ + export const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2 + } + /** + * @private + */ + export const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3 + } + /** + * @language zh_CN + * 包围盒类型。 + * @version DragonBones 5.0 + */ + export const enum BoundingBoxType { + Rectangle = 0, + Ellipse = 1, + Polygon = 2 + } + /** + * @private + */ + export const enum ActionType { + Play = 0, + Frame = 10, + Sound = 11 + } + /** + * @private + */ + export 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 + */ + export const enum TweenType { + None = 0, + Line = 1, + Curve = 2, + QuadIn = 3, + QuadOut = 4, + QuadInOut = 5 + } + /** + * @private + */ + export const enum TimelineType { + Action = 0, + ZOrder = 1, + + BoneAll = 10, + BoneT = 11, + BoneR = 12, + BoneS = 13, + BoneX = 14, + BoneY = 15, + BoneRotate = 16, + BoneSkew = 17, + BoneScaleX = 18, + BoneScaleY = 19, + + SlotVisible = 23, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + + AnimationTime = 40, + AnimationWeight = 41 + } + /** + * @private + */ + export const enum OffsetMode { + None, + Additive, + Override + } + /** + * @language zh_CN + * 动画混合的淡出方式。 + * @version DragonBones 4.5 + */ + export const enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + None = 0, + /** + * 淡出同层的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer = 1, + /** + * 淡出同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup = 2, + /** + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * 淡出所有动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + All = 4, + /** + * 不替换同名动画。 + * @version DragonBones 5.1 + * @language zh_CN + */ + Single = 5 + } + /** + * @private + */ + export interface Map { + [key: string]: T; + } + /** + * @private + */ + export class DragonBones { + public static yDown: boolean = true; + public static debug: boolean = false; + public static debugDraw: boolean = false; + public static webAssembly: boolean = false; + public static readonly VERSION: string = "5.1.0"; + + private readonly _clock: WorldClock = new WorldClock(); + private readonly _events: Array = []; + private readonly _objects: Array = []; + private _eventManager: IEventDispatcher = null as any; + + public constructor(eventManager: IEventDispatcher) { + this._eventManager = eventManager; + } + + public advanceTime(passedTime: number): void { + if (this._objects.length > 0) { + for (const object of this._objects) { + object.returnToPool(); + } + + this._objects.length = 0; + } + + this._clock.advanceTime(passedTime); + + if (this._events.length > 0) { + for (let i = 0; i < this._events.length; ++i) { + const eventObject = this._events[i]; + const armature = eventObject.armature; + + armature.eventDispatcher._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type === EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(eventObject.type, eventObject); + } + + this.bufferObject(eventObject); + } + + this._events.length = 0; + } + } + + public bufferEvent(value: EventObject): void { + if (this._events.indexOf(value) < 0) { + this._events.push(value); + } + } + + public bufferObject(object: BaseObject): void { + if (this._objects.indexOf(object) < 0) { + this._objects.push(object); + } + } + + public get clock(): WorldClock { + return this._clock; + } + + public get eventManager(): IEventDispatcher { + return this._eventManager; + } + } + + if (!console.warn) { + console.warn = function () { }; + } + + if (!console.assert) { + console.assert = function () { }; + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/event/EventObject.ts b/reference/DragonBones/src/dragonBones/event/EventObject.ts new file mode 100644 index 0000000..6764435 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/event/EventObject.ts @@ -0,0 +1,129 @@ +namespace dragonBones { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + export class EventObject extends BaseObject { + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly START: string = "start"; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly LOOP_COMPLETE: string = "loopComplete"; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly COMPLETE: string = "complete"; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly FADE_IN: string = "fadeIn"; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly FADE_IN_COMPLETE: string = "fadeInComplete"; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly FADE_OUT: string = "fadeOut"; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly FADE_OUT_COMPLETE: string = "fadeOutComplete"; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly FRAME_EVENT: string = "frameEvent"; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public static readonly SOUND_EVENT: string = "soundEvent"; + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.EventObject]"; + } + /** + * @private + */ + public time: number; + /** + * 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public type: EventStringType; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + public name: string; + /** + * 发出事件的骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public armature: Armature; + /** + * 发出事件的骨骼。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public bone: Bone | null; + /** + * 发出事件的插槽。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public slot: Slot | null; + /** + * 发出事件的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public animationState: AnimationState; + /** + * 自定义数据 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + public data: UserData | null; + /** + * @private + */ + protected _onClear(): void { + this.time = 0.0; + this.type = ""; + this.name = ""; + this.armature = null as any; + this.bone = null; + this.slot = null; + this.animationState = null as any; + this.data = null; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/event/IEventDispatcher.ts b/reference/DragonBones/src/dragonBones/event/IEventDispatcher.ts new file mode 100644 index 0000000..8dc7f6a --- /dev/null +++ b/reference/DragonBones/src/dragonBones/event/IEventDispatcher.ts @@ -0,0 +1,43 @@ +namespace dragonBones { + /** + * @private + */ + export type EventStringType = + string | "start" | "loopComplete" | "complete" | + "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | + "frameEvent" | "soundEvent"; + /** + * 事件接口。 + * @version DragonBones 4.5 + * @language zh_CN + */ + export interface IEventDispatcher { + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/factory/BaseFactory.ts b/reference/DragonBones/src/dragonBones/factory/BaseFactory.ts new file mode 100644 index 0000000..a11eda2 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/factory/BaseFactory.ts @@ -0,0 +1,813 @@ +namespace dragonBones { + /** + * @private + */ + export class BuildArmaturePackage { + public dataName: string = ""; + public textureAtlasName: string = ""; + public data: DragonBonesData; + public armature: ArmatureData; + public skin: SkinData | null = null; + } + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + export abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser = null as any; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser = null as any; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + public autoSearch: boolean = false; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map = {}; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map> = {}; + /** + * @private + */ + protected _dragonBones: DragonBones = null as any; + /** + * @private + */ + protected _dataParser: DataParser = null as any; + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public constructor(dataParser: DataParser | null = null) { + if (BaseFactory._objectParser === null) { + BaseFactory._objectParser = new ObjectDataParser(); + } + + if (BaseFactory._binaryParser === null) { + BaseFactory._binaryParser = new BinaryDataParser(); + } + + this._dataParser = dataParser !== null ? dataParser : BaseFactory._objectParser; + } + /** + * @private + */ + protected _isSupportMesh(): boolean { + return true; + } + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null { + if (textureAtlasName in this._textureAtlasDataMap) { + for (const textureAtlasData of this._textureAtlasDataMap[textureAtlasName]) { + const textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + + if (this.autoSearch) { // Will be search all data, if the autoSearch is true. + for (let k in this._textureAtlasDataMap) { + for (const textureAtlasData of this._textureAtlasDataMap[k]) { + if (textureAtlasData.autoSearch) { + const textureData = textureAtlasData.getTexture(textureName); + if (textureData !== null) { + return textureData; + } + } + } + } + } + + return null; + } + /** + * @private + */ + protected _fillBuildArmaturePackage( + dataPackage: BuildArmaturePackage, + dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string + ): boolean { + let dragonBonesData: DragonBonesData | null = null; + let armatureData: ArmatureData | null = 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 (let 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 as any; + dataPackage.armature = armatureData; + dataPackage.skin = null; + + if (skinName.length > 0) { + dataPackage.skin = armatureData.getSkin(skinName); + if (dataPackage.skin === null && this.autoSearch) { + for (let k in this._dragonBonesDataMap) { + const skinDragonBonesData = this._dragonBonesDataMap[k]; + const skinArmatureData = skinDragonBonesData.getArmature(skinName); + if (skinArmatureData !== null) { + dataPackage.skin = skinArmatureData.defaultSkin; + break; + } + } + } + } + + if (dataPackage.skin === null) { + dataPackage.skin = armatureData.defaultSkin; + } + + return true; + } + + return false; + } + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void { + const bones = dataPackage.armature.sortedBones; + for (let i = 0; i < (DragonBones.webAssembly ? (bones as any).size() : bones.length); ++i) { + const boneData = DragonBones.webAssembly ? (bones as any).get(i) as BoneData : bones[i]; + const bone = DragonBones.webAssembly ? new Module["Bone"]() as Bone : BaseObject.borrowObject(Bone); + bone.init(boneData); + + if (boneData.parent !== null) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + + const constraints = boneData.constraints; + for (let j = 0; j < (DragonBones.webAssembly ? (constraints as any).size() : constraints.length); ++j) { + const constraintData = DragonBones.webAssembly ? (constraints as any).get(j) as ConstraintData : constraints[j]; + const target = armature.getBone(constraintData.target.name); + if (target === null) { + continue; + } + + // TODO more constraint type. + const ikConstraintData = constraintData as IKConstraintData; + const constraint = DragonBones.webAssembly ? new Module["IKConstraint"]() as IKConstraint : BaseObject.borrowObject(IKConstraint); + const root = ikConstraintData.root !== null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + + if (root !== null) { + root.addConstraint(constraint); + } + else { + bone.addConstraint(constraint); + } + } + } + } + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void { + const currentSkin = dataPackage.skin; + const defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin === null || defaultSkin === null) { + return; + } + + const skinSlots: Map> = {}; + for (let k in defaultSkin.displays) { + const displays = defaultSkin.displays[k]; + skinSlots[k] = displays; + } + + if (currentSkin !== defaultSkin) { + for (let k in currentSkin.displays) { + const displays = currentSkin.displays[k]; + skinSlots[k] = displays; + } + } + + for (const slotData of dataPackage.armature.sortedSlots) { + if (!(slotData.name in skinSlots)) { + continue; + } + + const displays = skinSlots[slotData.name]; + const slot = this._buildSlot(dataPackage, slotData, displays, armature); + const displayList = new Array(); + for (const displayData of displays) { + if (displayData !== null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.push(null); + } + } + + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + } + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any { + const dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.name; + let display: any = null; + switch (displayData.type) { + case DisplayType.Image: + const imageDisplayData = displayData as ImageDisplayData; + if (imageDisplayData.texture === null) { + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + + if (rawDisplayData !== null && rawDisplayData.type === DisplayType.Mesh && this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + + case DisplayType.Mesh: + const meshDisplayData = displayData as MeshDisplayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + + case DisplayType.Armature: + const armatureDisplayData = displayData as ArmatureDisplayData; + const childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + if (childArmature !== null) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + const actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.length > 0) { + for (const action of actions) { + childArmature._bufferAction(action, true); + } + } + else { + childArmature.animation.play(); + } + } + + armatureDisplayData.armature = childArmature.armatureData; // + } + + display = childArmature; + break; + } + + return display; + } + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + + if (displayIndex < 0) { + displayIndex = 0; + } + + const displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + + for (let i = 0, l = displayList.length; i < l; ++i) { // Clean undefined. + if (!displayList[i]) { + displayList[i] = null; + } + } + } + + if (slot._displayDatas.length <= displayIndex) { + slot._displayDatas.length = displayIndex + 1; + + for (let i = 0, l = slot._displayDatas.length; i < l; ++i) { // Clean undefined. + if (!slot._displayDatas[i]) { + slot._displayDatas[i] = null; + } + } + } + + slot._displayDatas[displayIndex] = displayData; + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay( + dataPackage, + displayData, + displayIndex < slot._rawDisplayDatas.length ? slot._rawDisplayDatas[displayIndex] : null, + slot + ); + } + else { + displayList[displayIndex] = null; + } + + slot.displayList = displayList; + } + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @returns DragonBonesData + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + public parseDragonBonesData(rawData: any, name: string | null = null, scale: number = 1.0): DragonBonesData | null { + let dragonBonesData: DragonBonesData | null = null; + if (rawData instanceof ArrayBuffer) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } + else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + + while (true) { + const textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + + return dragonBonesData; + } + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 + * @language zh_CN + */ + public parseTextureAtlasData(rawData: any, textureAtlas: any, name: string | null = null, scale: number = 0.0): TextureAtlasData { + const textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + + return textureAtlasData; + } + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + public updateTextureAtlasData(name: string, textureAtlases: Array): void { + const textureAtlasDatas = this.getTextureAtlasData(name); + if (textureAtlasDatas !== null) { + for (let i = 0, l = textureAtlasDatas.length; i < l; ++i) { + if (i < textureAtlases.length) { + this._buildTextureAtlasData(textureAtlasDatas[i], textureAtlases[i]); + } + } + } + } + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + public getDragonBonesData(name: string): DragonBonesData | null { + return (name in this._dragonBonesDataMap) ? this._dragonBonesDataMap[name] : null; + } + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + public addDragonBonesData(data: DragonBonesData, name: string | null = null): void { + name = name !== null ? name : data.name; + if (name in this._dragonBonesDataMap) { + if (this._dragonBonesDataMap[name] === data) { + return; + } + + console.warn("Replace data: " + name); + this._dragonBonesDataMap[name].returnToPool(); + } + + this._dragonBonesDataMap[name] = data; + } + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + public removeDragonBonesData(name: string, disposeData: boolean = true): void { + if (name in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[name]); + } + + delete this._dragonBonesDataMap[name]; + } + } + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + public getTextureAtlasData(name: string): Array | null { + return (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : null; + } + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + public addTextureAtlasData(data: TextureAtlasData, name: string | null = null): void { + name = name !== null ? name : data.name; + const textureAtlasList = (name in this._textureAtlasDataMap) ? this._textureAtlasDataMap[name] : (this._textureAtlasDataMap[name] = []); + if (textureAtlasList.indexOf(data) < 0) { + textureAtlasList.push(data); + } + } + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + public removeTextureAtlasData(name: string, disposeData: boolean = true): void { + if (name in this._textureAtlasDataMap) { + const textureAtlasDataList = this._textureAtlasDataMap[name]; + if (disposeData) { + for (const textureAtlasData of textureAtlasDataList) { + this._dragonBones.bufferObject(textureAtlasData); + } + } + + delete this._textureAtlasDataMap[name]; + } + } + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + public getArmatureData(name: string, dragonBonesName: string = ""): ArmatureData | null { + const dataPackage: BuildArmaturePackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName, name, "", "")) { + return null; + } + + return dataPackage.armature; + } + /** + * 清除所有的数据。 + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public clear(disposeData: boolean = true): void { + for (let k in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBones.bufferObject(this._dragonBonesDataMap[k]); + } + + delete this._dragonBonesDataMap[k]; + } + + for (let k in this._textureAtlasDataMap) { + if (disposeData) { + const textureAtlasDataList = this._textureAtlasDataMap[k]; + for (const textureAtlasData of textureAtlasDataList) { + this._dragonBones.bufferObject(textureAtlasData); + } + } + + delete this._textureAtlasDataMap[k]; + } + } + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + public buildArmature(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null, textureAtlasName: string | null = null): Armature | null { + const dataPackage: BuildArmaturePackage = new BuildArmaturePackage(); + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, skinName || "", textureAtlasName || "")) { + console.warn("No armature data. " + armatureName + ", " + (dragonBonesName !== null ? dragonBonesName : "")); + return null; + } + + const armature = this._buildArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0.0); // Update armature pose. + + return armature; + } + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public replaceSlotDisplay( + dragonBonesName: string | null, armatureName: string, slotName: string, displayName: string, + slot: Slot, displayIndex: number = -1 + ): void { + const dataPackage: BuildArmaturePackage = {} as any; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + + const displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + + for (const display of displays) { + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + } + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public replaceSlotDisplayList( + dragonBonesName: string | null, armatureName: string, slotName: string, + slot: Slot + ): void { + const dataPackage: BuildArmaturePackage = {} as any; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + + const displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + + let displayIndex = 0; + for (const displayData of displays) { + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + } + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + public changeSkin(armature: Armature, skin: SkinData, exclude: Array | null = null): void { + for (const slot of armature.getSlots()) { + if (!(slot.name in skin.displays) || (exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + + const displays = skin.displays[slot.name]; + const displayList = slot.displayList; // Copy. + displayList.length = displays.length; // Modify displayList length. + for (let i = 0, l = displays.length; i < l; ++i) { + const displayData = displays[i]; + if (displayData !== null) { + displayList[i] = this._getSlotDisplay(null, displayData, null, slot); + } + else { + displayList[i] = null; + } + } + + slot._rawDisplayDatas = displays; + slot._displayDatas.length = displays.length; + for (let i = 0, l = slot._displayDatas.length; i < l; ++i) { + slot._displayDatas[i] = displays[i]; + } + + slot.displayList = displayList; + } + } + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + public copyAnimationsToArmature( + toArmature: Armature, + fromArmatreName: string, fromSkinName: string | null = null, fromDragonBonesDataName: string | null = null, + replaceOriginalAnimation: boolean = true + ): boolean { + const dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage(dataPackage, fromDragonBonesDataName || "", fromArmatreName, fromSkinName || "", "")) { + const fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.animation.animations = fromArmatureData.animations; + } + else { + const animations: Map = {}; + for (let animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + + for (let animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + + toArmature.animation.animations = animations; + } + + if (dataPackage.skin) { + const slots = toArmature.getSlots(); + for (let i = 0, l = slots.length; i < l; ++i) { + const toSlot = slots[i]; + const toSlotDisplayList = toSlot.displayList; + for (let j = 0, lJ = toSlotDisplayList.length; j < lJ; ++j) { + const toDisplayObject = toSlotDisplayList[j]; + if (toDisplayObject instanceof Armature) { + const displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays !== null && j < displays.length) { + const fromDisplayData = displays[j]; + if (fromDisplayData !== null && fromDisplayData.type === DisplayType.Armature) { + this.copyAnimationsToArmature(toDisplayObject as Armature, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + + return true; + } + } + + return false; + } + /** + * @private + */ + public getAllDragonBonesData(): Map { + return this._dragonBonesDataMap; + } + /** + * @private + */ + public getAllTextureAtlasData(): Map> { + return this._textureAtlasDataMap; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/geom/ColorTransform.ts b/reference/DragonBones/src/dragonBones/geom/ColorTransform.ts new file mode 100644 index 0000000..faca3b8 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/geom/ColorTransform.ts @@ -0,0 +1,28 @@ +namespace dragonBones { + /** + * @private + */ + export class ColorTransform { + public constructor( + public alphaMultiplier: number = 1.0, public redMultiplier: number = 1.0, public greenMultiplier: number = 1.0, public blueMultiplier: number = 1.0, + public alphaOffset: number = 0, public redOffset: number = 0, public greenOffset: number = 0, public blueOffset: number = 0 + ) { + } + + public copyFrom(value: ColorTransform): void { + 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; + } + + public identity(): void { + this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1.0; + this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/geom/Matrix.ts b/reference/DragonBones/src/dragonBones/geom/Matrix.ts new file mode 100644 index 0000000..f45146a --- /dev/null +++ b/reference/DragonBones/src/dragonBones/geom/Matrix.ts @@ -0,0 +1,161 @@ +namespace dragonBones { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class Matrix { + public constructor( + public a: number = 1.0, public b: number = 0.0, + public c: number = 0.0, public d: number = 1.0, + public tx: number = 0.0, public ty: number = 0.0 + ) { + } + /** + * @private + */ + public toString(): string { + return "[object dragonBones.Matrix] a:" + this.a + " b:" + this.b + " c:" + this.c + " d:" + this.d + " tx:" + this.tx + " ty:" + this.ty; + } + /** + * @private + */ + public copyFrom(value: Matrix): Matrix { + 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 + */ + public copyFromArray(value: Array, offset: number = 0): Matrix { + 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; + } + /** + * 转换为单位矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public identity(): Matrix { + this.a = this.d = 1.0; + this.b = this.c = 0.0; + this.tx = this.ty = 0.0; + + return this; + } + /** + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public concat(value: Matrix): Matrix { + let aA = this.a * value.a; + let bA = 0.0; + let cA = 0.0; + let dA = this.d * value.d; + let txA = this.tx * value.a + value.tx; + let 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; + } + /** + * 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public invert(): Matrix { + let aA = this.a; + let bA = this.b; + let cA = this.c; + let dA = this.d; + const txA = this.tx; + const 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; + } + + let 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; + let 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; + } + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public transformPoint(x: number, y: number, result: { x: number, y: number }, delta: boolean = false): void { + 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; + } + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/geom/Point.ts b/reference/DragonBones/src/dragonBones/geom/Point.ts new file mode 100644 index 0000000..37dfcf6 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/geom/Point.ts @@ -0,0 +1,15 @@ +namespace dragonBones { + export class Point { + public constructor(public x: number = 0.0, public y: number = 0.0) { + } + + public copyFrom(value: Point): void { + this.x = value.x; + this.y = value.y; + } + + public clear(): void { + this.x = this.y = 0.0; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/geom/Rectangle.ts b/reference/DragonBones/src/dragonBones/geom/Rectangle.ts new file mode 100644 index 0000000..8e48bc8 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/geom/Rectangle.ts @@ -0,0 +1,21 @@ +namespace dragonBones { + export class Rectangle { + public constructor( + public x: number = 0.0, public y: number = 0.0, + public width: number = 0.0, public height: number = 0.0 + ) { + } + + public copyFrom(value: Rectangle): void { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + } + + public clear(): void { + this.x = this.y = 0.0; + this.width = this.height = 0.0; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/geom/Transform.ts b/reference/DragonBones/src/dragonBones/geom/Transform.ts new file mode 100644 index 0000000..3d05cb8 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/geom/Transform.ts @@ -0,0 +1,207 @@ +namespace dragonBones { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class Transform { + /** + * @private + */ + public static readonly PI_D: number = Math.PI * 2.0; + /** + * @private + */ + public static readonly PI_H: number = Math.PI / 2.0; + /** + * @private + */ + public static readonly PI_Q: number = Math.PI / 4.0; + /** + * @private + */ + public static readonly RAD_DEG: number = 180.0 / Math.PI; + /** + * @private + */ + public static readonly DEG_RAD: number = Math.PI / 180.0; + /** + * @private + */ + public static normalizeRadian(value: number): number { + value = (value + Math.PI) % (Math.PI * 2.0); + value += value > 0.0 ? -Math.PI : Math.PI; + + return value; + } + + public constructor( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public x: number = 0.0, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public y: number = 0.0, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public skew: number = 0.0, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public rotation: number = 0.0, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public scaleX: number = 1.0, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public scaleY: number = 1.0 + ) { + } + /** + * @private + */ + public toString(): string { + 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 + */ + public copyFrom(value: Transform): Transform { + 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 + */ + public identity(): Transform { + this.x = this.y = 0.0; + this.skew = this.rotation = 0.0; + this.scaleX = this.scaleY = 1.0; + + return this; + } + /** + * @private + */ + public add(value: Transform): Transform { + 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 + */ + public minus(value: Transform): Transform { + 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; + } + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public fromMatrix(matrix: Matrix): Transform { + const backupScaleX = this.scaleX, backupScaleY = this.scaleY; + const PI_Q = Transform.PI_Q; + + this.x = matrix.tx; + this.y = matrix.ty; + this.rotation = Math.atan(matrix.b / matrix.a); + let 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; + } + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public toMatrix(matrix: Matrix): Transform { + if (this.skew !== 0.0 || this.rotation !== 0.0) { + 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; + } + } + else { + matrix.a = this.scaleX; + matrix.b = 0.0; + matrix.c = 0.0; + matrix.d = this.scaleY; + } + + matrix.tx = this.x; + matrix.ty = this.y; + + return this; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/AnimationConfig.ts b/reference/DragonBones/src/dragonBones/model/AnimationConfig.ts new file mode 100644 index 0000000..056b64f --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/AnimationConfig.ts @@ -0,0 +1,285 @@ +namespace dragonBones { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + export class AnimationConfig extends BaseObject { + public static toString(): string { + return "[class dragonBones.AnimationConfig]"; + } + /** + * 是否暂停淡出的动画。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public pauseFadeOut: boolean; + /** + * 淡出模式。 + * @default dragonBones.AnimationFadeOutMode.All + * @see dragonBones.AnimationFadeOutMode + * @version DragonBones 5.0 + * @language zh_CN + */ + public fadeOutMode: AnimationFadeOutMode; + /** + * 淡出缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + public fadeOutTweenType: TweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public fadeOutTime: number; + + /** + * 否能触发行为。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public actionEnabled: boolean; + /** + * 是否以增加的方式混合。 + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + public additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public displayControl: boolean; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + public pauseFadeIn: boolean; + /** + * 是否将没有动画的对象重置为初始值。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + public resetToPose: boolean; + /** + * 淡入缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + public fadeInTweenType: TweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public playTimes: number; + /** + * 混合图层,图层高会优先获取混合权重。 + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + public layer: number; + /** + * 开始时间。 (以秒为单位) + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + public position: number; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public duration: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + public timeScale: number; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public fadeInTime: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public autoFadeOutTime: number; + /** + * 混合权重。 + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + public weight: number; + /** + * 动画状态名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public name: string; + /** + * 动画数据名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public animation: string; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public group: string; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public readonly boneMask: Array = []; + /** + * @private + */ + protected _onClear(): void { + this.pauseFadeOut = true; + this.fadeOutMode = AnimationFadeOutMode.All; + this.fadeOutTweenType = TweenType.Line; + this.fadeOutTime = -1.0; + + this.actionEnabled = true; + this.additiveBlending = false; + this.displayControl = true; + this.pauseFadeIn = true; + this.resetToPose = true; + this.fadeInTweenType = TweenType.Line; + this.playTimes = -1; + this.layer = 0; + this.position = 0.0; + this.duration = -1.0; + this.timeScale = -100.0; + this.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.weight = 1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + } + + public clear(): void { + this._onClear(); + } + + public copyFrom(value: AnimationConfig): void { + this.pauseFadeOut = value.pauseFadeOut; + this.fadeOutMode = value.fadeOutMode; + this.autoFadeOutTime = value.autoFadeOutTime; + this.fadeOutTweenType = value.fadeOutTweenType; + + this.actionEnabled = value.actionEnabled; + this.additiveBlending = value.additiveBlending; + 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 (let i = 0, l = this.boneMask.length; i < l; ++i) { + this.boneMask[i] = value.boneMask[i]; + } + } + + public containsBoneMask(name: string): boolean { + return this.boneMask.length === 0 || this.boneMask.indexOf(name) >= 0; + } + + public addBoneMask(armature: Armature, name: string, recursive: boolean = true): void { + const currentBone = armature.getBone(name); + if (currentBone === null) { + return; + } + + if (this.boneMask.indexOf(name) < 0) { // Add mixing + this.boneMask.push(name); + } + + if (recursive) { // Add recursive mixing. + for (const bone of armature.getBones()) { + if (this.boneMask.indexOf(bone.name) < 0 && currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + + public removeBoneMask(armature: Armature, name: string, recursive: boolean = true): void { + const index = this.boneMask.indexOf(name); + if (index >= 0) { // Remove mixing. + this.boneMask.splice(index, 1); + } + + if (recursive) { + const currentBone = armature.getBone(name); + if (currentBone !== null) { + if (this.boneMask.length > 0) { // Remove recursive mixing. + for (const bone of armature.getBones()) { + const index = this.boneMask.indexOf(bone.name); + if (index >= 0 && currentBone.contains(bone)) { + this.boneMask.splice(index, 1); + } + } + } + else { // Add unrecursive mixing. + for (const bone of armature.getBones()) { + if (bone === currentBone) { + continue; + } + + if (!currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/AnimationData.ts b/reference/DragonBones/src/dragonBones/model/AnimationData.ts new file mode 100644 index 0000000..f331fa3 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/AnimationData.ts @@ -0,0 +1,246 @@ +namespace dragonBones { + /** + * 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class AnimationData extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.AnimationData]"; + } + /** + * @private + */ + public frameIntOffset: number; // FrameIntArray. + /** + * @private + */ + public frameFloatOffset: number; // FrameFloatArray. + /** + * @private + */ + public frameOffset: number; // FrameArray. + /** + * 持续的帧数。 ([1~N]) + * @version DragonBones 3.0 + * @language zh_CN + */ + public frameCount: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + public playTimes: number; + /** + * 持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public duration: number; + /** + * @private + */ + public scale: number; + /** + * 淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + public fadeInTime: number; + /** + * @private + */ + public cacheFrameRate: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * @private + */ + public readonly cachedFrames: Array = []; + /** + * @private + */ + public readonly boneTimelines: Map> = {}; + /** + * @private + */ + public readonly slotTimelines: Map> = {}; + /** + * @private + */ + public readonly boneCachedFrameIndices: Map> = {}; + /** + * @private + */ + public readonly slotCachedFrameIndices: Map> = {}; + /** + * @private + */ + public actionTimeline: TimelineData | null = null; // Initial value. + /** + * @private + */ + public zOrderTimeline: TimelineData | null = null; // Initial value. + /** + * @private + */ + public parent: ArmatureData; + /** + * @private + */ + protected _onClear(): void { + for (let k in this.boneTimelines) { + for (let kA in this.boneTimelines[k]) { + this.boneTimelines[k][kA].returnToPool(); + } + + delete this.boneTimelines[k]; + } + + for (let k in this.slotTimelines) { + for (let kA in this.slotTimelines[k]) { + this.slotTimelines[k][kA].returnToPool(); + } + + delete this.slotTimelines[k]; + } + + for (let k in this.boneCachedFrameIndices) { + delete this.boneCachedFrameIndices[k]; + } + + for (let 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.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.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null as any; // + } + /** + * @private + */ + public cacheFrames(frameRate: number): void { + if (this.cacheFrameRate > 0.0) { // TODO clear cache. + return; + } + + this.cacheFrameRate = Math.max(Math.ceil(frameRate * this.scale), 1.0); + const cacheFrameCount = Math.ceil(this.cacheFrameRate * this.duration) + 1; // Cache one more frame. + + this.cachedFrames.length = cacheFrameCount; + for (let i = 0, l = this.cacheFrames.length; i < l; ++i) { + this.cachedFrames[i] = false; + } + + for (const bone of this.parent.sortedBones) { + const indices = new Array(cacheFrameCount); + for (let i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + + this.boneCachedFrameIndices[bone.name] = indices; + } + + for (const slot of this.parent.sortedSlots) { + const indices = new Array(cacheFrameCount); + for (let i = 0, l = indices.length; i < l; ++i) { + indices[i] = -1; + } + + this.slotCachedFrameIndices[slot.name] = indices; + } + } + /** + * @private + */ + public addBoneTimeline(bone: BoneData, timeline: TimelineData): void { + const timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + } + /** + * @private + */ + public addSlotTimeline(slot: SlotData, timeline: TimelineData): void { + const timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + } + /** + * @private + */ + public getBoneTimelines(name: string): Array | null { + return name in this.boneTimelines ? this.boneTimelines[name] : null; + } + /** + * @private + */ + public getSlotTimeline(name: string): Array | null { + return name in this.slotTimelines ? this.slotTimelines[name] : null; + } + /** + * @private + */ + public getBoneCachedFrameIndices(name: string): Array | null { + return name in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[name] : null; + } + /** + * @private + */ + public getSlotCachedFrameIndices(name: string): Array | null { + return name in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[name] : null; + } + } + /** + * @private + */ + export class TimelineData extends BaseObject { + public static toString(): string { + return "[class dragonBones.TimelineData]"; + } + + public type: TimelineType; + public offset: number; // TimelineArray. + public frameIndicesOffset: number; // FrameIndices. + + protected _onClear(): void { + this.type = TimelineType.BoneAll; + this.offset = 0; + this.frameIndicesOffset = -1; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/ArmatureData.ts b/reference/DragonBones/src/dragonBones/model/ArmatureData.ts new file mode 100644 index 0000000..638d002 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/ArmatureData.ts @@ -0,0 +1,630 @@ +namespace dragonBones { + /** + * @private + */ + export class CanvasData extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.CanvasData]"; + } + + public hasBackground: boolean; + public color: number; + public x: number; + public y: number; + public width: number; + public height: number; + /** + * @private + */ + protected _onClear(): void { + this.hasBackground = false; + this.color = 0x000000; + this.x = 0; + this.y = 0; + this.width = 0; + this.height = 0; + } + } + /** + * 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class ArmatureData extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.ArmatureData]"; + } + /** + * @private + */ + public type: ArmatureType; + /** + * 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public frameRate: number; + /** + * @private + */ + public cacheFrameRate: number; + /** + * @private + */ + public scale: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * @private + */ + public readonly aabb: Rectangle = new Rectangle(); + /** + * 所有动画数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly animationNames: Array = []; + /** + * @private + */ + public readonly sortedBones: Array = []; + /** + * @private + */ + public readonly sortedSlots: Array = []; + /** + * @private + */ + public readonly defaultActions: Array = []; + /** + * @private + */ + public readonly actions: Array = []; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly bones: Map = {}; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly slots: Map = {}; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly skins: Map = {}; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly animations: Map = {}; + /** + * 获取默认皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + * @language zh_CN + */ + public defaultSkin: SkinData | null; + /** + * 获取默认动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + public defaultAnimation: AnimationData | null; + /** + * @private + */ + public canvas: CanvasData | null = null; // Initial value. + /** + * @private + */ + public userData: UserData | null = null; // Initial value. + /** + * 所属的龙骨数据。 + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + public parent: DragonBonesData; + /** + * @private + */ + protected _onClear(): void { + for (const action of this.defaultActions) { + action.returnToPool(); + } + + for (const action of this.actions) { + action.returnToPool(); + } + + for (let k in this.bones) { + this.bones[k].returnToPool(); + delete this.bones[k]; + } + + for (let k in this.slots) { + this.slots[k].returnToPool(); + delete this.slots[k]; + } + + for (let k in this.skins) { + this.skins[k].returnToPool(); + delete this.skins[k]; + } + + for (let 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 = ArmatureType.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.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null as any; // + } + /** + * @private + */ + public sortBones(): void { + const total = this.sortedBones.length; + if (total <= 0) { + return; + } + + const sortHelper = this.sortedBones.concat(); + let index = 0; + let count = 0; + this.sortedBones.length = 0; + while (count < total) { + const bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + + if (this.sortedBones.indexOf(bone) >= 0) { + continue; + } + + if (bone.constraints.length > 0) { // Wait constraint. + let flag = false; + for (const constraint of bone.constraints) { + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + + if (flag) { + continue; + } + } + + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { // Wait parent. + continue; + } + + this.sortedBones.push(bone); + count++; + } + } + /** + * @private + */ + public cacheFrames(frameRate: number): void { + if (this.cacheFrameRate > 0) { // TODO clear cache. + return; + } + + this.cacheFrameRate = frameRate; + for (let k in this.animations) { + this.animations[k].cacheFrames(this.cacheFrameRate); + } + } + /** + * @private + */ + public setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number { + const dataArray = this.parent.cachedFrames; + let 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; + } + /** + * @private + */ + public getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void { + const 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; + } + /** + * @private + */ + public addBone(value: BoneData): void { + if (value.name in this.bones) { + console.warn("Replace bone: " + value.name); + this.bones[value.name].returnToPool(); + } + + this.bones[value.name] = value; + this.sortedBones.push(value); + } + /** + * @private + */ + public addSlot(value: SlotData): void { + if (value.name in this.slots) { + console.warn("Replace slot: " + value.name); + this.slots[value.name].returnToPool(); + } + + this.slots[value.name] = value; + this.sortedSlots.push(value); + } + /** + * @private + */ + public addSkin(value: SkinData): void { + if (value.name in this.skins) { + console.warn("Replace skin: " + value.name); + this.skins[value.name].returnToPool(); + } + + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + } + /** + * @private + */ + public addAnimation(value: AnimationData): void { + if (value.name in this.animations) { + console.warn("Replace animation: " + value.name); + this.animations[value.name].returnToPool(); + } + + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + } + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + public getBone(name: string): BoneData | null { + return name in this.bones ? this.bones[name] : null; + } + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + public getSlot(name: string): SlotData | null { + return name in this.slots ? this.slots[name] : null; + } + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + public getSkin(name: string): SkinData | null { + return name in this.skins ? this.skins[name] : null; + } + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + public getAnimation(name: string): AnimationData | null { + return name in this.animations ? this.animations[name] : null; + } + } + /** + * 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class BoneData extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.BoneData]"; + } + /** + * @private + */ + public inheritTranslation: boolean; + /** + * @private + */ + public inheritRotation: boolean; + /** + * @private + */ + public inheritScale: boolean; + /** + * @private + */ + public inheritReflection: boolean; + /** + * @private + */ + public length: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * @private + */ + public readonly transform: Transform = new Transform(); + /** + * @private + */ + public readonly constraints: Array = []; + /** + * @private + */ + public userData: UserData | null = null; // Initial value. + /** + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public parent: BoneData | null; + /** + * @private + */ + protected _onClear(): void { + for (const constraint of this.constraints) { + constraint.returnToPool(); + } + + if (this.userData !== null) { + this.userData.returnToPool(); + } + + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0.0; + this.name = ""; + this.transform.identity(); + this.constraints.length = 0; + this.userData = null; + this.parent = null; + } + } + /** + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + export class SlotData extends BaseObject { + /** + * @private + */ + public static readonly DEFAULT_COLOR: ColorTransform = new ColorTransform(); + /** + * @private + */ + public static createColor(): ColorTransform { + return new ColorTransform(); + } + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.SlotData]"; + } + /** + * @private + */ + public blendMode: BlendMode; + /** + * @private + */ + public displayIndex: number; + /** + * @private + */ + public zOrder: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * @private + */ + public color: ColorTransform = null as any; // Initial value. + /** + * @private + */ + public userData: UserData | null = null; // Initial value. + /** + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + public parent: BoneData; + /** + * @private + */ + protected _onClear(): void { + if (this.userData !== null) { + this.userData.returnToPool(); + } + + this.blendMode = BlendMode.Normal; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null as any; // + this.userData = null; + this.parent = null as any; // + } + } + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + export class SkinData extends BaseObject { + public static toString(): string { + return "[class dragonBones.SkinData]"; + } + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * @private + */ + public readonly displays: Map> = {}; + /** + * @private + */ + protected _onClear(): void { + for (let k in this.displays) { + const slotDisplays = this.displays[k]; + for (const display of slotDisplays) { + if (display !== null) { + display.returnToPool(); + } + } + + delete this.displays[k]; + } + + this.name = ""; + // this.displays.clear(); + } + /** + * @private + */ + public addDisplay(slotName: string, value: DisplayData | null): void { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + + const slotDisplays = this.displays[slotName]; // TODO clear prev + slotDisplays.push(value); + } + /** + * @private + */ + public getDisplay(slotName: string, displayName: string): DisplayData | null { + const slotDisplays = this.getDisplays(slotName); + if (slotDisplays !== null) { + for (const display of slotDisplays) { + if (display !== null && display.name === displayName) { + return display; + } + } + } + + return null; + } + /** + * @private + */ + public getDisplays(slotName: string): Array | null { + if (!(slotName in this.displays)) { + return null; + } + + return this.displays[slotName]; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/BoundingBoxData.ts b/reference/DragonBones/src/dragonBones/model/BoundingBoxData.ts new file mode 100644 index 0000000..9deac0b --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/BoundingBoxData.ts @@ -0,0 +1,705 @@ +namespace dragonBones { + /** + * 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + export abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public type: BoundingBoxType; + /** + * 边界框颜色。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public color: number; + /** + * 边界框宽。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + public width: number; + /** + * 边界框高。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + public height: number; + /** + * @private + */ + protected _onClear(): void { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + } + /** + * 是否包含点。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public abstract containsPoint(pX: number, pY: number): boolean; + /** + * 是否与线段相交。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public 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; + } + /** + * Cohen–Sutherland algorithm https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm + * ---------------------- + * | 0101 | 0100 | 0110 | + * ---------------------- + * | 0001 | 0000 | 0010 | + * ---------------------- + * | 1001 | 1000 | 1010 | + * ---------------------- + */ + const enum OutCode { + InSide = 0, // 0000 + Left = 1, // 0001 + Right = 2, // 0010 + Top = 4, // 0100 + Bottom = 8 // 1000 + } + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + export class RectangleBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.RectangleBoundingBoxData]"; + } + /** + * Compute the bit code for a point (x, y) using the clip rectangle + */ + private static _computeOutCode(x: number, y: number, xMin: number, yMin: number, xMax: number, yMax: number): number { + let code = OutCode.InSide; // initialised as being inside of [[clip window]] + + if (x < xMin) { // to the left of clip window + code |= OutCode.Left; + } + else if (x > xMax) { // to the right of clip window + code |= OutCode.Right; + } + + if (y < yMin) { // below the clip window + code |= OutCode.Top; + } + else if (y > yMax) { // above the clip window + code |= OutCode.Bottom; + } + + return code; + } + /** + * @private + */ + public static rectangleIntersectsSegment( + xA: number, yA: number, xB: number, yB: number, + xMin: number, yMin: number, xMax: number, yMax: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + const inSideA = xA > xMin && xA < xMax && yA > yMin && yA < yMax; + const inSideB = xB > xMin && xB < xMax && yB > yMin && yB < yMax; + + if (inSideA && inSideB) { + return -1; + } + + let intersectionCount = 0; + let outcode0 = RectangleBoundingBoxData._computeOutCode(xA, yA, xMin, yMin, xMax, yMax); + let 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 + let x = 0.0; + let y = 0.0; + let normalRadian = 0.0; + + // At least one endpoint is outside the clip rectangle; pick it. + const outcodeOut = outcode0 !== 0 ? outcode0 : outcode1; + + // Now find the intersection point; + if ((outcodeOut & OutCode.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 & OutCode.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 & OutCode.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 & OutCode.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; + } + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + this.type = BoundingBoxType.Rectangle; + } + /** + * @inherDoc + */ + public containsPoint(pX: number, pY: number): boolean { + const widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + const heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + return true; + } + } + + return false; + } + /** + * @inherDoc + */ + public intersectsSegment( + xA: number, yA: number, xB: number, yB: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + const widthH = this.width * 0.5; + const heightH = this.height * 0.5; + const intersectionCount = RectangleBoundingBoxData.rectangleIntersectsSegment( + xA, yA, xB, yB, + -widthH, -heightH, widthH, heightH, + intersectionPointA, intersectionPointB, normalRadians + ); + + return intersectionCount; + } + } + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + export class EllipseBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.EllipseData]"; + } + /** + * @private + */ + public static ellipseIntersectsSegment( + xA: number, yA: number, xB: number, yB: number, + xC: number, yC: number, widthH: number, heightH: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + const d = widthH / heightH; + const dd = d * d; + + yA *= d; + yB *= d; + + const dX = xB - xA; + const dY = yB - yA; + const lAB = Math.sqrt(dX * dX + dY * dY); + const xD = dX / lAB; + const yD = dY / lAB; + const a = (xC - xA) * xD + (yC - yA) * yD; + const aa = a * a; + const ee = xA * xA + yA * yA; + const rr = widthH * widthH; + const dR = rr - ee + aa; + let intersectionCount = 0; + + if (dR >= 0.0) { + const dT = Math.sqrt(dR); + const sA = a - dT; + const sB = a + dT; + const inSideA = sA < 0.0 ? -1 : (sA <= lAB ? 0 : 1); + const inSideB = sB < 0.0 ? -1 : (sB <= lAB ? 0 : 1); + const 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; + } + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + this.type = BoundingBoxType.Ellipse; + } + /** + * @inherDoc + */ + public containsPoint(pX: number, pY: number): boolean { + const widthH = this.width * 0.5; + if (pX >= -widthH && pX <= widthH) { + const heightH = this.height * 0.5; + if (pY >= -heightH && pY <= heightH) { + pY *= widthH / heightH; + return Math.sqrt(pX * pX + pY * pY) <= widthH; + } + } + + return false; + } + /** + * @inherDoc + */ + public intersectsSegment( + xA: number, yA: number, xB: number, yB: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + const intersectionCount = EllipseBoundingBoxData.ellipseIntersectsSegment( + xA, yA, xB, yB, + 0.0, 0.0, this.width * 0.5, this.height * 0.5, + intersectionPointA, intersectionPointB, normalRadians + ); + + return intersectionCount; + } + } + /** + * 多边形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + export class PolygonBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.PolygonBoundingBoxData]"; + } + /** + * @private + */ + public static polygonIntersectsSegment( + xA: number, yA: number, xB: number, yB: number, + vertices: Array | Float32Array, offset: number, count: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + if (xA === xB) { + xA = xB + 0.000001; + } + + if (yA === yB) { + yA = yB + 0.000001; + } + + const dXAB = xA - xB; + const dYAB = yA - yB; + const llAB = xA * yB - yA * xB; + let intersectionCount = 0; + let xC = vertices[offset + count - 2]; + let yC = vertices[offset + count - 1]; + let dMin = 0.0; + let dMax = 0.0; + let xMin = 0.0; + let yMin = 0.0; + let xMax = 0.0; + let yMax = 0.0; + + for (let i = 0; i < count; i += 2) { + const xD = vertices[offset + i]; + const yD = vertices[offset + i + 1]; + + if (xC === xD) { + xC = xD + 0.0001; + } + + if (yC === yD) { + yC = yD + 0.0001; + } + + const dXCD = xC - xD; + const dYCD = yC - yD; + const llCD = xC * yD - yC * xD; + const ll = dXAB * dYCD - dYAB * dXCD; + const 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))) { + const 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) { + let 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; + } + /** + * @private + */ + public count: number; + /** + * @private + */ + public offset: number; // FloatArray. + /** + * @private + */ + public x: number; + /** + * @private + */ + public y: number; + /** + * 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + public vertices: Array | Float32Array; // FloatArray. + /** + * @private + */ + public weight: WeightData | null = null; // Initial value. + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + if (this.weight !== null) { + this.weight.returnToPool(); + } + + this.type = BoundingBoxType.Polygon; + this.count = 0; + this.offset = 0; + this.x = 0.0; + this.y = 0.0; + this.vertices = null as any; // + this.weight = null; + } + /** + * @inherDoc + */ + public containsPoint(pX: number, pY: number): boolean { + let isInSide = false; + if (pX >= this.x && pX <= this.width && pY >= this.y && pY <= this.height) { + for (let i = 0, l = this.count, iP = l - 2; i < l; i += 2) { + const yA = this.vertices[this.offset + iP + 1]; + const yB = this.vertices[this.offset + i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + const xA = this.vertices[this.offset + iP]; + const xB = this.vertices[this.offset + i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + + iP = i; + } + } + + return isInSide; + } + /** + * @inherDoc + */ + public intersectsSegment( + xA: number, yA: number, xB: number, yB: number, + intersectionPointA: { x: number, y: number } | null = null, + intersectionPointB: { x: number, y: number } | null = null, + normalRadians: { x: number, y: number } | null = null + ): number { + let intersectionCount = 0; + if (RectangleBoundingBoxData.rectangleIntersectsSegment(xA, yA, xB, yB, this.x, this.y, this.width, this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment( + xA, yA, xB, yB, + this.vertices, this.offset, this.count, + intersectionPointA, intersectionPointB, normalRadians + ); + } + + return intersectionCount; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/ConstraintData.ts b/reference/DragonBones/src/dragonBones/model/ConstraintData.ts new file mode 100644 index 0000000..44528f6 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/ConstraintData.ts @@ -0,0 +1,38 @@ +namespace dragonBones { + /** + * @private + */ + export abstract class ConstraintData extends BaseObject { + public order: number; + public target: BoneData; + public bone: BoneData; + public root: BoneData | null; + + protected _onClear(): void { + this.order = 0; + this.target = null as any; // + this.bone = null as any; // + this.root = null; + } + } + /** + * @private + */ + export class IKConstraintData extends ConstraintData { + public static toString(): string { + return "[class dragonBones.IKConstraintData]"; + } + + public bendPositive: boolean; + public scaleEnabled: boolean; + public weight: number; + + protected _onClear(): void { + super._onClear(); + + this.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/DisplayData.ts b/reference/DragonBones/src/dragonBones/model/DisplayData.ts new file mode 100644 index 0000000..a65b232 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/DisplayData.ts @@ -0,0 +1,127 @@ +namespace dragonBones { + /** + * @private + */ + export abstract class DisplayData extends BaseObject { + public type: DisplayType; + public name: string; + public path: string; + public readonly transform: Transform = new Transform(); + public parent: ArmatureData; + + protected _onClear(): void { + this.name = ""; + this.path = ""; + this.transform.identity(); + this.parent = null as any; // + } + } + /** + * @private + */ + export class ImageDisplayData extends DisplayData { + public static toString(): string { + return "[class dragonBones.ImageDisplayData]"; + } + + public readonly pivot: Point = new Point(); + public texture: TextureData | null; + + protected _onClear(): void { + super._onClear(); + + this.type = DisplayType.Image; + this.pivot.clear(); + this.texture = null; + } + } + /** + * @private + */ + export class ArmatureDisplayData extends DisplayData { + public static toString(): string { + return "[class dragonBones.ArmatureDisplayData]"; + } + + public inheritAnimation: boolean; + public readonly actions: Array = []; + public armature: ArmatureData | null; + + protected _onClear(): void { + super._onClear(); + + for (const action of this.actions) { + action.returnToPool(); + } + + this.type = DisplayType.Armature; + this.inheritAnimation = false; + this.actions.length = 0; + this.armature = null; + } + } + /** + * @private + */ + export class MeshDisplayData extends ImageDisplayData { + public static toString(): string { + return "[class dragonBones.MeshDisplayData]"; + } + + public inheritAnimation: boolean; + public offset: number; // IntArray. + public weight: WeightData | null = null; // Initial value. + + protected _onClear(): void { + super._onClear(); + + if (this.weight !== null) { + this.weight.returnToPool(); + } + + this.type = DisplayType.Mesh; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + } + } + /** + * @private + */ + export class BoundingBoxDisplayData extends DisplayData { + public static toString(): string { + return "[class dragonBones.BoundingBoxDisplayData]"; + } + + public boundingBox: BoundingBoxData | null = null; // Initial value. + + protected _onClear(): void { + super._onClear(); + + if (this.boundingBox !== null) { + this.boundingBox.returnToPool(); + } + + this.type = DisplayType.BoundingBox; + this.boundingBox = null; + } + } + /** + * @private + */ + export class WeightData extends BaseObject { + public static toString(): string { + return "[class dragonBones.WeightData]"; + } + + public count: number; + public offset: number; // IntArray. + public readonly bones: Array = []; + + protected _onClear(): void { + this.count = 0; + this.offset = 0; + this.bones.length = 0; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/DragonBonesData.ts b/reference/DragonBones/src/dragonBones/model/DragonBonesData.ts new file mode 100644 index 0000000..e12c2ad --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/DragonBonesData.ts @@ -0,0 +1,154 @@ +namespace dragonBones { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + export class DragonBonesData extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.DragonBonesData]"; + } + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + public autoSearch: boolean; + /** + * 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public frameRate: number; + /** + * 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public version: string; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * @private + */ + public readonly frameIndices: Array = []; + /** + * @private + */ + public readonly cachedFrames: Array = []; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly armatureNames: Array = []; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + public readonly armatures: Map = {}; + /** + * @private + */ + public intArray: Array | Int16Array; + /** + * @private + */ + public floatArray: Array | Float32Array; + /** + * @private + */ + public frameIntArray: Array | Int16Array; + /** + * @private + */ + public frameFloatArray: Array | Float32Array; + /** + * @private + */ + public frameArray: Array | Int16Array; + /** + * @private + */ + public timelineArray: Array | Uint16Array; + /** + * @private + */ + public userData: UserData | null = null; // Initial value. + /** + * @private + */ + protected _onClear(): void { + for (let 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.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + //this.armatures.clear(); + this.intArray = null as any; // + this.floatArray = null as any; // + this.frameIntArray = null as any; // + this.frameFloatArray = null as any; // + this.frameArray = null as any; // + this.timelineArray = null as any; // + this.userData = null; + } + /** + * @private + */ + public addArmature(value: ArmatureData): void { + if (value.name in this.armatures) { + console.warn("Replace armature: " + value.name); + this.armatures[value.name].returnToPool(); + } + + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + } + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + public getArmature(name: string): ArmatureData | null { + return name in this.armatures ? this.armatures[name] : null; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + public dispose(): void { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/TextureAtlasData.ts b/reference/DragonBones/src/dragonBones/model/TextureAtlasData.ts new file mode 100644 index 0000000..6c423f0 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/TextureAtlasData.ts @@ -0,0 +1,149 @@ +namespace dragonBones { + /** + * 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + public autoSearch: boolean; + /** + * @private + */ + public width: number; + /** + * @private + */ + public height: number; + /** + * 贴图集缩放系数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public scale: number; + /** + * 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public name: string; + /** + * 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public imagePath: string; + /** + * @private + */ + public readonly textures: Map = {}; + /** + * @private + */ + protected _onClear(): void { + for (let 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 + */ + public copyFrom(value: TextureAtlasData): void { + 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 (let k in this.textures) { + this.textures[k].returnToPool(); + delete this.textures[k]; + } + + // this.textures.clear(); + + for (let k in value.textures) { + const texture = this.createTexture(); + texture.copyFrom(value.textures[k]); + this.textures[k] = texture; + } + } + /** + * @private + */ + public abstract createTexture(): TextureData; + /** + * @private + */ + public addTexture(value: TextureData): void { + if (value.name in this.textures) { + console.warn("Replace texture: " + value.name); + this.textures[value.name].returnToPool(); + } + + value.parent = this; + this.textures[value.name] = value; + } + /** + * @private + */ + public getTexture(name: string): TextureData | null { + return name in this.textures ? this.textures[name] : null; + } + } + /** + * @private + */ + export abstract class TextureData extends BaseObject { + public static createRectangle(): Rectangle { + return new Rectangle(); + } + + public rotated: boolean; + public name: string; + public readonly region: Rectangle = new Rectangle(); + public parent: TextureAtlasData; + public frame: Rectangle | null = null; // Initial value. + + protected _onClear(): void { + this.rotated = false; + this.name = ""; + this.region.clear(); + this.parent = null as any; // + this.frame = null; + } + + public copyFrom(value: TextureData): void { + 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); + } + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/model/UserData.ts b/reference/DragonBones/src/dragonBones/model/UserData.ts new file mode 100644 index 0000000..fb13f52 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/model/UserData.ts @@ -0,0 +1,91 @@ +namespace dragonBones { + /** + * 自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + export class UserData extends BaseObject { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.UserData]"; + } + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public readonly ints: Array = []; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public readonly floats: Array = []; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public readonly strings: Array = []; + /** + * @private + */ + protected _onClear(): void { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + } + /** + * 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public getInt(index: number = 0): number { + return index >= 0 && index < this.ints.length ? this.ints[index] : 0; + } + /** + * 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public getFloat(index: number = 0): number { + return index >= 0 && index < this.floats.length ? this.floats[index] : 0.0; + } + /** + * 获取自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + public getString(index: number = 0): string { + return index >= 0 && index < this.strings.length ? this.strings[index] : ""; + } + } + /** + * @private + */ + export class ActionData extends BaseObject { + public static toString(): string { + return "[class dragonBones.ActionData]"; + } + + public type: ActionType; + public name: string; // Frame event name | Sound event name | Animation name + public bone: BoneData | null; + public slot: SlotData | null; + public data: UserData | null = null; // + + protected _onClear(): void { + if (this.data !== null) { + this.data.returnToPool(); + } + + this.type = ActionType.Play; + this.name = ""; + this.bone = null; + this.slot = null; + this.data = null; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/modules.ts b/reference/DragonBones/src/dragonBones/modules.ts new file mode 100644 index 0000000..c5a9303 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/modules.ts @@ -0,0 +1 @@ +declare const Module: any; // TODO need remove. \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/parser/BinaryDataParser.ts b/reference/DragonBones/src/dragonBones/parser/BinaryDataParser.ts new file mode 100644 index 0000000..e6a22af --- /dev/null +++ b/reference/DragonBones/src/dragonBones/parser/BinaryDataParser.ts @@ -0,0 +1,435 @@ +namespace dragonBones { + /** + * @private + */ + export class BinaryDataParser extends ObjectDataParser { + private _binary: ArrayBuffer; + private _binaryOffset: number; + private _intArray: Int16Array; + private _floatArray: Float32Array; + private _frameIntArray: Int16Array; + private _frameFloatArray: Float32Array; + private _frameArray: Int16Array; + private _timelineArray: Uint16Array; + + private _inRange(a: number, min: number, max: number): boolean { + return min <= a && a <= max; + } + + private _decodeUTF8(data: Uint8Array): string { + const EOF_byte = -1; + const EOF_code_point = -1; + const FATAL_POINT = 0xFFFD; + + let pos = 0; + let result = ""; + let code_point; + let utf8_code_point = 0; + let utf8_bytes_needed = 0; + let utf8_bytes_seen = 0; + let utf8_lower_boundary = 0; + + while (data.length > pos) { + + let _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 { + + let cp = utf8_code_point; + let 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; + } + + private _getUTF16Key(value: string): string { + for (let i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + + return value; + } + + private _parseBinaryTimeline(type: TimelineType, offset: number, timelineData: TimelineData | null = null): TimelineData { + // const timeline = timelineData !== null ? timelineData : BaseObject.borrowObject(TimelineData); + const timeline = timelineData !== null ? timelineData : (DragonBones.webAssembly ? new Module["TimelineData"]() as TimelineData : BaseObject.borrowObject(TimelineData)); + timeline.type = type; + timeline.offset = offset; + + this._timeline = timeline; + + const keyFrameCount = this._timelineArray[timeline.offset + BinaryOffset.TimelineKeyFrameCount]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + const totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + const frameIndices = this._data.frameIndices; + if (DragonBones.webAssembly) { + timeline.frameIndicesOffset = (frameIndices as any).size(); + // (frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (let j = 0; j < totalFrameCount; ++j) { + (frameIndices as any).push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + + for ( + let i = 0, iK = 0, frameStart = 0, frameCount = 0; + i < totalFrameCount; + ++i + ) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + BinaryOffset.TimelineFrameOffset + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + BinaryOffset.TimelineFrameOffset + iK + 1]] - frameStart; + } + + iK++; + } + + if (DragonBones.webAssembly) { + (frameIndices as any).set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + + this._timeline = null as any; // + + return timeline; + } + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void { + mesh.offset = rawData[ObjectDataParser.OFFSET]; + + const weightOffset = this._intArray[mesh.offset + BinaryOffset.MeshWeightOffset]; + if (weightOffset >= 0) { + // const weight = BaseObject.borrowObject(WeightData); + const weight = DragonBones.webAssembly ? new Module["WeightData"]() as WeightData : BaseObject.borrowObject(WeightData); + const vertexCount = this._intArray[mesh.offset + BinaryOffset.MeshVertexCount]; + const boneCount = this._intArray[weightOffset + BinaryOffset.WeigthBoneCount]; + weight.offset = weightOffset; + if (DragonBones.webAssembly) { + (weight.bones as any).resize(boneCount, null); + for (let i = 0; i < boneCount; ++i) { + const boneIndex = this._intArray[weightOffset + BinaryOffset.WeigthBoneIndices + i]; + (weight.bones as any).set(i, this._rawBones[boneIndex]); + } + } + else { + weight.bones.length = boneCount; + + for (let i = 0; i < boneCount; ++i) { + const boneIndex = this._intArray[weightOffset + BinaryOffset.WeigthBoneIndices + i]; + weight.bones[i] = this._rawBones[boneIndex]; + } + } + + let boneIndicesOffset = weightOffset + BinaryOffset.WeigthBoneIndices + boneCount; + for (let i = 0, l = vertexCount; i < l; ++i) { + const vertexBoneCount = this._intArray[boneIndicesOffset++]; + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + + mesh.weight = weight; + } + } + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData { + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + const polygonBoundingBox = DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() as PolygonBoundingBoxData : BaseObject.borrowObject(PolygonBoundingBoxData); + polygonBoundingBox.offset = rawData[ObjectDataParser.OFFSET]; + polygonBoundingBox.vertices = this._floatArray; + + return polygonBoundingBox; + } + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData { + // const animation = BaseObject.borrowObject(AnimationData); + const animation = DragonBones.webAssembly ? new Module["AnimationData"]() as AnimationData : BaseObject.borrowObject(AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + + // Offsets. + const offsets = rawData[ObjectDataParser.OFFSET] as Array; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + + this._animation = animation; + + if (ObjectDataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(TimelineType.Action, rawData[ObjectDataParser.ACTION]); + } + + if (ObjectDataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(TimelineType.ZOrder, rawData[ObjectDataParser.Z_ORDER]); + } + + if (ObjectDataParser.BONE in rawData) { + const rawTimeliness = rawData[ObjectDataParser.BONE]; + for (let k in rawTimeliness) { + const rawTimelines = rawTimeliness[k] as Array; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(k); + } + + const bone = this._armature.getBone(k); + if (bone === null) { + continue; + } + + for (let i = 0, l = rawTimelines.length; i < l; i += 2) { + const timelineType = rawTimelines[i]; + const timelineOffset = rawTimelines[i + 1]; + const timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addBoneTimeline(bone, timeline); + } + } + } + + if (ObjectDataParser.SLOT in rawData) { + const rawTimeliness = rawData[ObjectDataParser.SLOT]; + for (let k in rawTimeliness) { + const rawTimelines = rawTimeliness[k] as Array; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(k); + } + + const slot = this._armature.getSlot(k); + if (slot === null) { + continue; + } + + for (let i = 0, l = rawTimelines.length; i < l; i += 2) { + const timelineType = rawTimelines[i]; + const timelineOffset = rawTimelines[i + 1]; + const timeline = this._parseBinaryTimeline(timelineType, timelineOffset); + this._animation.addSlotTimeline(slot, timeline); + } + } + } + + this._animation = null as any; + + return animation; + } + /** + * @private + */ + protected _parseArray(rawData: any): void { + const offsets = rawData[ObjectDataParser.OFFSET] as Array; + if (DragonBones.webAssembly) { + const tmpIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + const tmpFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + const tmpFrameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + const tmpFrameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + const tmpFrameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + const tmpTimelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + + const intArrayBuf = Module._malloc(tmpIntArray.length * tmpIntArray.BYTES_PER_ELEMENT); + const floatArrayBuf = Module._malloc(tmpFloatArray.length * tmpFloatArray.BYTES_PER_ELEMENT); + const frameIntArrayBuf = Module._malloc(tmpFrameIntArray.length * tmpFrameIntArray.BYTES_PER_ELEMENT); + const frameFloatArrayBuf = Module._malloc(tmpFrameFloatArray.length * tmpFrameFloatArray.BYTES_PER_ELEMENT); + const frameArrayBuf = Module._malloc(tmpFrameArray.length * tmpFrameArray.BYTES_PER_ELEMENT); + const timelineArrayBuf = Module._malloc(tmpTimelineArray.length * tmpTimelineArray.BYTES_PER_ELEMENT); + + this._intArray = new Int16Array(Module.HEAP16.buffer, intArrayBuf, tmpIntArray.length); + this._floatArray = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, tmpFloatArray.length); + this._frameIntArray = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, tmpFrameIntArray.length); + this._frameFloatArray = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, tmpFrameFloatArray.length); + this._frameArray = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, tmpFrameArray.length); + this._timelineArray = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, tmpTimelineArray.length); + + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + // Module.HEAPF32.set(tmpFloatArray, floatArrayBuf); + // Module.HEAP16.set(tmpFrameIntArray, frameIntArrayBuf); + // Module.HEAPF32.set(tmpFrameFloatArray, frameFloatArrayBuf); + // Module.HEAP16.set(tmpFrameArray, frameArrayBuf); + // Module.HEAPU16.set(tmpTimelineArray, timelineArrayBuf); + + for (let i1 = 0; i1 < tmpIntArray.length; ++i1) { + this._intArray[i1] = tmpIntArray[i1]; + } + + for (let i2 = 0; i2 < tmpFloatArray.length; ++i2) { + this._floatArray[i2] = tmpFloatArray[i2]; + } + + for (let i3 = 0; i3 < tmpFrameIntArray.length; ++i3) { + this._frameIntArray[i3] = tmpFrameIntArray[i3]; + } + + for (let i4 = 0; i4 < tmpFrameFloatArray.length; ++i4) { + this._frameFloatArray[i4] = tmpFrameFloatArray[i4]; + } + + for (let i5 = 0; i5 < tmpFrameArray.length; ++i5) { + this._frameArray[i5] = tmpFrameArray[i5]; + } + + for (let i6 = 0; i6 < tmpTimelineArray.length; ++i6) { + this._timelineArray[i6] = tmpTimelineArray[i6]; + } + + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], + [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + } + else { + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + } + } + /** + * @inheritDoc + */ + public parseDragonBonesData(rawData: any, scale: number = 1): DragonBonesData | null { + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer); + + const 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; + } + + const headerLength = new Uint32Array(rawData, 8, 1)[0]; + const headerBytes = new Uint8Array(rawData, 8 + 4, headerLength); + const headerString = this._decodeUTF8(headerBytes); + const header = JSON.parse(headerString); + + this._binary = rawData; + this._binaryOffset = 8 + 4 + headerLength; + + return super.parseDragonBonesData(header, scale); + } + + /** + * @private + */ + private static _binaryDataParserInstance: BinaryDataParser = null as any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + public static getInstance(): BinaryDataParser { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + + return BinaryDataParser._binaryDataParserInstance; + } + } +} \ No newline at end of file diff --git a/reference/DragonBones/src/dragonBones/parser/DataParser.ts b/reference/DragonBones/src/dragonBones/parser/DataParser.ts new file mode 100644 index 0000000..46d96f9 --- /dev/null +++ b/reference/DragonBones/src/dragonBones/parser/DataParser.ts @@ -0,0 +1,302 @@ +namespace dragonBones { + /** + * @private + */ + export abstract class DataParser { + protected static readonly DATA_VERSION_2_3: string = "2.3"; + protected static readonly DATA_VERSION_3_0: string = "3.0"; + protected static readonly DATA_VERSION_4_0: string = "4.0"; + protected static readonly DATA_VERSION_4_5: string = "4.5"; + protected static readonly DATA_VERSION_5_0: string = "5.0"; + protected static readonly DATA_VERSION: string = DataParser.DATA_VERSION_5_0; + + protected static readonly DATA_VERSIONS: Array = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + ]; + + protected static readonly TEXTURE_ATLAS: string = "textureAtlas"; + protected static readonly SUB_TEXTURE: string = "SubTexture"; + protected static readonly FORMAT: string = "format"; + protected static readonly IMAGE_PATH: string = "imagePath"; + protected static readonly WIDTH: string = "width"; + protected static readonly HEIGHT: string = "height"; + protected static readonly ROTATED: string = "rotated"; + protected static readonly FRAME_X: string = "frameX"; + protected static readonly FRAME_Y: string = "frameY"; + protected static readonly FRAME_WIDTH: string = "frameWidth"; + protected static readonly FRAME_HEIGHT: string = "frameHeight"; + + protected static readonly DRADON_BONES: string = "dragonBones"; + protected static readonly USER_DATA: string = "userData"; + protected static readonly ARMATURE: string = "armature"; + protected static readonly BONE: string = "bone"; + protected static readonly IK: string = "ik"; + protected static readonly SLOT: string = "slot"; + protected static readonly SKIN: string = "skin"; + protected static readonly DISPLAY: string = "display"; + protected static readonly ANIMATION: string = "animation"; + protected static readonly Z_ORDER: string = "zOrder"; + protected static readonly FFD: string = "ffd"; + protected static readonly FRAME: string = "frame"; + protected static readonly TRANSLATE_FRAME: string = "translateFrame"; + protected static readonly ROTATE_FRAME: string = "rotateFrame"; + protected static readonly SCALE_FRAME: string = "scaleFrame"; + protected static readonly VISIBLE_FRAME: string = "visibleFrame"; + protected static readonly DISPLAY_FRAME: string = "displayFrame"; + protected static readonly COLOR_FRAME: string = "colorFrame"; + protected static readonly DEFAULT_ACTIONS: string = "defaultActions"; + protected static readonly ACTIONS: string = "actions"; + protected static readonly EVENTS: string = "events"; + protected static readonly INTS: string = "ints"; + protected static readonly FLOATS: string = "floats"; + protected static readonly STRINGS: string = "strings"; + protected static readonly CANVAS: string = "canvas"; + + protected static readonly TRANSFORM: string = "transform"; + protected static readonly PIVOT: string = "pivot"; + protected static readonly AABB: string = "aabb"; + protected static readonly COLOR: string = "color"; + + protected static readonly VERSION: string = "version"; + protected static readonly COMPATIBLE_VERSION: string = "compatibleVersion"; + protected static readonly FRAME_RATE: string = "frameRate"; + protected static readonly TYPE: string = "type"; + protected static readonly SUB_TYPE: string = "subType"; + protected static readonly NAME: string = "name"; + protected static readonly PARENT: string = "parent"; + protected static readonly TARGET: string = "target"; + protected static readonly SHARE: string = "share"; + protected static readonly PATH: string = "path"; + protected static readonly LENGTH: string = "length"; + protected static readonly DISPLAY_INDEX: string = "displayIndex"; + protected static readonly BLEND_MODE: string = "blendMode"; + protected static readonly INHERIT_TRANSLATION: string = "inheritTranslation"; + protected static readonly INHERIT_ROTATION: string = "inheritRotation"; + protected static readonly INHERIT_SCALE: string = "inheritScale"; + protected static readonly INHERIT_REFLECTION: string = "inheritReflection"; + protected static readonly INHERIT_ANIMATION: string = "inheritAnimation"; + protected static readonly INHERIT_FFD: string = "inheritFFD"; + protected static readonly BEND_POSITIVE: string = "bendPositive"; + protected static readonly CHAIN: string = "chain"; + protected static readonly WEIGHT: string = "weight"; + + protected static readonly FADE_IN_TIME: string = "fadeInTime"; + protected static readonly PLAY_TIMES: string = "playTimes"; + protected static readonly SCALE: string = "scale"; + protected static readonly OFFSET: string = "offset"; + protected static readonly POSITION: string = "position"; + protected static readonly DURATION: string = "duration"; + protected static readonly TWEEN_TYPE: string = "tweenType"; + protected static readonly TWEEN_EASING: string = "tweenEasing"; + protected static readonly TWEEN_ROTATE: string = "tweenRotate"; + protected static readonly TWEEN_SCALE: string = "tweenScale"; + protected static readonly CURVE: string = "curve"; + protected static readonly SOUND: string = "sound"; + protected static readonly EVENT: string = "event"; + protected static readonly ACTION: string = "action"; + + protected static readonly X: string = "x"; + protected static readonly Y: string = "y"; + protected static readonly SKEW_X: string = "skX"; + protected static readonly SKEW_Y: string = "skY"; + protected static readonly SCALE_X: string = "scX"; + protected static readonly SCALE_Y: string = "scY"; + protected static readonly VALUE: string = "value"; + protected static readonly ROTATE: string = "rotate"; + protected static readonly SKEW: string = "skew"; + + protected static readonly ALPHA_OFFSET: string = "aO"; + protected static readonly RED_OFFSET: string = "rO"; + protected static readonly GREEN_OFFSET: string = "gO"; + protected static readonly BLUE_OFFSET: string = "bO"; + protected static readonly ALPHA_MULTIPLIER: string = "aM"; + protected static readonly RED_MULTIPLIER: string = "rM"; + protected static readonly GREEN_MULTIPLIER: string = "gM"; + protected static readonly BLUE_MULTIPLIER: string = "bM"; + + protected static readonly UVS: string = "uvs"; + protected static readonly VERTICES: string = "vertices"; + protected static readonly TRIANGLES: string = "triangles"; + protected static readonly WEIGHTS: string = "weights"; + protected static readonly SLOT_POSE: string = "slotPose"; + protected static readonly BONE_POSE: string = "bonePose"; + + protected static readonly GOTO_AND_PLAY: string = "gotoAndPlay"; + + protected static readonly DEFAULT_NAME: string = "default"; + + protected static _getArmatureType(value: string): ArmatureType { + switch (value.toLowerCase()) { + case "stage": + return ArmatureType.Stage; + + case "armature": + return ArmatureType.Armature; + + case "movieclip": + return ArmatureType.MovieClip; + + default: + return ArmatureType.Armature; + } + } + + protected static _getDisplayType(value: string): DisplayType { + switch (value.toLowerCase()) { + case "image": + return DisplayType.Image; + + case "mesh": + return DisplayType.Mesh; + + case "armature": + return DisplayType.Armature; + + case "boundingbox": + return DisplayType.BoundingBox; + + default: + return DisplayType.Image; + } + } + + protected static _getBoundingBoxType(value: string): BoundingBoxType { + switch (value.toLowerCase()) { + case "rectangle": + return BoundingBoxType.Rectangle; + + case "ellipse": + return BoundingBoxType.Ellipse; + + case "polygon": + return BoundingBoxType.Polygon; + + default: + return BoundingBoxType.Rectangle; + } + } + + protected static _getActionType(value: string): ActionType { + switch (value.toLowerCase()) { + case "play": + return ActionType.Play; + + case "frame": + return ActionType.Frame; + + case "sound": + return ActionType.Sound; + + default: + return ActionType.Play; + } + } + + protected static _getBlendMode(value: string): BlendMode { + switch (value.toLowerCase()) { + case "normal": + return BlendMode.Normal; + + case "add": + return BlendMode.Add; + + case "alpha": + return BlendMode.Alpha; + + case "darken": + return BlendMode.Darken; + + case "difference": + return BlendMode.Difference; + + case "erase": + return BlendMode.Erase; + + case "hardlight": + return BlendMode.HardLight; + + case "invert": + return BlendMode.Invert; + + case "layer": + return BlendMode.Layer; + + case "lighten": + return BlendMode.Lighten; + + case "multiply": + return BlendMode.Multiply; + + case "overlay": + return BlendMode.Overlay; + + case "screen": + return BlendMode.Screen; + + case "subtract": + return BlendMode.Subtract; + + default: + return BlendMode.Normal; + } + } + /** + * @private + */ + public abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + /** + * @private + */ + public abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + public static parseDragonBonesData(rawData: any): DragonBonesData | null { + if (rawData instanceof ArrayBuffer) { + return BinaryDataParser.getInstance().parseDragonBonesData(rawData); + } + else { + return ObjectDataParser.getInstance().parseDragonBonesData(rawData); + } + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + public static parseTextureAtlasData(rawData: any, scale: number = 1): any { + console.warn("已废弃,请参考 @see"); + const textureAtlasData = {} as any; + + const subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (let i = 0, len = subTextureList.length; i < len; i++) { + const subTextureObject = subTextureList[i]; + const subTextureName = subTextureObject[DataParser.NAME]; + const subTextureRegion = new Rectangle(); + let subTextureFrame: Rectangle | null = null; + + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + } + + return textureAtlasData; + } + } +} diff --git a/reference/DragonBones/src/dragonBones/parser/ObjectDataParser.ts b/reference/DragonBones/src/dragonBones/parser/ObjectDataParser.ts new file mode 100644 index 0000000..130b24c --- /dev/null +++ b/reference/DragonBones/src/dragonBones/parser/ObjectDataParser.ts @@ -0,0 +1,1795 @@ +namespace dragonBones { + /** + * @private + */ + export class ObjectDataParser extends DataParser { + + /** + * @private + */ + + private _intArrayJson: Array = []; + private _floatArrayJson: Array = []; + private _frameIntArrayJson: Array = []; + private _frameFloatArrayJson: Array = []; + private _frameArrayJson: Array = []; + private _timelineArrayJson: Array = []; + + private _intArrayBuffer: Int16Array; + private _floatArrayBuffer: Float32Array; + private _frameIntArrayBuffer: Int16Array; + private _frameFloatArrayBuffer: Float32Array; + private _frameArrayBuffer: Int16Array; + private _timelineArrayBuffer: Uint16Array; + + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean { + if (key in rawData) { + const value = rawData[key]; + const 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; + } + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number { + if (key in rawData) { + const value = rawData[key]; + if (value === null || value === "NaN") { + return defaultValue; + } + + return +value || 0; + } + + return defaultValue; + } + /** + * @private + */ + protected static _getString(rawData: any, key: string, defaultValue: string): string { + if (key in rawData) { + const value = rawData[key]; + const type = typeof value; + if (type === "string") { + if (dragonBones.DragonBones.webAssembly) { + for (let i = 0, l = (value as string).length; i < l; ++i) { + if ((value as string).charCodeAt(i) > 255) { + return encodeURI(value); + } + } + } + + return value; + } + + return String(value); + } + + return defaultValue; + } + + protected _rawTextureAtlasIndex: number = 0; + protected readonly _rawBones: Array = []; + protected _data: DragonBonesData = null as any; // + protected _armature: ArmatureData = null as any; // + protected _bone: BoneData = null as any; // + protected _slot: SlotData = null as any; // + protected _skin: SkinData = null as any; // + protected _mesh: MeshDisplayData = null as any; // + protected _animation: AnimationData = null as any; // + protected _timeline: TimelineData = null as any; // + protected _rawTextureAtlases: Array | null = null; + + private _defalultColorOffset: number = -1; + private _prevTweenRotate: number = 0; + private _prevRotation: number = 0.0; + private readonly _helpMatrixA: Matrix = new Matrix(); + private readonly _helpMatrixB: Matrix = new Matrix(); + private readonly _helpTransform: Transform = new Transform(); + private readonly _helpColorTransform: ColorTransform = new ColorTransform(); + private readonly _helpPoint: Point = new Point(); + private readonly _helpArray: Array = []; + private readonly _actionFrames: Array = []; + private readonly _weightSlotPose: Map> = {}; + private readonly _weightBonePoses: Map> = {}; + private readonly _weightBoneIndices: Map> = {}; + private readonly _cacheBones: Map> = {}; + private readonly _meshs: Map = {}; + private readonly _slotChildActions: Map> = {}; + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + /** + * @private + */ + private _getCurvePoint(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, t: number, result: Point): void { + const l_t = 1.0 - t; + const powA = l_t * l_t; + const powB = t * t; + const kA = l_t * powA; + const kB = 3.0 * t * powA; + const kC = 3.0 * l_t * powB; + const kD = t * powB; + + result.x = kA * x1 + kB * x2 + kC * x3 + kD * x4; + result.y = kA * y1 + kB * y2 + kC * y3 + kD * y4; + } + /** + * @private + */ + private _samplingEasingCurve(curve: Array, samples: Array): void { + const curveCount = curve.length; + let stepIndex = -2; + for (let i = 0, l = samples.length; i < l; ++i) { + let t = (i + 1) / (l + 1); + while ((stepIndex + 6 < curveCount ? curve[stepIndex + 6] : 1) < t) { // stepIndex + 3 * 2 + stepIndex += 6; + } + + const isInCurve = stepIndex >= 0 && stepIndex + 6 < curveCount; + const x1 = isInCurve ? curve[stepIndex] : 0.0; + const y1 = isInCurve ? curve[stepIndex + 1] : 0.0; + const x2 = curve[stepIndex + 2]; + const y2 = curve[stepIndex + 3]; + const x3 = curve[stepIndex + 4]; + const y3 = curve[stepIndex + 5]; + const x4 = isInCurve ? curve[stepIndex + 6] : 1.0; + const y4 = isInCurve ? curve[stepIndex + 7] : 1.0; + + let lower = 0.0; + let higher = 1.0; + while (higher - lower > 0.0001) { + const 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; + } + } + + private _sortActionFrame(a: ActionFrame, b: ActionFrame): number { + return a.frameStart > b.frameStart ? 1 : -1; + } + + private _parseActionDataInFrame(rawData: any, frameStart: number, bone: BoneData | null, slot: SlotData | null): void { + if (ObjectDataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENT], frameStart, ActionType.Frame, bone, slot); + } + + if (ObjectDataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.SOUND], frameStart, ActionType.Sound, bone, slot); + } + + if (ObjectDataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTION], frameStart, ActionType.Play, bone, slot); + } + + if (ObjectDataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENTS], frameStart, ActionType.Frame, bone, slot); + } + + if (ObjectDataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTIONS], frameStart, ActionType.Play, bone, slot); + } + } + + private _mergeActionFrame(rawData: any, frameStart: number, type: ActionType, bone: BoneData | null, slot: SlotData | null): void { + const actionOffset = DragonBones.webAssembly ? (this._armature.actions as any).size() : this._armature.actions.length; + const actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + let frame: ActionFrame | null = null; + + if (this._actionFrames.length === 0) { // First frame. + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + + for (const eachFrame of this._actionFrames) { // Get same frame. + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + } + + if (frame === null) { // Create and cache frame. + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.push(frame); + } + + for (let i = 0; i < actionCount; ++i) { // Cache action offsets. + frame.actions.push(actionOffset + i); + } + } + + private _parseCacheActionFrame(frame: ActionFrame): number { + const frameArray = DragonBones.webAssembly ? this._frameArrayJson : (this._data.frameArray as Array); + const frameOffset = frameArray.length; + const actionCount = frame.actions.length; + frameArray.length += 1 + 1 + actionCount; + frameArray[frameOffset + BinaryOffset.FramePosition] = frame.frameStart; + frameArray[frameOffset + BinaryOffset.FramePosition + 1] = actionCount; // Action count. + + for (let i = 0; i < actionCount; ++i) { // Action offsets. + frameArray[frameOffset + BinaryOffset.FramePosition + 2 + i] = frame.actions[i]; + } + + return frameOffset; + } + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData { + // const armature = BaseObject.borrowObject(ArmatureData); + const armature = DragonBones.webAssembly ? new Module["ArmatureData"]() as ArmatureData : BaseObject.borrowObject(ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, ArmatureType.Armature); + } + + if (armature.frameRate === 0) { // Data error. + armature.frameRate = 24; + } + + this._armature = armature; + + if (ObjectDataParser.AABB in rawData) { + const rawAABB = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.X, 0.0); + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.Y, 0.0); + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.WIDTH, 0.0); + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.HEIGHT, 0.0); + } + + if (ObjectDataParser.CANVAS in rawData) { + const rawCanvas = rawData[ObjectDataParser.CANVAS]; + const canvas = BaseObject.borrowObject(CanvasData); + + if (ObjectDataParser.COLOR in rawCanvas) { + ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + + canvas.color = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.X, 0); + canvas.y = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.HEIGHT, 0); + + armature.canvas = canvas; + } + + if (ObjectDataParser.BONE in rawData) { + const rawBones = rawData[ObjectDataParser.BONE] as Array; + for (const rawBone of rawBones) { + const parentName = ObjectDataParser._getString(rawBone, ObjectDataParser.PARENT, ""); + const bone = this._parseBone(rawBone); + + if (parentName.length > 0) { // Get bone parent. + const parent = armature.getBone(parentName); + if (parent !== null) { + bone.parent = parent; + } + else { // Cache. + (this._cacheBones[parentName] = this._cacheBones[parentName] || []).push(bone); + } + } + + if (bone.name in this._cacheBones) { + for (const child of this._cacheBones[bone.name]) { + child.parent = bone; + } + + delete this._cacheBones[bone.name]; + } + + armature.addBone(bone); + + this._rawBones.push(bone); // Raw bone sort. + } + } + + if (ObjectDataParser.IK in rawData) { + const rawIKS = rawData[ObjectDataParser.IK] as Array; + for (const rawIK of rawIKS) { + this._parseIKConstraint(rawIK); + } + } + + armature.sortBones(); + + if (ObjectDataParser.SLOT in rawData) { + const rawSlots = rawData[ObjectDataParser.SLOT] as Array; + for (const rawSlot of rawSlots) { + armature.addSlot(this._parseSlot(rawSlot)); + } + } + + if (ObjectDataParser.SKIN in rawData) { + const rawSkins = rawData[ObjectDataParser.SKIN] as Array; + for (const rawSkin of rawSkins) { + armature.addSkin(this._parseSkin(rawSkin)); + } + } + + if (ObjectDataParser.ANIMATION in rawData) { + const rawAnimations = rawData[ObjectDataParser.ANIMATION] as Array; + for (const rawAnimation of rawAnimations) { + const animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + + if (ObjectDataParser.DEFAULT_ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.DEFAULT_ACTIONS], armature.defaultActions, ActionType.Play, null, null); + } + + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armature.actions, ActionType.Play, null, null); + } + + // for (const action of armature.defaultActions) { // Set default animation from default action. + for (let i = 0; i < (DragonBones.webAssembly ? (armature.defaultActions as any).size() : armature.defaultActions.length); ++i) { + const action = DragonBones.webAssembly ? (armature.defaultActions as any).get(i) as ActionData : armature.defaultActions[i]; + if (action.type === ActionType.Play) { + const animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + break; + } + } + + // Clear helper. + this._rawBones.length = 0; + this._armature = null as any; + for (let k in this._meshs) { + delete this._meshs[k]; + } + for (let k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (let k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + for (let k in this._weightSlotPose) { + delete this._weightSlotPose[k]; + } + for (let k in this._weightBonePoses) { + delete this._weightBonePoses[k]; + } + for (let k in this._weightBoneIndices) { + delete this._weightBoneIndices[k]; + } + + return armature; + } + /** + * @private + */ + protected _parseBone(rawData: any): BoneData { + // const bone = BaseObject.borrowObject(BoneData); + const bone = DragonBones.webAssembly ? new Module["BoneData"]() as BoneData : BaseObject.borrowObject(BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform, this._armature.scale); + + } + + return bone; + } + /** + * @private + */ + protected _parseIKConstraint(rawData: any): void { + const bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + + const target = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, "")); + if (target === null) { + return; + } + + // const constraint = BaseObject.borrowObject(IKConstraintData); + const constraint = DragonBones.webAssembly ? new Module["IKConstraintData"]() : BaseObject.borrowObject(IKConstraintData); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, ObjectDataParser.SCALE, false); + constraint.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1.0); + constraint.bone = bone; + constraint.target = target; + + const chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + if (DragonBones.webAssembly) { + (bone.constraints as any).push_back(constraint); + } + else { + bone.constraints.push(constraint); + } + } + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData { + // const slot = BaseObject.borrowObject(SlotData); + const slot = DragonBones.webAssembly ? new Module["SlotData"]() : BaseObject.borrowObject(SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = DragonBones.webAssembly ? (this._armature.sortedSlots as any).size() : this._armature.sortedSlots.length; + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, "")) as any; // + + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] === "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, BlendMode.Normal); + } + + if (ObjectDataParser.COLOR in rawData) { + // slot.color = SlotData.createColor(); + slot.color = DragonBones.webAssembly ? Module["SlotData"].createColor() : SlotData.createColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = DragonBones.webAssembly ? Module["SlotData"].DEFAULT_COLOR : SlotData.DEFAULT_COLOR; + } + + if (ObjectDataParser.ACTIONS in rawData) { + const actions = this._slotChildActions[slot.name] = []; + this._parseActionData(rawData[ObjectDataParser.ACTIONS], actions, ActionType.Play, null, null); + } + + return slot; + } + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData { + // const skin = BaseObject.borrowObject(SkinData); + const skin = DragonBones.webAssembly ? new Module["SkinData"]() : BaseObject.borrowObject(SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + + const rawSlots = rawData[ObjectDataParser.SLOT]; + for (const rawSlot of rawSlots) { + const slotName = ObjectDataParser._getString(rawSlot, ObjectDataParser.NAME, ""); + const slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + + if (ObjectDataParser.DISPLAY in rawSlot) { + const rawDisplays = rawSlot[ObjectDataParser.DISPLAY]; + for (const rawDisplay of rawDisplays) { + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + + this._slot = null as any; // + } + } + + this._skin = null as any; // + } + + return skin; + } + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData | null { + let display: DisplayData | null = null; + const name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + const path = ObjectDataParser._getString(rawData, ObjectDataParser.PATH, ""); + let type = DisplayType.Image; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, type); + } + + switch (type) { + case DisplayType.Image: + // const imageDisplay = display = BaseObject.borrowObject(ImageDisplayData); + const imageDisplay = display = DragonBones.webAssembly ? new Module["ImageDisplayData"]() as ImageDisplayData : BaseObject.borrowObject(ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + + case DisplayType.Armature: + // const armatureDisplay = display = BaseObject.borrowObject(ArmatureDisplayData); + const armatureDisplay = display = DragonBones.webAssembly ? new Module["ArmatureDisplayData"]() as ArmatureDisplayData : BaseObject.borrowObject(ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armatureDisplay.actions, ActionType.Play, null, null); + } + else if (this._slot.name in this._slotChildActions) { + const displays = this._skin.getDisplays(this._slot.name); + if (displays === null ? this._slot.displayIndex === 0 : this._slot.displayIndex === displays.length) { + for (const action of this._slotChildActions[this._slot.name]) { + if (DragonBones.webAssembly) { + (armatureDisplay.actions as any).push_back(action); + } + else { + armatureDisplay.actions.push(action); + } + } + + delete this._slotChildActions[this._slot.name]; + } + } + break; + + case DisplayType.Mesh: + // const meshDisplay = display = BaseObject.borrowObject(MeshDisplayData); + const meshDisplay = display = DragonBones.webAssembly ? new Module["MeshDisplayData"]() as MeshDisplayData : BaseObject.borrowObject(MeshDisplayData); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.inheritAnimation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + + const shareName = ObjectDataParser._getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length > 0) { + const shareMesh = this._meshs[shareName]; + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } + else { + this._parseMesh(rawData, meshDisplay); + this._meshs[meshDisplay.name] = meshDisplay; + } + break; + + case DisplayType.BoundingBox: + const boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + // const boundingBoxDisplay = display = BaseObject.borrowObject(BoundingBoxDisplayData); + const boundingBoxDisplay = display = DragonBones.webAssembly ? new Module["BoundingBoxDisplayData"]() as BoundingBoxDisplayData : BaseObject.borrowObject(BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + + if (display !== null) { + display.parent = this._armature; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform, this._armature.scale); + } + } + + return display; + } + /** + * @private + */ + protected _parsePivot(rawData: any, display: ImageDisplayData): void { + if (ObjectDataParser.PIVOT in rawData) { + const rawPivot = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + } + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void { + const rawVertices = rawData[ObjectDataParser.VERTICES] as Array; + const rawUVs = rawData[ObjectDataParser.UVS] as Array; + const rawTriangles = rawData[ObjectDataParser.TRIANGLES] as Array; + const intArray = DragonBones.webAssembly ? this._intArrayJson : this._data.intArray as Array; + const floatArray = DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray as Array; + const vertexCount = Math.floor(rawVertices.length / 2); // uint + const triangleCount = Math.floor(rawTriangles.length / 3); // uint + const vertexOffset = floatArray.length; + const uvOffset = vertexOffset + vertexCount * 2; + + mesh.offset = intArray.length; + intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; + intArray[mesh.offset + BinaryOffset.MeshVertexCount] = vertexCount; + intArray[mesh.offset + BinaryOffset.MeshTriangleCount] = triangleCount; + intArray[mesh.offset + BinaryOffset.MeshFloatOffset] = vertexOffset; + for (let i = 0, l = triangleCount * 3; i < l; ++i) { + intArray[mesh.offset + BinaryOffset.MeshVertexIndices + i] = rawTriangles[i]; + } + + floatArray.length += vertexCount * 2 + vertexCount * 2; + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray[vertexOffset + i] = rawVertices[i]; + floatArray[uvOffset + i] = rawUVs[i]; + } + + if (ObjectDataParser.WEIGHTS in rawData) { + const rawWeights = rawData[ObjectDataParser.WEIGHTS] as Array; + const rawSlotPose = rawData[ObjectDataParser.SLOT_POSE] as Array; + const rawBonePoses = rawData[ObjectDataParser.BONE_POSE] as Array; + const weightBoneIndices = new Array(); + const weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + const floatOffset = floatArray.length; + // const weight = BaseObject.borrowObject(WeightData); + const weight = DragonBones.webAssembly ? new Module["WeightData"]() : BaseObject.borrowObject(WeightData); + + weight.count = (rawWeights.length - vertexCount) / 2; + weight.offset = intArray.length; + weight.bones.length = weightBoneCount; + weightBoneIndices.length = weightBoneCount; + intArray.length += 1 + 1 + weightBoneCount + vertexCount + weight.count; + intArray[weight.offset + BinaryOffset.WeigthFloatOffset] = floatOffset; + + for (let i = 0; i < weightBoneCount; ++i) { + const rawBoneIndex = rawBonePoses[i * 7]; // uint + const bone = this._rawBones[rawBoneIndex]; + weight.bones[i] = bone; + weightBoneIndices[i] = rawBoneIndex; + + if (DragonBones.webAssembly) { + for (let j = 0; j < (this._armature.sortedBones as any).size(); j++) { + if ((this._armature.sortedBones as any).get(j) === bone) { + intArray[weight.offset + BinaryOffset.WeigthBoneIndices + i] = j; + } + } + } + else { + intArray[weight.offset + BinaryOffset.WeigthBoneIndices + i] = this._armature.sortedBones.indexOf(bone); + } + } + + floatArray.length += weight.count * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + + for ( + let i = 0, iW = 0, iB = weight.offset + BinaryOffset.WeigthBoneIndices + weightBoneCount, iV = floatOffset; + i < vertexCount; + ++i + ) { + const iD = i * 2; + const vertexBoneCount = intArray[iB++] = rawWeights[iW++]; // uint + + let x = floatArray[vertexOffset + iD]; + let y = floatArray[vertexOffset + iD + 1]; + this._helpMatrixA.transformPoint(x, y, this._helpPoint); + x = this._helpPoint.x; + y = this._helpPoint.y; + + for (let j = 0; j < vertexBoneCount; ++j) { + const rawBoneIndex = rawWeights[iW++]; // uint + const bone = this._rawBones[rawBoneIndex]; + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray[iB++] = weight.bones.indexOf(bone); + floatArray[iV++] = rawWeights[iW++]; + floatArray[iV++] = this._helpPoint.x; + floatArray[iV++] = this._helpPoint.y; + } + } + + mesh.weight = weight; + + // + this._weightSlotPose[mesh.name] = rawSlotPose; + this._weightBonePoses[mesh.name] = rawBonePoses; + this._weightBoneIndices[mesh.name] = weightBoneIndices; + } + } + /** + * @private + */ + protected _parseBoundingBox(rawData: any): BoundingBoxData | null { + let boundingBox: BoundingBoxData | null = null; + let type = BoundingBoxType.Rectangle; + if (ObjectDataParser.SUB_TYPE in rawData && typeof rawData[ObjectDataParser.SUB_TYPE] === "string") { + type = ObjectDataParser._getBoundingBoxType(rawData[ObjectDataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.SUB_TYPE, type); + } + + switch (type) { + case BoundingBoxType.Rectangle: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = DragonBones.webAssembly ? new Module["RectangleBoundingBoxData"]() as RectangleBoundingBoxData : BaseObject.borrowObject(RectangleBoundingBoxData); + break; + + case BoundingBoxType.Ellipse: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = DragonBones.webAssembly ? new Module["EllipseBoundingBoxData"]() as EllipseBoundingBoxData : BaseObject.borrowObject(EllipseBoundingBoxData); + break; + + case BoundingBoxType.Polygon: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type === BoundingBoxType.Rectangle || boundingBox.type === BoundingBoxType.Ellipse) { + boundingBox.width = ObjectDataParser._getNumber(rawData, ObjectDataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0.0); + } + } + + return boundingBox; + } + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData { + const rawVertices = rawData[ObjectDataParser.VERTICES] as Array; + const floatArray = DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray as Array; + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + const polygonBoundingBox = DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() as PolygonBoundingBoxData : BaseObject.borrowObject(PolygonBoundingBoxData); + + polygonBoundingBox.offset = floatArray.length; + polygonBoundingBox.count = rawVertices.length; + polygonBoundingBox.vertices = floatArray; + floatArray.length += polygonBoundingBox.count; + + for (let i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + const iN = i + 1; + const x = rawVertices[i]; + const y = rawVertices[iN]; + floatArray[polygonBoundingBox.offset + i] = x; + floatArray[polygonBoundingBox.offset + iN] = 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; + } + } + } + + return polygonBoundingBox; + } + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData { + // const animation = BaseObject.borrowObject(AnimationData); + const animation = DragonBones.webAssembly ? new Module["AnimationData"]() as AnimationData : BaseObject.borrowObject(AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + if (DragonBones.webAssembly) { + animation.frameIntOffset = this._frameIntArrayJson.length; + animation.frameFloatOffset = this._frameFloatArrayJson.length; + animation.frameOffset = this._frameArrayJson.length; + } + else { + animation.frameIntOffset = this._data.frameIntArray.length; + animation.frameFloatOffset = this._data.frameFloatArray.length; + animation.frameOffset = this._data.frameArray.length; + } + + this._animation = animation; + + if (ObjectDataParser.FRAME in rawData) { + const rawFrames = rawData[ObjectDataParser.FRAME] as Array; + const keyFrameCount = rawFrames.length; + if (keyFrameCount > 0) { + for (let i = 0, frameStart = 0; i < keyFrameCount; ++i) { + const rawFrame = rawFrames[i]; + this._parseActionDataInFrame(rawFrame, frameStart, null, null); + frameStart += ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + } + } + } + + if (ObjectDataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline( + rawData[ObjectDataParser.Z_ORDER], TimelineType.ZOrder, + false, false, 0, + this._parseZOrderFrame + ); + } + + if (ObjectDataParser.BONE in rawData) { + const rawTimelines = rawData[ObjectDataParser.BONE] as Array; + for (const rawTimeline of rawTimelines) { + this._parseBoneTimeline(rawTimeline); + } + } + + if (ObjectDataParser.SLOT in rawData) { + const rawTimelines = rawData[ObjectDataParser.SLOT] as Array; + for (const rawTimeline of rawTimelines) { + this._parseSlotTimeline(rawTimeline); + } + } + + if (ObjectDataParser.FFD in rawData) { + const rawTimelines = rawData[ObjectDataParser.FFD] as Array; + for (const rawTimeline of rawTimelines) { + const slotName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.SLOT, ""); + const displayName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.NAME, ""); + const slot = this._armature.getSlot(slotName); + if (slot === null) { + continue; + } + + this._slot = slot; + this._mesh = this._meshs[displayName]; + + const timelineFFD = this._parseTimeline(rawTimeline, TimelineType.SlotFFD, false, true, 0, this._parseSlotFFDFrame); + if (timelineFFD !== null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + + this._slot = null as any; // + this._mesh = null as any; // + } + } + + if (this._actionFrames.length > 0) { + this._actionFrames.sort(this._sortActionFrame); + + // const timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData); + const timeline = this._animation.actionTimeline = DragonBones.webAssembly ? new Module["TimelineData"]() as TimelineData : BaseObject.borrowObject(TimelineData); + const timelineArray = DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray as Array; + const keyFrameCount = this._actionFrames.length; + timeline.type = TimelineType.Action; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + BinaryOffset.TimelineScale] = 100; + timelineArray[timeline.offset + BinaryOffset.TimelineOffset] = 0; + timelineArray[timeline.offset + BinaryOffset.TimelineKeyFrameCount] = keyFrameCount; + timelineArray[timeline.offset + BinaryOffset.TimelineFrameValueCount] = 0; + timelineArray[timeline.offset + BinaryOffset.TimelineFrameValueOffset] = 0; + + this._timeline = timeline; + + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + BinaryOffset.TimelineFrameOffset + 0] = this._parseCacheActionFrame(this._actionFrames[0]) - this._animation.frameOffset; + } + else { + const totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + const frameIndices = this._data.frameIndices; + if (DragonBones.webAssembly) { + timeline.frameIndicesOffset = (frameIndices as any).size(); + //(frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (let j = 0; j < totalFrameCount; ++j) { + (frameIndices as any).push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + + for ( + let i = 0, iK = 0, frameStart = 0, frameCount = 0; + i < totalFrameCount; + ++i + ) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + const frame = this._actionFrames[iK]; + frameStart = frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + + timelineArray[timeline.offset + BinaryOffset.TimelineFrameOffset + iK] = this._parseCacheActionFrame(frame) - this._animation.frameOffset; + iK++; + } + + if (DragonBones.webAssembly) { + (frameIndices as any).set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + + this._timeline = null as any; // + this._actionFrames.length = 0; + } + + this._animation = null as any; // + + return animation; + } + /** + * @private + */ + protected _parseTimeline( + rawData: any, type: TimelineType, + addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, + frameParser: (rawData: any, frameStart: number, frameCount: number) => number + ): TimelineData | null { + if (!(ObjectDataParser.FRAME in rawData)) { + return null; + } + + const rawFrames: Array = rawData[ObjectDataParser.FRAME]; + const keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + + const timelineArray = DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray as Array; + const frameIntArrayLength = DragonBones.webAssembly ? this._frameIntArrayJson.length : this._data.frameIntArray.length; + const frameFloatArrayLength = DragonBones.webAssembly ? this._frameFloatArrayJson.length : this._data.frameFloatArray.length; + // const timeline = BaseObject.borrowObject(TimelineData); + const timeline = DragonBones.webAssembly ? new Module["TimelineData"]() as TimelineData : BaseObject.borrowObject(TimelineData); + timeline.type = type; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + BinaryOffset.TimelineScale] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0) * 100); + timelineArray[timeline.offset + BinaryOffset.TimelineOffset] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0.0) * 100); + timelineArray[timeline.offset + BinaryOffset.TimelineKeyFrameCount] = keyFrameCount; + timelineArray[timeline.offset + BinaryOffset.TimelineFrameValueCount] = frameValueCount; + if (addIntOffset) { + timelineArray[timeline.offset + BinaryOffset.TimelineFrameValueOffset] = frameIntArrayLength - this._animation.frameIntOffset; + } + else if (addFloatOffset) { + timelineArray[timeline.offset + BinaryOffset.TimelineFrameValueOffset] = frameFloatArrayLength - this._animation.frameFloatOffset; + } + else { + timelineArray[timeline.offset + BinaryOffset.TimelineFrameValueOffset] = 0; + } + + this._timeline = timeline; + + if (keyFrameCount === 1) { // Only one frame. + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + BinaryOffset.TimelineFrameOffset + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + const frameIndices = this._data.frameIndices; + const totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + if (DragonBones.webAssembly) { + timeline.frameIndicesOffset = (frameIndices as any).size(); + // frameIndices.resize( frameIndices.size() + totalFrameCount); + for (let j = 0; j < totalFrameCount; ++j) { + (frameIndices as any).push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + + for ( + let i = 0, iK = 0, frameStart = 0, frameCount = 0; + i < totalFrameCount; + ++i + ) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + const rawFrame = rawFrames[iK]; + frameStart = i; + frameCount = ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + + timelineArray[timeline.offset + BinaryOffset.TimelineFrameOffset + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + + if (DragonBones.webAssembly) { + (frameIndices as any).set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + + this._timeline = null as any; // + + return timeline; + } + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): void { + const bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name) as any; + + const timeline = this._parseTimeline( + rawData, TimelineType.BoneAll, + false, true, 6, + this._parseBoneFrame + ); + if (timeline !== null) { + this._animation.addBoneTimeline(bone, timeline); + } + + this._bone = null as any; // + this._slot = null as any; // + } + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): void { + const slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (slot === null) { + return; + } + + this._slot = slot; + + const displayIndexTimeline = this._parseTimeline(rawData, TimelineType.SlotDisplay, false, false, 0, this._parseSlotDisplayIndexFrame); + if (displayIndexTimeline !== null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + + const colorTimeline = this._parseTimeline(rawData, TimelineType.SlotColor, true, false, 1, this._parseSlotColorFrame); + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + + this._slot = null as any; // + } + /** + * @private + */ + protected _parseFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number { + rawData; + frameCount; + + const frameOffset = frameArray.length; + frameArray.length += 1; + frameArray[frameOffset + BinaryOffset.FramePosition] = frameStart; + + return frameOffset; + } + /** + * @private + */ + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number { + const frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + + if (frameCount > 0) { + if (ObjectDataParser.CURVE in rawData) { + const sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[ObjectDataParser.CURVE], this._helpArray); + + frameArray.length += 1 + 1 + this._helpArray.length; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.Curve; + frameArray[frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount] = sampleCount; + for (let i = 0; i < sampleCount; ++i) { + frameArray[frameOffset + BinaryOffset.FrameCurveSamples + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + const noTween = -2.0; + let tweenEasing = noTween; + if (ObjectDataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + + if (tweenEasing === noTween) { + frameArray.length += 1; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.None; + } + else if (tweenEasing === 0.0) { + frameArray.length += 1; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.Line; + } + else if (tweenEasing < 0.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.QuadIn; + frameArray[frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.QuadOut; + frameArray[frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount] = Math.round(tweenEasing * 100.0); + } + else { + frameArray.length += 1 + 1; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.QuadInOut; + frameArray[frameOffset + BinaryOffset.FrameTweenEasingOrCurveSampleCount] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + frameArray.length += 1; + frameArray[frameOffset + BinaryOffset.FrameTweenType] = TweenType.None; + } + + return frameOffset; + } + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number { + const frameArray = DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray as Array; + const frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + + if (ObjectDataParser.Z_ORDER in rawData) { + const rawZOrder = rawData[ObjectDataParser.Z_ORDER] as Array; + if (rawZOrder.length > 0) { + const slotCount = this._armature.sortedSlots.length; + const unchanged = new Array(slotCount - rawZOrder.length / 2); + const zOrders = new Array(slotCount); + + for (let i = 0; i < slotCount; ++i) { + zOrders[i] = -1; + } + + let originalIndex = 0; + let unchangedIndex = 0; + for (let i = 0, l = rawZOrder.length; i < l; i += 2) { + const slotIndex = rawZOrder[i]; + const zOrderOffset = rawZOrder[i + 1]; + + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + + zOrders[originalIndex + zOrderOffset] = originalIndex++; + } + + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + + frameArray.length += 1 + slotCount; + frameArray[frameOffset + 1] = slotCount; + + let i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex]; + } + else { + frameArray[frameOffset + 2 + i] = zOrders[i]; + } + } + + return frameOffset; + } + } + + frameArray.length += 1; + frameArray[frameOffset + 1] = 0; + + return frameOffset; + } + /** + * @private + */ + protected _parseBoneFrame(rawData: any, frameStart: number, frameCount: number): number { + const frameFloatArray = DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray as Array; + const frameArray = DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray as Array; + const frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + + this._helpTransform.identity(); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], this._helpTransform, 1.0); + } + + // Modify rotation. + let rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevTweenRotate === 0) { + rotation = this._prevRotation + Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + + rotation = this._prevRotation + rotation - this._prevRotation + Transform.PI_D * this._prevTweenRotate; + } + } + + this._prevTweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + + let frameFloatOffset = frameFloatArray.length; + frameFloatArray.length += 6; + frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + frameFloatArray[frameFloatOffset++] = rotation; + frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + + return frameOffset; + } + /** + * @private + */ + protected _parseSlotDisplayIndexFrame(rawData: any, frameStart: number, frameCount: number): number { + const frameArray = DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray as Array; + const frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + + frameArray.length += 1; + frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + + return frameOffset; + } + /** + * @private + */ + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number { + const intArray = DragonBones.webAssembly ? this._intArrayJson : this._data.intArray as Array; + const frameIntArray = DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray as Array; + const frameArray = DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray as Array; + const frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + + let colorOffset = -1; + if (ObjectDataParser.COLOR in rawData) { + const rawColor = rawData[ObjectDataParser.COLOR]; + for (let k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + } + + colorOffset = this._defalultColorOffset; + } + + const frameIntOffset = frameIntArray.length; + frameIntArray.length += 1; + frameIntArray[frameIntOffset] = colorOffset; + + return frameOffset; + } + /** + * @private + */ + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number { + const intArray = DragonBones.webAssembly ? this._intArrayJson : this._data.intArray as Array; + const frameFloatArray = DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray as Array; + const frameArray = DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray as Array; + const frameFloatOffset = frameFloatArray.length; + const frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + const rawVertices = ObjectDataParser.VERTICES in rawData ? rawData[ObjectDataParser.VERTICES] as Array : null; + const offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); // uint + const vertexCount = intArray[this._mesh.offset + BinaryOffset.MeshVertexCount]; + + let x = 0.0; + let y = 0.0; + let iB = 0; + let iV = 0; + if (this._mesh.weight !== null) { + const rawSlotPose = this._weightSlotPose[this._mesh.name]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.length += this._mesh.weight.count * 2; + iB = this._mesh.weight.offset + BinaryOffset.WeigthBoneIndices + this._mesh.weight.bones.length; + } + else { + frameFloatArray.length += vertexCount * 2; + } + + for ( + let 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 (this._mesh.weight !== null) { // If mesh is skinned, transform point by bone bind pose. + const rawBonePoses = this._weightBonePoses[this._mesh.name]; + const weightBoneIndices = this._weightBoneIndices[this._mesh.name]; + const vertexBoneCount = intArray[iB++]; + + this._helpMatrixA.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + + for (let j = 0; j < vertexBoneCount; ++j) { + const boneIndex = intArray[iB++]; + const bone = this._mesh.weight.bones[boneIndex]; + const rawBoneIndex = this._rawBones.indexOf(bone); + + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + frameFloatArray[frameFloatOffset + i] = x; + frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + + if (frameStart === 0) { + const frameIntArray = DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray as Array; + const timelineArray = DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray as Array; + const frameIntOffset = frameIntArray.length; + frameIntArray.length += 1 + 1 + 1 + 1 + 1; + frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineMeshOffset] = this._mesh.offset; + frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineFFDCount] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineValueCount] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineValueOffset] = 0; + frameIntArray[frameIntOffset + BinaryOffset.FFDTimelineFloatOffset] = frameFloatOffset; + timelineArray[this._timeline.offset + BinaryOffset.TimelineFrameValueCount] = frameIntOffset - this._animation.frameIntOffset; + } + + return frameOffset; + } + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, type: ActionType, bone: BoneData | null, slot: SlotData | null): number { + let actionCount = 0; + + if (typeof rawData === "string") { + // const action = BaseObject.borrowObject(ActionData); + const action = DragonBones.webAssembly ? new Module["ActionData"]() as ActionData : BaseObject.borrowObject(ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + DragonBones.webAssembly ? (actions as any).push_back(action) : actions.push(action); + actionCount++; + } + else if (rawData instanceof Array) { + for (const rawAction of rawData) { + // const action = BaseObject.borrowObject(ActionData); + const action = DragonBones.webAssembly ? new Module["ActionData"]() as ActionData : BaseObject.borrowObject(ActionData); + if (ObjectDataParser.GOTO_AND_PLAY in rawAction) { + action.type = ActionType.Play; + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } + else { + if (ObjectDataParser.TYPE in rawAction && typeof rawAction[ObjectDataParser.TYPE] === "string") { + action.type = ObjectDataParser._getActionType(rawAction[ObjectDataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, ObjectDataParser.TYPE, type); + } + + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.NAME, ""); + } + + if (ObjectDataParser.BONE in rawAction) { + const boneName = ObjectDataParser._getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + + if (ObjectDataParser.SLOT in rawAction) { + const slotName = ObjectDataParser._getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + + if (ObjectDataParser.INTS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = DragonBones.webAssembly ? new Module["UserData"]() as UserData : BaseObject.borrowObject(UserData); + } + + const rawInts = rawAction[ObjectDataParser.INTS] as Array; + for (const rawValue of rawInts) { + DragonBones.webAssembly ? (action.data.ints as any).push_back(rawValue) : action.data.ints.push(rawValue); + } + } + + if (ObjectDataParser.FLOATS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = DragonBones.webAssembly ? new Module["UserData"]() as UserData : BaseObject.borrowObject(UserData); + } + + const rawFloats = rawAction[ObjectDataParser.FLOATS] as Array; + for (const rawValue of rawFloats) { + DragonBones.webAssembly ? (action.data.floats as any).push_back(rawValue) : action.data.floats.push(rawValue); + } + } + + if (ObjectDataParser.STRINGS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = DragonBones.webAssembly ? new Module["UserData"]() as UserData : BaseObject.borrowObject(UserData); + } + + const rawStrings = rawAction[ObjectDataParser.STRINGS] as Array; + for (const rawValue of rawStrings) { + DragonBones.webAssembly ? (action.data.strings as any).push_back(rawValue) : action.data.strings.push(rawValue); + } + } + + DragonBones.webAssembly ? (actions as any).push_back(action) : actions.push(action); + actionCount++; + } + } + + return actionCount; + } + /** + * @private + */ + protected _parseTransform(rawData: any, transform: Transform, scale: number): void { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0.0) * scale; + + if (ObjectDataParser.ROTATE in rawData || ObjectDataParser.SKEW in rawData) { + transform.rotation = Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.ROTATE, 0.0) * Transform.DEG_RAD); + transform.skew = Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW, 0.0) * Transform.DEG_RAD); + } + else if (ObjectDataParser.SKEW_X in rawData || ObjectDataParser.SKEW_Y in rawData) { + transform.rotation = Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0.0) * Transform.DEG_RAD); + transform.skew = Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0.0) * Transform.DEG_RAD) - transform.rotation; + } + + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1.0); + } + /** + * @private + */ + protected _parseColorTransform(rawData: any, color: ColorTransform): void { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + } + /** + * @private + */ + protected _parseArray(rawData: any): void { + rawData; + + if (DragonBones.webAssembly) { + return; + } + + this._data.intArray = []; + this._data.floatArray = []; + this._data.frameIntArray = []; + this._data.frameFloatArray = []; + this._data.frameArray = []; + this._data.timelineArray = []; + } + /** + * @private + */ + protected _parseWASMArray(): void { + let intArrayBuf = Module._malloc(this._intArrayJson.length * 2); + this._intArrayBuffer = new Int16Array(Module.HEAP16.buffer, intArrayBuf, this._intArrayJson.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + for (let i1 = 0; i1 < this._intArrayJson.length; ++i1) { + this._intArrayBuffer[i1] = this._intArrayJson[i1]; + } + + var floatArrayBuf = Module._malloc(this._floatArrayJson.length * 4); + // Module.HEAPF32.set(this._floatArrayJson, floatArrayBuf); + this._floatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, this._floatArrayJson.length); + for (let i2 = 0; i2 < this._floatArrayJson.length; ++i2) { + this._floatArrayBuffer[i2] = this._floatArrayJson[i2]; + } + + var frameIntArrayBuf = Module._malloc(this._frameIntArrayJson.length * 2); + // Module.HEAP16.set(this._frameIntArrayJson, frameIntArrayBuf); + this._frameIntArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, this._frameIntArrayJson.length); + for (let i3 = 0; i3 < this._frameIntArrayJson.length; ++i3) { + this._frameIntArrayBuffer[i3] = this._frameIntArrayJson[i3]; + } + + var frameFloatArrayBuf = Module._malloc(this._frameFloatArrayJson.length * 4); + // Module.HEAPF32.set(this._frameFloatArrayJson, frameFloatArrayBuf); + this._frameFloatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, this._frameFloatArrayJson.length); + for (let i4 = 0; i4 < this._frameFloatArrayJson.length; ++i4) { + this._frameFloatArrayBuffer[i4] = this._frameFloatArrayJson[i4]; + } + + var frameArrayBuf = Module._malloc(this._frameArrayJson.length * 2); + // Module.HEAP16.set(this._frameArrayJson, frameArrayBuf); + this._frameArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, this._frameArrayJson.length); + for (let i5 = 0; i5 < this._frameArrayJson.length; ++i5) { + this._frameArrayBuffer[i5] = this._frameArrayJson[i5]; + } + + var timelineArrayBuf = Module._malloc(this._timelineArrayJson.length * 2); + // Module.HEAPU16.set(this._timelineArrayJson, timelineArrayBuf); + this._timelineArrayBuffer = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, this._timelineArrayJson.length); + for (let i6 = 0; i6 < this._timelineArrayJson.length; ++i6) { + this._timelineArrayBuffer[i6] = this._timelineArrayJson[i6]; + } + + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], + [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + + } + + /** + * @inheritDoc + */ + public parseDragonBonesData(rawData: any, scale: number = 1): DragonBonesData | null { + console.assert(rawData !== null && rawData !== undefined); + + const version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, ""); + const compatibleVersion = ObjectDataParser._getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + + if ( + ObjectDataParser.DATA_VERSIONS.indexOf(version) >= 0 || + ObjectDataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0 + ) { + // const data = BaseObject.borrowObject(DragonBonesData); + const data = DragonBones.webAssembly ? new Module["DragonBonesData"]() as DragonBonesData : BaseObject.borrowObject(DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24); + + if (data.frameRate === 0) { // Data error. + data.frameRate = 24; + } + + if (ObjectDataParser.ARMATURE in rawData) { + this._defalultColorOffset = -1; + this._data = data; + + this._parseArray(rawData); + + const rawArmatures = rawData[ObjectDataParser.ARMATURE] as Array; + for (const rawArmature of rawArmatures) { + data.addArmature(this._parseArmature(rawArmature, scale)); + } + if (this._intArrayJson.length > 0) { + this._parseWASMArray(); + } + + this._data = null as any; + } + + this._rawTextureAtlasIndex = 0; + if (ObjectDataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[ObjectDataParser.TEXTURE_ATLAS]; + } + else { + this._rawTextureAtlases = null; + } + + return data; + } + else { + console.assert(false, "Nonsupport data version."); + } + + return null; + } + /** + * @inheritDoc + */ + public parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number = 0.0): boolean { + console.assert(rawData !== undefined); + + if (rawData === null) { + if (this._rawTextureAtlases === null) { + return false; + } + + const 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, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + + if (scale > 0.0) { // Use params scale. + textureAtlasData.scale = scale; + } + else { // Use data scale. + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + + scale = 1.0 / scale; // + + if (ObjectDataParser.SUB_TEXTURE in rawData) { + const rawTextures = rawData[ObjectDataParser.SUB_TEXTURE] as Array; + for (let i = 0, l = rawTextures.length; i < l; ++i) { + const rawTexture = rawTextures[i]; + const textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.X, 0.0) * scale; + textureData.region.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.Y, 0.0) * scale; + textureData.region.width = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.WIDTH, 0.0) * scale; + textureData.region.height = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.HEIGHT, 0.0) * scale; + + const frameWidth = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_WIDTH, -1.0); + const frameHeight = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = DragonBones.webAssembly ? Module["TextureData"].createRectangle() as Rectangle : TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_X, 0.0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_Y, 0.0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + + textureAtlasData.addTexture(textureData); + } + } + + return true; + } + + /** + * @private + */ + private static _objectDataParserInstance: ObjectDataParser = null as any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + public static getInstance(): ObjectDataParser { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + + return ObjectDataParser._objectDataParserInstance; + } + } + class ActionFrame { + public frameStart: number = 0; + public readonly actions: Array = []; + } +} diff --git a/reference/DragonBones/tsconfig.json b/reference/DragonBones/tsconfig.json new file mode 100644 index 0000000..7ef7244 --- /dev/null +++ b/reference/DragonBones/tsconfig.json @@ -0,0 +1,71 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": false, + "declaration": true, + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "outFile": "out/dragonBones.js", + "lib": [ + "es5", + "dom", + "es2015.promise" + ] + }, + "exclude": [ + "node_modules", + "out" + ], + "files": [ + "./src/dragonBones/modules.ts", + + "./src/dragonBones/core/DragonBones.ts", + "./src/dragonBones/core/BaseObject.ts", + + "./src/dragonBones/geom/Matrix.ts", + "./src/dragonBones/geom/Transform.ts", + "./src/dragonBones/geom/ColorTransform.ts", + "./src/dragonBones/geom/Point.ts", + "./src/dragonBones/geom/Rectangle.ts", + + "./src/dragonBones/model/UserData.ts", + "./src/dragonBones/model/DragonBonesData.ts", + "./src/dragonBones/model/ArmatureData.ts", + "./src/dragonBones/model/ConstraintData.ts", + "./src/dragonBones/model/DisplayData.ts", + "./src/dragonBones/model/BoundingBoxData.ts", + "./src/dragonBones/model/AnimationData.ts", + "./src/dragonBones/model/AnimationConfig.ts", + "./src/dragonBones/model/TextureAtlasData.ts", + + "./src/dragonBones/armature/IArmatureProxy.ts", + "./src/dragonBones/armature/Armature.ts", + "./src/dragonBones/armature/TransformObject.ts", + "./src/dragonBones/armature/Bone.ts", + "./src/dragonBones/armature/Slot.ts", + "./src/dragonBones/armature/Constraint.ts", + + "./src/dragonBones/animation/IAnimatable.ts", + "./src/dragonBones/animation/WorldClock.ts", + "./src/dragonBones/animation/Animation.ts", + "./src/dragonBones/animation/AnimationState.ts", + "./src/dragonBones/animation/BaseTimelineState.ts", + "./src/dragonBones/animation/TimelineState.ts", + + "./src/dragonBones/event/EventObject.ts", + "./src/dragonBones/event/IEventDispatcher.ts", + + "./src/dragonBones/parser/DataParser.ts", + "./src/dragonBones/parser/ObjectDataParser.ts", + "./src/dragonBones/parser/BinaryDataParser.ts", + + "./src/dragonBones/factory/BaseFactory.ts" + ] +} \ No newline at end of file diff --git a/reference/DragonBones/tslint.json b/reference/DragonBones/tslint.json new file mode 100644 index 0000000..eeb58d1 --- /dev/null +++ b/reference/DragonBones/tslint.json @@ -0,0 +1,15 @@ +{ + "rules": { + "no-unused-expression": true, + "no-unreachable": true, + "no-duplicate-variable": true, + "no-duplicate-key": true, + "no-unused-variable": true, + "curly": false, + "class-name": true, + "triple-equals": true, + "semicolon": [ + true + ] + } +} \ No newline at end of file diff --git a/reference/Egret/4.x/README.md b/reference/Egret/4.x/README.md new file mode 100644 index 0000000..161b092 --- /dev/null +++ b/reference/Egret/4.x/README.md @@ -0,0 +1,8 @@ +## How to build +``` +$npm install +$npm run build +``` + +## Egret declaration +[egret.d.ts](https://github.com/egret-labs/egret-core/blob/master/build/egret/egret.d.ts) \ No newline at end of file diff --git a/reference/Egret/4.x/out/dragonBones.d.ts b/reference/Egret/4.x/out/dragonBones.d.ts new file mode 100644 index 0000000..d663a30 --- /dev/null +++ b/reference/Egret/4.x/out/dragonBones.d.ts @@ -0,0 +1,5313 @@ +declare const Module: any; +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + FFDTimelineMeshOffset = 0, + FFDTimelineFFDCount = 1, + FFDTimelineValueCount = 2, + FFDTimelineValueOffset = 3, + FFDTimelineFloatOffset = 4, + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * @language zh_CN + * 包围盒类型。 + * @version DragonBones 5.0 + */ + 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, + BoneT = 11, + BoneR = 12, + BoneS = 13, + BoneX = 14, + BoneY = 15, + BoneRotate = 16, + BoneSkew = 17, + BoneScaleX = 18, + BoneScaleY = 19, + SlotVisible = 23, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * @private + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * @language zh_CN + * 动画混合的淡出方式。 + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + None = 0, + /** + * 淡出同层的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer = 1, + /** + * 淡出同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup = 2, + /** + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * 淡出所有动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + All = 4, + /** + * 不替换同名动画。 + * @version DragonBones 5.1 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + static readonly VERSION: string; + 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 namespace 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); + /** + * @private + */ + static toString(): string; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * 对象的唯一标识。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +declare namespace dragonBones { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * 转换为单位矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: 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; + constructor( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x?: number, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y?: number, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew?: number, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation?: number, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX?: number, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fromMatrix(matrix: Matrix): Transform; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + toMatrix(matrix: Matrix): Transform; + } +} +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; + } +} +declare namespace dragonBones { + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * 自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * 获取自定义字符串。 + * @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; + } +} +declare namespace dragonBones { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly frameIndices: Array; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatures: Map; + /** + * @private + */ + intArray: Array | Int16Array; + /** + * @private + */ + floatArray: Array | Float32Array; + /** + * @private + */ + frameIntArray: Array | Int16Array; + /** + * @private + */ + frameFloatArray: Array | Float32Array; + /** + * @private + */ + frameArray: Array | Int16Array; + /** + * @private + */ + timelineArray: Array | Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addArmature(value: ArmatureData): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + /** + * @private + */ + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * 所有动画数据名称。 + * @see #armatures + * @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; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly bones: Map; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly slots: Map; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly skins: Map; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animations: Map; + /** + * 获取默认皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * 获取默认动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的龙骨数据。 + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parent: DragonBonesData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + sortBones(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @private + */ + addBone(value: BoneData): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + length: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + readonly constraints: Array; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static createColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + target: BoneData; + bone: BoneData; + root: BoneData | null; + protected _onClear(): void; + } + /** + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: ArmatureData; + 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 + */ + class MeshDisplayData extends ImageDisplayData { + static toString(): string; + inheritAnimation: boolean; + offset: number; + weight: WeightData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * 边界框颜色。 + * @version DragonBones 5.0 + * @language zh_CN + */ + color: number; + /** + * 边界框宽。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + width: number; + /** + * 边界框高。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * 是否包含点。 + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * 是否与线段相交。 + * @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; + } + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 多边形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array | Float32Array, offset: number, count: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + count: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + vertices: Array | Float32Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } +} +declare namespace dragonBones { + /** + * 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + frameIntOffset: number; + /** + * @private + */ + frameFloatOffset: number; + /** + * @private + */ + frameOffset: number; + /** + * 持续的帧数。 ([1~N]) + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * 淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimeline(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * 是否暂停淡出的动画。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeOut: boolean; + /** + * 淡出模式。 + * @default dragonBones.AnimationFadeOutMode.All + * @see dragonBones.AnimationFadeOutMode + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * 淡出缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTweenType: TweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTime: number; + /** + * 否能触发行为。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 是否以增加的方式混合。 + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeIn: boolean; + /** + * 是否将没有动画的对象重置为初始值。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 淡入缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTweenType: TweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + playTimes: number; + /** + * 混合图层,图层高会优先获取混合权重。 + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * 开始时间。 (以秒为单位) + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * 混合权重。 + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * 动画状态名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * 动画数据名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + clear(): void; + copyFrom(value: AnimationConfig): void; + containsBoneMask(name: string): boolean; + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * 贴图集缩放系数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scale: number; + /** + * 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + abstract createTexture(): TextureData; + /** + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: 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; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架代理接口。 + * @version DragonBones 5.0 + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + init(armature: Armature): void; + /** + * @private + */ + clear(): void; + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + dispose(disposeProxy: boolean): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @language zh_CN + * 获取骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + readonly armature: Armature; + /** + * @language zh_CN + * 获取动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + readonly animation: Animation; + } +} +declare namespace dragonBones { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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); + /** + * 是否继承父骨架的动画状态。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + debugDraw: boolean; + /** + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + */ + armatureData: ArmatureData; + /** + * 用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + private _debugDraw; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + /** + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlotDisplay?: boolean): void; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string | null): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + flipX: boolean; + flipY: boolean; + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * @pivate + */ + readonly eventDispatcher: IEventDispatcher; + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + replaceTexture(texture: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + hasEventListener(type: EventStringType): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + enableAnimationCache(frameRate: number): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + } +} +declare namespace dragonBones { + /** + * 基础变换对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * 对象的名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + */ + origin: Transform; + /** + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * @private + */ + updateGlobalTransform(): void; + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +declare namespace dragonBones { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * @private + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + readonly constraints: Array; + /** + * @readonly + */ + boneData: BoneData; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + /** + * @internal + * @private + */ + _blendDirty: boolean; + private _localDirty; + private _visible; + private _cachedFrameIndex; + /** + * @internal + * @private + */ + _blendLayer: number; + /** + * @internal + * @private + */ + _blendLeftWeight: number; + /** + * @internal + * @private + */ + _blendLayerWeight: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(isCache); + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * @internal + * @private + */ + addConstraint(constraint: Constraint): void; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(child: TransformObject): boolean; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + readonly length: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + readonly slot: Slot | null; + } +} +declare namespace dragonBones { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 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; + /** + * @readonly + */ + slotData: SlotData; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + _colorDirty: boolean; + /** + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @private + */ + readonly _ffdVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @internal + * @private + */ + _rawDisplayDatas: Array; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @private + */ + init(slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + * @internal + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + target: Bone; + bone: Bone; + root: Bone | null; + protected _onClear(): void; + abstract update(): void; + } + /** + * @private + * @internal + */ + class IKConstraint extends Constraint { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + update(): void; + } +} +declare namespace dragonBones { + /** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * 更新时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 当前所属的 WordClock 实例。 + * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * 添加 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * 移除 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _animationDirty; + /** + * @internal + * @private + */ + _timelineDirty: boolean; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * 清除所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 上一个正在播放的动画状态名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationList: Array; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 是否以增加的方式混合。 + * @version DragonBones 3.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否能触发行为。 + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 混合图层。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + layer: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 混合权重。 + * @version DragonBones 3.0 + * @language zh_CN + */ + weight: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * @version DragonBones 3.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * 动画名称。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + name: string; + /** + * 混合组。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + group: string; + /** + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + animationData: AnimationData; + private _timelineDirty; + /** + * @internal + * @private + * xx: Play Enabled, Fade Play Enabled + */ + _playheadState: number; + /** + * @internal + * @private + * -1: Fade in, 0: Fade complete, 1: Fade out; + */ + _fadeState: number; + /** + * @internal + * @private + * -1: Fade start, 0: Fading, 1: Fade complete; + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + private _weightResult; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _slotTimelines; + private readonly _bonePoses; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @private + */ + protected _onClear(): void; + private _isDisabled(slot); + private _advanceFadeTime(passedTime); + private _blendBoneTimline(timeline); + /** + * @private + * @internal + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @private + * @internal + */ + updateTimelines(): void; + /** + * @private + * @internal + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + readonly clip: AnimationData; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class SlotDislayIndexTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _ffdCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } +} +declare namespace dragonBones { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + time: number; + /** + * 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * 发出事件的骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * 发出事件的骨骼。 + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * 发出事件的插槽。 + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * 发出事件的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * 自定义数据 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * 事件接口。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } +} +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: 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 BONE: string; + protected static readonly IK: string; + protected static readonly SLOT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly VISIBLE_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 CANVAS: 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 SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_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_FFD: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: 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_TYPE: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: 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_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 GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + private _intArrayJson; + private _floatArrayJson; + private _frameIntArrayJson; + private _frameFloatArrayJson; + private _frameArrayJson; + private _timelineArrayJson; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + 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 _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defalultColorOffset; + private _prevTweenRotate; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _weightBoneIndices; + private readonly _cacheBones; + private readonly _meshs; + private readonly _slotChildActions; + /** + * @private + */ + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + /** + * @private + */ + private _samplingEasingCurve(curve, samples); + private _sortActionFrame(a, b); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + private _parseCacheActionFrame(frame); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIKConstraint(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData | null; + /** + * @private + */ + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseTimeline(rawData: any, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): void; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): void; + /** + * @private + */ + protected _parseFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseBoneFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotDisplayIndexFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, type: ActionType, bone: BoneData | null, slot: SlotData | null): number; + /** + * @private + */ + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + /** + * @private + */ + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @private + */ + protected _parseWASMArray(): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + /** + * @private + */ + private static _objectDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binary; + private _binaryOffset; + private _intArray; + private _floatArray; + private _frameIntArray; + private _frameFloatArray; + private _frameArray; + private _timelineArray; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @private + */ + private static _binaryDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): BinaryDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * 清除所有的数据。 + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): Armature | null; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string | null, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): void; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): void; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string | null, fromDragonBonesDataName?: string | null, replaceOriginalAnimation?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} +declare namespace dragonBones { + /** + * Egret 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretTextureAtlasData extends TextureAtlasData { + static toString(): string; + private _renderTexture; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + createTexture(): TextureData; + /** + * Egret 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + renderTexture: egret.Texture | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + dispose(): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + readonly texture: egret.Texture | null; + } + /** + * @private + */ + class EgretTextureData extends TextureData { + static toString(): string; + renderTexture: egret.Texture | null; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * Egret 事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EgretEvent extends egret.Event { + /** + * 事件对象。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventObject: EventObject; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + readonly animationName: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#armature + */ + readonly armature: Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#bone + */ + readonly bone: Bone | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#slot + */ + readonly slot: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + readonly animationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + readonly frameLabel: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + readonly sound: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationName + */ + readonly movementID: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.START + */ + static START: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + static LOOP_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.COMPLETE + */ + static COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN + */ + static FADE_IN: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + static FADE_IN_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT + */ + static FADE_OUT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + static FADE_OUT_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static ANIMATION_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static BONE_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static MOVEMENT_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND: string; + } + /** + * @inheritDoc + */ + class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureProxy { + private static _cleanBeforeRender(); + /** + * @internal + * @private + */ + _batchEnabled: boolean; + private _disposeProxy; + protected _armature: Armature; + private _debugDrawer; + /** + * @inheritDoc + */ + init(armature: Armature): void; + /** + * @inheritDoc + */ + clear(): void; + /** + * @inheritDoc + */ + dispose(disposeProxy?: boolean): void; + /** + * @inheritDoc + */ + debugUpdate(isEnabled: boolean): void; + /** + * @inheritDoc + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * @inheritDoc + */ + hasEvent(type: EventStringType): boolean; + /** + * @inheritDoc + */ + addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * @inheritDoc + */ + removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * 关闭批次渲染。(批次渲染处于性能考虑,不会更新渲染对象的边界属性,这样无法正确获得渲染对象的绘制区域,如果需要使用这些属性,可以关闭批次渲染) + * @version DragonBones 5.1 + * @language zh_CN + */ + disableBatch(): void; + /** + * @inheritDoc + */ + readonly armature: Armature; + /** + * @inheritDoc + */ + readonly animation: Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + advanceTimeBySelf(on: boolean): void; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature + */ + type FastArmature = Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Bone + */ + type FastBone = Bone; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Slot + */ + type FastSlot = Slot; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Animation + */ + type FastAnimation = Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.AnimationState + */ + type FastAnimationState = AnimationState; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class Event extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class ArmatureEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class AnimationEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class FrameEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class SoundEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFacory#parseTextureAtlasData() + */ + class EgretTextureAtlas extends EgretTextureAtlasData { + /** + * @private + */ + static toString(): string; + constructor(texture: egret.Texture, rawData: any, scale?: number); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + class EgretSheetAtlas extends EgretTextureAtlas { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + class SoundEventManager { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + static getInstance(): EgretArmatureDisplay; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + class AnimationCacheManager { + constructor(); + } +} +declare namespace dragonBones { + /** + * Egret 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretSlot extends Slot { + static toString(): string; + /** + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 + * @language zh_CN + */ + transformUpdateEnabled: boolean; + private _armatureDisplay; + private _renderDisplay; + private _colorFilter; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected _initDisplay(value: any): void; + /** + * @private + */ + protected _disposeDisplay(value: any): void; + /** + * @private + */ + protected _onUpdateDisplay(): void; + /** + * @private + */ + protected _addDisplay(): void; + /** + * @private + */ + protected _replaceDisplay(value: any): void; + /** + * @private + */ + protected _removeDisplay(): void; + /** + * @private + */ + protected _updateZOrder(): void; + /** + * @internal + * @private + */ + _updateVisible(): void; + /** + * @private + */ + protected _updateBlendMode(): void; + /** + * @private + */ + protected _updateColor(): void; + /** + * @private + */ + protected _updateFrame(): void; + /** + * @private + */ + protected _updateMesh(): void; + /** + * @private + */ + protected _updateTransform(isSkinnedMesh: boolean): void; + } +} +declare namespace dragonBones { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretFactory extends BaseFactory { + private static _dragonBonesInstance; + private static _factory; + private static _clockHandler(time); + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + static readonly factory: EgretFactory; + /** + * @inheritDoc + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: EgretTextureAtlasData | null, textureAtlas: egret.Texture | null): EgretTextureAtlasData; + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + buildArmatureDisplay(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): EgretArmatureDisplay | null; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureDisplay(textureName: string, textureAtlasName?: string | null): egret.Bitmap | null; + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly soundEventManager: EgretArmatureDisplay; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName?: string | null): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getDragonBonesData() + */ + getSkeletonData(dragonBonesName: string): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + removeSkeletonData(dragonBonesName: string): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addTextureAtlasData() + */ + addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName?: string | null): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getTextureAtlasData() + */ + getTextureAtlas(dragonBonesName: string): TextureAtlasData[] | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + removeTextureAtlas(dragonBonesName: string): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#buildArmature() + */ + buildFastArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null): FastArmature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#clear() + */ + dispose(): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager() + */ + readonly soundEventManater: EgretArmatureDisplay; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 是否包含指定名称的动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function hasMovieGroup(groupName: string): boolean; + /** + * @language zh_CN + * 添加动画组。 + * @param groupData 动画二进制数据。 + * @param textureAtlas 贴图集或贴图集列表。 + * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 + * @version DragonBones 4.7 + */ + function addMovieGroup(groupData: ArrayBuffer, textureAtlas: egret.Texture | egret.Texture[], groupName?: string | null): void; + /** + * @language zh_CN + * 移除动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function removeMovieGroup(groupName: string): void; + /** + * @language zh_CN + * 移除所有的动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function removeAllMovieGroup(): void; + /** + * @language zh_CN + * 创建一个动画。 + * @param movieName 动画的名称。 + * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 + * @version DragonBones 4.7 + */ + function buildMovie(movieName: string, groupName?: string | null): Movie | null; + /** + * @language zh_CN + * 获取指定动画组内包含的所有动画名称。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function getMovieNames(groupName: string): string[] | null; + /** + * @language zh_CN + * 动画事件。 + * @version DragonBones 4.7 + */ + class MovieEvent extends egret.Event { + /** + * @language zh_CN + * 动画剪辑开始播放。 + * @version DragonBones 4.7 + */ + static START: string; + /** + * @language zh_CN + * 动画剪辑循环播放一次完成。 + * @version DragonBones 4.7 + */ + static LOOP_COMPLETE: string; + /** + * @language zh_CN + * 动画剪辑播放完成。 + * @version DragonBones 4.7 + */ + static COMPLETE: string; + /** + * @language zh_CN + * 动画剪辑帧事件。 + * @version DragonBones 4.7 + */ + static FRAME_EVENT: string; + /** + * @language zh_CN + * 动画剪辑声音事件。 + * @version DragonBones 4.7 + */ + static SOUND_EVENT: string; + /** + * @language zh_CN + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.7 + */ + name: string; + /** + * @language zh_CN + * 发出事件的插槽名称。 + * @version DragonBones 4.7 + */ + slotName: string; + /** + * @language zh_CN + * 发出事件的动画剪辑名称。 + * @version DragonBones 4.7 + */ + clipName: string; + /** + * @language zh_CN + * 发出事件的动画。 + * @version DragonBones 4.7 + */ + movie: Movie; + /** + * @private + */ + constructor(type: string); + /** + * @private + */ + readonly armature: any; + /** + * @private + */ + readonly bone: any; + /** + * @private + */ + readonly animationState: any; + /** + * @private + */ + readonly frameLabel: any; + /** + * @private + */ + readonly movementID: any; + } + /** + * @language zh_CN + * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 + * @see dragonBones.buildMovie + * @version DragonBones 4.7 + */ + class Movie extends egret.DisplayObjectContainer implements IAnimatable { + private static _cleanBeforeRender(); + /** + * @language zh_CN + * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 4.7 + */ + timeScale: number; + /** + * @language zh_CN + * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * (当再次播放其他动画剪辑时,此值将被重置为 1) + * @default 1 + * @version DragonBones 4.7 + */ + clipTimeScale: number; + private _batchEnabled; + private _isLockDispose; + private _isDelayDispose; + private _isStarted; + private _isPlaying; + private _isReversing; + private _isCompleted; + private _playTimes; + private _time; + private _currentTime; + private _currentPlayTimes; + private _cacheFrameIndex; + private _frameSize; + private _cacheRectangle; + private _clock; + private _groupConfig; + private _config; + private _clipConfig; + private _currentFrameConfig; + private _clipArray; + private _clipNames; + private _slots; + private _childMovies; + /** + * @internal + * @private + */ + constructor(createMovieHelper: any); + private _configToEvent(config, event); + private _onCrossFrame(frameConfig); + private _updateSlotBlendMode(slot); + private _updateSlotColor(slot, aM, rM, gM, bM, aO, rO, gO, bO); + private _updateSlotDisplay(slot); + private _getSlot(name); + /** + * @inheritDoc + */ + $render(): void; + /** + * @inheritDoc + */ + $measureContentBounds(bounds: egret.Rectangle): void; + /** + * @inheritDoc + */ + $doAddChild(child: egret.DisplayObject, index: number, notifyListeners?: boolean): egret.DisplayObject; + /** + * @inheritDoc + */ + $doRemoveChild(index: number, notifyListeners?: boolean): egret.DisplayObject; + /** + * 释放动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @inheritDoc + */ + advanceTime(passedTime: number): void; + /** + * 播放动画剪辑。 + * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 + * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 4.7 + * @language zh_CN + */ + play(clipName?: string | null, playTimes?: number): void; + /** + * 暂停播放动画。 + * @version DragonBones 4.7 + * @language zh_CN + */ + stop(): void; + /** + * 从指定时间播放动画。 + * @param clipName 动画剪辑的名称。 + * @param time 指定时间。(以秒为单位) + * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 5.0 + * @language zh_CN + */ + gotoAndPlay(clipName: string | null | undefined, time: number, playTimes?: number): void; + /** + * 将动画停止到指定时间。 + * @param clipName 动画剪辑的名称。 + * @param time 指定时间。(以秒为单位) + * @version DragonBones 5.0 + * @language zh_CN + */ + gotoAndStop(clipName: string | null | undefined, time: number): void; + /** + * 是否包含指定动画剪辑。 + * @param clipName 动画剪辑的名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + hasClip(clipName: string): boolean; + /** + * 动画剪辑是否处正在播放。 + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 动画剪辑是否均播放完毕。 + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly isComplete: boolean; + /** + * 当前动画剪辑的播放时间。 (以秒为单位) + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly currentTime: number; + /** + * 当前动画剪辑的总时间。 (以秒为单位) + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly totalTime: number; + /** + * 当前动画剪辑的播放次数。 + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly playTimes: number; + readonly groupName: string; + /** + * 正在播放的动画剪辑名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly clipName: string; + /** + * 所有动画剪辑的名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + readonly clipNames: string[]; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Movie#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Movie#timescale + * @see dragonBones.Movie#stop() + */ + advanceTimeBySelf(on: boolean): void; + /** + * @private + */ + readonly display: any; + /** + * @private + */ + readonly animation: any; + /** + * @private + */ + readonly armature: any; + /** + * @private + */ + getAnimation(): any; + /** + * @private + */ + getArmature(): any; + /** + * @private + */ + getDisplay(): any; + /** + * @private + */ + hasAnimation(name: string): boolean; + /** + * @private + */ + invalidUpdate(...args: any[]): void; + /** + * @private + */ + readonly lastAnimationName: string; + /** + * @private + */ + readonly animationNames: string[]; + /** + * @private + */ + readonly animationList: string[]; + } +} diff --git a/reference/Egret/4.x/out/dragonBones.js b/reference/Egret/4.x/out/dragonBones.js new file mode 100644 index 0000000..ce1ef9d --- /dev/null +++ b/reference/Egret/4.x/out/dragonBones.js @@ -0,0 +1,13179 @@ +"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 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; + } + 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; + armature.eventDispatcher._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(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.yDown = true; + DragonBones.debug = false; + DragonBones.debugDraw = false; + DragonBones.webAssembly = false; + DragonBones.VERSION = "5.1.0"; + return DragonBones; + }()); + dragonBones.DragonBones = DragonBones; + if (!console.warn) { + console.warn = function () { }; + } + if (!console.assert) { + console.assert = function () { }; + } +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var BaseObject = (function () { + function BaseObject() { + /** + * 对象的唯一标识。 + * @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._defaultMaxCount : BaseObject._maxCountMap[classType]; + var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.push(object); + } + else { + console.assert(false, "The object is already in the pool."); + } + } + else { + } + }; + /** + * @private + */ + BaseObject.toString = function () { + throw new Error(); + }; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @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) { + if (classType in BaseObject._maxCountMap) { + continue; + } + var pool = BaseObject._poolsMap[classType]; + if (pool.length > maxCount) { + pool.length = maxCount; + } + BaseObject._maxCountMap[classType] = maxCount; + } + } + }; + /** + * 清除对象池缓存的对象。 + * @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; + } + } + }; + /** + * 从对象池中创建指定对象。 + * @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; + }; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseObject.prototype.returnToPool = function () { + this._onClear(); + BaseObject._returnObject(this); + }; + BaseObject._hashCode = 0; + BaseObject._defaultMaxCount = 1000; + BaseObject._maxCountMap = {}; + BaseObject._poolsMap = {}; + return BaseObject; + }()); + dragonBones.BaseObject = BaseObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Matrix = (function () { + 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; + } + /** + * @private + */ + 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; + }; + /** + * 转换为单位矩阵。 + * @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; + }; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @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; + }; + /** + * 转换为逆矩阵。 + * @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; + }; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params 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; + } + }; + return Matrix; + }()); + dragonBones.Matrix = Matrix; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Transform = (function () { + function Transform( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Transform.prototype.toMatrix = function (matrix) { + if (this.skew !== 0.0 || this.rotation !== 0.0) { + 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; + } + } + else { + matrix.a = this.scaleX; + matrix.b = 0.0; + matrix.c = 0.0; + matrix.d = this.scaleY; + } + matrix.tx = this.x; + matrix.ty = this.y; + return this; + }; + /** + * @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 = {})); +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 = {})); +var dragonBones; +(function (dragonBones) { + var Point = (function () { + function Point(x, y) { + if (x === void 0) { x = 0.0; } + if (y === void 0) { y = 0.0; } + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function () { + this.x = this.y = 0.0; + }; + return Point; + }()); + dragonBones.Point = Point; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + var Rectangle = (function () { + 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; + } + Rectangle.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function () { + this.x = this.y = 0.0; + this.width = this.height = 0.0; + }; + return Rectangle; + }()); + dragonBones.Rectangle = Rectangle; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 自定义数据。 + * @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; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.ints = []; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.floats = []; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.strings = []; + return _this; + } + /** + * @private + */ + UserData.toString = function () { + return "[class dragonBones.UserData]"; + }; + /** + * @private + */ + UserData.prototype._onClear = function () { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + /** + * 获取自定义整数。 + * @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; + }; + /** + * 获取自定义浮点数。 + * @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; + }; + /** + * 获取自定义字符串。 + * @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 = {})); +var dragonBones; +(function (dragonBones) { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @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; + /** + * @private + */ + _this.frameIndices = []; + /** + * @private + */ + _this.cachedFrames = []; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatureNames = []; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatures = {}; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + DragonBonesData.toString = function () { + return "[class dragonBones.DragonBonesData]"; + }; + /** + * @private + */ + 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.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + //this.armatures.clear(); + this.intArray = null; // + this.floatArray = null; // + this.frameIntArray = null; // + this.frameFloatArray = null; // + this.frameArray = null; // + this.timelineArray = null; // + this.userData = null; + }; + /** + * @private + */ + DragonBonesData.prototype.addArmature = function (value) { + if (value.name in this.armatures) { + console.warn("Replace armature: " + value.name); + this.armatures[value.name].returnToPool(); + } + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + DragonBonesData.prototype.getArmature = function (name) { + return name in this.armatures ? this.armatures[name] : null; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + DragonBonesData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + return DragonBonesData; + }(dragonBones.BaseObject)); + dragonBones.DragonBonesData = DragonBonesData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var CanvasData = (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + /** + * @private + */ + 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; + /** + * 骨架数据。 + * @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(); + /** + * 所有动画数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.bones = {}; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.slots = {}; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.skins = {}; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + /** + * @private + */ + 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.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.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + 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; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @private + */ + 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); + } + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Replace bone: " + value.name); + this.bones[value.name].returnToPool(); + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Replace slot: " + value.name); + this.slots[value.name].returnToPool(); + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Replace skin: " + value.name); + this.skins[value.name].returnToPool(); + } + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + }; + /** + * @private + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Replace animation: " + value.name); + this.animations[value.name].returnToPool(); + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (name) { + return name in this.bones ? this.bones[name] : null; + }; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (name) { + return name in this.slots ? this.slots[name] : null; + }; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (name) { + return name in this.skins ? this.skins[name] : null; + }; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (name) { + return name in this.animations ? this.animations[name] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * 骨骼数据。 + * @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.constraints = []; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + /** + * @private + */ + BoneData.prototype._onClear = function () { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0.0; + this.name = ""; + this.transform.identity(); + this.constraints.length = 0; + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * 插槽数据。 + * @see dragonBones.Slot + * @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; + } + /** + * @private + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + /** + * @private + */ + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + /** + * @private + */ + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @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]"; + }; + /** + * @private + */ + 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(); + }; + /** + * @private + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + 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 = {})); +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.target = null; // + this.bone = null; // + this.root = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @private + */ + 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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @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; + }; + 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.weight = null; // Initial value. + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Mesh */; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + }; + return MeshDisplayData; + }(ImageDisplayData)); + 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 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; + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 边界框数据基类。 + * @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; + } + /** + * @private + */ + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 多边形边界框。 + * @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; + /** + * @private + */ + _this.weight = null; // Initial value. + return _this; + } + /** + * @private + */ + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, offset, count, 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 dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[offset + count - 2]; + var yC = vertices[offset + 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[offset + i]; + var yD = vertices[offset + 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; + }; + /** + * @private + */ + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Polygon */; + this.count = 0; + this.offset = 0; + this.x = 0.0; + this.y = 0.0; + this.vertices = null; // + this.weight = null; + }; + /** + * @inherDoc + */ + 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.count, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[this.offset + iP + 1]; + var yB = this.vertices[this.offset + i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[this.offset + iP]; + var xB = this.vertices[this.offset + i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inherDoc + */ + 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.width, this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, this.offset, this.count, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画数据。 + * @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.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + /** + * @private + */ + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var kA in this.boneTimelines[k]) { + this.boneTimelines[k][kA].returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var kA in this.slotTimelines[k]) { + this.slotTimelines[k][kA].returnToPool(); + } + delete this.slotTimelines[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.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.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @private + */ + 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 (bone, timeline) { + var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (slot, timeline) { + var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (name) { + return name in this.boneTimelines ? this.boneTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimeline = function (name) { + return name in this.slotTimelines ? this.slotTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (name) { + return name in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (name) { + return name in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[name] : 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; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + var AnimationConfig = (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + /** + * @private + */ + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additiveBlending = 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.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.weight = 1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + 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.additiveBlending = value.additiveBlending; + 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]; + } + }; + AnimationConfig.prototype.containsBoneMask = function (name) { + return this.boneMask.length === 0 || this.boneMask.indexOf(name) >= 0; + }; + AnimationConfig.prototype.addBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = armature.getBone(name); + if (currentBone === null) { + return; + } + if (this.boneMask.indexOf(name) < 0) { + this.boneMask.push(name); + } + if (recursive) { + for (var _i = 0, _a = 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); + } + } + } + }; + AnimationConfig.prototype.removeBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this.boneMask.indexOf(name); + if (index >= 0) { + this.boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = armature.getBone(name); + if (currentBone !== null) { + if (this.boneMask.length > 0) { + for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_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 _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 贴图集数据。 + * @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; + } + /** + * @private + */ + 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; + } + }; + /** + * @private + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Replace texture: " + value.name); + this.textures[value.name].returnToPool(); + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (name) { + return name in this.textures ? this.textures[name] : 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 = {})); +var dragonBones; +(function (dragonBones_1) { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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 = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @private + */ + _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._zOrder > b._zOrder ? 1 : -1; + }; + /** + * @private + */ + 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._actions; _d < _e.length; _d++) { + var action = _e[_d]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.clear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null; // + this.userData = null; + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._actions.length = 0; + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + Armature.prototype._sortBones = function () { + var total = this._bones.length; + if (total <= 0) { + return; + } + var sortHelper = this._bones.concat(); + var index = 0; + var count = 0; + this._bones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this._bones.indexOf(bone) >= 0) { + continue; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this._bones.indexOf(bone.parent) < 0) { + continue; + } + this._bones.push(bone); + count++; + } + }; + Armature.prototype._sortSlots = function () { + this._slots.sort(Armature._onSortSlots); + }; + /** + * @internal + * @private + */ + 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 + * @private + */ + Armature.prototype._addBoneToBoneList = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeBoneFromBoneList = function (value) { + var index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._addSlotToSlotList = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeSlotFromSlotList = function (value) { + var index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this.armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @private + */ + 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.init(this); + this._animation.init(this); + this._animation.animations = this.armatureData.animations; + }; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + if (this.armatureData === null) { + console.assert(false, "The armature has been disposed."); + return; + } + else if (this.armatureData.parent === null) { + console.assert(false, "The armature data has been disposed."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update nimation. + this._animation.advanceTime(passedTime); + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + // 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); + } + } + if (this._actions.length > 0) { + this._lockUpdate = true; + for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { + var action = _a[_i]; + if (action.type === 0 /* Play */) { + this._animation.fadeIn(action.name); + } + } + this._actions.length = 0; + this._lockUpdate = false; + } + // + var drawed = this.debugDraw || dragonBones_1.DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + }; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlotDisplay) { + 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 (updateSlotDisplay) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @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; + }; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + }; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @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; + }; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @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; + }; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @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; + }; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @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; + }; + /** + * @deprecated + */ + Armature.prototype.addBone = function (value, parentName) { + if (parentName === void 0) { parentName = null; } + console.assert(value !== null); + value._setArmature(this); + value._setParent(parentName !== null ? this.getBone(parentName) : null); + }; + /** + * @deprecated + */ + Armature.prototype.removeBone = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * @deprecated + */ + Armature.prototype.addSlot = function (value, parentName) { + var bone = this.getBone(parentName); + console.assert(value !== null && bone !== null); + value._setArmature(this); + value._setParent(bone); + }; + /** + * @deprecated + */ + Armature.prototype.removeSlot = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + 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", { + 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", { + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @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", { + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this.armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * 获得动画控制器。 + * @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", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + 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", { + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + Armature.prototype.replaceTexture = function (texture) { + this.replacedTexture = texture; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.hasEventListener = function (type) { + return this._proxy.hasEvent(type); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.addEventListener = function (type, listener, target) { + this._proxy.addEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.removeEventListener = function (type, listener, target) { + this._proxy.removeEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + Armature.prototype.enableAnimationCache = function (frameRate) { + this.cacheFrameRate = frameRate; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础变换对象。 + * @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; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + * @private + */ + TransformObject.prototype._onClear = function () { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; // + this.userData = null; + this._globalDirty = false; + this._armature = null; // + this._parent = null; // + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setArmature = function (value) { + this._armature = value; + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setParent = function (value) { + this._parent = value; + }; + /** + * @private + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransformObject.prototype, "parent", { + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + TransformObject._helpMatrix = new dragonBones.Matrix(); + /** + * @private + */ + TransformObject._helpTransform = new dragonBones.Transform(); + /** + * @private + */ + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @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 + * @private + */ + _this.animationPose = new dragonBones.Transform(); + /** + * @internal + * @private + */ + _this.constraints = []; + _this._bones = []; + _this._slots = []; + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + /** + * @private + */ + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this.constraints.length = 0; + this.boneData = null; // + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1.0; + this._blendLayerWeight = 0.0; + this._bones.length = 0; + this._slots.length = 0; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var inherit = this._parent !== null; + var dR = 0.0; + if (this.offsetMode === 1 /* Additive */) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } + else if (this.offsetMode === 0 /* None */) { + global.copyFrom(this.origin).add(this.animationPose); + } + else { + inherit = false; + global.copyFrom(this.offset); + } + if (inherit) { + var parentMatrix = this._parent.globalTransformMatrix; + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (this.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 (this.boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + if (this._parent.global.scaleX < 0.0) { + dR += Math.PI; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + dR -= global.rotation * 2.0; + if (flipX !== flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + global.rotation += dR; + } + else if (flipX || flipY) { + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + * @private + */ + Bone.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + var oldSlots = null; + var oldBones = null; + if (this._armature !== null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + this._armature = value; // + if (this._armature !== null) { + this._armature._addBoneToBoneList(this); + } + if (oldSlots !== null) { + for (var _i = 0, oldSlots_1 = oldSlots; _i < oldSlots_1.length; _i++) { + var slot = oldSlots_1[_i]; + if (slot.parent === this) { + slot._setArmature(this._armature); + } + } + } + if (oldBones !== null) { + for (var _a = 0, oldBones_1 = oldBones; _a < oldBones_1.length; _a++) { + var bone = oldBones_1[_a]; + if (bone.parent === this) { + bone._setArmature(this._armature); + } + } + } + }; + /** + * @internal + * @private + */ + Bone.prototype.init = function (boneData) { + if (this.boneData !== null) { + return; + } + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + }; + /** + * @internal + * @private + */ + Bone.prototype.update = function (cacheFrameIndex) { + this._blendDirty = false; + 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.constraints.length > 0) { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + 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.constraints.length > 0) { + for (var _b = 0, _c = this.constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + 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 + * @private + */ + 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; + } + }; + /** + * @internal + * @private + */ + Bone.prototype.addConstraint = function (constraint) { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.push(constraint); + } + }; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (child) { + if (child === this) { + return false; + } + var ancestor = child; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getBones = function () { + this._bones.length = 0; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.parent === this) { + this._bones.push(bone); + } + } + return this._bones; + }; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getSlots = function () { + this._slots.length = 0; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + this._slots.push(slot); + } + } + return this._slots; + }; + Object.defineProperty(Bone.prototype, "visible", { + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @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, "length", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + get: function () { + return this.boneData.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + get: function () { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + return slot; + } + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @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; + /** + * @private + */ + _this._localMatrix = new dragonBones.Matrix(); + /** + * @private + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @private + */ + _this._ffdVertices = []; + /** + * @private + */ + _this._displayDatas = []; + /** + * @private + */ + _this._displayList = []; + /** + * @private + */ + _this._meshBones = []; + /** + * @private + */ + _this._rawDisplay = null; // Initial value. + /** + * @private + */ + _this._meshDisplay = null; // Initial value. + return _this; + } + /** + * @private + */ + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { + var eachDisplay = _a[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + 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); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { + this._disposeDisplay(this._meshDisplay); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay); + } + this.displayController = null; + this.slotData = null; // + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.length = 0; + this._displayList.length = 0; + this._displayDatas.length = 0; + this._meshBones.length = 0; + this._rawDisplayDatas = null; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Slot.prototype._updateDisplayData = function () { + var prevDisplayData = this._displayData; + var prevTextureData = this._textureData; + var prevMeshData = this._meshData; + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.length) { + this._displayData = this._displayDatas[this._displayIndex]; + } + else { + this._displayData = null; + } + // Update texture and mesh data. + if (this._displayData !== null) { + if (this._displayData.type === 0 /* Image */ || this._displayData.type === 2 /* Mesh */) { + this._textureData = this._displayData.texture; + if (this._displayData.type === 2 /* Mesh */) { + this._meshData = this._displayData; + } + else if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */) { + this._meshData = rawDisplayData; + } + else { + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + // Update bounding box data. + if (this._displayData !== null && this._displayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = this._displayData.boundingBox; + } + else if (rawDisplayData !== null && rawDisplayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = rawDisplayData.boundingBox; + } + else { + this._boundingBoxData = null; + } + if (this._displayData !== prevDisplayData || this._textureData !== prevTextureData || this._meshData !== prevMeshData) { + // Update pivot offset. + if (this._meshData !== null) { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + else if (this._textureData !== null) { + var imageDisplayData = this._displayData; + var 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 * scale; + var height = rect.height * scale; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width; + this._pivotY *= height; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update mesh bones and ffd vertices. + if (this._meshData !== prevMeshData) { + if (this._meshData !== null) { + if (this._meshData.weight !== null) { + this._ffdVertices.length = this._meshData.weight.count * 2; + this._meshBones.length = this._meshData.weight.bones.length; + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.weight.bones[i].name); + } + } + else { + var vertexCount = this._meshData.parent.parent.intArray[this._meshData.offset + 0 /* MeshVertexCount */]; + this._ffdVertices.length = vertexCount * 2; + this._meshBones.length = 0; + } + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0.0; + } + this._meshDirty = true; + } + else { + this._ffdVertices.length = 0; + this._meshBones.length = 0; + } + } + else if (this._meshData !== null && this._textureData !== prevTextureData) { + this._meshDirty = true; + } + if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData && this._meshData === null) { + 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; + this._displayData.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; + } + // Update original transform. + if (rawDisplayData !== null) { + this.origin = rawDisplayData.transform; + } + else if (this._displayData !== null) { + this.origin = this._displayData.transform; + } + this._displayDirty = true; + this._transformDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + 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._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + // Update frame. + if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { + this._updateFrame(); + } + // 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. + var actions = null; + if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { + actions = this._displayData.actions; + } + else { + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { + actions = rawDisplayData.actions; + } + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + }; + /** + * @private + */ + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._isMeshBonesUpdate = function () { + for (var _i = 0, _a = this._meshBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + * @private + */ + Slot.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + if (this._armature !== null) { + this._armature._removeSlotFromSlotList(this); + } + this._armature = value; // + this._onUpdateDisplay(); + if (this._armature !== null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); + } + }; + /** + * @internal + * @private + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return false; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return false; + } + this._displayIndex = value; + this._displayDirty = true; + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setZorder = function (value) { + if (this._zOrder === value) { + //return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return this._colorDirty; + }; + /** + * @private + */ + Slot.prototype._setDisplayList = function (value) { + if (value !== null && value.length > 0) { + if (this._displayList.length !== value.length) { + this._displayList.length = value.length; + } + for (var i = 0, l = value.length; i < l; ++i) { + var eachDisplay = value[i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { + this._initDisplay(eachDisplay); + } + this._displayList[i] = eachDisplay; + } + } + else if (this._displayList.length > 0) { + this._displayList.length = 0; + } + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display !== this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display !== null; + } + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @private + */ + Slot.prototype.init = function (slotData, displayDatas, rawDisplay, meshDisplay) { + if (this.slotData !== null) { + return; + } + this.slotData = slotData; + this.name = this.slotData.name; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._displayDatas.length = this._rawDisplayDatas.length; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) { + this._displayDatas[i] = this._rawDisplayDatas[i]; + } + }; + /** + * @internal + * @private + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + if (this._transformDirty) { + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + 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._display === null) { + return; + } + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + if (this._meshData !== null && this._display === this._meshDisplay) { + var isSkinned = this._meshData.weight !== null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + return; + } + } + if (this._transformDirty) { + this._transformDirty = false; + 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(false); + } + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + }; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @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); + }; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + }; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDirty = true; + this._transformDirty = true; + }; + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._displayList.concat(); + }, + set: function (value) { + var backupDisplayList = this._displayList.concat(); // Copy. + var disposeDisplayList = new Array(); + if (this._setDisplayList(value)) { + this.update(-1); + } + // Release replaced displays. + for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { + var eachDisplay = backupDisplayList_1[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { + var eachDisplay = disposeDisplayList_2[_a]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + 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", { + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + var displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength === 0) { + this._displayIndex = 0; + } + if (this._displayIndex < 0) { + return; + } + else { + var replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @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 + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + * @internal + */ + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this.target = null; // + this.bone = null; // + this.root = null; // + }; + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @private + * @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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this.target.global; + var global = this.bone.global; + var globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + var ikRadian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadian += Math.PI; + } + global.rotation += (ikRadian - 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 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 ikRadianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + ikRadianA += 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; + if (parent._parent !== null) { + var parentParentMatrix = parent._parent.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; + } + ikRadianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + var parentRadian = rawRadianA + dR; + global.x = parentGlobal.x + Math.cos(parentRadian) * lP; + global.y = parentGlobal.y + Math.sin(parentRadian) * lP; + var ikRadianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadianB += Math.PI; + } + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.update = function () { + if (this.root === null) { + this.bone.updateByConstraint(); + this._computeA(); + } + else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = (function () { + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = -1.0; } + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._animatebles = []; + this._clock = null; + if (time < 0.0) { + this.time = new Date().getTime() * 0.001; + } + else { + this.time = time; + } + } + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + if (passedTime < 0.0) { + passedTime = new Date().getTime() * 0.001 - this.time; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + if (passedTime === 0.0) { + return; + } + 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; + } + }; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + return this._animatebles.indexOf(value) >= 0; + }; + /** + * 添加 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; + } + }; + /** + * 移除 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; + } + }; + /** + * 清除所有的 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 + }); + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.clock = new WorldClock(); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @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._animationConfig = null; // Initial value. + return _this; + } + /** + * @private + */ + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + /** + * @private + */ + 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]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._timelineDirty = false; + 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.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.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.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]; + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 0 /* None */: + case 5 /* Single */: + default: + break; + } + }; + /** + * @internal + * @private + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + * @private + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { + passedTime *= this._armature._parent._armature.animation.timeScale; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + 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]; + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + this._timelineDirty = false; + }; + /** + * 清除所有动画状态。 + * @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._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * 暂停播放动画。 + * @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(); + } + } + }; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @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.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 > 1) { + 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) { + } + else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + // Child armature play same name animation. + 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); // + } + } + if (animationConfig.fadeInTime <= 0.0) { + this._armature.advanceTime(0.0); + } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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.duration * frame / animationData.frameCount; + } + return this.playConfig(this._animationConfig); + }; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName) { + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName) { + return animationState; + } + } + return null; + }; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * 动画是否处于播放状态。 + * @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", { + /** + * 所有动画状态是否均已播放完毕。 + * @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", { + /** + * 上一个正在播放的动画状态名称。 + * @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", { + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @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._animations[k] = value[k]; + this._animationNames.push(k); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * 一个可以快速使用的动画配置实例。 + * @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", { + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (duration === void 0) { duration = -1; } + 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 */; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + var animationData = this._animations[animationName]; + if (animationData && duration > 0.0) { + this._animationConfig.timeScale = animationData.duration / duration; + } + return this.playConfig(this._animationConfig); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + Animation.prototype.gotoAndStop = function (animationName, time) { + if (time === void 0) { time = 0; } + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); + } + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var BonePose = (function (_super) { + __extends(BonePose, _super); + function BonePose() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.current = new dragonBones.Transform(); + _this.delta = new dragonBones.Transform(); + _this.result = new dragonBones.Transform(); + return _this; + } + BonePose.toString = function () { + return "[class dragonBones.BonePose]"; + }; + BonePose.prototype._onClear = function () { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return BonePose; + }(dragonBones.BaseObject)); + dragonBones.BonePose = BonePose; + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @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._slotTimelines = []; + _this._bonePoses = {}; + /** + * @internal + * @private + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + /** + * @private + */ + 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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1.0; + this.weight = 1.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this.animationData = null; // + this._timelineDirty = true; + 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._slotTimelines.length = 0; + // this._bonePoses.clear(); + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + }; + AnimationState.prototype._isDisabled = function (slot) { + if (this.displayControl) { + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + return false; + } + } + return true; + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasEvent(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 eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + }; + AnimationState.prototype._blendBoneTimline = function (timeline) { + var bone = timeline.bone; + var bonePose = timeline.bonePose.result; + var animationPose = bone.animationPose; + var boneWeight = this._weightResult > 0.0 ? this._weightResult : -this._weightResult; + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1.0; + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1.0) * boneWeight + 1.0; + animationPose.scaleY = (bonePose.scaleY - 1.0) * boneWeight + 1.0; + } + else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1.0) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1.0) * boneWeight; + } + if (this._fadeState !== 0 || this._subFadeState !== 0) { + bone._transformDirty = true; + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + 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); + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.updateTimelines = function () { + var boneTimelines = {}; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.bone.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + var timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (timelineName in boneTimelines) { + delete boneTimelines[timelineName]; + } + else { + var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); + if (timelineDatas !== null) { + for (var _d = 0, timelineDatas_1 = timelineDatas; _d < timelineDatas_1.length; _d++) { + var timelineData = timelineDatas_1[_d]; + switch (timelineData.type) { + case 10 /* BoneAll */: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + case 11 /* BoneT */: + case 12 /* BoneR */: + case 13 /* BoneS */: + // TODO + break; + case 14 /* BoneX */: + case 15 /* BoneY */: + case 16 /* BoneRotate */: + case 17 /* BoneSkew */: + case 18 /* BoneScaleX */: + case 19 /* BoneScaleY */: + // TODO + break; + } + } + } + else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + for (var k in boneTimelines) { + for (var _e = 0, _f = boneTimelines[k]; _e < _f.length; _e++) { + var timeline = _f[_e]; + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + var slotTimelines = {}; + var ffdFlags = []; + for (var _g = 0, _h = this._slotTimelines; _g < _h.length; _g++) { + var timeline = _h[_g]; + var timelineName = timeline.slot.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _j = 0, _k = this._armature.getSlots(); _j < _k.length; _j++) { + var slot = _k[_j]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + var timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (timelineName in slotTimelines) { + delete slotTimelines[timelineName]; + } + else { + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + if (timelineDatas !== null) { + for (var _l = 0, timelineDatas_2 = timelineDatas; _l < timelineDatas_2.length; _l++) { + var timelineData = timelineDatas_2[_l]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 21 /* SlotColor */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotFFD */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + if (this.resetToPose) { + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + for (var _m = 0, _o = slot._rawDisplayDatas; _m < _o.length; _m++) { + var displayData = _o[_m]; + if (displayData !== null && displayData.type === 2 /* Mesh */ && ffdFlags.indexOf(displayData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { + for (var _p = 0, _q = slotTimelines[k]; _p < _q.length; _p++) { + var timeline = _q[_p]; + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + }; + /** + * @private + * @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; + } + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + if (this.weight === 0.0) { + return; + } + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this.weight * this._fadeProgress; + this._actionTimeline.update(time); // Update main timeline. + if (isCacheEnabled) { + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null) { + 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) { + if (isUpdateBoneTimeline) { + var bone = null; + var prevTimeline = null; // + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (bone !== timeline.bone) { + if (bone !== null) { + this._blendBoneTimline(prevTimeline); + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0.0) { + if (bone._blendLayer !== this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0.0; + bone = null; + } + else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0.0; + } + } + } + else { + bone = null; + } + } + } + bone = timeline.bone; + } + if (bone !== null) { + timeline.update(time); + if (i === l - 1) { + this._blendBoneTimline(timeline); + } + else { + prevTimeline = timeline; + } + } + } + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (this._isDisabled(timeline.slot)) { + continue; + } + timeline.update(time); + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * 淡出动画。 + * @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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (name) { + return this._boneMask.length === 0 || this._boneMask.indexOf(name) >= 0; + }; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(name); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(name) < 0) { + this._boneMask.push(name); + } + 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 = true; + }; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(name); + if (index >= 0) { + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(name); + 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_2 = this._boneMask.indexOf(bone.name); + if (index_2 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_2, 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 = true; + }; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = true; + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * 是否正在播放。 + * @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", { + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * 当前播放的时间。 (以秒为单位) + * @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) { + 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, "clip", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + get: function () { + return this.animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var TimelineState = (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this._tweenState = 0 /* None */; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 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._dragonBonesData = null; // + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._frameIntArray = null; // + this._frameFloatArray = 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._duration; + } + } + 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._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + if (this._timelineData !== null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._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 () { }; + TimelineState.prototype.update = function (passedTime) { + if (this.playState <= 0 && 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._tweenState !== 0 /* None */) { + this._onUpdateFrame(); + } + } + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + * @private + */ + 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 segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : 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._tweenProgress = 0.0; + this._tweenEasing = 0.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 */]; // TODO recode ture tween type. + this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; + 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; + } + 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]; + this._frameDurationR = 1.0 / (this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition); + } + } + else { + this._tweenState = 1 /* Once */; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._tweenState === 2 /* Always */) { + 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); + } + } + else { + this._tweenProgress = 0.0; + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + * @private + */ + var BoneTimelineState = (function (_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.bone = null; // + this.bonePose = null; // + }; + return BoneTimelineState; + }(TweenTimelineState)); + dragonBones.BoneTimelineState = BoneTimelineState; + /** + * @internal + * @private + */ + var SlotTimelineState = (function (_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.slot = null; // + }; + return SlotTimelineState; + }(TweenTimelineState)); + dragonBones.SlotTimelineState = SlotTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + 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._armature.armatureData.actions; + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + if (action.slot !== null) { + var slot = this._armature.getSlot(action.slot.name); + if (slot !== null) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature._bufferAction(action, true); + } + } + } + else if (action.bone !== null) { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null && slot.parent.boneData === action.bone) { + childArmature._bufferAction(action, true); + } + } + } + else { + this._armature._bufferAction(action, true); + } + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasEvent(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.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + if (action.bone !== null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + if (action.slot !== null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + 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.playState <= 0 && this._setCurrentTime(passedTime)) { + 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 (eventDispatcher.hasEvent(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 (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasEvent(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.hasEvent(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 + * @private + */ + 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 + * @private + */ + 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._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + current.x = frameFloatArray[valueOffset++]; + current.y = frameFloatArray[valueOffset++]; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + delta.x = frameFloatArray[valueOffset++] - current.x; + delta.y = frameFloatArray[valueOffset++] - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } + // else { + // delta.x = 0.0; + // delta.y = 0.0; + // delta.rotation = 0.0; + // delta.skew = 0.0; + // delta.scaleX = 0.0; + // delta.scaleY = 0.0; + // } + } + else { + var current = this.bonePose.current; + current.x = 0.0; + current.y = 0.0; + current.rotation = 0.0; + current.skew = 0.0; + current.scaleX = 1.0; + current.scaleY = 1.0; + } + }; + BoneAllTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + var scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneAllTimelineState; + }(dragonBones.BoneTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + * @private + */ + var SlotDislayIndexTimelineState = (function (_super) { + __extends(SlotDislayIndexTimelineState, _super); + function SlotDislayIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDislayIndexTimelineState.toString = function () { + return "[class dragonBones.SlotDislayIndexTimelineState]"; + }; + SlotDislayIndexTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot.slotData.displayIndex; + if (this.slot.displayIndex !== displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + }; + return SlotDislayIndexTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotDislayIndexTimelineState = SlotDislayIndexTimelineState; + /** + * @internal + * @private + */ + 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._delta = [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._onClear = function () { + _super.prototype._onClear.call(this); + this._dirty = false; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var intArray = this._dragonBonesData.intArray; + var frameIntArray = this._dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + var colorOffset = frameIntArray[valueOffset]; + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1 * 1]; + } + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } + else { + var color = this.slot.slotData.color; + this._current[0] = color.alphaMultiplier * 100.0; + this._current[1] = color.redMultiplier * 100.0; + this._current[2] = color.greenMultiplier * 100.0; + this._current[3] = color.blueMultiplier * 100.0; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.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; + this.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]; + this.slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + * @private + */ + var SlotFFDTimelineState = (function (_super) { + __extends(SlotFFDTimelineState, _super); + function SlotFFDTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + SlotFFDTimelineState.toString = function () { + return "[class dragonBones.SlotFFDTimelineState]"; + }; + SlotFFDTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.meshOffset = 0; + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + SlotFFDTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var isTween = this._tweenState === 2 /* Always */; + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + if (isTween) { + var nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex === this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = frameFloatArray[nextValueOffset + i] - (this._current[i] = frameFloatArray[valueOffset + i]); + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = frameFloatArray[valueOffset + i]; + } + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = 0.0; + } + } + }; + SlotFFDTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + for (var i = 0; i < this._valueCount; ++i) { + this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + } + }; + SlotFFDTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntArray = this._dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this.meshOffset = frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */]; + this._ffdCount = frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */]; + this._valueOffset = frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */]; + this._frameFloatOffset = frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] + this._animationData.frameFloatOffset; + } + else { + this._valueCount = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = 0.0; + } + }; + SlotFFDTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotFFDTimelineState.prototype.update = function (passedTime) { + if (this.slot._meshData === null || (this._timelineData !== null && this.slot._meshData.offset !== this.meshOffset)) { + return; + } + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.slot._ffdVertices; + if (this._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] += (frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; + } + else { + result[i] += (frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + } + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] = frameFloatArray[this._frameFloatOffset + i]; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] = this._result[i - this._valueOffset]; + } + else { + result[i] = frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + } + } + this.slot._meshDirty = true; + } + } + else { + this._ffdCount = result.length; // + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + result[i] += (0.0 - result[i]) * fadeProgress; + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + result[i] = 0.0; + } + this.slot._meshDirty = true; + } + } + } + }; + return SlotFFDTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotFFDTimelineState = SlotFFDTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + /** + * @private + */ + 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.data = null; + }; + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(dragonBones || (dragonBones = {})); +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._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 */; + 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._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._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 */; + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + DataParser.parseDragonBonesData = function (rawData) { + if (rawData instanceof ArrayBuffer) { + return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); + } + else { + return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + DataParser.parseTextureAtlasData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.warn("已废弃,请参考 @see"); + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + } + return textureAtlasData; + }; + 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 = DataParser.DATA_VERSION_5_0; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + ]; + 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.BONE = "bone"; + DataParser.IK = "ik"; + DataParser.SLOT = "slot"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.Z_ORDER = "zOrder"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.VISIBLE_FRAME = "visibleFrame"; + 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.CANVAS = "canvas"; + 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.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + 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_FFD = "inheritFFD"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_TYPE = "tweenType"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + 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_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.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var ObjectDataParser = (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + /** + * @private + */ + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._intArrayJson = []; + _this._floatArrayJson = []; + _this._frameIntArrayJson = []; + _this._frameFloatArrayJson = []; + _this._frameArrayJson = []; + _this._timelineArrayJson = []; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._defalultColorOffset = -1; + _this._prevTweenRotate = 0; + _this._prevRotation = 0.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._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._weightBoneIndices = {}; + _this._cacheBones = {}; + _this._meshs = {}; + _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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + if (dragonBones.DragonBones.webAssembly) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + } + return value; + } + return String(value); + } + return defaultValue; + }; + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); + 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; + } + }; + ObjectDataParser.prototype._sortActionFrame = function (a, b) { + return a.frameStart > b.frameStart ? 1 : -1; + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (ObjectDataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (ObjectDataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (ObjectDataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + var frame = null; + if (this._actionFrames.length === 0) { + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _i = 0, _a = this._actionFrames; _i < _a.length; _i++) { + var eachFrame = _a[_i]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + } + if (frame === null) { + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.push(frame); + } + for (var i = 0; i < actionCount; ++i) { + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseCacheActionFrame = function (frame) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = frameArray.length; + var actionCount = frame.actions.length; + frameArray.length += 1 + 1 + actionCount; + frameArray[frameOffset + 0 /* FramePosition */] = frame.frameStart; + frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { + frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + // const armature = BaseObject.borrowObject(ArmatureData); + var armature = dragonBones.DragonBones.webAssembly ? new Module["ArmatureData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { + armature.frameRate = 24; + } + this._armature = armature; + if (ObjectDataParser.AABB in rawData) { + var rawAABB = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.X, 0.0); + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.Y, 0.0); + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.WIDTH, 0.0); + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.HEIGHT, 0.0); + } + if (ObjectDataParser.CANVAS in rawData) { + var rawCanvas = rawData[ObjectDataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (ObjectDataParser.COLOR in rawCanvas) { + ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.X, 0); + canvas.y = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.HEIGHT, 0); + armature.canvas = canvas; + } + if (ObjectDataParser.BONE in rawData) { + var rawBones = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, ObjectDataParser.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 { + (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); // Raw bone sort. + } + } + if (ObjectDataParser.IK in rawData) { + var rawIKS = rawData[ObjectDataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + this._parseIKConstraint(rawIK); + } + } + armature.sortBones(); + if (ObjectDataParser.SLOT in rawData) { + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot)); + } + } + if (ObjectDataParser.SKIN in rawData) { + var rawSkins = rawData[ObjectDataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (ObjectDataParser.ANIMATION in rawData) { + var rawAnimations = rawData[ObjectDataParser.ANIMATION]; + for (var _f = 0, rawAnimations_1 = rawAnimations; _f < rawAnimations_1.length; _f++) { + var rawAnimation = rawAnimations_1[_f]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (ObjectDataParser.DEFAULT_ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.DEFAULT_ACTIONS], armature.defaultActions, 0 /* Play */, null, null); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armature.actions, 0 /* Play */, null, null); + } + // for (const action of armature.defaultActions) { // Set default animation from default action. + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? armature.defaultActions.size() : armature.defaultActions.length); ++i) { + var action = dragonBones.DragonBones.webAssembly ? armature.defaultActions.get(i) : armature.defaultActions[i]; + if (action.type === 0 /* Play */) { + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + break; + } + } + // Clear helper. + this._rawBones.length = 0; + this._armature = null; + for (var k in this._meshs) { + delete this._meshs[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + 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._weightBoneIndices) { + delete this._weightBoneIndices[k]; + } + return armature; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBone = function (rawData) { + // const bone = BaseObject.borrowObject(BoneData); + var bone = dragonBones.DragonBones.webAssembly ? new Module["BoneData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform, this._armature.scale); + } + return bone; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, "")); + if (target === null) { + return; + } + // const constraint = BaseObject.borrowObject(IKConstraintData); + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraintData"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, ObjectDataParser.SCALE, false); + constraint.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1.0); + constraint.bone = bone; + constraint.target = target; + var chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + if (dragonBones.DragonBones.webAssembly) { + bone.constraints.push_back(constraint); + } + else { + bone.constraints.push(constraint); + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlot = function (rawData) { + // const slot = BaseObject.borrowObject(SlotData); + var slot = dragonBones.DragonBones.webAssembly ? new Module["SlotData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = dragonBones.DragonBones.webAssembly ? this._armature.sortedSlots.size() : this._armature.sortedSlots.length; + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, "")); // + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] === "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); + } + if (ObjectDataParser.COLOR in rawData) { + // slot.color = SlotData.createColor(); + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].createColor() : dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].DEFAULT_COLOR : dragonBones.SlotData.DEFAULT_COLOR; + } + if (ObjectDataParser.ACTIONS in rawData) { + var actions = this._slotChildActions[slot.name] = []; + this._parseActionData(rawData[ObjectDataParser.ACTIONS], actions, 0 /* Play */, null, null); + } + return slot; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSkin = function (rawData) { + // const skin = BaseObject.borrowObject(SkinData); + var skin = dragonBones.DragonBones.webAssembly ? new Module["SkinData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (ObjectDataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[ObjectDataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var display = null; + var name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, ObjectDataParser.PATH, ""); + var type = 0 /* Image */; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: + // const imageDisplay = display = BaseObject.borrowObject(ImageDisplayData); + var imageDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ImageDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + case 1 /* Armature */: + // const armatureDisplay = display = BaseObject.borrowObject(ArmatureDisplayData); + var armatureDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ArmatureDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armatureDisplay.actions, 0 /* Play */, null, null); + } + 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 _i = 0, _a = this._slotChildActions[this._slot.name]; _i < _a.length; _i++) { + var action = _a[_i]; + if (dragonBones.DragonBones.webAssembly) { + armatureDisplay.actions.push_back(action); + } + else { + armatureDisplay.actions.push(action); + } + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + case 2 /* Mesh */: + // const meshDisplay = display = BaseObject.borrowObject(MeshDisplayData); + var meshDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["MeshDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.inheritAnimation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + var shareName = ObjectDataParser._getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length > 0) { + var shareMesh = this._meshs[shareName]; + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } + else { + this._parseMesh(rawData, meshDisplay); + this._meshs[meshDisplay.name] = meshDisplay; + } + break; + case 3 /* BoundingBox */: + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + // const boundingBoxDisplay = display = BaseObject.borrowObject(BoundingBoxDisplayData); + var boundingBoxDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["BoundingBoxDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + if (display !== null) { + display.parent = this._armature; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform, this._armature.scale); + } + } + return display; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (ObjectDataParser.PIVOT in rawData) { + var rawPivot = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var rawUVs = rawData[ObjectDataParser.UVS]; + var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = Math.floor(rawTriangles.length / 3); // uint + var vertexOffset = floatArray.length; + var uvOffset = vertexOffset + vertexCount * 2; + mesh.offset = intArray.length; + intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; + intArray[mesh.offset + 0 /* MeshVertexCount */] = vertexCount; + intArray[mesh.offset + 1 /* MeshTriangleCount */] = triangleCount; + intArray[mesh.offset + 2 /* MeshFloatOffset */] = vertexOffset; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + intArray[mesh.offset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; + } + floatArray.length += vertexCount * 2 + vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray[vertexOffset + i] = rawVertices[i]; + floatArray[uvOffset + i] = rawUVs[i]; + } + if (ObjectDataParser.WEIGHTS in rawData) { + var rawWeights = rawData[ObjectDataParser.WEIGHTS]; + var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; + var rawBonePoses = rawData[ObjectDataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + var floatOffset = floatArray.length; + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = (rawWeights.length - vertexCount) / 2; + weight.offset = intArray.length; + weight.bones.length = weightBoneCount; + weightBoneIndices.length = weightBoneCount; + intArray.length += 1 + 1 + weightBoneCount + vertexCount + weight.count; + intArray[weight.offset + 1 /* WeigthFloatOffset */] = floatOffset; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.bones[i] = bone; + weightBoneIndices[i] = rawBoneIndex; + if (dragonBones.DragonBones.webAssembly) { + for (var j = 0; j < this._armature.sortedBones.size(); j++) { + if (this._armature.sortedBones.get(j) === bone) { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = j; + } + } + } + else { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = this._armature.sortedBones.indexOf(bone); + } + } + floatArray.length += weight.count * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = intArray[iB++] = rawWeights[iW++]; // uint + var x = floatArray[vertexOffset + iD]; + var y = floatArray[vertexOffset + 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 bone = this._rawBones[rawBoneIndex]; + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray[iB++] = weight.bones.indexOf(bone); + floatArray[iV++] = rawWeights[iW++]; + floatArray[iV++] = this._helpPoint.x; + floatArray[iV++] = this._helpPoint.y; + } + } + mesh.weight = weight; + // + this._weightSlotPose[mesh.name] = rawSlotPose; + this._weightBonePoses[mesh.name] = rawBonePoses; + this._weightBoneIndices[mesh.name] = weightBoneIndices; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (ObjectDataParser.SUB_TYPE in rawData && typeof rawData[ObjectDataParser.SUB_TYPE] === "string") { + type = ObjectDataParser._getBoundingBoxType(rawData[ObjectDataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["RectangleBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["EllipseBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, ObjectDataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = floatArray.length; + polygonBoundingBox.count = rawVertices.length; + polygonBoundingBox.vertices = floatArray; + floatArray.length += polygonBoundingBox.count; + for (var i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + var iN = i + 1; + var x = rawVertices[i]; + var y = rawVertices[iN]; + floatArray[polygonBoundingBox.offset + i] = x; + floatArray[polygonBoundingBox.offset + iN] = 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; + } + } + } + return polygonBoundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + if (dragonBones.DragonBones.webAssembly) { + animation.frameIntOffset = this._frameIntArrayJson.length; + animation.frameFloatOffset = this._frameFloatArrayJson.length; + animation.frameOffset = this._frameArrayJson.length; + } + else { + animation.frameIntOffset = this._data.frameIntArray.length; + animation.frameFloatOffset = this._data.frameFloatArray.length; + animation.frameOffset = this._data.frameArray.length; + } + this._animation = animation; + if (ObjectDataParser.FRAME in rawData) { + var rawFrames = rawData[ObjectDataParser.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, ObjectDataParser.DURATION, 1); + } + } + } + if (ObjectDataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[ObjectDataParser.Z_ORDER], 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); + } + if (ObjectDataParser.BONE in rawData) { + var rawTimelines = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (ObjectDataParser.SLOT in rawData) { + var rawTimelines = rawData[ObjectDataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (ObjectDataParser.FFD in rawData) { + var rawTimelines = rawData[ObjectDataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var slotName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot === null) { + continue; + } + this._slot = slot; + this._mesh = this._meshs[displayName]; + var timelineFFD = this._parseTimeline(rawTimeline, 22 /* SlotFFD */, false, true, 0, this._parseSlotFFDFrame); + if (timelineFFD !== null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + this._slot = null; // + this._mesh = null; // + } + } + if (this._actionFrames.length > 0) { + this._actionFrames.sort(this._sortActionFrame); + // const timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData); + var timeline = this._animation.actionTimeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var keyFrameCount = this._actionFrames.length; + timeline.type = 0 /* Action */; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = 100; + timelineArray[timeline.offset + 1 /* TimelineOffset */] = 0; + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = 0; + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = this._parseCacheActionFrame(this._actionFrames[0]) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + //(frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var frame = this._actionFrames[iK]; + frameStart = frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = this._parseCacheActionFrame(frame) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + this._actionFrames.length = 0; + } + this._animation = null; // + return animation; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTimeline = function (rawData, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { + if (!(ObjectDataParser.FRAME in rawData)) { + return null; + } + var rawFrames = rawData[ObjectDataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntArrayLength = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson.length : this._data.frameIntArray.length; + var frameFloatArrayLength = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson.length : this._data.frameFloatArray.length; + // const timeline = BaseObject.borrowObject(TimelineData); + var timeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0) * 100); + timelineArray[timeline.offset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0.0) * 100); + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = frameValueCount; + if (addIntOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + } + else if (addFloatOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + } + else { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + } + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var frameIndices = this._data.frameIndices; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // frameIndices.resize( frameIndices.size() + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + 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; + frameCount = ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + var timeline = this._parseTimeline(rawData, 10 /* BoneAll */, false, true, 6, this._parseBoneFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone, timeline); + } + this._bone = null; // + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (slot === null) { + return; + } + this._slot = slot; + var displayIndexTimeline = this._parseTimeline(rawData, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayIndexFrame); + if (displayIndexTimeline !== null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + var colorTimeline = this._parseTimeline(rawData, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount, frameArray) { + rawData; + frameCount; + var frameOffset = frameArray.length; + frameArray.length += 1; + frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount, frameArray) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (frameCount > 0) { + if (ObjectDataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[ObjectDataParser.CURVE], this._helpArray); + frameArray.length += 1 + 1 + this._helpArray.length; + frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; + for (var i = 0; i < sampleCount; ++i) { + frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (ObjectDataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (ObjectDataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[ObjectDataParser.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 < slotCount; ++i_1) { + zOrders[i_1] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_2 = 0, l = rawZOrder.length; i_2 < l; i_2 += 2) { + var slotIndex = rawZOrder[i_2]; + var zOrderOffset = rawZOrder[i_2 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + zOrders[originalIndex + zOrderOffset] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + frameArray.length += 1 + slotCount; + frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex]; + } + else { + frameArray[frameOffset + 2 + i] = zOrders[i]; + } + } + return frameOffset; + } + } + frameArray.length += 1; + frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneFrame = function (rawData, frameStart, frameCount) { + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + this._helpTransform.identity(); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevTweenRotate === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevTweenRotate; + } + } + this._prevTweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + var frameFloatOffset = frameFloatArray.length; + frameFloatArray.length += 6; + frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + frameFloatArray[frameFloatOffset++] = rotation; + frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotDisplayIndexFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + frameArray.length += 1; + frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var colorOffset = -1; + if (ObjectDataParser.COLOR in rawData) { + var rawColor = rawData[ObjectDataParser.COLOR]; + for (var k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + } + colorOffset = this._defalultColorOffset; + } + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1; + frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameFloatOffset = frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var rawVertices = ObjectDataParser.VERTICES in rawData ? rawData[ObjectDataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); // uint + var vertexCount = intArray[this._mesh.offset + 0 /* MeshVertexCount */]; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (this._mesh.weight !== null) { + var rawSlotPose = this._weightSlotPose[this._mesh.name]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.length += this._mesh.weight.count * 2; + iB = this._mesh.weight.offset + 2 /* WeigthBoneIndices */ + this._mesh.weight.bones.length; + } + else { + 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 (this._mesh.weight !== null) { + var rawBonePoses = this._weightBonePoses[this._mesh.name]; + var weightBoneIndices = this._weightBoneIndices[this._mesh.name]; + var vertexBoneCount = 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 = intArray[iB++]; + var bone = this._mesh.weight.bones[boneIndex]; + var rawBoneIndex = this._rawBones.indexOf(bone); + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + frameFloatArray[frameFloatOffset + i] = x; + frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1 + 1 + 1 + 1 + 1; + frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */] = this._mesh.offset; + frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */] = 0; + frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] = frameFloatOffset; + timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseActionData = function (rawData, actions, type, bone, slot) { + var actionCount = 0; + if (typeof rawData === "string") { + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_1 = rawData; _i < rawData_1.length; _i++) { + var rawAction = rawData_1[_i]; + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (ObjectDataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } + else { + if (ObjectDataParser.TYPE in rawAction && typeof rawAction[ObjectDataParser.TYPE] === "string") { + action.type = ObjectDataParser._getActionType(rawAction[ObjectDataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, ObjectDataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.NAME, ""); + } + if (ObjectDataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (ObjectDataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + if (ObjectDataParser.INTS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[ObjectDataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + dragonBones.DragonBones.webAssembly ? action.data.ints.push_back(rawValue) : action.data.ints.push(rawValue); + } + } + if (ObjectDataParser.FLOATS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[ObjectDataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + dragonBones.DragonBones.webAssembly ? action.data.floats.push_back(rawValue) : action.data.floats.push(rawValue); + } + } + if (ObjectDataParser.STRINGS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[ObjectDataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + dragonBones.DragonBones.webAssembly ? action.data.strings.push_back(rawValue) : action.data.strings.push(rawValue); + } + } + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + } + return actionCount; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0.0) * scale; + if (ObjectDataParser.ROTATE in rawData || ObjectDataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (ObjectDataParser.SKEW_X in rawData || ObjectDataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1.0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArray = function (rawData) { + rawData; + if (dragonBones.DragonBones.webAssembly) { + return; + } + this._data.intArray = []; + this._data.floatArray = []; + this._data.frameIntArray = []; + this._data.frameFloatArray = []; + this._data.frameArray = []; + this._data.timelineArray = []; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseWASMArray = function () { + var intArrayBuf = Module._malloc(this._intArrayJson.length * 2); + this._intArrayBuffer = new Int16Array(Module.HEAP16.buffer, intArrayBuf, this._intArrayJson.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + for (var i1 = 0; i1 < this._intArrayJson.length; ++i1) { + this._intArrayBuffer[i1] = this._intArrayJson[i1]; + } + var floatArrayBuf = Module._malloc(this._floatArrayJson.length * 4); + // Module.HEAPF32.set(this._floatArrayJson, floatArrayBuf); + this._floatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, this._floatArrayJson.length); + for (var i2 = 0; i2 < this._floatArrayJson.length; ++i2) { + this._floatArrayBuffer[i2] = this._floatArrayJson[i2]; + } + var frameIntArrayBuf = Module._malloc(this._frameIntArrayJson.length * 2); + // Module.HEAP16.set(this._frameIntArrayJson, frameIntArrayBuf); + this._frameIntArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, this._frameIntArrayJson.length); + for (var i3 = 0; i3 < this._frameIntArrayJson.length; ++i3) { + this._frameIntArrayBuffer[i3] = this._frameIntArrayJson[i3]; + } + var frameFloatArrayBuf = Module._malloc(this._frameFloatArrayJson.length * 4); + // Module.HEAPF32.set(this._frameFloatArrayJson, frameFloatArrayBuf); + this._frameFloatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, this._frameFloatArrayJson.length); + for (var i4 = 0; i4 < this._frameFloatArrayJson.length; ++i4) { + this._frameFloatArrayBuffer[i4] = this._frameFloatArrayJson[i4]; + } + var frameArrayBuf = Module._malloc(this._frameArrayJson.length * 2); + // Module.HEAP16.set(this._frameArrayJson, frameArrayBuf); + this._frameArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, this._frameArrayJson.length); + for (var i5 = 0; i5 < this._frameArrayJson.length; ++i5) { + this._frameArrayBuffer[i5] = this._frameArrayJson[i5]; + } + var timelineArrayBuf = Module._malloc(this._timelineArrayJson.length * 2); + // Module.HEAPU16.set(this._timelineArrayJson, timelineArrayBuf); + this._timelineArrayBuffer = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, this._timelineArrayJson.length); + for (var i6 = 0; i6 < this._timelineArrayJson.length; ++i6) { + this._timelineArrayBuffer[i6] = this._timelineArrayJson[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined); + var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + if (ObjectDataParser.DATA_VERSIONS.indexOf(version) >= 0 || + ObjectDataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + // const data = BaseObject.borrowObject(DragonBonesData); + var data = dragonBones.DragonBones.webAssembly ? new Module["DragonBonesData"]() : dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { + data.frameRate = 24; + } + if (ObjectDataParser.ARMATURE in rawData) { + this._defalultColorOffset = -1; + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[ObjectDataParser.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._intArrayJson.length > 0) { + this._parseWASMArray(); + } + this._data = null; + } + this._rawTextureAtlasIndex = 0; + if (ObjectDataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[ObjectDataParser.TEXTURE_ATLAS]; + } + else { + this._rawTextureAtlases = null; + } + return data; + } + else { + console.assert(false, "Nonsupport data version."); + } + return null; + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 0.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null) { + 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, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + if (scale > 0.0) { + textureAtlasData.scale = scale; + } + else { + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + scale = 1.0 / scale; // + if (ObjectDataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[ObjectDataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.X, 0.0) * scale; + textureData.region.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.Y, 0.0) * scale; + textureData.region.width = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.WIDTH, 0.0) * scale; + textureData.region.height = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.HEIGHT, 0.0) * scale; + var frameWidth = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.DragonBones.webAssembly ? Module["TextureData"].createRectangle() : dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_X, 0.0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_Y, 0.0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + /** + * @private + */ + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + var ActionFrame = (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); +})(dragonBones || (dragonBones = {})); +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._getUTF16Key = function (value) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + return value; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + // const timeline = timelineData !== null ? timelineData : BaseObject.borrowObject(TimelineData); + var timeline = timelineData !== null ? timelineData : (dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData)); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // (frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { + mesh.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + var weightOffset = this._intArray[mesh.offset + 3 /* MeshWeightOffset */]; + if (weightOffset >= 0) { + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArray[mesh.offset + 0 /* MeshVertexCount */]; + var boneCount = this._intArray[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + if (dragonBones.DragonBones.webAssembly) { + weight.bones.resize(boneCount, null); + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones.set(i, this._rawBones[boneIndex]); + } + } + else { + weight.bones.length = boneCount; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones[i] = this._rawBones[boneIndex]; + } + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArray[boneIndicesOffset++]; + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + mesh.weight = weight; + } + }; + /** + * @private + */ + BinaryDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + polygonBoundingBox.vertices = this._floatArray; + return polygonBoundingBox; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.DURATION, 1), 1); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.ObjectDataParser.NAME, dragonBones.ObjectDataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.ObjectDataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.ObjectDataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.ObjectDataParser.ACTION]); + } + if (dragonBones.ObjectDataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.ObjectDataParser.Z_ORDER]); + } + if (dragonBones.ObjectDataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + if (dragonBones.ObjectDataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + this._animation = null; + return animation; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + if (dragonBones.DragonBones.webAssembly) { + var tmpIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + var tmpFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + var tmpFrameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + var tmpTimelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + var intArrayBuf = Module._malloc(tmpIntArray.length * tmpIntArray.BYTES_PER_ELEMENT); + var floatArrayBuf = Module._malloc(tmpFloatArray.length * tmpFloatArray.BYTES_PER_ELEMENT); + var frameIntArrayBuf = Module._malloc(tmpFrameIntArray.length * tmpFrameIntArray.BYTES_PER_ELEMENT); + var frameFloatArrayBuf = Module._malloc(tmpFrameFloatArray.length * tmpFrameFloatArray.BYTES_PER_ELEMENT); + var frameArrayBuf = Module._malloc(tmpFrameArray.length * tmpFrameArray.BYTES_PER_ELEMENT); + var timelineArrayBuf = Module._malloc(tmpTimelineArray.length * tmpTimelineArray.BYTES_PER_ELEMENT); + this._intArray = new Int16Array(Module.HEAP16.buffer, intArrayBuf, tmpIntArray.length); + this._floatArray = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, tmpFloatArray.length); + this._frameIntArray = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, tmpFrameIntArray.length); + this._frameFloatArray = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, tmpFrameFloatArray.length); + this._frameArray = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, tmpFrameArray.length); + this._timelineArray = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, tmpTimelineArray.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + // Module.HEAPF32.set(tmpFloatArray, floatArrayBuf); + // Module.HEAP16.set(tmpFrameIntArray, frameIntArrayBuf); + // Module.HEAPF32.set(tmpFrameFloatArray, frameFloatArrayBuf); + // Module.HEAP16.set(tmpFrameArray, frameArrayBuf); + // Module.HEAPU16.set(tmpTimelineArray, timelineArrayBuf); + for (var i1 = 0; i1 < tmpIntArray.length; ++i1) { + this._intArray[i1] = tmpIntArray[i1]; + } + for (var i2 = 0; i2 < tmpFloatArray.length; ++i2) { + this._floatArray[i2] = tmpFloatArray[i2]; + } + for (var i3 = 0; i3 < tmpFrameIntArray.length; ++i3) { + this._frameIntArray[i3] = tmpFrameIntArray[i3]; + } + for (var i4 = 0; i4 < tmpFrameFloatArray.length; ++i4) { + this._frameFloatArray[i4] = tmpFrameFloatArray[i4]; + } + for (var i5 = 0; i5 < tmpFrameArray.length; ++i5) { + this._frameArray[i5] = tmpFrameArray[i5]; + } + for (var i6 = 0; i6 < tmpTimelineArray.length; ++i6) { + this._timelineArray[i6] = tmpTimelineArray[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + } + else { + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + } + }; + /** + * @inheritDoc + */ + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer); + 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._binary = rawData; + this._binaryOffset = 8 + 4 + headerLength; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + /** + * @private + */ + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var BuildArmaturePackage = (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = (function () { + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + this.autoSearch = false; + /** + * @private + */ + this._dragonBonesDataMap = {}; + /** + * @private + */ + this._textureAtlasDataMap = {}; + /** + * @private + */ + this._dragonBones = null; + /** + * @private + */ + 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; + } + /** + * @private + */ + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + var bones = dataPackage.armature.sortedBones; + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? bones.size() : bones.length); ++i) { + var boneData = dragonBones.DragonBones.webAssembly ? bones.get(i) : bones[i]; + var bone = dragonBones.DragonBones.webAssembly ? new Module["Bone"]() : dragonBones.BaseObject.borrowObject(dragonBones.Bone); + bone.init(boneData); + if (boneData.parent !== null) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + var constraints = boneData.constraints; + for (var j = 0; j < (dragonBones.DragonBones.webAssembly ? constraints.size() : constraints.length); ++j) { + var constraintData = dragonBones.DragonBones.webAssembly ? constraints.get(j) : constraints[j]; + var target = armature.getBone(constraintData.target.name); + if (target === null) { + continue; + } + // TODO more constraint type. + var ikConstraintData = constraintData; + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraint"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + var root = ikConstraintData.root !== null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + if (root !== null) { + root.addConstraint(constraint); + } + else { + bone.addConstraint(constraint); + } + } + } + }; + /** + * @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.displays[k]; + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.displays[k]; + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + if (!(slotData.name in skinSlots)) { + continue; + } + var displays = skinSlots[slotData.name]; + var slot = this._buildSlot(dataPackage, slotData, displays, armature); + var displayList = new Array(); + for (var _b = 0, displays_1 = displays; _b < displays_1.length; _b++) { + var displayData = displays_1[_b]; + if (displayData !== null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.push(null); + } + } + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + /** + * @private + */ + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.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); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 2 /* Mesh */: + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 1 /* Armature */: + var armatureDisplayData = displayData; + var childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + 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_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + childArmature._bufferAction(action, true); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + return display; + }; + /** + * @private + */ + BaseFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + var displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + for (var i = 0, l = displayList.length; i < l; ++i) { + if (!displayList[i]) { + displayList[i] = null; + } + } + } + if (slot._displayDatas.length <= displayIndex) { + slot._displayDatas.length = displayIndex + 1; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + if (!slot._displayDatas[i]) { + slot._displayDatas[i] = null; + } + } + } + slot._displayDatas[displayIndex] = displayData; + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay(dataPackage, displayData, displayIndex < slot._rawDisplayDatas.length ? slot._rawDisplayDatas[displayIndex] : null, slot); + } + else { + displayList[displayIndex] = null; + } + slot.displayList = displayList; + }; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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 dragonBonesData = null; + if (rawData instanceof ArrayBuffer) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } + else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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 = 0.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { + 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]); + } + } + } + }; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @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; + }; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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("Replace data: " + name); + this._dragonBonesDataMap[name].returnToPool(); + } + this._dragonBonesDataMap[name] = data; + }; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @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]; + } + }; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @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; + }; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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); + } + }; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @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]; + } + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @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; + }; + /** + * 清除所有的数据。 + * @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]; + } + }; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + 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); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + for (var _i = 0, displays_2 = displays; _i < displays_2.length; _i++) { + var display = displays_2[_i]; + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + }; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + var displayIndex = 0; + for (var _i = 0, displays_3 = displays; _i < displays_3.length; _i++) { + var displayData = displays_3[_i]; + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + }; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { + if (exclude === void 0) { exclude = null; } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (!(slot.name in skin.displays) || (exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + var displays = skin.displays[slot.name]; + var displayList = slot.displayList; // Copy. + displayList.length = displays.length; // Modify displayList length. + for (var i = 0, l = displays.length; i < l; ++i) { + var displayData = displays[i]; + if (displayData !== null) { + displayList[i] = this._getSlotDisplay(null, displayData, null, slot); + } + else { + displayList[i] = null; + } + } + slot._rawDisplayDatas = displays; + slot._displayDatas.length = displays.length; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + slot._displayDatas[i] = displays[i]; + } + slot.displayList = displayList; + } + }; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { + if (fromSkinName === void 0) { fromSkinName = null; } + if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } + if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } + var dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage(dataPackage, fromDragonBonesDataName || "", fromArmatreName, fromSkinName || "", "")) { + var fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.animation.animations = fromArmatureData.animations; + } + else { + var animations = {}; + for (var animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + for (var animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + toArmature.animation.animations = animations; + } + if (dataPackage.skin) { + var slots = toArmature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var toSlot = slots[i]; + var toSlotDisplayList = toSlot.displayList; + for (var j = 0, lJ = toSlotDisplayList.length; j < lJ; ++j) { + var toDisplayObject = toSlotDisplayList[j]; + if (toDisplayObject instanceof dragonBones.Armature) { + var displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays !== null && j < displays.length) { + var fromDisplayData = displays[j]; + if (fromDisplayData !== null && fromDisplayData.type === 1 /* Armature */) { + this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + return true; + } + } + return false; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + /** + * @private + */ + BaseFactory._objectParser = null; + /** + * @private + */ + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretTextureAtlasData = (function (_super) { + __extends(EgretTextureAtlasData, _super); + function EgretTextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._renderTexture = null; // Initial value. + return _this; + } + EgretTextureAtlasData.toString = function () { + return "[class dragonBones.EgretTextureAtlasData]"; + }; + /** + * @private + */ + EgretTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this._renderTexture !== null) { + //this.texture.dispose(); + } + this._renderTexture = null; + }; + /** + * @private + */ + EgretTextureAtlasData.prototype.createTexture = function () { + return dragonBones.BaseObject.borrowObject(EgretTextureData); + }; + Object.defineProperty(EgretTextureAtlasData.prototype, "renderTexture", { + /** + * Egret 贴图。 + * @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) { + var bitmapData = this._renderTexture.bitmapData; + var textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; + var textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; + for (var k in this.textures) { + var textureData = this.textures[k]; + var subTextureWidth = Math.min(textureData.region.width, textureAtlasWidth - textureData.region.x); // TODO need remove + var subTextureHeight = Math.min(textureData.region.height, textureAtlasHeight - textureData.region.y); // TODO need remove + if (textureData.renderTexture === null) { + textureData.renderTexture = new egret.Texture(); + if (textureData.rotated) { + textureData.renderTexture.$initData(textureData.region.x, textureData.region.y, subTextureHeight, subTextureWidth, 0, 0, subTextureHeight, subTextureWidth, textureAtlasWidth, textureAtlasHeight, textureData.rotated); + } + else { + textureData.renderTexture.$initData(textureData.region.x, textureData.region.y, subTextureWidth, subTextureHeight, 0, 0, subTextureWidth, subTextureHeight, textureAtlasWidth, textureAtlasHeight); + } + } + textureData.renderTexture._bitmapData = bitmapData; + } + } + else { + for (var k in this.textures) { + var textureData = this.textures[k]; + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + EgretTextureAtlasData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + Object.defineProperty(EgretTextureAtlasData.prototype, "texture", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + get: function () { + return this.renderTexture; + }, + enumerable: true, + configurable: true + }); + return EgretTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.EgretTextureAtlasData = EgretTextureAtlasData; + /** + * @private + */ + var EgretTextureData = (function (_super) { + __extends(EgretTextureData, _super); + function EgretTextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.renderTexture = null; // Initial value. + return _this; + } + EgretTextureData.toString = function () { + return "[class dragonBones.EgretTextureData]"; + }; + EgretTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + //this.texture.dispose(); + } + this.renderTexture = null; + }; + return EgretTextureData; + }(dragonBones.TextureData)); + dragonBones.EgretTextureData = EgretTextureData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EgretEvent = (function (_super) { + __extends(EgretEvent, _super); + function EgretEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(EgretEvent.prototype, "eventObject", { + /** + * 事件对象。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationName", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + get: function () { + var animationState = this.eventObject.animationState; + return animationState !== null ? animationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "armature", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#armature + */ + get: function () { + return this.eventObject.armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "bone", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#bone + */ + get: function () { + return this.eventObject.bone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#slot + */ + get: function () { + return this.eventObject.slot; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationState", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + get: function () { + return this.eventObject.animationState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "frameLabel", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "sound", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "movementID", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationName + */ + get: function () { + return this.animationName; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.START + */ + EgretEvent.START = dragonBones.EventObject.START; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.COMPLETE + */ + EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN + */ + EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT + */ + EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND = dragonBones.EventObject.SOUND_EVENT; + return EgretEvent; + }(egret.Event)); + dragonBones.EgretEvent = EgretEvent; + /** + * @inheritDoc + */ + var EgretArmatureDisplay = (function (_super) { + __extends(EgretArmatureDisplay, _super); + function EgretArmatureDisplay() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * @internal + * @private + */ + _this._batchEnabled = true; + _this._disposeProxy = false; + _this._armature = null; // + _this._debugDrawer = null; + return _this; + } + EgretArmatureDisplay._cleanBeforeRender = function () { }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.init = function (armature) { + this._armature = armature; + // + this.$renderNode = new egret.sys.GroupNode(); + this.$renderNode.cleanBeforeRender = EgretArmatureDisplay._cleanBeforeRender; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.clear = function () { + this._disposeProxy = false; + this._armature = null; + this._debugDrawer = null; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.dispose = function (disposeProxy) { + if (disposeProxy === void 0) { disposeProxy = true; } + this._disposeProxy = disposeProxy; + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.debugUpdate = function (isEnabled) { + if (isEnabled) { + if (this._debugDrawer === null) { + this._debugDrawer = new egret.Sprite(); + } + this.addChild(this._debugDrawer); + this._debugDrawer.graphics.clear(); + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + var boneLength = bone.boneData.length; + var startX = bone.globalTransformMatrix.tx; + var startY = bone.globalTransformMatrix.ty; + var endX = startX + bone.globalTransformMatrix.a * boneLength; + var endY = startY + bone.globalTransformMatrix.b * boneLength; + this._debugDrawer.graphics.lineStyle(2.0, 0x00FFFF, 0.7); + this._debugDrawer.graphics.moveTo(startX, startY); + this._debugDrawer.graphics.lineTo(endX, endY); + this._debugDrawer.graphics.lineStyle(0.0, 0, 0.0); + this._debugDrawer.graphics.beginFill(0x00FFFF, 0.7); + this._debugDrawer.graphics.drawCircle(startX, startY, 3.0); + this._debugDrawer.graphics.endFill(); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + var boundingBoxData = slot.boundingBoxData; + if (boundingBoxData !== null) { + var child = this._debugDrawer.getChildByName(slot.name); + if (child === null) { + child = new egret.Shape(); + child.name = slot.name; + this._debugDrawer.addChild(child); + } + child.graphics.clear(); + child.graphics.beginFill(boundingBoxData.color ? boundingBoxData.color : 0xFF00FF, 0.3); + switch (boundingBoxData.type) { + case 0 /* Rectangle */: + child.graphics.drawRect(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); + break; + case 1 /* Ellipse */: + child.graphics.drawEllipse(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); + break; + case 2 /* Polygon */: + var polygon = boundingBoxData; + var vertices = polygon.vertices; + for (var j = 0; j < polygon.count; j += 2) { + if (j === 0) { + child.graphics.moveTo(vertices[polygon.offset + j], vertices[polygon.offset + j + 1]); + } + else { + child.graphics.lineTo(vertices[polygon.offset + j], vertices[polygon.offset + j + 1]); + } + } + break; + default: + break; + } + child.graphics.endFill(); + slot.updateTransformAndMatrix(); + slot.updateGlobalTransform(); + child.$setMatrix(slot.globalTransformMatrix, true); + } + else { + var child = this._debugDrawer.getChildByName(slot.name); + if (child !== null) { + this._debugDrawer.removeChild(child); + } + } + } + } + else if (this._debugDrawer !== null && this._debugDrawer.parent === this) { + this.removeChild(this._debugDrawer); + } + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype._dispatchEvent = function (type, eventObject) { + var event = egret.Event.create(EgretEvent, type); + event.data = eventObject; + _super.prototype.dispatchEvent.call(this, event); + egret.Event.release(event); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.hasEvent = function (type) { + return this.hasEventListener(type); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.addEvent = function (type, listener, target) { + this.addEventListener(type, listener, target); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.removeEvent = function (type, listener, target) { + this.removeEventListener(type, listener, target); + }; + /** + * 关闭批次渲染。(批次渲染处于性能考虑,不会更新渲染对象的边界属性,这样无法正确获得渲染对象的绘制区域,如果需要使用这些属性,可以关闭批次渲染) + * @version DragonBones 5.1 + * @language zh_CN + */ + EgretArmatureDisplay.prototype.disableBatch = function () { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + // (slot as EgretSlot).transformUpdateEnabled = true; + var display = (slot.rawDisplay || slot.meshDisplay); + var node = display.$renderNode; + // Transform. + if (node.matrix) { + display.$setMatrix(slot.globalTransformMatrix, false); + } + // ZOrder. + this.addChild(display); + } + this._batchEnabled = false; + this.$renderNode.cleanBeforeRender = null; + this.$renderNode = null; + }; + Object.defineProperty(EgretArmatureDisplay.prototype, "armature", { + /** + * @inheritDoc + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretArmatureDisplay.prototype, "animation", { + /** + * @inheritDoc + */ + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + EgretArmatureDisplay.prototype.advanceTimeBySelf = function (on) { + if (on) { + this._armature.clock = dragonBones.EgretFactory.clock; + } + else { + this._armature.clock = null; + } + }; + return EgretArmatureDisplay; + }(egret.DisplayObjectContainer)); + dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var Event = (function (_super) { + __extends(Event, _super); + function Event() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Event; + }(EgretEvent)); + dragonBones.Event = Event; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var ArmatureEvent = (function (_super) { + __extends(ArmatureEvent, _super); + function ArmatureEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ArmatureEvent; + }(EgretEvent)); + dragonBones.ArmatureEvent = ArmatureEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var AnimationEvent = (function (_super) { + __extends(AnimationEvent, _super); + function AnimationEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return AnimationEvent; + }(EgretEvent)); + dragonBones.AnimationEvent = AnimationEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var FrameEvent = (function (_super) { + __extends(FrameEvent, _super); + function FrameEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return FrameEvent; + }(EgretEvent)); + dragonBones.FrameEvent = FrameEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var SoundEvent = (function (_super) { + __extends(SoundEvent, _super); + function SoundEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return SoundEvent; + }(EgretEvent)); + dragonBones.SoundEvent = SoundEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFacory#parseTextureAtlasData() + */ + var EgretTextureAtlas = (function (_super) { + __extends(EgretTextureAtlas, _super); + function EgretTextureAtlas(texture, rawData, scale) { + if (scale === void 0) { scale = 1; } + var _this = _super.call(this) || this; + console.warn("已废弃,请参考 @see"); + _this._onClear(); + dragonBones.ObjectDataParser.getInstance().parseTextureAtlasData(rawData, _this, scale); + _this.renderTexture = texture; + return _this; + } + /** + * @private + */ + EgretTextureAtlas.toString = function () { + return "[class dragonBones.EgretTextureAtlas]"; + }; + return EgretTextureAtlas; + }(dragonBones.EgretTextureAtlasData)); + dragonBones.EgretTextureAtlas = EgretTextureAtlas; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + var EgretSheetAtlas = (function (_super) { + __extends(EgretSheetAtlas, _super); + function EgretSheetAtlas() { + return _super !== null && _super.apply(this, arguments) || this; + } + return EgretSheetAtlas; + }(EgretTextureAtlas)); + dragonBones.EgretSheetAtlas = EgretSheetAtlas; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + var SoundEventManager = (function () { + function SoundEventManager() { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + SoundEventManager.getInstance = function () { + console.warn("已废弃,请参考 @see"); + return dragonBones.EgretFactory.factory.soundEventManager; + }; + return SoundEventManager; + }()); + dragonBones.SoundEventManager = SoundEventManager; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + var AnimationCacheManager = (function () { + function AnimationCacheManager() { + console.warn("已废弃,请参考 @see"); + } + return AnimationCacheManager; + }()); + dragonBones.AnimationCacheManager = AnimationCacheManager; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretSlot = (function (_super) { + __extends(EgretSlot, _super); + function EgretSlot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.transformUpdateEnabled = false; + _this._armatureDisplay = null; + _this._renderDisplay = null; + _this._colorFilter = null; + return _this; + } + EgretSlot.toString = function () { + return "[class dragonBones.EgretSlot]"; + }; + /** + * @private + */ + EgretSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._armatureDisplay = null; // + this._renderDisplay = null; // + this._colorFilter = null; + }; + /** + * @private + */ + EgretSlot.prototype._initDisplay = function (value) { + value; + }; + /** + * @private + */ + EgretSlot.prototype._disposeDisplay = function (value) { + value; + }; + /** + * @private + */ + EgretSlot.prototype._onUpdateDisplay = function () { + this._armatureDisplay = this._armature.display; + this._renderDisplay = (this._display !== null ? this._display : this._rawDisplay); + if (this._armatureDisplay._batchEnabled && this._renderDisplay !== this._rawDisplay && this._renderDisplay !== this._meshDisplay) { + this._armatureDisplay.disableBatch(); + } + if (this._armatureDisplay._batchEnabled) { + var node = this._renderDisplay.$renderNode; + if (!node.matrix) { + node.matrix = new egret.Matrix(); + } + } + }; + /** + * @private + */ + EgretSlot.prototype._addDisplay = function () { + if (this._armatureDisplay._batchEnabled) { + this._armatureDisplay.$renderNode.addNode(this._renderDisplay.$renderNode); + } + else { + this._armatureDisplay.addChild(this._renderDisplay); + } + }; + /** + * @private + */ + EgretSlot.prototype._replaceDisplay = function (value) { + var prevDisplay = value; + if (this._armatureDisplay._batchEnabled) { + var nodes = this._armatureDisplay.$renderNode.drawData; + nodes[nodes.indexOf(value.$renderNode)] = this._renderDisplay.$renderNode; + } + else { + this._armatureDisplay.addChild(this._renderDisplay); + this._armatureDisplay.swapChildren(this._renderDisplay, prevDisplay); + this._armatureDisplay.removeChild(prevDisplay); + } + }; + /** + * @private + */ + EgretSlot.prototype._removeDisplay = function () { + if (this._armatureDisplay._batchEnabled) { + var nodes = this._armatureDisplay.$renderNode.drawData; + nodes.splice(nodes.indexOf(this._renderDisplay.$renderNode), 1); + } + else { + this._renderDisplay.parent.removeChild(this._renderDisplay); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateZOrder = function () { + if (this._armatureDisplay._batchEnabled) { + var nodes = this._armatureDisplay.$renderNode.drawData; + nodes[this._zOrder] = this._renderDisplay.$renderNode; + } + else { + var index = this._armatureDisplay.getChildIndex(this._renderDisplay); + if (index === this._zOrder) { + return; + } + this._armatureDisplay.addChildAt(this._renderDisplay, this._zOrder); + } + }; + /** + * @internal + * @private + */ + EgretSlot.prototype._updateVisible = function () { + if (this._armatureDisplay._batchEnabled) { + var node = this._renderDisplay.$renderNode; + node.alpha = this._parent.visible ? 1.0 : 0.0; + } + else { + this._renderDisplay.visible = this._parent.visible; + } + }; + /** + * @private + */ + EgretSlot.prototype._updateBlendMode = function () { + switch (this._blendMode) { + case 0 /* Normal */: + this._renderDisplay.blendMode = egret.BlendMode.NORMAL; + break; + case 1 /* Add */: + this._renderDisplay.blendMode = egret.BlendMode.ADD; + break; + case 5 /* Erase */: + this._renderDisplay.blendMode = egret.BlendMode.ERASE; + break; + default: + break; + } + if (this._armatureDisplay._batchEnabled) { + var node = this._renderDisplay.$renderNode; + node.blendMode = egret.sys.blendModeToNumber(this._renderDisplay.blendMode); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateColor = function () { + if (this._colorTransform.redMultiplier !== 1.0 || + this._colorTransform.greenMultiplier !== 1.0 || + this._colorTransform.blueMultiplier !== 1.0 || + this._colorTransform.redOffset !== 0 || + this._colorTransform.greenOffset !== 0 || + this._colorTransform.blueOffset !== 0 || + this._colorTransform.alphaOffset !== 0) { + if (this._colorFilter === null) { + this._colorFilter = new egret.ColorMatrixFilter(); + } + var colorMatrix = this._colorFilter.matrix; + colorMatrix[0] = this._colorTransform.redMultiplier; + colorMatrix[6] = this._colorTransform.greenMultiplier; + colorMatrix[12] = this._colorTransform.blueMultiplier; + colorMatrix[18] = this._colorTransform.alphaMultiplier; + colorMatrix[4] = this._colorTransform.redOffset; + colorMatrix[9] = this._colorTransform.greenOffset; + colorMatrix[14] = this._colorTransform.blueOffset; + colorMatrix[19] = this._colorTransform.alphaOffset; + this._colorFilter.matrix = colorMatrix; + if (this._armatureDisplay._batchEnabled) { + var node = this._renderDisplay.$renderNode; + node.filter = this._colorFilter; + node.alpha = 1.0; + } + var filters = this._renderDisplay.filters; + if (!filters) { + filters = []; + } + if (filters.indexOf(this._colorFilter) < 0) { + filters.push(this._colorFilter); + } + this._renderDisplay.filters = filters; + this._renderDisplay.$setAlpha(1.0); + } + else { + if (this._armatureDisplay._batchEnabled) { + var node = this._renderDisplay.$renderNode; + node.filter = null; + node.alpha = this._colorTransform.alphaMultiplier; + } + this._renderDisplay.filters = null; + this._renderDisplay.$setAlpha(this._colorTransform.alphaMultiplier); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateFrame = function () { + var meshData = this._display === this._meshDisplay ? this._meshData : null; + var currentTextureData = this._textureData; + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + if (this._armature.replacedTexture !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { + var currentTextureAtlasData = currentTextureData.parent; + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData; + } + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); + } + if (currentTextureData.renderTexture !== null) { + if (meshData !== null) { + var intArray = meshData.parent.parent.intArray; + var floatArray = meshData.parent.parent.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var triangleCount = intArray[meshData.offset + 1 /* MeshTriangleCount */]; + var verticesOffset = intArray[meshData.offset + 2 /* MeshFloatOffset */]; + var uvOffset = verticesOffset + vertexCount * 2; + var meshDisplay = this._renderDisplay; + var meshNode = meshDisplay.$renderNode; + meshNode.uvs.length = vertexCount * 2; + meshNode.vertices.length = vertexCount * 2; + meshNode.indices.length = triangleCount * 3; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[verticesOffset + i]; + meshNode.uvs[i] = floatArray[uvOffset + i]; + } + for (var i = 0; i < triangleCount * 3; ++i) { + meshNode.indices[i] = intArray[meshData.offset + 4 /* MeshVertexIndices */ + i]; + } + if (this._armatureDisplay._batchEnabled) { + var texture = currentTextureData.renderTexture; + var node = this._renderDisplay.$renderNode; + egret.sys.RenderNode.prototype.cleanBeforeRender.call(this._renderDisplay.$renderNode); + node.image = texture._bitmapData; + node.drawMesh(texture._bitmapX, texture._bitmapY, texture._bitmapWidth, texture._bitmapHeight, texture._offsetX, texture._offsetY, texture.textureWidth, texture.textureHeight); + node.imageWidth = texture._sourceWidth; + node.imageHeight = texture._sourceHeight; + } + meshDisplay.texture = currentTextureData.renderTexture; + meshDisplay.$setAnchorOffsetX(this._pivotX); + meshDisplay.$setAnchorOffsetY(this._pivotY); + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + } + else { + var normalDisplay = this._renderDisplay; + normalDisplay.texture = currentTextureData.renderTexture; + if (this._armatureDisplay._batchEnabled) { + var texture = currentTextureData.renderTexture; + var node = this._renderDisplay.$renderNode; + egret.sys.RenderNode.prototype.cleanBeforeRender.call(this._renderDisplay.$renderNode); + node.image = texture._bitmapData; + node.drawImage(texture._bitmapX, texture._bitmapY, texture._bitmapWidth, texture._bitmapHeight, texture._offsetX, texture._offsetY, texture.textureWidth, texture.textureHeight); + node.imageWidth = texture._sourceWidth; + node.imageHeight = texture._sourceHeight; + } + normalDisplay.$setAnchorOffsetX(this._pivotX); + normalDisplay.$setAnchorOffsetY(this._pivotY); + } + return; + } + } + if (this._armatureDisplay._batchEnabled) { + this._renderDisplay.$renderNode.image = null; + } + if (meshData !== null) { + var meshDisplay = this._renderDisplay; + meshDisplay.$setBitmapData(null); + meshDisplay.x = 0.0; + meshDisplay.y = 0.0; + } + else { + var normalDisplay = this._renderDisplay; + normalDisplay.$setBitmapData(null); + normalDisplay.x = 0.0; + normalDisplay.y = 0.0; + } + }; + /** + * @private + */ + EgretSlot.prototype._updateMesh = function () { + var hasFFD = this._ffdVertices.length > 0; + var meshData = this._meshData; + var weight = meshData.weight; + var meshDisplay = this._renderDisplay; + var meshNode = meshDisplay.$renderNode; + if (weight !== null) { + var intArray = meshData.parent.parent.intArray; + var floatArray = meshData.parent.parent.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var weightFloatOffset = intArray[weight.offset + 1 /* WeigthFloatOffset */]; + for (var i = 0, iD = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.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 = this._meshBones[boneIndex]; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + var weight_1 = floatArray[iV++]; + var xL = floatArray[iV++]; + var yL = floatArray[iV++]; + if (hasFFD) { + xL += this._ffdVertices[iF++]; + yL += this._ffdVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight_1; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight_1; + } + } + meshNode.vertices[iD++] = xG; + meshNode.vertices[iD++] = yG; + } + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + } + else if (hasFFD) { + var intArray = meshData.parent.parent.intArray; + var floatArray = meshData.parent.parent.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var vertexOffset = intArray[meshData.offset + 2 /* MeshFloatOffset */]; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[vertexOffset + i] + this._ffdVertices[i]; + } + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateTransform = function (isSkinnedMesh) { + if (isSkinnedMesh) { + var transformationMatrix = this._renderDisplay.matrix; + transformationMatrix.identity(); + this._renderDisplay.$setMatrix(transformationMatrix, this.transformUpdateEnabled); + } + else { + var globalTransformMatrix = this.globalTransformMatrix; + if (this._armatureDisplay._batchEnabled) { + var displayMatrix = this._renderDisplay.$renderNode.matrix; + displayMatrix.a = globalTransformMatrix.a; + displayMatrix.b = globalTransformMatrix.b; + displayMatrix.c = globalTransformMatrix.c; + displayMatrix.d = globalTransformMatrix.d; + displayMatrix.tx = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); + displayMatrix.ty = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); + } + else if (this.transformUpdateEnabled) { + this._renderDisplay.$setMatrix(globalTransformMatrix, true); + } + else { + var values = this._renderDisplay.$DisplayObject; + var displayMatrix = values[6]; + displayMatrix.a = this.globalTransformMatrix.a; + displayMatrix.b = this.globalTransformMatrix.b; + displayMatrix.c = this.globalTransformMatrix.c; + displayMatrix.d = this.globalTransformMatrix.d; + displayMatrix.tx = this.globalTransformMatrix.tx; + displayMatrix.ty = this.globalTransformMatrix.ty; + this._renderDisplay.$removeFlags(8); + this._renderDisplay.$invalidatePosition(); + } + } + }; + return EgretSlot; + }(dragonBones.Slot)); + dragonBones.EgretSlot = EgretSlot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretFactory = (function (_super) { + __extends(EgretFactory, _super); + /** + * @inheritDoc + */ + function EgretFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + var _this = _super.call(this, dataParser) || this; + if (EgretFactory._dragonBonesInstance === null) { + var eventManager = new dragonBones.EgretArmatureDisplay(); + EgretFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); + EgretFactory._dragonBonesInstance.clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretFactory._clockHandler, EgretFactory); + } + _this._dragonBones = EgretFactory._dragonBonesInstance; + return _this; + } + EgretFactory._clockHandler = function (time) { + time *= 0.001; + var clock = EgretFactory._dragonBonesInstance.clock; + var passedTime = time - clock.time; + EgretFactory._dragonBonesInstance.advanceTime(passedTime); + clock.time = time; + return false; + }; + Object.defineProperty(EgretFactory, "clock", { + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return EgretFactory._dragonBonesInstance.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretFactory, "factory", { + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + if (EgretFactory._factory === null) { + EgretFactory._factory = new EgretFactory(); + } + return EgretFactory._factory; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + EgretFactory.prototype._isSupportMesh = function () { + if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { + return true; + } + console.warn("Canvas can not support mesh, please change renderMode to webgl."); + return false; + }; + /** + * @private + */ + EgretFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); + } + return textureAtlasData; + }; + /** + * @private + */ + EgretFactory.prototype._buildArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplay = new dragonBones.EgretArmatureDisplay(); + armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones); + return armature; + }; + /** + * @private + */ + EgretFactory.prototype._buildSlot = function (dataPackage, slotData, displays, armature) { + dataPackage; + armature; + var slot = dragonBones.BaseObject.borrowObject(dragonBones.EgretSlot); + slot.init(slotData, displays, new egret.Bitmap(), new egret.Mesh()); + return slot; + }; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + EgretFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + var armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.display; + } + return null; + }; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + EgretFactory.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) { + return new egret.Bitmap(textureData.renderTexture); + } + return null; + }; + Object.defineProperty(EgretFactory.prototype, "soundEventManager", { + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._dragonBones.eventManager; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + EgretFactory.prototype.addSkeletonData = function (dragonBonesData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + console.warn("已废弃,请参考 @see"); + this.addDragonBonesData(dragonBonesData, dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getDragonBonesData() + */ + EgretFactory.prototype.getSkeletonData = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + return this.getDragonBonesData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + EgretFactory.prototype.removeSkeletonData = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + this.removeDragonBonesData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addTextureAtlasData() + */ + EgretFactory.prototype.addTextureAtlas = function (textureAtlasData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + console.warn("已废弃,请参考 @see"); + this.addTextureAtlasData(textureAtlasData, dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getTextureAtlasData() + */ + EgretFactory.prototype.getTextureAtlas = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + return this.getTextureAtlasData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + EgretFactory.prototype.removeTextureAtlas = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + this.removeTextureAtlasData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#buildArmature() + */ + EgretFactory.prototype.buildFastArmature = function (armatureName, dragonBonesName, skinName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + console.warn("已废弃,请参考 @see"); + return this.buildArmature(armatureName, dragonBonesName, skinName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#clear() + */ + EgretFactory.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.clear(); + }; + Object.defineProperty(EgretFactory.prototype, "soundEventManater", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager() + */ + get: function () { + return this.soundEventManager; + }, + enumerable: true, + configurable: true + }); + EgretFactory._dragonBonesInstance = null; + EgretFactory._factory = null; + return EgretFactory; + }(dragonBones.BaseFactory)); + dragonBones.EgretFactory = EgretFactory; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var _helpRectangle = new egret.Rectangle(); + /** + * @private + */ + var _helpMatrix = new egret.Matrix(); + /** + * @private + */ + var _groupConfigMap = {}; + /** + * @private + */ + function _findObjectInArray(array, name) { + for (var i = 0, l = array.length; i < l; ++i) { + var data = array[i]; + if (data.name === name) { + return data; + } + } + return null; + } + /** + * @private + */ + function _fillCreateMovieHelper(createMovieHelper) { + if (createMovieHelper.groupName) { + var groupConfig = _groupConfigMap[createMovieHelper.groupName]; + if (groupConfig) { + var movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); + if (movieConfig) { + createMovieHelper.groupConfig = groupConfig; + createMovieHelper.movieConfig = movieConfig; + return true; + } + } + } + if (!createMovieHelper.groupName) { + for (var groupName in _groupConfigMap) { + var groupConfig = _groupConfigMap[groupName]; + if (!createMovieHelper.groupName) { + var movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); + if (movieConfig) { + createMovieHelper.groupName = groupName; + createMovieHelper.groupConfig = groupConfig; + createMovieHelper.movieConfig = movieConfig; + return true; + } + } + } + } + return false; + } + /** + * @language zh_CN + * 是否包含指定名称的动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function hasMovieGroup(groupName) { + return groupName in _groupConfigMap; + } + dragonBones.hasMovieGroup = hasMovieGroup; + /** + * @language zh_CN + * 添加动画组。 + * @param groupData 动画二进制数据。 + * @param textureAtlas 贴图集或贴图集列表。 + * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 + * @version DragonBones 4.7 + */ + function addMovieGroup(groupData, textureAtlas, groupName) { + if (groupName === void 0) { groupName = null; } + if (groupData) { + var byteArray = new egret.ByteArray(groupData); + byteArray.endian = egret.Endian.LITTLE_ENDIAN; + byteArray.position = 8; // TODO format + var groupConfig = JSON.parse(byteArray.readUTF()); + groupConfig.offset = byteArray.position; + groupConfig.arrayBuffer = groupData; + groupConfig.textures = []; + var p = groupConfig.offset % 4; + if (p) { + groupConfig.offset += 4 - p; + } + for (var i = 0, l = groupConfig.position.length; i < l; i += 3) { + switch (i / 3) { + case 1: + groupConfig.displayFrameArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + case 2: + groupConfig.rectangleArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + case 3: + groupConfig.transformArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + case 4: + groupConfig.colorArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + } + } + groupName = groupName || groupConfig.name; + if (_groupConfigMap[groupName]) { + console.warn("Replace group: " + groupName); + } + _groupConfigMap[groupName] = groupConfig; + // + if (textureAtlas instanceof Array) { + for (var i = 0, l = textureAtlas.length; i < l; ++i) { + var texture = textureAtlas[i]; + groupConfig.textures.push(texture); + } + } + else { + groupConfig.textures.push(textureAtlas); + } + } + else { + throw new Error(); + } + } + dragonBones.addMovieGroup = addMovieGroup; + /** + * @language zh_CN + * 移除动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function removeMovieGroup(groupName) { + var groupConfig = _groupConfigMap[groupName]; + if (groupConfig) { + delete _groupConfigMap[groupName]; + } + } + dragonBones.removeMovieGroup = removeMovieGroup; + /** + * @language zh_CN + * 移除所有的动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function removeAllMovieGroup() { + for (var i in _groupConfigMap) { + delete _groupConfigMap[i]; + } + } + dragonBones.removeAllMovieGroup = removeAllMovieGroup; + /** + * @language zh_CN + * 创建一个动画。 + * @param movieName 动画的名称。 + * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 + * @version DragonBones 4.7 + */ + function buildMovie(movieName, groupName) { + if (groupName === void 0) { groupName = null; } + var createMovieHelper = { movieName: movieName, groupName: groupName }; + if (_fillCreateMovieHelper(createMovieHelper)) { + var movie = new Movie(createMovieHelper); + dragonBones.EgretFactory.factory; + movie.clock = dragonBones.EgretFactory.clock; + return movie; + } + else { + console.warn("No movie named: " + movieName); + } + return null; + } + dragonBones.buildMovie = buildMovie; + /** + * @language zh_CN + * 获取指定动画组内包含的所有动画名称。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + function getMovieNames(groupName) { + var groupConfig = _groupConfigMap[groupName]; + if (groupConfig) { + var movieNameGroup = []; + var movie = groupConfig.movie || groupConfig.animation; + for (var i = 0, l = movie.length; i < l; ++i) { + movieNameGroup.push(movie[i].name); + } + return movieNameGroup; + } + else { + console.warn("No group named: " + groupName); + } + return null; + } + dragonBones.getMovieNames = getMovieNames; + /** + * @language zh_CN + * 动画事件。 + * @version DragonBones 4.7 + */ + var MovieEvent = (function (_super) { + __extends(MovieEvent, _super); + /** + * @private + */ + function MovieEvent(type) { + var _this = _super.call(this, type) || this; + /** + * @language zh_CN + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.7 + */ + _this.name = ""; + /** + * @language zh_CN + * 发出事件的插槽名称。 + * @version DragonBones 4.7 + */ + _this.slotName = ""; + /** + * @language zh_CN + * 发出事件的动画剪辑名称。 + * @version DragonBones 4.7 + */ + _this.clipName = ""; + return _this; + } + Object.defineProperty(MovieEvent.prototype, "armature", { + //========================================= // 兼容旧数据 + /** + * @private + */ + get: function () { + return this.movie; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MovieEvent.prototype, "bone", { + /** + * @private + */ + get: function () { + return null; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MovieEvent.prototype, "animationState", { + /** + * @private + */ + get: function () { + return { name: this.clipName }; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MovieEvent.prototype, "frameLabel", { + /** + * @private + */ + get: function () { + return this.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(MovieEvent.prototype, "movementID", { + /** + * @private + */ + get: function () { + return this.clipName; + }, + enumerable: true, + configurable: true + }); + /** + * @language zh_CN + * 动画剪辑开始播放。 + * @version DragonBones 4.7 + */ + MovieEvent.START = "start"; + /** + * @language zh_CN + * 动画剪辑循环播放一次完成。 + * @version DragonBones 4.7 + */ + MovieEvent.LOOP_COMPLETE = "loopComplete"; + /** + * @language zh_CN + * 动画剪辑播放完成。 + * @version DragonBones 4.7 + */ + MovieEvent.COMPLETE = "complete"; + /** + * @language zh_CN + * 动画剪辑帧事件。 + * @version DragonBones 4.7 + */ + MovieEvent.FRAME_EVENT = "frameEvent"; + /** + * @language zh_CN + * 动画剪辑声音事件。 + * @version DragonBones 4.7 + */ + MovieEvent.SOUND_EVENT = "soundEvent"; + return MovieEvent; + }(egret.Event)); + dragonBones.MovieEvent = MovieEvent; + /** + * @private + */ + var MovieSlot = (function (_super) { + __extends(MovieSlot, _super); + function MovieSlot(slotConfig) { + var _this = _super.call(this) || this; + _this.displayIndex = -1; + _this.colorIndex = -1; + _this.transformIndex = -1; + _this.rawDisplay = new egret.Bitmap(); + _this.childMovies = {}; + _this.displayConfig = null; + _this.childMovie = null; + _this.colorFilter = null; + _this.display = _this.rawDisplay; + _this.config = slotConfig; + _this.rawDisplay.name = _this.config.name; + if (!_this.config.blendMode) { + _this.config.blendMode = 0 /* Normal */; + } + return _this; + } + MovieSlot.prototype.dispose = function () { + this.rawDisplay = null; + this.childMovies = null; + this.config = null; + this.displayConfig = null; + this.display = null; + this.childMovie = null; + this.colorFilter = null; + }; + return MovieSlot; + }(egret.HashObject)); + /** + * @language zh_CN + * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 + * @see dragonBones.buildMovie + * @version DragonBones 4.7 + */ + var Movie = (function (_super) { + __extends(Movie, _super); + /** + * @internal + * @private + */ + function Movie(createMovieHelper) { + var _this = _super.call(this) || this; + /** + * @language zh_CN + * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 4.7 + */ + _this.timeScale = 1; + /** + * @language zh_CN + * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * (当再次播放其他动画剪辑时,此值将被重置为 1) + * @default 1 + * @version DragonBones 4.7 + */ + _this.clipTimeScale = 1; + _this._batchEnabled = true; + _this._isLockDispose = false; + _this._isDelayDispose = false; + _this._isStarted = false; + _this._isPlaying = false; + _this._isReversing = false; + _this._isCompleted = false; + _this._playTimes = 0; + _this._time = 0; + _this._currentTime = 0; + _this._currentPlayTimes = 0; + _this._cacheFrameIndex = 0; + _this._frameSize = 0; + _this._cacheRectangle = null; + _this._clock = null; + _this._currentFrameConfig = null; + _this._clipNames = []; + _this._slots = []; + _this._childMovies = []; + _this._groupConfig = createMovieHelper.groupConfig; + _this._config = createMovieHelper.movieConfig; + _this._batchEnabled = !(_this._config.isNested || _this._config.hasChildAnimation); + if (_this._batchEnabled) { + _this.$renderNode = new egret.sys.GroupNode(); + _this.$renderNode.cleanBeforeRender = Movie._cleanBeforeRender; + } + _this._clipNames.length = 0; + for (var i = 0, l = _this._config.clip.length; i < l; ++i) { + _this._clipNames.push(_this._config.clip[i].name); + } + for (var i = 0, l = _this._config.slot.length; i < l; ++i) { + var slot = new MovieSlot(_this._config.slot[i]); + _this._updateSlotBlendMode(slot); + _this._slots.push(slot); + if (_this._batchEnabled) { + _this.$renderNode.addNode(slot.rawDisplay.$renderNode); + } + else { + _this.addChild(slot.rawDisplay); + } + } + _this._frameSize = (1 + 1) * _this._slots.length; // displayFrame, transformFrame. + _this.name = _this._config.name; + _this.play(); + _this.advanceTime(0.000001); + _this.stop(); + return _this; + } + Movie._cleanBeforeRender = function () { }; + Movie.prototype._configToEvent = function (config, event) { + event.movie = this; + event.clipName = this._clipConfig.name; + event.name = config.name; + event.slotName = config.slot || ""; + }; + Movie.prototype._onCrossFrame = function (frameConfig) { + for (var i = 0, l = frameConfig.actionAndEvent.length; i < l; ++i) { + var actionAndEvent = frameConfig.actionAndEvent[i]; + if (actionAndEvent) { + switch (actionAndEvent.type) { + case 11 /* Sound */: + if (dragonBones.EgretFactory.factory.soundEventManager.hasEventListener(MovieEvent.SOUND_EVENT)) { + var event_1 = egret.Event.create(MovieEvent, MovieEvent.SOUND_EVENT); + this._configToEvent(actionAndEvent, event_1); + dragonBones.EgretFactory.factory.soundEventManager.dispatchEvent(event_1); + egret.Event.release(event_1); + } + break; + case 10 /* Frame */: + if (this.hasEventListener(MovieEvent.FRAME_EVENT)) { + var event_2 = egret.Event.create(MovieEvent, MovieEvent.FRAME_EVENT); + this._configToEvent(actionAndEvent, event_2); + this.dispatchEvent(event_2); + egret.Event.release(event_2); + } + break; + case 0 /* Play */: + if (actionAndEvent.slot) { + var slot = this._getSlot(actionAndEvent.slot); + if (slot && slot.childMovie) { + slot.childMovie.play(actionAndEvent.name); + } + } + else { + this.play(actionAndEvent.name); + } + break; + } + } + } + }; + Movie.prototype._updateSlotBlendMode = function (slot) { + var blendMode = ""; + switch (slot.config.blendMode) { + case 0 /* Normal */: + blendMode = egret.BlendMode.NORMAL; + break; + case 1 /* Add */: + blendMode = egret.BlendMode.ADD; + break; + case 5 /* Erase */: + blendMode = egret.BlendMode.ERASE; + break; + default: + break; + } + if (blendMode) { + if (this._batchEnabled) { + // RenderNode display. + slot.display.$renderNode.blendMode = egret.sys.blendModeToNumber(blendMode); + } + else { + // Classic display. + slot.display.blendMode = blendMode; + } + } + }; + Movie.prototype._updateSlotColor = function (slot, aM, rM, gM, bM, aO, rO, gO, bO) { + if (rM !== 1 || + gM !== 1 || + bM !== 1 || + rO !== 0 || + gO !== 0 || + bO !== 0 || + aO !== 0) { + if (!slot.colorFilter) { + slot.colorFilter = new egret.ColorMatrixFilter(); + } + var colorMatrix = slot.colorFilter.matrix; + colorMatrix[0] = rM; + colorMatrix[6] = gM; + colorMatrix[12] = bM; + colorMatrix[18] = aM; + colorMatrix[4] = rO; + colorMatrix[9] = gO; + colorMatrix[14] = bO; + colorMatrix[19] = aO; + slot.colorFilter.matrix = colorMatrix; + if (this._batchEnabled) { + // RenderNode display. + slot.display.$renderNode.filter = slot.colorFilter; + slot.display.$renderNode.alpha = 1.0; + } + else { + // Classic display. + var filters = slot.display.filters; + if (!filters) { + filters = []; + } + if (filters.indexOf(slot.colorFilter) < 0) { + filters.push(slot.colorFilter); + } + slot.display.filters = filters; + slot.display.$setAlpha(1.0); + } + } + else { + if (slot.colorFilter) { + slot.colorFilter = null; + } + if (this._batchEnabled) { + // RenderNode display. + slot.display.$renderNode.filter = null; + slot.display.$renderNode.alpha = aM; + } + else { + // Classic display. + slot.display.filters = null; + slot.display.$setAlpha(aM); + } + } + }; + Movie.prototype._updateSlotDisplay = function (slot) { + var prevDisplay = slot.display || slot.rawDisplay; + var prevChildMovie = slot.childMovie; + if (slot.displayIndex >= 0) { + slot.displayConfig = this._groupConfig.display[slot.displayIndex]; + if (slot.displayConfig.type === 1 /* Armature */) { + var childMovie = slot.displayConfig.name in slot.childMovies ? slot.childMovies[slot.displayConfig.name] : null; + if (!childMovie) { + childMovie = buildMovie(slot.displayConfig.name, this._groupConfig.name); + if (childMovie) { + slot.childMovies[slot.displayConfig.name] = childMovie; + } + } + if (childMovie) { + slot.display = childMovie; + slot.childMovie = childMovie; + } + else { + slot.display = slot.rawDisplay; + slot.childMovie = null; + } + } + else { + slot.display = slot.rawDisplay; + slot.childMovie = null; + } + } + else { + slot.displayConfig = null; + slot.display = slot.rawDisplay; + slot.childMovie = null; + } + if (slot.display !== prevDisplay) { + if (prevDisplay) { + this.addChild(slot.display); + this.swapChildren(slot.display, prevDisplay); + this.removeChild(prevDisplay); + } + // Update blendMode. + this._updateSlotBlendMode(slot); + } + // Update frame. + if (slot.display === slot.rawDisplay) { + if (slot.displayConfig && slot.displayConfig.regionIndex !== null && slot.displayConfig.regionIndex !== undefined) { + if (!slot.displayConfig.texture) { + var textureAtlasTexture = this._groupConfig.textures[slot.displayConfig.textureIndex || 0]; + var regionIndex = slot.displayConfig.regionIndex * 4; + var x = this._groupConfig.rectangleArray[regionIndex]; + var y = this._groupConfig.rectangleArray[regionIndex + 1]; + var width = this._groupConfig.rectangleArray[regionIndex + 2]; + var height = this._groupConfig.rectangleArray[regionIndex + 3]; + slot.displayConfig.texture = new egret.Texture(); + slot.displayConfig.texture._bitmapData = textureAtlasTexture._bitmapData; + slot.displayConfig.texture.$initData(x, y, Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), 0, 0, Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), textureAtlasTexture.textureWidth, textureAtlasTexture.textureHeight); + } + if (this._batchEnabled) { + // RenderNode display. + var texture = slot.displayConfig.texture; + var bitmapNode = slot.rawDisplay.$renderNode; + egret.sys.RenderNode.prototype.cleanBeforeRender.call(slot.rawDisplay.$renderNode); + bitmapNode.image = texture._bitmapData; + bitmapNode.drawImage(texture._bitmapX, texture._bitmapY, texture._bitmapWidth, texture._bitmapHeight, texture._offsetX, texture._offsetY, texture.textureWidth, texture.textureHeight); + bitmapNode.imageWidth = texture._sourceWidth; + bitmapNode.imageHeight = texture._sourceHeight; + } + else { + // Classic display. + slot.rawDisplay.visible = true; + slot.rawDisplay.$setBitmapData(slot.displayConfig.texture); + } + } + else { + if (this._batchEnabled) { + // RenderNode display. + slot.rawDisplay.$renderNode.image = null; + } + else { + // Classic display. + slot.rawDisplay.visible = false; + slot.rawDisplay.$setBitmapData(null); + } + } + } + // Update child movie. + if (slot.childMovie !== prevChildMovie) { + if (prevChildMovie) { + prevChildMovie.stop(); + this._childMovies.slice(this._childMovies.indexOf(prevChildMovie), 1); + } + if (slot.childMovie) { + if (this._childMovies.indexOf(slot.childMovie) < 0) { + this._childMovies.push(slot.childMovie); + } + if (slot.config.action) { + slot.childMovie.play(slot.config.action); + } + else { + slot.childMovie.play(slot.childMovie._config.action); + } + } + } + }; + Movie.prototype._getSlot = function (name) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + var slot = this._slots[i]; + if (slot.config.name === name) { + return slot; + } + } + return null; + }; + /** + * @inheritDoc + */ + Movie.prototype.$render = function () { + if (this._batchEnabled) { + // RenderNode display. + } + else { + // Classic display. + _super.prototype.$render.call(this); + } + }; + /** + * @inheritDoc + */ + Movie.prototype.$measureContentBounds = function (bounds) { + if (this._batchEnabled && this._cacheRectangle) { + // RenderNode display. + bounds.setTo(this._cacheRectangle.x, this._cacheRectangle.y, this._cacheRectangle.width - this._cacheRectangle.x, this._cacheRectangle.height - this._cacheRectangle.y); + } + else { + // Classic display. + _super.prototype.$measureContentBounds.call(this, bounds); + } + }; + /** + * @inheritDoc + */ + Movie.prototype.$doAddChild = function (child, index, notifyListeners) { + if (this._batchEnabled) { + // RenderNode display. + console.warn("Can not add child."); + return null; + } + // Classic display. + return _super.prototype.$doAddChild.call(this, child, index, notifyListeners); + }; + /** + * @inheritDoc + */ + Movie.prototype.$doRemoveChild = function (index, notifyListeners) { + if (this._batchEnabled) { + // RenderNode display. + console.warn("Can not remove child."); + return null; + } + // Classic display. + return _super.prototype.$doRemoveChild.call(this, index, notifyListeners); + }; + /** + * 释放动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Movie.prototype.dispose = function () { + if (this._isLockDispose) { + this._isDelayDispose = true; + } + else { + if (this._clock) { + this._clock.remove(this); + } + if (this._slots) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].dispose(); + } + } + this._isPlaying = false; + this._cacheRectangle = null; + this._clock = null; + this._groupConfig = null; + this._config = null; + this._clipConfig = null; + this._currentFrameConfig = null; + this._clipArray = null; + this._clipNames = null; + this._slots = null; + this._childMovies = null; + } + }; + /** + * @inheritDoc + */ + Movie.prototype.advanceTime = function (passedTime) { + if (this._isPlaying) { + this._isLockDispose = true; + if (passedTime < 0) { + passedTime = -passedTime; + } + passedTime *= this.timeScale; + this._time += passedTime * this.clipTimeScale; + // Modify time. + var duration = this._clipConfig.duration; + var totalTime = duration * this._playTimes; + var currentTime = this._time; + var currentPlayTimes = this._currentPlayTimes; + if (this._playTimes > 0 && (currentTime >= totalTime || currentTime <= -totalTime)) { + this._isCompleted = true; + currentPlayTimes = this._playTimes; + if (currentTime < 0) { + currentTime = 0; + } + else { + currentTime = duration; + } + } + else { + this._isCompleted = false; + if (currentTime < 0) { + currentPlayTimes = Math.floor(-currentTime / duration); + currentTime = duration - (-currentTime % duration); + } + else { + currentPlayTimes = Math.floor(currentTime / duration); + currentTime %= duration; + } + if (this._playTimes > 0 && currentPlayTimes > this._playTimes) { + currentPlayTimes = this._playTimes; + } + } + if (this._currentTime === currentTime) { + return; + } + var cacheFrameIndex = Math.floor(currentTime * this._clipConfig.cacheTimeToFrameScale); + if (this._cacheFrameIndex !== cacheFrameIndex) { + this._cacheFrameIndex = cacheFrameIndex; + var displayFrameArray = this._groupConfig.displayFrameArray; + var transformArray = this._groupConfig.transformArray; + var colorArray = this._groupConfig.colorArray; + // + var isFirst = true; + var hasDisplay = false; + var needCacheRectangle = false; + var prevCacheRectangle = this._cacheRectangle; + this._cacheRectangle = this._clipConfig.cacheRectangles[this._cacheFrameIndex]; + if (this._batchEnabled && !this._cacheRectangle) { + needCacheRectangle = true; + this._cacheRectangle = new egret.Rectangle(); + this._clipConfig.cacheRectangles[this._cacheFrameIndex] = this._cacheRectangle; + } + // Update slots. + for (var i = 0, l = this._slots.length; i < l; ++i) { + var slot = this._slots[i]; + var clipFrameIndex = this._frameSize * this._cacheFrameIndex + i * 2; + if (clipFrameIndex >= this._clipArray.length) { + clipFrameIndex = this._frameSize * (this._cacheFrameIndex - 1) + i * 2; + } + var displayFrameIndex = this._clipArray[clipFrameIndex] * 2; + if (displayFrameIndex >= 0) { + var displayIndex = displayFrameArray[displayFrameIndex]; + var colorIndex = displayFrameArray[displayFrameIndex + 1] * 8; + var transformIndex = this._clipArray[clipFrameIndex + 1] * 6; + var colorChange = false; + if (slot.displayIndex !== displayIndex) { + slot.displayIndex = displayIndex; + colorChange = true; + this._updateSlotDisplay(slot); + } + if (slot.colorIndex !== colorIndex || colorChange) { + slot.colorIndex = colorIndex; + if (slot.colorIndex >= 0) { + this._updateSlotColor(slot, colorArray[colorIndex] * 0.01, colorArray[colorIndex + 1] * 0.01, colorArray[colorIndex + 2] * 0.01, colorArray[colorIndex + 3] * 0.01, colorArray[colorIndex + 4], colorArray[colorIndex + 5], colorArray[colorIndex + 6], colorArray[colorIndex + 7]); + } + else { + this._updateSlotColor(slot, 1, 1, 1, 1, 0, 0, 0, 0); + } + } + hasDisplay = true; + if (slot.transformIndex !== transformIndex) { + slot.transformIndex = transformIndex; + if (this._batchEnabled) { + // RenderNode display. + var matrix = slot.display.$renderNode.matrix; + if (!matrix) { + matrix = slot.display.$renderNode.matrix = new egret.Matrix(); + } + matrix.a = transformArray[transformIndex]; + matrix.b = transformArray[transformIndex + 1]; + matrix.c = transformArray[transformIndex + 2]; + matrix.d = transformArray[transformIndex + 3]; + matrix.tx = transformArray[transformIndex + 4]; + matrix.ty = transformArray[transformIndex + 5]; + } + else { + // Classic display. + _helpMatrix.a = transformArray[transformIndex]; + _helpMatrix.b = transformArray[transformIndex + 1]; + _helpMatrix.c = transformArray[transformIndex + 2]; + _helpMatrix.d = transformArray[transformIndex + 3]; + _helpMatrix.tx = transformArray[transformIndex + 4]; + _helpMatrix.ty = transformArray[transformIndex + 5]; + slot.display.$setMatrix(_helpMatrix); + } + } + // + if (this._batchEnabled && needCacheRectangle && slot.displayConfig) { + // RenderNode display. + var matrix = slot.display.$renderNode.matrix; + _helpRectangle.x = 0; + _helpRectangle.y = 0; + _helpRectangle.width = slot.displayConfig.texture.textureWidth; + _helpRectangle.height = slot.displayConfig.texture.textureHeight; + matrix.$transformBounds(_helpRectangle); + if (isFirst) { + isFirst = false; + this._cacheRectangle.x = _helpRectangle.x; + this._cacheRectangle.width = _helpRectangle.x + _helpRectangle.width; + this._cacheRectangle.y = _helpRectangle.y; + this._cacheRectangle.height = _helpRectangle.y + _helpRectangle.height; + } + else { + this._cacheRectangle.x = Math.min(this._cacheRectangle.x, _helpRectangle.x); + this._cacheRectangle.width = Math.max(this._cacheRectangle.width, _helpRectangle.x + _helpRectangle.width); + this._cacheRectangle.y = Math.min(this._cacheRectangle.y, _helpRectangle.y); + this._cacheRectangle.height = Math.max(this._cacheRectangle.height, _helpRectangle.y + _helpRectangle.height); + } + } + } + else if (slot.displayIndex !== -1) { + slot.displayIndex = -1; + this._updateSlotDisplay(slot); + } + } + // + if (this._cacheRectangle) { + if (hasDisplay && needCacheRectangle && isFirst && prevCacheRectangle) { + this._cacheRectangle.x = prevCacheRectangle.x; + this._cacheRectangle.y = prevCacheRectangle.y; + this._cacheRectangle.width = prevCacheRectangle.width; + this._cacheRectangle.height = prevCacheRectangle.height; + } + this.$invalidateContentBounds(); + } + } + if (this._isCompleted) { + this._isPlaying = false; + } + if (!this._isStarted) { + this._isStarted = true; + if (this.hasEventListener(MovieEvent.START)) { + var event_3 = egret.Event.create(MovieEvent, MovieEvent.START); + event_3.movie = this; + event_3.clipName = this._clipConfig.name; + event_3.name = ""; + event_3.slotName = ""; + this.dispatchEvent(event_3); + } + } + this._isReversing = this._currentTime > currentTime && this._currentPlayTimes === currentPlayTimes; + this._currentTime = currentTime; + // Action and event. + var frameCount = this._clipConfig.frame ? this._clipConfig.frame.length : 0; + if (frameCount > 0) { + var currentFrameIndex = Math.floor(this._currentTime * this._config.frameRate); + var currentFrameConfig = this._groupConfig.frame[this._clipConfig.frame[currentFrameIndex]]; + if (this._currentFrameConfig !== currentFrameConfig) { + if (frameCount > 1) { + var crossedFrameConfig = this._currentFrameConfig; + this._currentFrameConfig = currentFrameConfig; + if (!crossedFrameConfig) { + var prevFrameIndex = Math.floor(this._currentTime * this._config.frameRate); + crossedFrameConfig = this._groupConfig.frame[this._clipConfig.frame[prevFrameIndex]]; + if (this._isReversing) { + } + else { + if (this._currentTime <= crossedFrameConfig.position || + this._currentPlayTimes !== currentPlayTimes) { + crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; + } + } + } + if (this._isReversing) { + while (crossedFrameConfig !== currentFrameConfig) { + this._onCrossFrame(crossedFrameConfig); + crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; + } + } + else { + while (crossedFrameConfig !== currentFrameConfig) { + crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.next]; + this._onCrossFrame(crossedFrameConfig); + } + } + } + else { + this._currentFrameConfig = currentFrameConfig; + if (this._currentFrameConfig) { + this._onCrossFrame(this._currentFrameConfig); + } + } + } + } + if (this._currentPlayTimes !== currentPlayTimes) { + this._currentPlayTimes = currentPlayTimes; + if (this.hasEventListener(MovieEvent.LOOP_COMPLETE)) { + var event_4 = egret.Event.create(MovieEvent, MovieEvent.LOOP_COMPLETE); + event_4.movie = this; + event_4.clipName = this._clipConfig.name; + event_4.name = ""; + event_4.slotName = ""; + this.dispatchEvent(event_4); + egret.Event.release(event_4); + } + if (this._isCompleted && this.hasEventListener(MovieEvent.COMPLETE)) { + var event_5 = egret.Event.create(MovieEvent, MovieEvent.COMPLETE); + event_5.movie = this; + event_5.clipName = this._clipConfig.name; + event_5.name = ""; + event_5.slotName = ""; + this.dispatchEvent(event_5); + egret.Event.release(event_5); + } + } + } + this._isLockDispose = false; + if (this._isDelayDispose) { + this.dispose(); + } + }; + /** + * 播放动画剪辑。 + * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 + * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 4.7 + * @language zh_CN + */ + Movie.prototype.play = function (clipName, playTimes) { + if (clipName === void 0) { clipName = null; } + if (playTimes === void 0) { playTimes = -1; } + if (clipName) { + var clipConfig = null; + for (var i = 0, l = this._config.clip.length; i < l; ++i) { + var data = this._config.clip[i]; + if (data.name === clipName) { + clipConfig = data; + } + } + if (clipConfig) { + this._clipConfig = clipConfig; + this._clipArray = new Int16Array(this._groupConfig.arrayBuffer, this._groupConfig.offset + this._groupConfig.position[0] + this._clipConfig.p, this._clipConfig.s / this._groupConfig.position[2]); + if (!this._clipConfig.cacheRectangles) { + this._clipConfig.cacheRectangles = []; + } + this._isPlaying = true; + this._isStarted = false; + this._isCompleted = false; + if (playTimes < 0 || playTimes !== playTimes) { + this._playTimes = this._clipConfig.playTimes; + } + else { + this._playTimes = playTimes; + } + this._time = 0; + this._currentTime = 0; + this._currentPlayTimes = 0; + this._cacheFrameIndex = -1; + this._currentFrameConfig = null; + this._cacheRectangle = null; + this.clipTimeScale = 1 / this._clipConfig.scale; + } + else { + console.warn("No clip in movie.", this._config.name, clipName); + } + } + else if (this._clipConfig) { + if (this._isPlaying || this._isCompleted) { + this.play(this._clipConfig.name, this._playTimes); + } + else { + this._isPlaying = true; + } + // playTimes + } + else if (this._config.action) { + this.play(this._config.action, playTimes); + } + }; + /** + * 暂停播放动画。 + * @version DragonBones 4.7 + * @language zh_CN + */ + Movie.prototype.stop = function () { + this._isPlaying = false; + }; + /** + * 从指定时间播放动画。 + * @param clipName 动画剪辑的名称。 + * @param time 指定时间。(以秒为单位) + * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 5.0 + * @language zh_CN + */ + Movie.prototype.gotoAndPlay = function (clipName, time, playTimes) { + if (clipName === void 0) { clipName = null; } + if (playTimes === void 0) { playTimes = -1; } + time %= this._clipConfig.duration; + if (time < 0) { + time += this._clipConfig.duration; + } + this.play(clipName, playTimes); + this._time = time; + this._currentTime = time; + }; + /** + * 将动画停止到指定时间。 + * @param clipName 动画剪辑的名称。 + * @param time 指定时间。(以秒为单位) + * @version DragonBones 5.0 + * @language zh_CN + */ + Movie.prototype.gotoAndStop = function (clipName, time) { + if (clipName === void 0) { clipName = null; } + time %= this._clipConfig.duration; + if (time < 0) { + time += this._clipConfig.duration; + } + this.play(clipName, 1); + this._time = time; + this._currentTime = time; + this.advanceTime(0.001); + this.stop(); + }; + /** + * 是否包含指定动画剪辑。 + * @param clipName 动画剪辑的名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + Movie.prototype.hasClip = function (clipName) { + for (var i = 0, l = this._config.clip.length; i < l; ++i) { + var clip = this._config.clip[i]; + if (clip.name === clipName) { + return true; + } + } + return false; + }; + Object.defineProperty(Movie.prototype, "isPlaying", { + /** + * 动画剪辑是否处正在播放。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._isPlaying && !this._isCompleted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "isComplete", { + /** + * 动画剪辑是否均播放完毕。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._isCompleted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "currentTime", { + /** + * 当前动画剪辑的播放时间。 (以秒为单位) + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._currentTime; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "totalTime", { + /** + * 当前动画剪辑的总时间。 (以秒为单位) + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._clipConfig ? this._clipConfig.duration : 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "currentPlayTimes", { + /** + * 当前动画剪辑的播放次数。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "playTimes", { + /** + * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._playTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "groupName", { + get: function () { + return this._groupConfig.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "clipName", { + /** + * 正在播放的动画剪辑名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._clipConfig ? this._clipConfig.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "clipNames", { + /** + * 所有动画剪辑的名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + return this._clipNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "clock", { + /** + * @inheritDoc + */ + get: function () { + return this._clock; + }, + set: function (value) { + if (this._clock === value) { + return; + } + var prevClock = this._clock; + if (prevClock) { + prevClock.remove(this); + } + this._clock = value; + if (this._clock) { + this._clock.add(this); + } + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Movie#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Movie#timescale + * @see dragonBones.Movie#stop() + */ + Movie.prototype.advanceTimeBySelf = function (on) { + if (on) { + this.clock = dragonBones.EgretFactory.clock; + } + else { + this.clock = null; + } + }; + Object.defineProperty(Movie.prototype, "display", { + //========================================= // 兼容旧数据 + /** + * @private + */ + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "animation", { + /** + * @private + */ + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "armature", { + /** + * @private + */ + get: function () { + return this; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + Movie.prototype.getAnimation = function () { + return this; + }; + /** + * @private + */ + Movie.prototype.getArmature = function () { + return this; + }; + /** + * @private + */ + Movie.prototype.getDisplay = function () { + return this; + }; + /** + * @private + */ + Movie.prototype.hasAnimation = function (name) { + return this.hasClip(name); + }; + /** + * @private + */ + Movie.prototype.invalidUpdate = function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + args; + }; + Object.defineProperty(Movie.prototype, "lastAnimationName", { + /** + * @private + */ + get: function () { + return this.clipName; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "animationNames", { + /** + * @private + */ + get: function () { + return this.clipNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Movie.prototype, "animationList", { + /** + * @private + */ + get: function () { + return this.clipNames; + }, + enumerable: true, + configurable: true + }); + return Movie; + }(egret.DisplayObjectContainer)); + dragonBones.Movie = Movie; +})(dragonBones || (dragonBones = {})); diff --git a/reference/Egret/4.x/out/dragonBones.min.js b/reference/Egret/4.x/out/dragonBones.min.js new file mode 100644 index 0000000..1499e96 --- /dev/null +++ b/reference/Egret/4.x/out/dragonBones.min.js @@ -0,0 +1 @@ +"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]};return function(e,i){t(e,i);function a(){this.constructor=e}e.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}}();var dragonBones;(function(t){var e=function(){function e(e){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=e}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var i=0,a=this._objects;i0){for(var n=0;ni){r.length=i}t._maxCountMap[a]=i}else{t._defaultMaxCount=i;for(var a in t._poolsMap){if(a in t._maxCountMap){continue}var r=t._poolsMap[a];if(r.length>i){r.length=i}t._maxCountMap[a]=i}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in t._poolsMap){var a=t._poolsMap[r];a.length=0}}};t.borrowObject=function(e){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=1e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=1}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=1}if(r===void 0){r=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=i;this.d=a;this.tx=r;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 i=0;var a=0;var r=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;i+=this.b*t.d;a+=this.c*t.a;r+=this.c*t.b}if(t.b!==0||t.c!==0){i+=this.a*t.b;a+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=i;this.c=a;this.d=r;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var i=this.c;var a=this.d;var r=this.tx;var n=this.ty;if(e===0&&i===0){this.b=this.c=0;if(t===0||a===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;a=this.d=1/a;this.tx=-t*r;this.ty=-a*n}return this}var s=t*a-e*i;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=a*s;e=this.b=-e*s;i=this.c=-i*s;a=this.d=t*s;this.tx=-(o*r+i*n);this.ty=-(e*r+a*n);return this};t.prototype.transformPoint=function(t,e,i,a){if(a===void 0){a=false}i.x=this.a*t+this.c*e;i.y=this.b*t+this.d*e;if(!a){i.x+=this.tx;i.y+=this.ty}};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}if(r===void 0){r=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=i;this.rotation=a;this.scaleX=r;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.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};t.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};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.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};t.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};t.prototype.fromMatrix=function(e){var i=this.scaleX,a=this.scaleY;var r=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-r&&this.rotation-r&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.skew!==0||this.rotation!==0){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}}else{t.a=this.scaleX;t.b=0;t.c=0;t.d=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(i===void 0){i=1}if(a===void 0){a=1}if(r===void 0){r=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=i;this.blueMultiplier=a;this.alphaOffset=r;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,i,a){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}this.x=t;this.y=e;this.width=i;this.height=a}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(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){i=0}if(this.sortedBones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames;var a=i.length;i.length+=10;i[a]=t.a;i[a+1]=t.b;i[a+2]=t.c;i[a+3]=t.d;i[a+4]=t.tx;i[a+5]=t.ty;i[a+6]=e.rotation;i[a+7]=e.skew;i[a+8]=e.scaleX;i[a+9]=e.scaleY;return a};i.prototype.getCacheFrame=function(t,e,i){var a=this.parent.cachedFrames;t.a=a[i];t.b=a[i+1];t.c=a[i+2];t.d=a[i+3];t.tx=a[i+4];t.ty=a[i+5];e.rotation=a[i+6];e.skew=a[i+7];e.scaleX=a[i+8];e.scaleY=a[i+9];e.x=t.tx;e.y=t.ty};i.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Replace bone: "+t.name);this.bones[t.name].returnToPool()}this.bones[t.name]=t;this.sortedBones.push(t)};i.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Replace slot: "+t.name);this.slots[t.name].returnToPool()}this.slots[t.name]=t;this.sortedSlots.push(t)};i.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Replace skin: "+t.name);this.skins[t.name].returnToPool()}this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}};i.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Replace animation: "+t.name);this.animations[t.name].returnToPool()}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return i}(t.BaseObject);t.ArmatureData=i;var a=function(e){__extends(i,e);function i(){var i=e!==null&&e.apply(this,arguments)||this;i.transform=new t.Transform;i.constraints=[];i.userData=null;return i}i.toString=function(){return"[class dragonBones.BoneData]"};i.prototype._onClear=function(){for(var t=0,e=this.constraints;tr){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,i,a,r,n,s,o,l,h,u,f){if(h===void 0){h=null}if(u===void 0){u=null}if(f===void 0){f=null}var _=t>n&&ts&&in&&as&&r=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){return true}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var u=e.rectangleIntersectsSegment(t,i,a,r,-l,-h,l,h,n,s,o);return u};return e}(e);t.RectangleBoundingBoxData=i;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,i,a,r,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;a*=f;var c=i-t;var p=a-e;var m=Math.sqrt(c*c+p*p);var d=c/m;var y=p/m;var g=(r-t)*d+(n-e)*y;var v=g*g;var b=t*t+e*e;var D=s*s;var T=D-b+v;var A=0;if(T>=0){var O=Math.sqrt(T);var x=g-O;var B=g+O;var E=x<0?-1:x<=m?0:1;var S=B<0?-1:B<=m?0:1;var M=E*S;if(M<0){return-1}else if(M===0){if(E===-1){A=2;i=t+B*d;a=(e+B*y)/f;if(l!==null){l.x=i;l.y=a}if(h!==null){h.x=i;h.y=a}if(u!==null){u.x=Math.atan2(a/D*_,i/D);u.y=u.x+Math.PI}}else if(S===1){A=1;t=t+x*d;e=(e+x*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/D*_,t/D);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+x*d;l.y=(e+x*y)/f;if(u!==null){u.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+B*d;h.y=(e+B*y)/f;if(u!==null){u.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var i=this.width*.5;if(t>=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){e*=i/a;return Math.sqrt(t*t+e*e)<=i}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,i,a,r,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.weight=null;return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,i,a,r,n,s,o,l,h){if(o===void 0){o=null}if(l===void 0){l=null}if(h===void 0){h=null}if(t===i){t=i+1e-6}if(e===a){e=a+1e-6}var u=t-i;var f=e-a;var _=t*a-e*i;var c=0;var p=r[n+s-2];var m=r[n+s-1];var d=0;var y=0;var g=0;var v=0;var b=0;var D=0;for(var T=0;T=p&&M<=A||M>=A&&M<=p)&&(u===0||M>=t&&M<=i||M>=i&&M<=t)){var w=(_*B-f*E)/S;if((w>=m&&w<=O||w>=O&&w<=m)&&(f===0||w>=e&&w<=a||w>=a&&w<=e)){if(l!==null){var P=M-t;if(P<0){P=-P}if(c===0){d=P;y=P;g=M;v=w;b=M;D=w;if(h!==null){h.x=Math.atan2(O-m,A-p)-Math.PI*.5;h.y=h.x}}else{if(Py){y=P;b=M;D=w;if(h!==null){h.y=Math.atan2(O-m,A-p)-Math.PI*.5}}}c++}else{g=M;v=w;b=M;D=w;c++;if(h!==null){h.x=Math.atan2(O-m,A-p)-Math.PI*.5;h.y=h.x}break}}}p=A;m=O}if(c===1){if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=g;l.y=v}if(h!==null){h.y=h.x+Math.PI}}else if(c>1){c++;if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=b;l.y=D}}return c};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.weight!==null){this.weight.returnToPool()}this.type=2;this.count=0;this.offset=0;this.x=0;this.y=0;this.vertices=null;this.weight=null};e.prototype.containsPoint=function(t,e){var i=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var a=0,r=this.count,n=r-2;a=e||s=e){var l=this.vertices[this.offset+n];var h=this.vertices[this.offset+a];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 i=0,a=this.cacheFrames.length;i=0};e.prototype.addBoneMask=function(t,e,i){if(i===void 0){i=true}var a=t.getBone(e);if(a===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(i){for(var r=0,n=t.getBones();r=0){this.boneMask.splice(a,1)}if(i){var r=t.getBone(e);if(r!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&r.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,u=t.getBones();he._zOrder?1:-1};i.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=t){i=0}if(this._bones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s=n){continue}var o=i[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(r)}}this._slotsDirty=true;this._zOrderDirty=!a}};i.prototype._addBoneToBoneList=function(t){if(this._bones.indexOf(t)<0){this._bonesDirty=true;this._bones.push(t);this._animation._timelineDirty=true}};i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);if(e>=0){this._bones.splice(e,1);this._animation._timelineDirty=true}};i.prototype._addSlotToSlotList=function(t){if(this._slots.indexOf(t)<0){this._slotsDirty=true;this._slots.push(t);this._animation._timelineDirty=true}};i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);if(e>=0){this._slots.splice(e,1);this._animation._timelineDirty=true}};i.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};i.prototype.dispose=function(){if(this.armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};i.prototype.init=function(e,i,a,r){if(this.armatureData!==null){return}this.armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=i;this._display=a;this._dragonBones=r;this._proxy.init(this);this._animation.init(this);this._animation.animations=this.armatureData.animations};i.prototype.advanceTime=function(e){if(this._lockUpdate){return}if(this.armatureData===null){console.assert(false,"The armature has been disposed.");return}else if(this.armatureData.parent===null){console.assert(false,"The armature data has been disposed.");return}var i=this._cacheFrameIndex;this._animation.advanceTime(e);if(this._bonesDirty){this._bonesDirty=false;this._sortBones()}if(this._slotsDirty){this._slotsDirty=false;this._sortSlots()}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==i){var a=0,r=0;for(a=0,r=this._bones.length;a0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var i=this.getBone(t);if(i!==null){i.invalidUpdate();if(e){for(var a=0,r=this._slots;a0){if(r!==null||n!==null){if(r!==null){var T=o?r.y-e:r.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;c=n.y;y=b;if(s!==null){m=s.y}}}}else{d=b;break}}}if(d!==null&&r!==null){r.x=u;r.y=f;if(s!==null){s.x=p}}if(y!==null&&n!==null){n.x=_;n.y=c;if(s!==null){s.y=m}}return d};i.prototype.getBone=function(t){for(var e=0,i=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.constraints.length>0){for(var i=0,a=this.constraints;i=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this.constraints.length>0){for(var n=0,s=this.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};i.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};i.prototype.addConstraint=function(t){if(this.constraints.indexOf(t)<0){this.constraints.push(t)}};i.prototype.invalidUpdate=function(){this._transformDirty=true};i.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};i.prototype.getBones=function(){this._bones.length=0;for(var t=0,e=this._armature.getBones();t=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var i=0,a=e.length;i0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=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._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._display===null){return}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._meshData!==null&&this._display===this._meshDisplay){var i=this._meshData.weight!==null;if(this._meshDirty||i&&this._isMeshBonesUpdate()){this._meshDirty=false;this._updateMesh()}if(i){if(this._transformDirty){this._transformDirty=false;this._updateTransform(true)}return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var a=t>=0;this._updateGlobalTransformMatrix(a);if(a&&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(false)}};i.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};i.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);return this._boundingBoxData.containsPoint(i._helpPoint.x,i._helpPoint.y)};i.prototype.intersectsSegment=function(t,e,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);t=i._helpPoint.x;e=i._helpPoint.y;i._helpMatrix.transformPoint(a,r,i._helpPoint);a=i._helpPoint.x;r=i._helpPoint.y;var l=this._boundingBoxData.intersectsSegment(t,e,a,r,n,s,o);if(l>0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,true);o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,true);o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x)}}return l};i.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat();var a=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var r=0,n=i;r0){this._animatebles[e-i]=r;this._animatebles[e]=null}r.advanceTime(t)}else{i++}}if(i>0){a=this._animatebles.length;for(;e=0};t.prototype.add=function(t){if(this._animatebles.indexOf(t)<0){this._animatebles.push(t);t.clock=this}};t.prototype.remove=function(t){var e=this._animatebles.indexOf(t);if(e>=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&i._subFadeState>0){this._armature._dragonBones.bufferObject(i);this._animationStates.length=0;this._lastAnimationState=null}else{var a=i.animationData;var r=a.cacheFrameRate;if(this._animationDirty&&r>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n1){for(var f=0,_=0;f0&&i._subFadeState>0){_++;this._armature._dragonBones.bufferObject(i);this._animationDirty=true;if(this._lastAnimationState===i){this._lastAnimationState=null}}else{if(_>0){this._animationStates[f-_]=i}if(this._timelineDirty){i.updateTimelines()}i.advanceTime(t,0)}if(f===e-1&&_>0){this._animationStates.length-=_;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}this._timelineDirty=false};i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=a.duration;e.position=a.duration-e.position}else if(e.position===a.duration){e.position-=1e-6}else if(e.position>a.duration){e.position%=a.duration}if(e.duration>0&&e.position+e.duration>a.duration){e.duration=a.duration-e.position}if(e.playTimes<0){e.playTimes=a.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,a,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,u=this._animationStates.length;h=this._animationStates[h].layer){}else{l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var f=0,_=this._armature.getSlots();f<_.length;f++){var c=_[f];var p=c.childArmature;if(p!==null&&p.inheritAnimation&&p.animation.hasAnimation(i)&&p.animation.getState(i)===null){p.animation.fadeIn(i)}}if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o;return o};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var i=this._armature.armatureData.defaultAnimation;if(i!==null){this._animationConfig.animation=i.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};i.prototype.fadeIn=function(t,e,i,a,r,n){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=0}if(r===void 0){r=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=i;this._animationConfig.layer=a;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=r!==null?r:"";return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByTime=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByFrame=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*e/a.frameCount}return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByProgress=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByTime(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByFrame(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByProgress(t,e,1);if(i!==null){i.stop()}return i};i.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var i=this._animationStates[e];if(i.name===t){return i}}return null};i.prototype.hasAnimation=function(t){return t in this._animations};i.prototype.getStates=function(){return this._animationStates};Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.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._animations[e]=t[e];this._animationNames.push(e)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});i.prototype.gotoAndPlay=function(t,e,i,a,r,n,s,o,l){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&i>0){this._animationConfig.timeScale=h.duration/i}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}return this.gotoAndStopByTime(t,e)};Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationDataList",{get:function(){var t=[];for(var e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var a=i?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=i?0:1}else if(this._fadeTime>0){this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=i?1:0}if(this._subFadeState>0){if(!i){this._playheadState|=1;this._fadeState=0}var a=i?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}};a.prototype._blendBoneTimline=function(t){var e=t.bone;var i=t.bonePose.result;var a=e.animationPose;var r=this._weightResult>0?this._weightResult:-this._weightResult;if(!e._blendDirty){e._blendDirty=true;e._blendLayer=this.layer;e._blendLayerWeight=r;e._blendLeftWeight=1;a.x=i.x*r;a.y=i.y*r;a.rotation=i.rotation*r;a.skew=i.skew*r;a.scaleX=(i.scaleX-1)*r+1;a.scaleY=(i.scaleY-1)*r+1}else{r*=e._blendLeftWeight;e._blendLayerWeight+=r;a.x+=i.x*r;a.y+=i.y*r;a.rotation+=i.rotation*r;a.skew+=i.skew*r;a.scaleX+=(i.scaleX-1)*r;a.scaleY+=(i.scaleY-1)*r}if(this._fadeState!==0||this._subFadeState!==0){e._transformDirty=true}};a.prototype.init=function(e,i,a){if(this._armature!==null){return}this._armature=e;this.animationData=i;this.resetToPose=a.resetToPose;this.additiveBlending=a.additiveBlending;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.weight=a.weight;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;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,n=this._boneMask.length;r0;var a=true;var r=true;var n=this._time;this._weightResult=this.weight*this._fadeProgress;this._actionTimeline.update(n);if(i){var s=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*s)/s}if(this._zOrderTimeline!==null){this._zOrderTimeline.update(n)}if(i){var o=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===o){a=false;r=false}else{this._armature._cacheFrameIndex=o;if(this.animationData.cachedFrames[o]){r=false}else{this.animationData.cachedFrames[o]=true}}}if(a){if(r){var l=null;var h=null;for(var u=0,f=this._boneTimelines.length;u0){if(l._blendLayer!==this.layer){if(l._blendLayerWeight>=l._blendLeftWeight){l._blendLeftWeight=0;l=null}else{l._blendLayer=this.layer;l._blendLeftWeight-=l._blendLayerWeight;l._blendLayerWeight=0}}}else{l=null}}}l=_.bone}if(l!==null){_.update(n);if(u===f-1){this._blendBoneTimline(_)}else{h=_}}}}for(var u=0,f=this._slotTimelines.length;u0){this._subFadeState=0}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};a.prototype.play=function(){this._playheadState=3};a.prototype.stop=function(){this._playheadState&=1};a.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 i=0,a=this._boneTimelines;i1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};a.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};a.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var i=this._armature.getBone(t);if(i===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var a=0,r=this._armature.getBones();a=0){this._boneMask.splice(i,1)}if(e){var a=this._armature.getBone(t);if(a!==null){var r=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=r;n=0&&a.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=r;h0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(a.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){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 i=0,a=this._boneTimelines;i=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var r=this._animationState.playTimes;var n=r*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(r>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=r;if(t<0){this.currentTime=0}else{this.currentTime=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===i&&this.currentTime===a){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i){this._frameIndex=-1}return true};e.prototype.init=function(t,e,i){this._armature=t;this._animationState=e;this._timelineData=i;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._frameRate=this._armature.armatureData.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._armature.armatureData.parent;this._animationData=this._animationState.animationData;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.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(){};e.prototype.update=function(t){if(this.playState<=0&&this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var i=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==i){this._frameIndex=i;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._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,i){var a=e;switch(t){case 3:a=Math.pow(e,2);break;case 4:a=1-Math.pow(1-e,2);break;case 5:a=.5*(1-Math.cos(e*Math.PI));break}return(a-e)*i+e};e._getEasingCurveValue=function(t,e,i,a){if(t<=0){return 0}else if(t>=1){return 1}var r=i+1;var n=Math.floor(t*r);var s=n===0?0:e[a+n-1];var o=n===r-1?1e4:e[a+n];return(s+(o-s)*(t*r-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){if(n.hasEvent(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.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 c=this._frameIndex;this._frameIndex=_;if(this._timelineArray!==null){this._frameOffset=this._animationData.frameOffset+this._timelineArray[u.offset+5+this._frameIndex];if(o){if(c<0){var p=Math.floor(r*this._frameRate);c=this._frameIndices[u.frameIndicesOffset+p];if(this.currentPlayTimes===a){if(c===_){c=-1}}}while(c>=0){var m=this._animationData.frameOffset+this._timelineArray[u.offset+5+c];var d=this._frameArray[m]/this._frameRate;if(this._position<=d&&d<=this._position+this._duration){this._onCrossFrame(c)}if(l!==null&&c===0){this._armature._dragonBones.bufferEvent(l);l=null}if(c>0){c--}else{c=this._frameCount-1}if(c===_){break}}}else{if(c<0){var p=Math.floor(r*this._frameRate);c=this._frameIndices[u.frameIndicesOffset+p];var m=this._animationData.frameOffset+this._timelineArray[u.offset+5+c];var d=this._frameArray[m]/this._frameRate;if(this.currentPlayTimes===a){if(r<=d){if(c>0){c--}else{c=this._frameCount-1}}else if(c===_){c=-1}}}while(c>=0){if(c=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}(t.TimelineState);t.ZOrderTimelineState=i;var a=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};i.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._dragonBonesData.frameFloatArray;var i=this.bonePose.current;var a=this.bonePose.delta;var r=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;i.x=t[r++];i.y=t[r++];i.rotation=t[r++];i.skew=t[r++];i.scaleX=t[r++];i.scaleY=t[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}a.x=t[r++]-i.x;a.y=t[r++]-i.y;a.rotation=t[r++]-i.rotation;a.skew=t[r++]-i.skew;a.scaleX=t[r++]-i.scaleX;a.scaleY=t[r++]-i.scaleY}}else{var i=this.bonePose.current;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1}};i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var i=this.bonePose.delta;var a=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}var r=this._armature.armatureData.scale;a.x=(t.x+i.x*this._tweenProgress)*r;a.y=(t.y+i.y*this._tweenProgress)*r;a.rotation=t.rotation+i.rotation*this._tweenProgress;a.skew=t.skew+i.skew*this._tweenProgress;a.scaleX=t.scaleX+i.scaleX*this._tweenProgress;a.scaleY=t.scaleY+i.scaleY*this._tweenProgress};i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return i}(t.BoneTimelineState);t.BoneAllTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDislayIndexTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot.slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayIndexTimelineState=r;var n=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var i=this._dragonBonesData.frameIntArray;var a=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var r=i[a];this._current[0]=e[r++];this._current[1]=e[r++];this._current[2]=e[r++];this._current[3]=e[r++];this._current[4]=e[r++];this._current[5]=e[r++];this._current[6]=e[r++];this._current[7]=e[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=i[this._animationData.frameIntOffset+this._frameValueOffset]}else{r=i[a+1*1]}this._delta[0]=e[r++]-this._current[0];this._delta[1]=e[r++]-this._current[1];this._delta[2]=e[r++]-this._current[2];this._delta[3]=e[r++]-this._current[3];this._delta[4]=e[r++]-this._current[4];this._delta[5]=e[r++]-this._current[5];this._delta[6]=e[r++]-this._current[6];this._delta[7]=e[r++]-this._current[7]}}else{var n=this.slot.slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var i=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var a=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*a;i.redMultiplier+=(this._result[1]-i.redMultiplier)*a;i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*a;i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*a;i.alphaOffset+=(this._result[4]-i.alphaOffset)*a;i.redOffset+=(this._result[5]-i.redOffset)*a;i.greenOffset+=(this._result[6]-i.greenOffset)*a;i.blueOffset+=(this._result[7]-i.blueOffset)*a;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){i.alphaMultiplier=this._result[0];i.redMultiplier=this._result[1];i.greenMultiplier=this._result[2];i.blueMultiplier=this._result[3];i.alphaOffset=this._result[4];i.redOffset=this._result[5];i.greenOffset=this._result[6];i.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=n;var s=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SlotFFDTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.meshOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._ffdCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._tweenState===2;var i=this._dragonBonesData.frameFloatArray;var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;if(e){var r=a+this._valueCount;if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n255){return encodeURI(r)}}}return r}return String(r)}return a};a.prototype._getCurvePoint=function(t,e,i,a,r,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var c=u*f;var p=3*l*f;var m=3*u*_;var d=l*_;h.x=c*t+p*i+m*r+d*s;h.y=c*e+p*a+m*n+d*o};a.prototype._samplingEasingCurve=function(t,e){var i=t.length;var a=-2;for(var r=0,n=e.length;r=0&&a+61e-4){var g=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,c,p,m,g,this._helpPoint);if(s-this._helpPoint.x>0){d=g}else{y=g}}e[r]=this._helpPoint.y}};a.prototype._sortActionFrame=function(t,e){return t.frameStart>e.frameStart?1:-1};a.prototype._parseActionDataInFrame=function(t,e,i,r){if(a.EVENT in t){this._mergeActionFrame(t[a.EVENT],e,10,i,r)}if(a.SOUND in t){this._mergeActionFrame(t[a.SOUND],e,11,i,r)}if(a.ACTION in t){this._mergeActionFrame(t[a.ACTION],e,0,i,r)}if(a.EVENTS in t){this._mergeActionFrame(t[a.EVENTS],e,10,i,r)}if(a.ACTIONS in t){this._mergeActionFrame(t[a.ACTIONS],e,0,i,r)}};a.prototype._mergeActionFrame=function(e,a,r,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,this._armature.actions,r,n,s);var h=null;if(this._actionFrames.length===0){h=new i;h.frameStart=0;this._actionFrames.push(h);h=null}for(var u=0,f=this._actionFrames;u0){var p=r.getBone(_);if(p!==null){c.parent=p}else{(this._cacheBones[_]=this._cacheBones[_]||[]).push(c)}}if(c.name in this._cacheBones){for(var m=0,d=this._cacheBones[c.name];m0){n.root=i.parent}if(t.DragonBones.webAssembly){i.constraints.push_back(n)}else{i.constraints.push(n)}};a.prototype._parseSlot=function(e){var i=t.DragonBones.webAssembly?new Module["SlotData"]:t.BaseObject.borrowObject(t.SlotData);i.displayIndex=a._getNumber(e,a.DISPLAY_INDEX,0);i.zOrder=t.DragonBones.webAssembly?this._armature.sortedSlots.size():this._armature.sortedSlots.length;i.name=a._getString(e,a.NAME,"");i.parent=this._armature.getBone(a._getString(e,a.PARENT,""));if(a.BLEND_MODE in e&&typeof e[a.BLEND_MODE]==="string"){i.blendMode=a._getBlendMode(e[a.BLEND_MODE])}else{i.blendMode=a._getNumber(e,a.BLEND_MODE,0)}if(a.COLOR in e){i.color=t.DragonBones.webAssembly?Module["SlotData"].createColor():t.SlotData.createColor();this._parseColorTransform(e[a.COLOR],i.color)}else{i.color=t.DragonBones.webAssembly?Module["SlotData"].DEFAULT_COLOR:t.SlotData.DEFAULT_COLOR}if(a.ACTIONS in e){var r=this._slotChildActions[i.name]=[];this._parseActionData(e[a.ACTIONS],r,0,null,null)}return i};a.prototype._parseSkin=function(e){var i=t.DragonBones.webAssembly?new Module["SkinData"]:t.BaseObject.borrowObject(t.SkinData);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length===0){i.name=a.DEFAULT_NAME}if(a.SLOT in e){this._skin=i;var r=e[a.SLOT];for(var n=0,s=r;n0?n:r;this._parsePivot(e,o);break;case 1:var l=i=t.DragonBones.webAssembly?new Module["ArmatureDisplayData"]:t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=r;l.path=n.length>0?n:r;l.inheritAnimation=true;if(a.ACTIONS in e){this._parseActionData(e[a.ACTIONS],l.actions,0,null,null)}else if(this._slot.name in this._slotChildActions){var h=this._skin.getDisplays(this._slot.name);if(h===null?this._slot.displayIndex===0:this._slot.displayIndex===h.length){for(var u=0,f=this._slotChildActions[this._slot.name];u0?n:r;c.inheritAnimation=a._getBoolean(e,a.INHERIT_FFD,true);this._parsePivot(e,c);var p=a._getString(e,a.SHARE,"");if(p.length>0){var m=this._meshs[p];c.offset=m.offset;c.weight=m.weight}else{this._parseMesh(e,c);this._meshs[c.name]=c}break;case 3:var d=this._parseBoundingBox(e);if(d!==null){var y=i=t.DragonBones.webAssembly?new Module["BoundingBoxDisplayData"]:t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=r;y.path=n.length>0?n:r;y.boundingBox=d}break}if(i!==null){i.parent=this._armature;if(a.TRANSFORM in e){this._parseTransform(e[a.TRANSFORM],i.transform,this._armature.scale)}}return i};a.prototype._parsePivot=function(t,e){if(a.PIVOT in t){var i=t[a.PIVOT];e.pivot.x=a._getNumber(i,a.X,0);e.pivot.y=a._getNumber(i,a.Y,0)}else{e.pivot.x=.5;e.pivot.y=.5}};a.prototype._parseMesh=function(e,i){var r=e[a.VERTICES];var n=e[a.UVS];var s=e[a.TRIANGLES];var o=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var l=t.DragonBones.webAssembly?this._floatArrayJson:this._data.floatArray;var h=Math.floor(r.length/2);var u=Math.floor(s.length/3);var f=l.length;var _=f+h*2;i.offset=o.length;o.length+=1+1+1+1+u*3;o[i.offset+0]=h;o[i.offset+1]=u;o[i.offset+2]=f;for(var c=0,p=u*3;cn.width){n.width=h}if(un.height){n.height=u}}}return n};a.prototype._parseAnimation=function(e){var i=t.DragonBones.webAssembly?new Module["AnimationData"]:t.BaseObject.borrowObject(t.AnimationData);i.frameCount=Math.max(a._getNumber(e,a.DURATION,1),1);i.playTimes=a._getNumber(e,a.PLAY_TIMES,1);i.duration=i.frameCount/this._armature.frameRate;i.fadeInTime=a._getNumber(e,a.FADE_IN_TIME,0);i.scale=a._getNumber(e,a.SCALE,1);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length<1){i.name=a.DEFAULT_NAME}if(t.DragonBones.webAssembly){i.frameIntOffset=this._frameIntArrayJson.length;i.frameFloatOffset=this._frameFloatArrayJson.length;i.frameOffset=this._frameArrayJson.length}else{i.frameIntOffset=this._data.frameIntArray.length;i.frameFloatOffset=this._data.frameFloatArray.length;i.frameOffset=this._data.frameArray.length}this._animation=i;if(a.FRAME in e){var r=e[a.FRAME];var n=r.length;if(n>0){for(var s=0,o=0;s0){this._actionFrames.sort(this._sortActionFrame);var D=this._animation.actionTimeline=t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);var T=t.DragonBones.webAssembly?this._timelineArrayJson:this._data.timelineArray;var n=this._actionFrames.length;D.type=0;D.offset=T.length;T.length+=1+1+1+1+1+n;T[D.offset+0]=100;T[D.offset+1]=0;T[D.offset+2]=n;T[D.offset+3]=0;T[D.offset+4]=0;this._timeline=D;if(n===1){D.frameIndicesOffset=-1;T[D.offset+5+0]=this._parseCacheActionFrame(this._actionFrames[0])-this._animation.frameOffset}else{var A=this._animation.frameCount+1;var O=this._data.frameIndices;if(t.DragonBones.webAssembly){D.frameIndicesOffset=O.size();for(var x=0;x0){if(a.CURVE in t){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(t[a.CURVE],this._helpArray);r.length+=1+1+this._helpArray.length;r[n+1]=2;r[n+2]=s;for(var o=0;o0){var l=this._armature.sortedSlots.length;var h=new Array(l-o.length/2);var u=new Array(l);for(var f=0;f0?l>=this._prevRotation:l<=this._prevRotation){this._prevTweenRotate=this._prevTweenRotate>0?this._prevTweenRotate-1:this._prevTweenRotate+1}l=this._prevRotation+l-this._prevRotation+t.Transform.PI_D*this._prevTweenRotate}}this._prevTweenRotate=a._getNumber(e,a.TWEEN_ROTATE,0);this._prevRotation=l;var h=n.length;n.length+=6;n[h++]=this._helpTransform.x;n[h++]=this._helpTransform.y;n[h++]=l;n[h++]=this._helpTransform.skew;n[h++]=this._helpTransform.scaleX;n[h++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,i,this._bone,this._slot);return o};a.prototype._parseSlotDisplayIndexFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var s=this._parseFrame(e,i,r,n);n.length+=1;n[s+1]=a._getNumber(e,a.DISPLAY_INDEX,0);this._parseActionDataInFrame(e,i,this._slot.parent,this._slot);return s};a.prototype._parseSlotColorFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameIntArrayJson:this._data.frameIntArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=this._parseTweenFrame(e,i,r,o);var h=-1;if(a.COLOR in e){var u=e[a.COLOR];for(var f in u){f;this._parseColorTransform(u,this._helpColorTransform);h=n.length;n.length+=8;n[h++]=Math.round(this._helpColorTransform.alphaMultiplier*100);n[h++]=Math.round(this._helpColorTransform.redMultiplier*100);n[h++]=Math.round(this._helpColorTransform.greenMultiplier*100);n[h++]=Math.round(this._helpColorTransform.blueMultiplier*100);n[h++]=Math.round(this._helpColorTransform.alphaOffset);n[h++]=Math.round(this._helpColorTransform.redOffset);n[h++]=Math.round(this._helpColorTransform.greenOffset);n[h++]=Math.round(this._helpColorTransform.blueOffset);h-=8;break}}if(h<0){if(this._defalultColorOffset<0){this._defalultColorOffset=h=n.length;n.length+=8;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=0;n[h++]=0;n[h++]=0;n[h++]=0}h=this._defalultColorOffset}var _=s.length;s.length+=1;s[_]=h;return l};a.prototype._parseSlotFFDFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameFloatArrayJson:this._data.frameFloatArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=s.length;var h=this._parseTweenFrame(e,i,r,o);var u=a.VERTICES in e?e[a.VERTICES]:null;var f=a._getNumber(e,a.OFFSET,0);var _=n[this._mesh.offset+0];var c=0;var p=0;var m=0;var d=0;if(this._mesh.weight!==null){var y=this._weightSlotPose[this._mesh.name];this._helpMatrixA.copyFromArray(y,0);s.length+=this._mesh.weight.count*2;m=this._mesh.weight.offset+2+this._mesh.weight.bones.length}else{s.length+=_*2}for(var g=0;g<_*2;g+=2){if(u===null){c=0;p=0}else{if(g=u.length){c=0}else{c=u[g-f]}if(g+1=u.length){p=0}else{p=u[g+1-f]}}if(this._mesh.weight!==null){var v=this._weightBonePoses[this._mesh.name];var b=this._weightBoneIndices[this._mesh.name];var D=n[m++];this._helpMatrixA.transformPoint(c,p,this._helpPoint,true);c=this._helpPoint.x;p=this._helpPoint.y;for(var T=0;T=0||a.DATA_VERSIONS.indexOf(n)>=0){var s=t.DragonBones.webAssembly?new Module["DragonBonesData"]:t.BaseObject.borrowObject(t.DragonBonesData);s.version=r;s.name=a._getString(e,a.NAME,"");s.frameRate=a._getNumber(e,a.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(a.ARMATURE in e){this._defalultColorOffset=-1;this._data=s;this._parseArray(e);var o=e[a.ARMATURE];for(var l=0,h=o;l0){this._parseWASMArray()}this._data=null}this._rawTextureAtlasIndex=0;if(a.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[a.TEXTURE_ATLAS]}else{this._rawTextureAtlases=null}return s}else{console.assert(false,"Nonsupport data version.")}return null};a.prototype.parseTextureAtlasData=function(e,i,r){if(r===void 0){r=0}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,i,r);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}i.width=a._getNumber(e,a.WIDTH,0);i.height=a._getNumber(e,a.HEIGHT,0);i.name=a._getString(e,a.NAME,"");i.imagePath=a._getString(e,a.IMAGE_PATH,"");if(r>0){i.scale=r}else{r=i.scale=a._getNumber(e,a.SCALE,i.scale)}r=1/r;if(a.SUB_TEXTURE in e){var s=e[a.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){u.frame=t.DragonBones.webAssembly?Module["TextureData"].createRectangle():t.TextureData.createRectangle();u.frame.x=a._getNumber(h,a.FRAME_X,0)*r;u.frame.y=a._getNumber(h,a.FRAME_Y,0)*r;u.frame.width=f*r;u.frame.height=_*r}i.addTexture(u)}}return true};a.getInstance=function(){if(a._objectDataParserInstance===null){a._objectDataParserInstance=new a}return a._objectDataParserInstance};a._objectDataParserInstance=null;return a}(t.DataParser);t.ObjectDataParser=e;var i=function(){function t(){this.frameStart=0;this.actions=[]}return t}()})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.prototype._inRange=function(t,e,i){return e<=t&&t<=i};i.prototype._decodeUTF8=function(t){var e=-1;var i=-1;var a=65533;var r=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>r){var f=t[r++];if(f===e){if(l!==0){s=a}else{s=i}}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;r--;s=f}else{h+=1;o=o+(f-128)*Math.pow(64,l-h);if(h!==l){s=null}else{var _=o;var c=u;o=0;l=0;h=0;u=0;if(this._inRange(_,c,1114111)&&!this._inRange(_,55296,57343)){s=_}else{s=f}}}}if(s!==null&&s!==i){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};i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255){return encodeURI(t)}}return t};i.prototype._parseBinaryTimeline=function(e,i,a){if(a===void 0){a=null}var r=a!==null?a:t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);r.type=e;r.offset=i;this._timeline=r;var n=this._timelineArray[r.offset+2];if(n===1){r.frameIndicesOffset=-1}else{var s=this._animation.frameCount+1;var o=this._data.frameIndices;if(t.DragonBones.webAssembly){r.frameIndicesOffset=o.size();for(var l=0;l=0){var r=t.DragonBones.webAssembly?new Module["WeightData"]:t.BaseObject.borrowObject(t.WeightData);var n=this._intArray[i.offset+0];var s=this._intArray[a+0];r.offset=a;if(t.DragonBones.webAssembly){r.bones.resize(s,null);for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(i)}}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(i);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=r;t.data=n;t.armature=s;t.skin=null;if(a.length>0){t.skin=s.getSkin(a);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(a);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};i.prototype._buildBones=function(e,i){var a=e.armature.sortedBones;for(var r=0;r<(t.DragonBones.webAssembly?a.size():a.length);++r){var n=t.DragonBones.webAssembly?a.get(r):a[r];var s=t.DragonBones.webAssembly?new Module["Bone"]:t.BaseObject.borrowObject(t.Bone);s.init(n);if(n.parent!==null){i.addBone(s,n.parent.name)}else{i.addBone(s)}var o=n.constraints;for(var l=0;l<(t.DragonBones.webAssembly?o.size():o.length);++l){var h=t.DragonBones.webAssembly?o.get(l):o[l];var u=i.getBone(h.target.name);if(u===null){continue}var f=h;var _=t.DragonBones.webAssembly?new Module["IKConstraint"]:t.BaseObject.borrowObject(t.IKConstraint);var c=f.root!==null?i.getBone(f.root.name):null;_.target=u;_.bone=s;_.root=c;_.bendPositive=f.bendPositive;_.scaleEnabled=f.scaleEnabled;_.weight=f.weight;if(c!==null){c.addConstraint(_)}else{s.addConstraint(_)}}}};i.prototype._buildSlots=function(t,e){var i=t.skin;var a=t.armature.defaultSkin;if(i===null||a===null){return}var r={};for(var n in a.displays){var s=a.displays[n];r[n]=s}if(i!==a){for(var n in i.displays){var s=i.displays[n];r[n]=s}}for(var o=0,l=t.armature.sortedSlots;o0){s.texture=this._getTextureData(t.textureAtlasName,e.path)}if(i!==null&&i.type===2&&this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 2:var o=e;if(o.texture===null){o.texture=this._getTextureData(r,o.path)}else if(t!==null&&t.textureAtlasName.length>0){o.texture=this._getTextureData(t.textureAtlasName,o.path)}if(this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 1:var l=e;var h=this.buildArmature(l.path,r,null,t!==null?t.textureAtlasName:null);if(h!==null){h.inheritAnimation=l.inheritAnimation;if(!h.inheritAnimation){var u=l.actions.length>0?l.actions:h.armatureData.defaultActions;if(u.length>0){for(var f=0,_=u;f<_.length;f++){var c=_[f];h._bufferAction(c,true)}}else{h.animation.play()}}l.armature=h.armatureData}n=h;break}return n};i.prototype._replaceSlotDisplay=function(t,e,i,a){if(a<0){a=i.displayIndex}if(a<0){a=0}var r=i.displayList;if(r.length<=a){r.length=a+1;for(var n=0,s=r.length;n=0){continue}var s=e.displays[n.name];var o=n.displayList;o.length=s.length;for(var l=0,h=s.length;l0?this.width:e.width;var a=this.height>0?this.height:e.height;for(var r in this.textures){var n=this.textures[r];var s=Math.min(n.region.width,i-n.region.x);var o=Math.min(n.region.height,a-n.region.y);if(n.renderTexture===null){n.renderTexture=new egret.Texture;if(n.rotated){n.renderTexture.$initData(n.region.x,n.region.y,o,s,0,0,o,s,i,a,n.rotated)}else{n.renderTexture.$initData(n.region.x,n.region.y,s,o,0,0,s,o,i,a)}}n.renderTexture._bitmapData=e}}else{for(var r in this.textures){var n=this.textures[r];n.renderTexture=null}}},enumerable:true,configurable:true});a.prototype.dispose=function(){console.warn("已废弃,请参考 @see");this.returnToPool()};Object.defineProperty(a.prototype,"texture",{get:function(){return this.renderTexture},enumerable:true,configurable:true});return a}(t.TextureAtlasData);t.EgretTextureAtlasData=e;var i=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.renderTexture=null;return e}e.toString=function(){return"[class dragonBones.EgretTextureData]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.renderTexture!==null){}this.renderTexture=null};return e}(t.TextureData);t.EgretTextureData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}Object.defineProperty(i.prototype,"eventObject",{get:function(){return this.data},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationName",{get:function(){var t=this.eventObject.animationState;return t!==null?t.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"armature",{get:function(){return this.eventObject.armature},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"bone",{get:function(){return this.eventObject.bone},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"slot",{get:function(){return this.eventObject.slot},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationState",{get:function(){return this.eventObject.animationState},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"frameLabel",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"sound",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"movementID",{get:function(){return this.animationName},enumerable:true,configurable:true});i.START=t.EventObject.START;i.LOOP_COMPLETE=t.EventObject.LOOP_COMPLETE;i.COMPLETE=t.EventObject.COMPLETE;i.FADE_IN=t.EventObject.FADE_IN;i.FADE_IN_COMPLETE=t.EventObject.FADE_IN_COMPLETE;i.FADE_OUT=t.EventObject.FADE_OUT;i.FADE_OUT_COMPLETE=t.EventObject.FADE_OUT_COMPLETE;i.FRAME_EVENT=t.EventObject.FRAME_EVENT;i.SOUND_EVENT=t.EventObject.SOUND_EVENT;i.ANIMATION_FRAME_EVENT=t.EventObject.FRAME_EVENT;i.BONE_FRAME_EVENT=t.EventObject.FRAME_EVENT;i.MOVEMENT_FRAME_EVENT=t.EventObject.FRAME_EVENT;i.SOUND=t.EventObject.SOUND_EVENT;return i}(egret.Event);t.EgretEvent=e;var i=function(i){__extends(a,i);function a(){var t=i!==null&&i.apply(this,arguments)||this;t._batchEnabled=true;t._disposeProxy=false;t._armature=null;t._debugDrawer=null;return t}a._cleanBeforeRender=function(){};a.prototype.init=function(t){this._armature=t;this.$renderNode=new egret.sys.GroupNode;this.$renderNode.cleanBeforeRender=a._cleanBeforeRender};a.prototype.clear=function(){this._disposeProxy=false;this._armature=null;this._debugDrawer=null};a.prototype.dispose=function(t){if(t===void 0){t=true}this._disposeProxy=t;if(this._armature!==null){this._armature.dispose();this._armature=null}};a.prototype.debugUpdate=function(t){if(t){if(this._debugDrawer===null){this._debugDrawer=new egret.Sprite}this.addChild(this._debugDrawer);this._debugDrawer.graphics.clear();for(var e=0,i=this._armature.getBones();e=0&&this._display!==null&&i!==null){if(this._armature.replacedTexture!==null&&this._rawDisplayDatas.indexOf(this._displayData)>=0){var a=i.parent;if(this._armature._replaceTextureAtlasData===null){a=t.BaseObject.borrowObject(t.EgretTextureAtlasData);a.copyFrom(i.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}i=a.getTexture(i.name)}if(i.renderTexture!==null){if(e!==null){var r=e.parent.parent.intArray;var n=e.parent.parent.floatArray;var s=r[e.offset+0];var o=r[e.offset+1];var l=r[e.offset+2];var h=l+s*2;var u=this._renderDisplay;var f=u.$renderNode;f.uvs.length=s*2;f.vertices.length=s*2;f.indices.length=o*3;for(var _=0,c=s*2;_0;var e=this._meshData;var i=e.weight;var a=this._renderDisplay;var r=a.$renderNode;if(i!==null){var n=e.parent.parent.intArray;var s=e.parent.parent.floatArray;var o=n[e.offset+0];var l=n[i.offset+1];for(var h=0,u=0,f=i.offset+2+i.bones.length,_=l,c=0;h=0){t.displayConfig=this._groupConfig.display[t.displayIndex];if(t.displayConfig.type===1){var a=t.displayConfig.name in t.childMovies?t.childMovies[t.displayConfig.name]:null;if(!a){a=u(t.displayConfig.name,this._groupConfig.name);if(a){t.childMovies[t.displayConfig.name]=a}}if(a){t.display=a;t.childMovie=a}else{t.display=t.rawDisplay;t.childMovie=null}}else{t.display=t.rawDisplay;t.childMovie=null}}else{t.displayConfig=null;t.display=t.rawDisplay;t.childMovie=null}if(t.display!==e){if(e){this.addChild(t.display);this.swapChildren(t.display,e);this.removeChild(e)}this._updateSlotBlendMode(t)}if(t.display===t.rawDisplay){if(t.displayConfig&&t.displayConfig.regionIndex!==null&&t.displayConfig.regionIndex!==undefined){if(!t.displayConfig.texture){var r=this._groupConfig.textures[t.displayConfig.textureIndex||0];var n=t.displayConfig.regionIndex*4;var s=this._groupConfig.rectangleArray[n];var o=this._groupConfig.rectangleArray[n+1];var l=this._groupConfig.rectangleArray[n+2];var h=this._groupConfig.rectangleArray[n+3];t.displayConfig.texture=new egret.Texture;t.displayConfig.texture._bitmapData=r._bitmapData;t.displayConfig.texture.$initData(s,o,Math.min(l,r.textureWidth-s),Math.min(h,r.textureHeight-o),0,0,Math.min(l,r.textureWidth-s),Math.min(h,r.textureHeight-o),r.textureWidth,r.textureHeight)}if(this._batchEnabled){var f=t.displayConfig.texture;var _=t.rawDisplay.$renderNode;egret.sys.RenderNode.prototype.cleanBeforeRender.call(t.rawDisplay.$renderNode);_.image=f._bitmapData;_.drawImage(f._bitmapX,f._bitmapY,f._bitmapWidth,f._bitmapHeight,f._offsetX,f._offsetY,f.textureWidth,f.textureHeight);_.imageWidth=f._sourceWidth;_.imageHeight=f._sourceHeight}else{t.rawDisplay.visible=true;t.rawDisplay.$setBitmapData(t.displayConfig.texture)}}else{if(this._batchEnabled){t.rawDisplay.$renderNode.image=null}else{t.rawDisplay.visible=false;t.rawDisplay.$setBitmapData(null)}}}if(t.childMovie!==i){if(i){i.stop();this._childMovies.slice(this._childMovies.indexOf(i),1)}if(t.childMovie){if(this._childMovies.indexOf(t.childMovie)<0){this._childMovies.push(t.childMovie)}if(t.config.action){t.childMovie.play(t.config.action)}else{t.childMovie.play(t.childMovie._config.action)}}}};r.prototype._getSlot=function(t){for(var e=0,i=this._slots.length;e0&&(n>=r||n<=-r)){this._isCompleted=true;s=this._playTimes;if(n<0){n=0}else{n=a}}else{this._isCompleted=false;if(n<0){s=Math.floor(-n/a);n=a- -n%a}else{s=Math.floor(n/a);n%=a}if(this._playTimes>0&&s>this._playTimes){s=this._playTimes}}if(this._currentTime===n){return}var o=Math.floor(n*this._clipConfig.cacheTimeToFrameScale);if(this._cacheFrameIndex!==o){this._cacheFrameIndex=o;var l=this._groupConfig.displayFrameArray;var h=this._groupConfig.transformArray;var u=this._groupConfig.colorArray;var f=true;var c=false;var p=false;var m=this._cacheRectangle;this._cacheRectangle=this._clipConfig.cacheRectangles[this._cacheFrameIndex];if(this._batchEnabled&&!this._cacheRectangle){p=true;this._cacheRectangle=new egret.Rectangle;this._clipConfig.cacheRectangles[this._cacheFrameIndex]=this._cacheRectangle}for(var d=0,y=this._slots.length;d=this._clipArray.length){v=this._frameSize*(this._cacheFrameIndex-1)+d*2}var b=this._clipArray[v]*2;if(b>=0){var D=l[b];var T=l[b+1]*8;var A=this._clipArray[v+1]*6;var O=false;if(g.displayIndex!==D){g.displayIndex=D;O=true;this._updateSlotDisplay(g)}if(g.colorIndex!==T||O){g.colorIndex=T;if(g.colorIndex>=0){this._updateSlotColor(g,u[T]*.01,u[T+1]*.01,u[T+2]*.01,u[T+3]*.01,u[T+4],u[T+5],u[T+6],u[T+7])}else{this._updateSlotColor(g,1,1,1,1,0,0,0,0)}}c=true;if(g.transformIndex!==A){g.transformIndex=A;if(this._batchEnabled){var x=g.display.$renderNode.matrix;if(!x){x=g.display.$renderNode.matrix=new egret.Matrix}x.a=h[A];x.b=h[A+1];x.c=h[A+2];x.d=h[A+3];x.tx=h[A+4];x.ty=h[A+5]}else{i.a=h[A];i.b=h[A+1];i.c=h[A+2];i.d=h[A+3];i.tx=h[A+4];i.ty=h[A+5];g.display.$setMatrix(i)}}if(this._batchEnabled&&p&&g.displayConfig){var x=g.display.$renderNode.matrix;e.x=0;e.y=0;e.width=g.displayConfig.texture.textureWidth;e.height=g.displayConfig.texture.textureHeight;x.$transformBounds(e);if(f){f=false;this._cacheRectangle.x=e.x;this._cacheRectangle.width=e.x+e.width;this._cacheRectangle.y=e.y;this._cacheRectangle.height=e.y+e.height}else{this._cacheRectangle.x=Math.min(this._cacheRectangle.x,e.x);this._cacheRectangle.width=Math.max(this._cacheRectangle.width,e.x+e.width);this._cacheRectangle.y=Math.min(this._cacheRectangle.y,e.y);this._cacheRectangle.height=Math.max(this._cacheRectangle.height,e.y+e.height)}}}else if(g.displayIndex!==-1){g.displayIndex=-1;this._updateSlotDisplay(g)}}if(this._cacheRectangle){if(c&&p&&f&&m){this._cacheRectangle.x=m.x;this._cacheRectangle.y=m.y;this._cacheRectangle.width=m.width;this._cacheRectangle.height=m.height}this.$invalidateContentBounds()}}if(this._isCompleted){this._isPlaying=false}if(!this._isStarted){this._isStarted=true;if(this.hasEventListener(_.START)){var B=egret.Event.create(_,_.START);B.movie=this;B.clipName=this._clipConfig.name;B.name="";B.slotName="";this.dispatchEvent(B)}}this._isReversing=this._currentTime>n&&this._currentPlayTimes===s;this._currentTime=n;var E=this._clipConfig.frame?this._clipConfig.frame.length:0;if(E>0){var S=Math.floor(this._currentTime*this._config.frameRate);var M=this._groupConfig.frame[this._clipConfig.frame[S]];if(this._currentFrameConfig!==M){if(E>1){var w=this._currentFrameConfig;this._currentFrameConfig=M;if(!w){var P=Math.floor(this._currentTime*this._config.frameRate);w=this._groupConfig.frame[this._clipConfig.frame[P]];if(this._isReversing){}else{if(this._currentTime<=w.position||this._currentPlayTimes!==s){w=this._groupConfig.frame[w.prev]}}}if(this._isReversing){while(w!==M){this._onCrossFrame(w);w=this._groupConfig.frame[w.prev]}}else{while(w!==M){w=this._groupConfig.frame[w.next];this._onCrossFrame(w)}}}else{this._currentFrameConfig=M;if(this._currentFrameConfig){this._onCrossFrame(this._currentFrameConfig)}}}}if(this._currentPlayTimes!==s){this._currentPlayTimes=s;if(this.hasEventListener(_.LOOP_COMPLETE)){var C=egret.Event.create(_,_.LOOP_COMPLETE);C.movie=this;C.clipName=this._clipConfig.name;C.name="";C.slotName="";this.dispatchEvent(C);egret.Event.release(C)}if(this._isCompleted&&this.hasEventListener(_.COMPLETE)){var I=egret.Event.create(_,_.COMPLETE);I.movie=this;I.clipName=this._clipConfig.name;I.name="";I.slotName="";this.dispatchEvent(I);egret.Event.release(I)}}}this._isLockDispose=false;if(this._isDelayDispose){this.dispose()}};r.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}if(t){var i=null;for(var a=0,r=this._config.clip.length;a void, target: any): void { + this.addEventListener(type, listener, target); + } + /** + * @inheritDoc + */ + public removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void { + this.removeEventListener(type, listener, target); + } + /** + * 关闭批次渲染。(批次渲染处于性能考虑,不会更新渲染对象的边界属性,这样无法正确获得渲染对象的绘制区域,如果需要使用这些属性,可以关闭批次渲染) + * @version DragonBones 5.1 + * @language zh_CN + */ + public disableBatch(): void { + for (const slot of this._armature.getSlots()) { + // (slot as EgretSlot).transformUpdateEnabled = true; + const display = (slot.rawDisplay || slot.meshDisplay) as (egret.Bitmap | egret.Mesh); + const node = display.$renderNode as (egret.sys.BitmapNode | egret.sys.MeshNode); + + // Transform. + if (node.matrix) { + display.$setMatrix(slot.globalTransformMatrix as any, false); + } + + // ZOrder. + this.addChild(display); + } + + this._batchEnabled = false; + this.$renderNode.cleanBeforeRender = null as any; + this.$renderNode = null as any; + } + /** + * @inheritDoc + */ + public get armature(): Armature { + return this._armature; + } + /** + * @inheritDoc + */ + public get animation(): Animation { + return this._armature.animation; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + public advanceTimeBySelf(on: boolean): void { + if (on) { + this._armature.clock = EgretFactory.clock; + } + else { + this._armature.clock = null; + } + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature + */ + export type FastArmature = Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Bone + */ + export type FastBone = Bone; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Slot + */ + export type FastSlot = Slot; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Animation + */ + export type FastAnimation = Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.AnimationState + */ + export type FastAnimationState = AnimationState; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class Event extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class ArmatureEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class AnimationEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class FrameEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class SoundEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFacory#parseTextureAtlasData() + */ + export class EgretTextureAtlas extends EgretTextureAtlasData { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.EgretTextureAtlas]"; + } + + public constructor(texture: egret.Texture, rawData: any, scale: number = 1) { + super(); + console.warn("已废弃,请参考 @see"); + + this._onClear(); + + ObjectDataParser.getInstance().parseTextureAtlasData(rawData, this, scale); + this.renderTexture = texture; + } + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + export class EgretSheetAtlas extends EgretTextureAtlas { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + export class SoundEventManager { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + public static getInstance(): EgretArmatureDisplay { + console.warn("已废弃,请参考 @see"); + return EgretFactory.factory.soundEventManager; + } + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + export class AnimationCacheManager { + public constructor() { + console.warn("已废弃,请参考 @see"); + } + } +} \ No newline at end of file diff --git a/reference/Egret/4.x/src/dragonBones/egret/EgretFactory.ts b/reference/Egret/4.x/src/dragonBones/egret/EgretFactory.ts new file mode 100644 index 0000000..b8168fa --- /dev/null +++ b/reference/Egret/4.x/src/dragonBones/egret/EgretFactory.ts @@ -0,0 +1,232 @@ +namespace dragonBones { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretFactory extends BaseFactory { + private static _dragonBonesInstance: DragonBones = null as any; + private static _factory: EgretFactory | null = null; + private static _clockHandler(time: number): boolean { + time *= 0.001; + const clock = EgretFactory._dragonBonesInstance.clock; + const passedTime = time - clock.time; + EgretFactory._dragonBonesInstance.advanceTime(passedTime); + clock.time = time; + + return false; + } + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + public static get clock(): WorldClock { + return EgretFactory._dragonBonesInstance.clock; + } + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public static get factory(): EgretFactory { + if (EgretFactory._factory === null) { + EgretFactory._factory = new EgretFactory(); + } + + return EgretFactory._factory; + } + /** + * @inheritDoc + */ + public constructor(dataParser: DataParser | null = null) { + super(dataParser); + + if (EgretFactory._dragonBonesInstance === null) { + const eventManager = new EgretArmatureDisplay(); + EgretFactory._dragonBonesInstance = new DragonBones(eventManager); + EgretFactory._dragonBonesInstance.clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretFactory._clockHandler, EgretFactory); + } + + this._dragonBones = EgretFactory._dragonBonesInstance; + } + /** + * @private + */ + protected _isSupportMesh(): boolean { + if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { + return true; + } + + console.warn("Canvas can not support mesh, please change renderMode to webgl."); + + return false; + } + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: EgretTextureAtlasData | null, textureAtlas: egret.Texture | null): EgretTextureAtlasData { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = BaseObject.borrowObject(EgretTextureAtlasData); + } + + return textureAtlasData; + } + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature { + const armature = BaseObject.borrowObject(Armature); + const armatureDisplay = new EgretArmatureDisplay(); + + armature.init( + dataPackage.armature, + armatureDisplay, armatureDisplay, this._dragonBones + ); + + return armature; + } + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot { + dataPackage; + armature; + const slot = BaseObject.borrowObject(EgretSlot); + slot.init( + slotData, displays, + new egret.Bitmap(), new egret.Mesh() + ); + + return slot; + } + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + public buildArmatureDisplay(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null, textureAtlasName: string | null = null): EgretArmatureDisplay | null { + const armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.display as EgretArmatureDisplay; + } + + return null; + } + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public getTextureDisplay(textureName: string, textureAtlasName: string | null = null): egret.Bitmap | null { + const textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName) as EgretTextureData; + if (textureData !== null && textureData.renderTexture !== null) { + return new egret.Bitmap(textureData.renderTexture); + } + + return null; + } + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public get soundEventManager(): EgretArmatureDisplay { + return this._dragonBones.eventManager as EgretArmatureDisplay; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + public addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName: string | null = null): void { + console.warn("已废弃,请参考 @see"); + this.addDragonBonesData(dragonBonesData, dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getDragonBonesData() + */ + public getSkeletonData(dragonBonesName: string) { + console.warn("已废弃,请参考 @see"); + return this.getDragonBonesData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + public removeSkeletonData(dragonBonesName: string): void { + console.warn("已废弃,请参考 @see"); + this.removeDragonBonesData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addTextureAtlasData() + */ + public addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName: string | null = null): void { + console.warn("已废弃,请参考 @see"); + this.addTextureAtlasData(textureAtlasData, dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getTextureAtlasData() + */ + public getTextureAtlas(dragonBonesName: string) { + console.warn("已废弃,请参考 @see"); + return this.getTextureAtlasData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + public removeTextureAtlas(dragonBonesName: string): void { + console.warn("已废弃,请参考 @see"); + this.removeTextureAtlasData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#buildArmature() + */ + public buildFastArmature(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null): FastArmature | null { + console.warn("已废弃,请参考 @see"); + return this.buildArmature(armatureName, dragonBonesName, skinName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#clear() + */ + public dispose(): void { + console.warn("已废弃,请参考 @see"); + this.clear(); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager() + */ + public get soundEventManater(): EgretArmatureDisplay { + return this.soundEventManager; + } + } +} \ No newline at end of file diff --git a/reference/Egret/4.x/src/dragonBones/egret/EgretSlot.ts b/reference/Egret/4.x/src/dragonBones/egret/EgretSlot.ts new file mode 100644 index 0000000..d413234 --- /dev/null +++ b/reference/Egret/4.x/src/dragonBones/egret/EgretSlot.ts @@ -0,0 +1,436 @@ +namespace dragonBones { + /** + * Egret 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretSlot extends Slot { + public static toString(): string { + return "[class dragonBones.EgretSlot]"; + } + /** + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 + * @language zh_CN + */ + public transformUpdateEnabled: boolean = false; + + private _armatureDisplay: EgretArmatureDisplay = null as any; + private _renderDisplay: egret.DisplayObject = null as any; + private _colorFilter: egret.ColorMatrixFilter | null = null; + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + this._armatureDisplay = null as any; // + this._renderDisplay = null as any; // + this._colorFilter = null; + } + /** + * @private + */ + protected _initDisplay(value: any): void { + value; + } + /** + * @private + */ + protected _disposeDisplay(value: any): void { + value; + } + /** + * @private + */ + protected _onUpdateDisplay(): void { + this._armatureDisplay = this._armature.display; + this._renderDisplay = (this._display !== null ? this._display : this._rawDisplay) as egret.DisplayObject; + + if (this._armatureDisplay._batchEnabled && this._renderDisplay !== this._rawDisplay && this._renderDisplay !== this._meshDisplay) { + this._armatureDisplay.disableBatch(); + } + + if (this._armatureDisplay._batchEnabled) { + const node = this._renderDisplay.$renderNode as (egret.sys.BitmapNode | egret.sys.MeshNode); + if (!node.matrix) { + node.matrix = new egret.Matrix(); + } + } + } + /** + * @private + */ + protected _addDisplay(): void { + if (this._armatureDisplay._batchEnabled) { + (this._armatureDisplay.$renderNode as egret.sys.GroupNode).addNode(this._renderDisplay.$renderNode); + } + else { + this._armatureDisplay.addChild(this._renderDisplay); + } + } + /** + * @private + */ + protected _replaceDisplay(value: any): void { + const prevDisplay = value as egret.DisplayObject; + + if (this._armatureDisplay._batchEnabled) { + const nodes = (this._armatureDisplay.$renderNode as egret.sys.GroupNode).drawData; + nodes[nodes.indexOf(value.$renderNode)] = this._renderDisplay.$renderNode; + } + else { + this._armatureDisplay.addChild(this._renderDisplay); + this._armatureDisplay.swapChildren(this._renderDisplay, prevDisplay); + this._armatureDisplay.removeChild(prevDisplay); + } + } + /** + * @private + */ + protected _removeDisplay(): void { + if (this._armatureDisplay._batchEnabled) { + const nodes = (this._armatureDisplay.$renderNode as egret.sys.GroupNode).drawData; + nodes.splice(nodes.indexOf(this._renderDisplay.$renderNode), 1); + } + else { + this._renderDisplay.parent.removeChild(this._renderDisplay); + } + } + /** + * @private + */ + protected _updateZOrder(): void { + if (this._armatureDisplay._batchEnabled) { + const nodes = (this._armatureDisplay.$renderNode as egret.sys.GroupNode).drawData; + nodes[this._zOrder] = this._renderDisplay.$renderNode; + } + else { + const index = this._armatureDisplay.getChildIndex(this._renderDisplay); + if (index === this._zOrder) { + return; + } + + this._armatureDisplay.addChildAt(this._renderDisplay, this._zOrder); + } + } + /** + * @internal + * @private + */ + public _updateVisible(): void { + if (this._armatureDisplay._batchEnabled) { + const node = this._renderDisplay.$renderNode as (egret.sys.BitmapNode); + node.alpha = this._parent.visible ? 1.0 : 0.0; + } + else { + this._renderDisplay.visible = this._parent.visible; + } + } + /** + * @private + */ + protected _updateBlendMode(): void { + switch (this._blendMode) { + case BlendMode.Normal: + this._renderDisplay.blendMode = egret.BlendMode.NORMAL; + break; + + case BlendMode.Add: + this._renderDisplay.blendMode = egret.BlendMode.ADD; + break; + + case BlendMode.Erase: + this._renderDisplay.blendMode = egret.BlendMode.ERASE; + break; + + default: + break; + } + + if (this._armatureDisplay._batchEnabled) { + const node = this._renderDisplay.$renderNode as (egret.sys.BitmapNode); + node.blendMode = egret.sys.blendModeToNumber(this._renderDisplay.blendMode); + } + } + /** + * @private + */ + protected _updateColor(): void { + if ( + this._colorTransform.redMultiplier !== 1.0 || + this._colorTransform.greenMultiplier !== 1.0 || + this._colorTransform.blueMultiplier !== 1.0 || + this._colorTransform.redOffset !== 0 || + this._colorTransform.greenOffset !== 0 || + this._colorTransform.blueOffset !== 0 || + this._colorTransform.alphaOffset !== 0 + ) { + if (this._colorFilter === null) { + this._colorFilter = new egret.ColorMatrixFilter(); + } + + const colorMatrix = this._colorFilter.matrix; + colorMatrix[0] = this._colorTransform.redMultiplier; + colorMatrix[6] = this._colorTransform.greenMultiplier; + colorMatrix[12] = this._colorTransform.blueMultiplier; + colorMatrix[18] = this._colorTransform.alphaMultiplier; + colorMatrix[4] = this._colorTransform.redOffset; + colorMatrix[9] = this._colorTransform.greenOffset; + colorMatrix[14] = this._colorTransform.blueOffset; + colorMatrix[19] = this._colorTransform.alphaOffset; + this._colorFilter.matrix = colorMatrix; + + if (this._armatureDisplay._batchEnabled) { + const node = this._renderDisplay.$renderNode as (egret.sys.BitmapNode); + node.filter = this._colorFilter; + node.alpha = 1.0; + } + + let filters = this._renderDisplay.filters; + if (!filters) { // null or undefined? + filters = []; + } + + if (filters.indexOf(this._colorFilter) < 0) { + filters.push(this._colorFilter); + } + + this._renderDisplay.filters = filters; + this._renderDisplay.$setAlpha(1.0); + } + else { + if (this._armatureDisplay._batchEnabled) { + const node = this._renderDisplay.$renderNode as (egret.sys.BitmapNode); + node.filter = null as any; + node.alpha = this._colorTransform.alphaMultiplier; + } + + this._renderDisplay.filters = null as any; + this._renderDisplay.$setAlpha(this._colorTransform.alphaMultiplier); + } + } + /** + * @private + */ + protected _updateFrame(): void { + const meshData = this._display === this._meshDisplay ? this._meshData : null; + let currentTextureData = this._textureData as (EgretTextureData | null); + + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + + if (this._armature.replacedTexture !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { // Update replaced texture atlas. + let currentTextureAtlasData = currentTextureData.parent as EgretTextureAtlasData; + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = BaseObject.borrowObject(EgretTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData as EgretTextureAtlasData; + } + + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name) as EgretTextureData; + } + + if (currentTextureData.renderTexture !== null) { + if (meshData !== null) { // Mesh. + const intArray = meshData.parent.parent.intArray; + const floatArray = meshData.parent.parent.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const triangleCount = intArray[meshData.offset + BinaryOffset.MeshTriangleCount]; + const verticesOffset = intArray[meshData.offset + BinaryOffset.MeshFloatOffset]; + const uvOffset = verticesOffset + vertexCount * 2; + + const meshDisplay = this._renderDisplay as egret.Mesh; + const meshNode = meshDisplay.$renderNode as egret.sys.MeshNode; + + meshNode.uvs.length = vertexCount * 2; + meshNode.vertices.length = vertexCount * 2; + meshNode.indices.length = triangleCount * 3; + + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[verticesOffset + i]; + meshNode.uvs[i] = floatArray[uvOffset + i]; + } + + for (let i = 0; i < triangleCount * 3; ++i) { + meshNode.indices[i] = intArray[meshData.offset + BinaryOffset.MeshVertexIndices + i]; + } + + if (this._armatureDisplay._batchEnabled) { + const texture = currentTextureData.renderTexture; + const node = this._renderDisplay.$renderNode as egret.sys.MeshNode; + egret.sys.RenderNode.prototype.cleanBeforeRender.call(this._renderDisplay.$renderNode); + node.image = texture._bitmapData; + + node.drawMesh( + texture._bitmapX, texture._bitmapY, + texture._bitmapWidth, texture._bitmapHeight, + texture._offsetX, texture._offsetY, + texture.textureWidth, texture.textureHeight + ); + + node.imageWidth = texture._sourceWidth; + node.imageHeight = texture._sourceHeight; + } + + meshDisplay.texture = currentTextureData.renderTexture; + meshDisplay.$setAnchorOffsetX(this._pivotX); + meshDisplay.$setAnchorOffsetY(this._pivotY); + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + } + else { // Normal texture. + const normalDisplay = this._renderDisplay as egret.Bitmap; + normalDisplay.texture = currentTextureData.renderTexture; + + if (this._armatureDisplay._batchEnabled) { + const texture = currentTextureData.renderTexture; + const node = this._renderDisplay.$renderNode as egret.sys.BitmapNode; + egret.sys.RenderNode.prototype.cleanBeforeRender.call(this._renderDisplay.$renderNode); + node.image = texture._bitmapData; + + node.drawImage( + texture._bitmapX, texture._bitmapY, + texture._bitmapWidth, texture._bitmapHeight, + texture._offsetX, texture._offsetY, + texture.textureWidth, texture.textureHeight + ); + + node.imageWidth = texture._sourceWidth; + node.imageHeight = texture._sourceHeight; + } + + normalDisplay.$setAnchorOffsetX(this._pivotX); + normalDisplay.$setAnchorOffsetY(this._pivotY); + } + + return; + } + } + + if (this._armatureDisplay._batchEnabled) { + (this._renderDisplay.$renderNode as egret.sys.BitmapNode).image = null as any; + } + + if (meshData !== null) { + const meshDisplay = this._renderDisplay as egret.Mesh; + meshDisplay.$setBitmapData(null as any); + meshDisplay.x = 0.0; + meshDisplay.y = 0.0; + } + else { + const normalDisplay = this._renderDisplay as egret.Bitmap; + normalDisplay.$setBitmapData(null as any); + normalDisplay.x = 0.0; + normalDisplay.y = 0.0; + } + } + /** + * @private + */ + protected _updateMesh(): void { + const hasFFD = this._ffdVertices.length > 0; + const meshData = this._meshData as MeshDisplayData; + const weight = meshData.weight; + const meshDisplay = this._renderDisplay as egret.Mesh; + const meshNode = meshDisplay.$renderNode as egret.sys.MeshNode; + + if (weight !== null) { + const intArray = meshData.parent.parent.intArray; + const floatArray = meshData.parent.parent.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const weightFloatOffset = intArray[weight.offset + BinaryOffset.WeigthFloatOffset]; + + for ( + let i = 0, iD = 0, iB = weight.offset + BinaryOffset.WeigthBoneIndices + weight.bones.length, iV = weightFloatOffset, iF = 0; + i < vertexCount; + ++i + ) { + const boneCount = intArray[iB++]; + let xG = 0.0, yG = 0.0; + for (let j = 0; j < boneCount; ++j) { + const boneIndex = intArray[iB++]; + const bone = this._meshBones[boneIndex]; + if (bone !== null) { + const matrix = bone.globalTransformMatrix; + const weight = floatArray[iV++]; + let xL = floatArray[iV++]; + let yL = floatArray[iV++]; + + if (hasFFD) { + xL += this._ffdVertices[iF++]; + yL += this._ffdVertices[iF++]; + } + + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + + meshNode.vertices[iD++] = xG; + meshNode.vertices[iD++] = yG; + } + + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + } + else if (hasFFD) { + const intArray = meshData.parent.parent.intArray; + const floatArray = meshData.parent.parent.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const vertexOffset = intArray[meshData.offset + BinaryOffset.MeshFloatOffset]; + + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[vertexOffset + i] + this._ffdVertices[i]; + } + + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + } + } + /** + * @private + */ + protected _updateTransform(isSkinnedMesh: boolean): void { + if (isSkinnedMesh) { // Identity transform. + const transformationMatrix = this._renderDisplay.matrix; + transformationMatrix.identity(); + this._renderDisplay.$setMatrix(transformationMatrix, this.transformUpdateEnabled); + } + else { + const globalTransformMatrix = this.globalTransformMatrix; + if (this._armatureDisplay._batchEnabled) { + let displayMatrix = (this._renderDisplay.$renderNode as (egret.sys.BitmapNode | egret.sys.MeshNode)).matrix; + displayMatrix.a = globalTransformMatrix.a; + displayMatrix.b = globalTransformMatrix.b; + displayMatrix.c = globalTransformMatrix.c; + displayMatrix.d = globalTransformMatrix.d; + displayMatrix.tx = this.globalTransformMatrix.tx - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); + displayMatrix.ty = this.globalTransformMatrix.ty - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); + } + else if (this.transformUpdateEnabled) { + this._renderDisplay.$setMatrix((globalTransformMatrix as any) as egret.Matrix, true); + } + else { + const values = this._renderDisplay.$DisplayObject as any; + const displayMatrix = values[6]; + + displayMatrix.a = this.globalTransformMatrix.a; + displayMatrix.b = this.globalTransformMatrix.b; + displayMatrix.c = this.globalTransformMatrix.c; + displayMatrix.d = this.globalTransformMatrix.d; + displayMatrix.tx = this.globalTransformMatrix.tx; + displayMatrix.ty = this.globalTransformMatrix.ty; + + this._renderDisplay.$removeFlags(8); + this._renderDisplay.$invalidatePosition(); + } + } + } + } +} \ No newline at end of file diff --git a/reference/Egret/4.x/src/dragonBones/egret/EgretTextureAtlasData.ts b/reference/Egret/4.x/src/dragonBones/egret/EgretTextureAtlasData.ts new file mode 100644 index 0000000..d72bbe9 --- /dev/null +++ b/reference/Egret/4.x/src/dragonBones/egret/EgretTextureAtlasData.ts @@ -0,0 +1,128 @@ +namespace dragonBones { + /** + * Egret 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretTextureAtlasData extends TextureAtlasData { + public static toString(): string { + return "[class dragonBones.EgretTextureAtlasData]"; + } + + private _renderTexture: egret.Texture | null = null; // Initial value. + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + if (this._renderTexture !== null) { + //this.texture.dispose(); + } + + this._renderTexture = null; + } + /** + * @private + */ + public createTexture(): TextureData { + return BaseObject.borrowObject(EgretTextureData); + } + /** + * Egret 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get renderTexture(): egret.Texture | null { + return this._renderTexture; + } + public set renderTexture(value: egret.Texture | null) { + if (this._renderTexture === value) { + return; + } + + this._renderTexture = value; + + if (this._renderTexture !== null) { + const bitmapData = this._renderTexture.bitmapData; + const textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; + const textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; + + for (let k in this.textures) { + const textureData = this.textures[k] as EgretTextureData; + const subTextureWidth = Math.min(textureData.region.width, textureAtlasWidth - textureData.region.x); // TODO need remove + const subTextureHeight = Math.min(textureData.region.height, textureAtlasHeight - textureData.region.y); // TODO need remove + + if (textureData.renderTexture === null) { + textureData.renderTexture = new egret.Texture(); + if (textureData.rotated) { + textureData.renderTexture.$initData( + textureData.region.x, textureData.region.y, + subTextureHeight, subTextureWidth, + 0, 0, + subTextureHeight, subTextureWidth, + textureAtlasWidth, textureAtlasHeight, + textureData.rotated + ); + } + else { + textureData.renderTexture.$initData( + textureData.region.x, textureData.region.y, + subTextureWidth, subTextureHeight, + 0, 0, + subTextureWidth, subTextureHeight, + textureAtlasWidth, textureAtlasHeight + ); + } + } + + textureData.renderTexture._bitmapData = bitmapData; + } + } + else { + for (let k in this.textures) { + const textureData = this.textures[k] as EgretTextureData; + textureData.renderTexture = null; + } + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + public dispose(): void { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + public get texture() { + return this.renderTexture; + } + } + /** + * @private + */ + export class EgretTextureData extends TextureData { + public static toString(): string { + return "[class dragonBones.EgretTextureData]"; + } + + public renderTexture: egret.Texture | null = null; // Initial value. + + protected _onClear(): void { + super._onClear(); + + if (this.renderTexture !== null) { + //this.texture.dispose(); + } + + this.renderTexture = null; + } + } +} \ No newline at end of file diff --git a/reference/Egret/4.x/src/dragonBones/egret/Movie.ts b/reference/Egret/4.x/src/dragonBones/egret/Movie.ts new file mode 100644 index 0000000..5aaa7ab --- /dev/null +++ b/reference/Egret/4.x/src/dragonBones/egret/Movie.ts @@ -0,0 +1,1474 @@ +namespace dragonBones { + /** + * @private + */ + type GroupConfig = { + name: string, + version: number, + + position: number[], + + display: DisplayConfig[], + frame: FrameConfig[], + movie: MovieConfig[], + animation: MovieConfig[], // 兼容旧数据 + + // Runtime + offset: number, + arrayBuffer: ArrayBuffer, + displayFrameArray: Int16Array, + rectangleArray: Float32Array, + transformArray: Float32Array, + colorArray: Int16Array, + textures: egret.Texture[] + }; + /** + * @private + */ + type DisplayConfig = { + name: string, + type: DisplayType, + textureIndex?: number, + regionIndex?: number, + + // Runtime + texture: egret.Texture + }; + /** + * @private + */ + type ActionAndEventConfig = { + type: ActionType, + name: string, + data?: any, + slot?: string + }; + /** + * @private + */ + type MovieConfig = { + name: string, + frameRate: number, + type?: number, + action?: string, + isNested?: boolean, + hasChildAnimation?: boolean, // 兼容旧数据 + + slot: SlotConfig[], + clip: ClipConfig[] + }; + /** + * @private + */ + type SlotConfig = { + name: string, + blendMode?: BlendMode, + action?: string + }; + /** + * @private + */ + type ClipConfig = { + name: string, + playTimes: number, + duration: number, + scale: number, + cacheTimeToFrameScale: number, + p: number, + s: number, + + frame: number[], + + // Runtime + cacheRectangles: egret.Rectangle[] + }; + /** + * @private + */ + type FrameConfig = { + prev: number, + next: number, + position: number, + actionAndEvent: ActionAndEventConfig[] + }; + /** + * @private + */ + type CreateMovieHelper = { + groupName: string, + movieName: string, + groupConfig: GroupConfig, + movieConfig: MovieConfig + }; + /** + * @private + */ + let _helpRectangle: egret.Rectangle = new egret.Rectangle(); + /** + * @private + */ + let _helpMatrix: egret.Matrix = new egret.Matrix(); + /** + * @private + */ + let _groupConfigMap: Map = {}; + /** + * @private + */ + function _findObjectInArray(array: T[], name: string): T | null { + for (let i = 0, l = array.length; i < l; ++i) { + const data = array[i]; + if (data.name === name) { + return data; + } + } + + return null; + } + /** + * @private + */ + function _fillCreateMovieHelper(createMovieHelper: CreateMovieHelper): boolean { + if (createMovieHelper.groupName) { + const groupConfig = _groupConfigMap[createMovieHelper.groupName]; + if (groupConfig) { + const movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); + if (movieConfig) { + createMovieHelper.groupConfig = groupConfig; + createMovieHelper.movieConfig = movieConfig; + return true; + } + } + } + + if (!createMovieHelper.groupName) { // || autoSearch Will be search all data, if do not give a data name or the autoSearch is true. + for (let groupName in _groupConfigMap) { + const groupConfig = _groupConfigMap[groupName]; + if (!createMovieHelper.groupName) { // || groupConfig.autoSearch + const movieConfig = _findObjectInArray(groupConfig.movie || groupConfig.animation, createMovieHelper.movieName); + if (movieConfig) { + createMovieHelper.groupName = groupName; + createMovieHelper.groupConfig = groupConfig; + createMovieHelper.movieConfig = movieConfig; + return true; + } + } + } + } + + return false; + } + /** + * @language zh_CN + * 是否包含指定名称的动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + export function hasMovieGroup(groupName: string): boolean { + return groupName in _groupConfigMap; + } + /** + * @language zh_CN + * 添加动画组。 + * @param groupData 动画二进制数据。 + * @param textureAtlas 贴图集或贴图集列表。 + * @param groupName 为动画组指定一个名称,如果未设置,则使用数据中的名称。 + * @version DragonBones 4.7 + */ + export function addMovieGroup(groupData: ArrayBuffer, textureAtlas: egret.Texture | egret.Texture[], groupName: string | null = null): void { + if (groupData) { + const byteArray = new egret.ByteArray(groupData); + byteArray.endian = egret.Endian.LITTLE_ENDIAN; + byteArray.position = 8; // TODO format + + const groupConfig = JSON.parse(byteArray.readUTF()); + groupConfig.offset = byteArray.position; + groupConfig.arrayBuffer = groupData; + groupConfig.textures = []; + + const p = groupConfig.offset % 4; + if (p) { + groupConfig.offset += 4 - p; + } + + for (let i = 0, l = groupConfig.position.length; i < l; i += 3) { + switch (i / 3) { + case 1: + groupConfig.displayFrameArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + case 2: + groupConfig.rectangleArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + case 3: + groupConfig.transformArray = new Float32Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + case 4: + groupConfig.colorArray = new Int16Array(groupConfig.arrayBuffer, groupConfig.offset + groupConfig.position[i], groupConfig.position[i + 1] / groupConfig.position[i + 2]); + break; + } + } + + groupName = groupName || groupConfig.name; + if (_groupConfigMap[groupName]) { + console.warn("Replace group: " + groupName); + } + + _groupConfigMap[groupName] = groupConfig; + + // + if (textureAtlas instanceof Array) { + for (let i = 0, l = textureAtlas.length; i < l; ++i) { + const texture = textureAtlas[i]; + groupConfig.textures.push(texture); + } + } + else { + groupConfig.textures.push(textureAtlas); + } + } + else { + throw new Error(); + } + } + /** + * @language zh_CN + * 移除动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + export function removeMovieGroup(groupName: string): void { + const groupConfig = _groupConfigMap[groupName]; + if (groupConfig) { + delete _groupConfigMap[groupName]; + } + } + /** + * @language zh_CN + * 移除所有的动画组。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + export function removeAllMovieGroup(): void { + for (let i in _groupConfigMap) { + delete _groupConfigMap[i]; + } + } + /** + * @language zh_CN + * 创建一个动画。 + * @param movieName 动画的名称。 + * @param groupName 动画组的名称,如果未设置,将检索所有的动画组,当多个动画组中包含同名的动画时,可能无法创建出准确的动画。 + * @version DragonBones 4.7 + */ + export function buildMovie(movieName: string, groupName: string | null = null): Movie | null { + const createMovieHelper = { movieName: movieName, groupName: groupName }; + if (_fillCreateMovieHelper(createMovieHelper)) { + const movie = new Movie(createMovieHelper); + dragonBones.EgretFactory.factory; + movie.clock = dragonBones.EgretFactory.clock; + return movie; + } + else { + console.warn("No movie named: " + movieName); + } + + return null; + } + /** + * @language zh_CN + * 获取指定动画组内包含的所有动画名称。 + * @param groupName 动画组的名称。 + * @version DragonBones 4.7 + */ + export function getMovieNames(groupName: string): string[] | null { + const groupConfig = _groupConfigMap[groupName]; + if (groupConfig) { + const movieNameGroup = []; + const movie = groupConfig.movie || groupConfig.animation; + for (let i = 0, l = movie.length; i < l; ++i) { + movieNameGroup.push(movie[i].name); + } + + return movieNameGroup; + } + else { + console.warn("No group named: " + groupName); + } + + return null; + } + /** + * @language zh_CN + * 动画事件。 + * @version DragonBones 4.7 + */ + export class MovieEvent extends egret.Event { + /** + * @language zh_CN + * 动画剪辑开始播放。 + * @version DragonBones 4.7 + */ + public static START: string = "start"; + /** + * @language zh_CN + * 动画剪辑循环播放一次完成。 + * @version DragonBones 4.7 + */ + public static LOOP_COMPLETE: string = "loopComplete"; + /** + * @language zh_CN + * 动画剪辑播放完成。 + * @version DragonBones 4.7 + */ + public static COMPLETE: string = "complete"; + /** + * @language zh_CN + * 动画剪辑帧事件。 + * @version DragonBones 4.7 + */ + public static FRAME_EVENT: string = "frameEvent"; + /** + * @language zh_CN + * 动画剪辑声音事件。 + * @version DragonBones 4.7 + */ + public static SOUND_EVENT: string = "soundEvent"; + /** + * @language zh_CN + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.7 + */ + public name: string = ""; + /** + * @language zh_CN + * 发出事件的插槽名称。 + * @version DragonBones 4.7 + */ + public slotName: string = ""; + /** + * @language zh_CN + * 发出事件的动画剪辑名称。 + * @version DragonBones 4.7 + */ + public clipName: string = ""; + /** + * @language zh_CN + * 发出事件的动画。 + * @version DragonBones 4.7 + */ + public movie: Movie; + /** + * @private + */ + public constructor(type: string) { + super(type); + } + + //========================================= // 兼容旧数据 + /** + * @private + */ + public get armature(): any { + return this.movie; + } + /** + * @private + */ + public get bone(): any { + return null; + } + /** + * @private + */ + public get animationState(): any { + return { name: this.clipName }; + } + /** + * @private + */ + public get frameLabel(): any { + return this.name; + } + /** + * @private + */ + public get movementID(): any { + return this.clipName; + } + //========================================= + } + /** + * @private + */ + class MovieSlot extends egret.HashObject { + public displayIndex: number = -1; + public colorIndex: number = -1; + public transformIndex: number = -1; + public rawDisplay: egret.Bitmap = new egret.Bitmap(); + public childMovies: Map = {}; + public config: SlotConfig; + public displayConfig: DisplayConfig | null = null; + public display: egret.DisplayObject; + public childMovie: Movie | null = null; + public colorFilter: egret.ColorMatrixFilter | null = null; + + public constructor(slotConfig: SlotConfig) { + super(); + + this.display = this.rawDisplay; + this.config = slotConfig; + this.rawDisplay.name = this.config.name; + + if (!this.config.blendMode) { + this.config.blendMode = BlendMode.Normal; + } + } + + public dispose(): void { + this.rawDisplay = null as any; + this.childMovies = null as any; + this.config = null as any; + this.displayConfig = null as any; + this.display = null as any; + this.childMovie = null as any; + this.colorFilter = null as any; + } + } + /** + * @language zh_CN + * 通过读取缓存的二进制动画数据来更新动画,具有良好的运行性能,同时对内存的占用也非常低。 + * @see dragonBones.buildMovie + * @version DragonBones 4.7 + */ + export class Movie extends egret.DisplayObjectContainer implements IAnimatable { + private static _cleanBeforeRender(): void { } + /** + * @language zh_CN + * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 4.7 + */ + public timeScale: number = 1; + /** + * @language zh_CN + * 动画剪辑的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * (当再次播放其他动画剪辑时,此值将被重置为 1) + * @default 1 + * @version DragonBones 4.7 + */ + public clipTimeScale: number = 1; + + private _batchEnabled: boolean = true; + private _isLockDispose: boolean = false; + private _isDelayDispose: boolean = false; + private _isStarted: boolean = false; + private _isPlaying: boolean = false; + private _isReversing: boolean = false; + private _isCompleted: boolean = false; + private _playTimes: number = 0; + private _time: number = 0; + private _currentTime: number = 0; + private _currentPlayTimes: number = 0; + private _cacheFrameIndex: number = 0; + private _frameSize: number = 0; + private _cacheRectangle: egret.Rectangle | null = null; + private _clock: WorldClock | null = null; + + private _groupConfig: GroupConfig; + private _config: MovieConfig; + private _clipConfig: ClipConfig; + private _currentFrameConfig: FrameConfig | null = null; + private _clipArray: Int16Array; + + private _clipNames: string[] = []; + private _slots: MovieSlot[] = []; + private _childMovies: Movie[] = []; + /** + * @internal + * @private + */ + public constructor(createMovieHelper: any) { + super(); + + this._groupConfig = (createMovieHelper as CreateMovieHelper).groupConfig; + this._config = (createMovieHelper as CreateMovieHelper).movieConfig; + + this._batchEnabled = !(this._config.isNested || this._config.hasChildAnimation); + + if (this._batchEnabled) { + this.$renderNode = new egret.sys.GroupNode(); + this.$renderNode.cleanBeforeRender = Movie._cleanBeforeRender; + } + + this._clipNames.length = 0; + for (let i = 0, l = this._config.clip.length; i < l; ++i) { + this._clipNames.push(this._config.clip[i].name); + } + + for (let i = 0, l = this._config.slot.length; i < l; ++i) { + const slot = new MovieSlot(this._config.slot[i]); + this._updateSlotBlendMode(slot); + this._slots.push(slot); + + if (this._batchEnabled) { + (this.$renderNode).addNode(slot.rawDisplay.$renderNode); + } + else { + this.addChild(slot.rawDisplay); + } + } + + this._frameSize = (1 + 1) * this._slots.length; // displayFrame, transformFrame. + this.name = this._config.name; + this.play(); + this.advanceTime(0.000001); + this.stop(); + } + + private _configToEvent(config: ActionAndEventConfig, event: MovieEvent): void { + event.movie = this; + event.clipName = this._clipConfig.name; + event.name = config.name; + event.slotName = config.slot || ""; + } + + private _onCrossFrame(frameConfig: FrameConfig): void { + for (let i = 0, l = frameConfig.actionAndEvent.length; i < l; ++i) { + const actionAndEvent = frameConfig.actionAndEvent[i]; + if (actionAndEvent) { + switch (actionAndEvent.type) { + case ActionType.Sound: + if (EgretFactory.factory.soundEventManager.hasEventListener(MovieEvent.SOUND_EVENT)) { + const event = egret.Event.create(MovieEvent, MovieEvent.SOUND_EVENT); + this._configToEvent(actionAndEvent, event); + EgretFactory.factory.soundEventManager.dispatchEvent(event); + egret.Event.release(event); + } + break; + + case ActionType.Frame: + if (this.hasEventListener(MovieEvent.FRAME_EVENT)) { + const event = egret.Event.create(MovieEvent, MovieEvent.FRAME_EVENT); + this._configToEvent(actionAndEvent, event); + this.dispatchEvent(event); + egret.Event.release(event); + } + break; + + case ActionType.Play: + if (actionAndEvent.slot) { + const slot = this._getSlot(actionAndEvent.slot); + if (slot && slot.childMovie) { + slot.childMovie.play(actionAndEvent.name); + } + } + else { + this.play(actionAndEvent.name); + } + break; + } + } + } + } + + private _updateSlotBlendMode(slot: MovieSlot): void { + let blendMode = ""; + + switch (slot.config.blendMode) { + case BlendMode.Normal: + blendMode = egret.BlendMode.NORMAL; + break; + + case BlendMode.Add: + blendMode = egret.BlendMode.ADD; + break; + + case BlendMode.Erase: + blendMode = egret.BlendMode.ERASE; + break; + + default: + break; + } + + if (blendMode) { + if (this._batchEnabled) { + // RenderNode display. + (slot.display.$renderNode).blendMode = egret.sys.blendModeToNumber(blendMode); + } + else { + // Classic display. + slot.display.blendMode = blendMode; + } + } + } + + private _updateSlotColor(slot: MovieSlot, aM: number, rM: number, gM: number, bM: number, aO: number, rO: number, gO: number, bO: number): void { + if ( + rM !== 1 || + gM !== 1 || + bM !== 1 || + rO !== 0 || + gO !== 0 || + bO !== 0 || + aO !== 0 + ) { + if (!slot.colorFilter) { + slot.colorFilter = new egret.ColorMatrixFilter(); + } + + const colorMatrix = slot.colorFilter.matrix; + colorMatrix[0] = rM; + colorMatrix[6] = gM; + colorMatrix[12] = bM; + colorMatrix[18] = aM; + colorMatrix[4] = rO; + colorMatrix[9] = gO; + colorMatrix[14] = bO; + colorMatrix[19] = aO; + + slot.colorFilter.matrix = colorMatrix; + + if (this._batchEnabled) { + // RenderNode display. + (slot.display.$renderNode).filter = slot.colorFilter; + (slot.display.$renderNode).alpha = 1.0; + } + else { + // Classic display. + let filters = slot.display.filters; + if (!filters) { + filters = []; + } + + if (filters.indexOf(slot.colorFilter) < 0) { + filters.push(slot.colorFilter); + } + + slot.display.filters = filters; + slot.display.$setAlpha(1.0); + } + } + else { + if (slot.colorFilter) { + slot.colorFilter = null; + } + + if (this._batchEnabled) { + // RenderNode display. + (slot.display.$renderNode).filter = null as any; + (slot.display.$renderNode).alpha = aM; + } + else { + // Classic display. + slot.display.filters = null as any; + slot.display.$setAlpha(aM); + } + } + } + + private _updateSlotDisplay(slot: MovieSlot): void { + const prevDisplay = slot.display || slot.rawDisplay; + const prevChildMovie = slot.childMovie; + + if (slot.displayIndex >= 0) { + slot.displayConfig = this._groupConfig.display[slot.displayIndex]; + if (slot.displayConfig.type === DisplayType.Armature) { + let childMovie = slot.displayConfig.name in slot.childMovies ? slot.childMovies[slot.displayConfig.name] : null; + + if (!childMovie) { + childMovie = buildMovie(slot.displayConfig.name, this._groupConfig.name); + if (childMovie) { + slot.childMovies[slot.displayConfig.name] = childMovie; + } + } + + if (childMovie) { + slot.display = childMovie; + slot.childMovie = childMovie; + } + else { + slot.display = slot.rawDisplay; + slot.childMovie = null; + } + } + else { + slot.display = slot.rawDisplay; + slot.childMovie = null; + } + } + else { + slot.displayConfig = null; + slot.display = slot.rawDisplay; + slot.childMovie = null; + } + + if (slot.display !== prevDisplay) { + if (prevDisplay) { + this.addChild(slot.display); + this.swapChildren(slot.display, prevDisplay); + this.removeChild(prevDisplay); + } + + // Update blendMode. + this._updateSlotBlendMode(slot); + } + + // Update frame. + if (slot.display === slot.rawDisplay) { + if (slot.displayConfig && slot.displayConfig.regionIndex !== null && slot.displayConfig.regionIndex !== undefined) { + if (!slot.displayConfig.texture) { + const textureAtlasTexture = this._groupConfig.textures[slot.displayConfig.textureIndex || 0]; + const regionIndex = slot.displayConfig.regionIndex * 4; + const x = this._groupConfig.rectangleArray[regionIndex]; + const y = this._groupConfig.rectangleArray[regionIndex + 1]; + const width = this._groupConfig.rectangleArray[regionIndex + 2]; + const height = this._groupConfig.rectangleArray[regionIndex + 3]; + + slot.displayConfig.texture = new egret.Texture(); + slot.displayConfig.texture._bitmapData = textureAtlasTexture._bitmapData; + slot.displayConfig.texture.$initData( + x, y, + Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), + 0, 0, + Math.min(width, textureAtlasTexture.textureWidth - x), Math.min(height, textureAtlasTexture.textureHeight - y), + textureAtlasTexture.textureWidth, textureAtlasTexture.textureHeight + ); + } + if (this._batchEnabled) { + // RenderNode display. + const texture = slot.displayConfig.texture; + const bitmapNode = slot.rawDisplay.$renderNode as egret.sys.BitmapNode; + egret.sys.RenderNode.prototype.cleanBeforeRender.call(slot.rawDisplay.$renderNode); + bitmapNode.image = texture._bitmapData; + + bitmapNode.drawImage( + texture._bitmapX, texture._bitmapY, + texture._bitmapWidth, texture._bitmapHeight, + texture._offsetX, texture._offsetY, + texture.textureWidth, texture.textureHeight + ); + + bitmapNode.imageWidth = texture._sourceWidth; + bitmapNode.imageHeight = texture._sourceHeight; + } + else { + // Classic display. + slot.rawDisplay.visible = true; + slot.rawDisplay.$setBitmapData(slot.displayConfig.texture); + } + } + else { + if (this._batchEnabled) { + // RenderNode display. + (slot.rawDisplay.$renderNode).image = null as any; + } + else { + // Classic display. + slot.rawDisplay.visible = false; + slot.rawDisplay.$setBitmapData(null as any); + } + } + } + + // Update child movie. + if (slot.childMovie !== prevChildMovie) { + if (prevChildMovie) { + prevChildMovie.stop(); + this._childMovies.slice(this._childMovies.indexOf(prevChildMovie), 1); + } + + if (slot.childMovie) { + if (this._childMovies.indexOf(slot.childMovie) < 0) { + this._childMovies.push(slot.childMovie); + } + + if (slot.config.action) { + slot.childMovie.play(slot.config.action); + } + else { + slot.childMovie.play(slot.childMovie._config.action); + } + } + } + } + + private _getSlot(name: string): MovieSlot | null { + for (let i = 0, l = this._slots.length; i < l; ++i) { + const slot = this._slots[i]; + if (slot.config.name === name) { + return slot; + } + } + + return null; + } + /** + * @inheritDoc + */ + $render(): void { + if (this._batchEnabled) { + // RenderNode display. + } + else { + // Classic display. + super.$render(); + } + } + /** + * @inheritDoc + */ + $measureContentBounds(bounds: egret.Rectangle): void { + if (this._batchEnabled && this._cacheRectangle) { + // RenderNode display. + bounds.setTo(this._cacheRectangle.x, this._cacheRectangle.y, this._cacheRectangle.width - this._cacheRectangle.x, this._cacheRectangle.height - this._cacheRectangle.y); + } + else { + // Classic display. + super.$measureContentBounds(bounds); + } + } + /** + * @inheritDoc + */ + $doAddChild(child: egret.DisplayObject, index: number, notifyListeners?: boolean): egret.DisplayObject { + if (this._batchEnabled) { + // RenderNode display. + console.warn("Can not add child."); + return null as any; + } + + // Classic display. + return super.$doAddChild(child, index, notifyListeners); + } + /** + * @inheritDoc + */ + $doRemoveChild(index: number, notifyListeners?: boolean): egret.DisplayObject { + if (this._batchEnabled) { + // RenderNode display. + console.warn("Can not remove child."); + return null as any; + } + + // Classic display. + return super.$doRemoveChild(index, notifyListeners); + } + /** + * 释放动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public dispose(): void { + if (this._isLockDispose) { + this._isDelayDispose = true; + } + else { + if (this._clock) { + this._clock.remove(this); + } + + if (this._slots) { + for (let i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].dispose(); + } + } + + this._isPlaying = false; + this._cacheRectangle = null; + this._clock = null; + this._groupConfig = null as any; + this._config = null as any; + this._clipConfig = null as any; + this._currentFrameConfig = null; + this._clipArray = null as any; + + this._clipNames = null as any; + this._slots = null as any; + this._childMovies = null as any; + } + } + /** + * @inheritDoc + */ + public advanceTime(passedTime: number): void { + if (this._isPlaying) { + this._isLockDispose = true; + if (passedTime < 0) { + passedTime = -passedTime; + } + passedTime *= this.timeScale; + this._time += passedTime * this.clipTimeScale; + + // Modify time. + const duration = this._clipConfig.duration; + const totalTime = duration * this._playTimes; + let currentTime = this._time; + let currentPlayTimes = this._currentPlayTimes; + if (this._playTimes > 0 && (currentTime >= totalTime || currentTime <= -totalTime)) { + this._isCompleted = true; + currentPlayTimes = this._playTimes; + + if (currentTime < 0) { + currentTime = 0; + } + else { + currentTime = duration; + } + } + else { + this._isCompleted = false; + + if (currentTime < 0) { + currentPlayTimes = Math.floor(-currentTime / duration); + currentTime = duration - (-currentTime % duration); + } + else { + currentPlayTimes = Math.floor(currentTime / duration); + currentTime %= duration; + } + + if (this._playTimes > 0 && currentPlayTimes > this._playTimes) { + currentPlayTimes = this._playTimes; + } + } + + if (this._currentTime === currentTime) { + return; + } + + const cacheFrameIndex = Math.floor(currentTime * this._clipConfig.cacheTimeToFrameScale); + if (this._cacheFrameIndex !== cacheFrameIndex) { + this._cacheFrameIndex = cacheFrameIndex; + + const displayFrameArray = this._groupConfig.displayFrameArray; + const transformArray = this._groupConfig.transformArray; + const colorArray = this._groupConfig.colorArray; + + // + let isFirst = true; + let hasDisplay = false; + let needCacheRectangle = false; + const prevCacheRectangle = this._cacheRectangle; + this._cacheRectangle = this._clipConfig.cacheRectangles[this._cacheFrameIndex]; + if (this._batchEnabled && !this._cacheRectangle) { + needCacheRectangle = true; + this._cacheRectangle = new egret.Rectangle(); + this._clipConfig.cacheRectangles[this._cacheFrameIndex] = this._cacheRectangle; + } + + // Update slots. + for (let i = 0, l = this._slots.length; i < l; ++i) { + const slot = this._slots[i]; + let clipFrameIndex = this._frameSize * this._cacheFrameIndex + i * 2; + if (clipFrameIndex >= this._clipArray.length) { + clipFrameIndex = this._frameSize * (this._cacheFrameIndex - 1) + i * 2; + } + const displayFrameIndex = this._clipArray[clipFrameIndex] * 2; + if (displayFrameIndex >= 0) { + const displayIndex = displayFrameArray[displayFrameIndex]; + const colorIndex = displayFrameArray[displayFrameIndex + 1] * 8; + const transformIndex = this._clipArray[clipFrameIndex + 1] * 6; + let colorChange = false; + + if (slot.displayIndex !== displayIndex) { + slot.displayIndex = displayIndex; + colorChange = true; + this._updateSlotDisplay(slot); + } + + if (slot.colorIndex !== colorIndex || colorChange) { + slot.colorIndex = colorIndex; + if (slot.colorIndex >= 0) { + this._updateSlotColor( + slot, + colorArray[colorIndex] * 0.01, + colorArray[colorIndex + 1] * 0.01, + colorArray[colorIndex + 2] * 0.01, + colorArray[colorIndex + 3] * 0.01, + colorArray[colorIndex + 4], + colorArray[colorIndex + 5], + colorArray[colorIndex + 6], + colorArray[colorIndex + 7] + ); + } + else { + this._updateSlotColor(slot, 1, 1, 1, 1, 0, 0, 0, 0); + } + } + + hasDisplay = true; + + if (slot.transformIndex !== transformIndex) { + slot.transformIndex = transformIndex; + + if (this._batchEnabled) { + // RenderNode display. + let matrix = (slot.display.$renderNode).matrix; + if (!matrix) { + matrix = (slot.display.$renderNode).matrix = new egret.Matrix(); + } + + matrix.a = transformArray[transformIndex]; + matrix.b = transformArray[transformIndex + 1]; + matrix.c = transformArray[transformIndex + 2]; + matrix.d = transformArray[transformIndex + 3]; + matrix.tx = transformArray[transformIndex + 4]; + matrix.ty = transformArray[transformIndex + 5]; + } + else { + // Classic display. + _helpMatrix.a = transformArray[transformIndex]; + _helpMatrix.b = transformArray[transformIndex + 1]; + _helpMatrix.c = transformArray[transformIndex + 2]; + _helpMatrix.d = transformArray[transformIndex + 3]; + _helpMatrix.tx = transformArray[transformIndex + 4]; + _helpMatrix.ty = transformArray[transformIndex + 5]; + + slot.display.$setMatrix(_helpMatrix); + } + } + + // + if (this._batchEnabled && needCacheRectangle && slot.displayConfig) { + // RenderNode display. + const matrix = (slot.display.$renderNode).matrix; + + _helpRectangle.x = 0; + _helpRectangle.y = 0; + _helpRectangle.width = slot.displayConfig.texture.textureWidth; + _helpRectangle.height = slot.displayConfig.texture.textureHeight; + matrix.$transformBounds(_helpRectangle); + + if (isFirst) { + isFirst = false; + this._cacheRectangle.x = _helpRectangle.x; + this._cacheRectangle.width = _helpRectangle.x + _helpRectangle.width; + this._cacheRectangle.y = _helpRectangle.y; + this._cacheRectangle.height = _helpRectangle.y + _helpRectangle.height; + } + else { + this._cacheRectangle.x = Math.min(this._cacheRectangle.x, _helpRectangle.x); + this._cacheRectangle.width = Math.max(this._cacheRectangle.width, _helpRectangle.x + _helpRectangle.width); + this._cacheRectangle.y = Math.min(this._cacheRectangle.y, _helpRectangle.y); + this._cacheRectangle.height = Math.max(this._cacheRectangle.height, _helpRectangle.y + _helpRectangle.height); + } + } + } + else if (slot.displayIndex !== -1) { + slot.displayIndex = -1; + this._updateSlotDisplay(slot); + } + } + + // + if (this._cacheRectangle) { + if (hasDisplay && needCacheRectangle && isFirst && prevCacheRectangle) { + this._cacheRectangle.x = prevCacheRectangle.x; + this._cacheRectangle.y = prevCacheRectangle.y; + this._cacheRectangle.width = prevCacheRectangle.width; + this._cacheRectangle.height = prevCacheRectangle.height; + } + + this.$invalidateContentBounds(); + } + } + + if (this._isCompleted) { + this._isPlaying = false; + } + + if (!this._isStarted) { + this._isStarted = true; + if (this.hasEventListener(MovieEvent.START)) { + const event = egret.Event.create(MovieEvent, MovieEvent.START); + event.movie = this; + event.clipName = this._clipConfig.name; + event.name = ""; + event.slotName = ""; + this.dispatchEvent(event); + } + } + + this._isReversing = this._currentTime > currentTime && this._currentPlayTimes === currentPlayTimes; + this._currentTime = currentTime; + + // Action and event. + const frameCount = this._clipConfig.frame ? this._clipConfig.frame.length : 0; + if (frameCount > 0) { + const currentFrameIndex = Math.floor(this._currentTime * this._config.frameRate); + const currentFrameConfig = this._groupConfig.frame[this._clipConfig.frame[currentFrameIndex]]; + if (this._currentFrameConfig !== currentFrameConfig) { + if (frameCount > 1) { + let crossedFrameConfig = this._currentFrameConfig; + this._currentFrameConfig = currentFrameConfig; + + if (!crossedFrameConfig) { + const prevFrameIndex = Math.floor(this._currentTime * this._config.frameRate); + crossedFrameConfig = this._groupConfig.frame[this._clipConfig.frame[prevFrameIndex]]; + + if (this._isReversing) { + + } + else { + if ( + this._currentTime <= crossedFrameConfig.position || + this._currentPlayTimes !== currentPlayTimes + ) { + crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; + } + } + } + + if (this._isReversing) { + while (crossedFrameConfig !== currentFrameConfig) { + this._onCrossFrame(crossedFrameConfig); + crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.prev]; + } + } + else { + while (crossedFrameConfig !== currentFrameConfig) { + crossedFrameConfig = this._groupConfig.frame[crossedFrameConfig.next]; + this._onCrossFrame(crossedFrameConfig); + } + } + } + else { + this._currentFrameConfig = currentFrameConfig; + if (this._currentFrameConfig) { + this._onCrossFrame(this._currentFrameConfig); + } + } + } + } + + if (this._currentPlayTimes !== currentPlayTimes) { + this._currentPlayTimes = currentPlayTimes; + if (this.hasEventListener(MovieEvent.LOOP_COMPLETE)) { + const event = egret.Event.create(MovieEvent, MovieEvent.LOOP_COMPLETE); + event.movie = this; + event.clipName = this._clipConfig.name; + event.name = ""; + event.slotName = ""; + this.dispatchEvent(event); + egret.Event.release(event); + } + + if (this._isCompleted && this.hasEventListener(MovieEvent.COMPLETE)) { + const event = egret.Event.create(MovieEvent, MovieEvent.COMPLETE); + event.movie = this; + event.clipName = this._clipConfig.name; + event.name = ""; + event.slotName = ""; + this.dispatchEvent(event); + egret.Event.release(event); + } + } + } + + this._isLockDispose = false; + if (this._isDelayDispose) { + this.dispose(); + } + } + /** + * 播放动画剪辑。 + * @param clipName 动画剪辑的名称,如果未设置,则播放默认动画剪辑,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画剪辑。 + * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 4.7 + * @language zh_CN + */ + public play(clipName: string | null = null, playTimes: number = -1): void { + if (clipName) { + let clipConfig: ClipConfig | null = null; + for (let i = 0, l = this._config.clip.length; i < l; ++i) { + const data = this._config.clip[i]; + if (data.name === clipName) { + clipConfig = data; + } + } + + if (clipConfig) { + this._clipConfig = clipConfig; + this._clipArray = new Int16Array(this._groupConfig.arrayBuffer, this._groupConfig.offset + this._groupConfig.position[0] + this._clipConfig.p, this._clipConfig.s / this._groupConfig.position[2]); + + if (!this._clipConfig.cacheRectangles) { + this._clipConfig.cacheRectangles = []; + } + + this._isPlaying = true; + this._isStarted = false; + this._isCompleted = false; + + if (playTimes < 0 || playTimes !== playTimes) { + this._playTimes = this._clipConfig.playTimes; + } + else { + this._playTimes = playTimes; + } + + this._time = 0; + this._currentTime = 0; + this._currentPlayTimes = 0; + this._cacheFrameIndex = -1; + this._currentFrameConfig = null; + this._cacheRectangle = null; + + this.clipTimeScale = 1 / this._clipConfig.scale; + } + else { + console.warn("No clip in movie.", this._config.name, clipName); + } + } + else if (this._clipConfig) { + if (this._isPlaying || this._isCompleted) { + this.play(this._clipConfig.name, this._playTimes); + } + else { + this._isPlaying = true; + } + // playTimes + } + else if (this._config.action) { + this.play(this._config.action, playTimes); + } + } + /** + * 暂停播放动画。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public stop(): void { + this._isPlaying = false; + } + /** + * 从指定时间播放动画。 + * @param clipName 动画剪辑的名称。 + * @param time 指定时间。(以秒为单位) + * @param playTimes 动画剪辑需要播放的次数。 [-1: 使用动画剪辑默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 5.0 + * @language zh_CN + */ + public gotoAndPlay(clipName: string | null = null, time: number, playTimes: number = -1): void { + time %= this._clipConfig.duration; + if (time < 0) { + time += this._clipConfig.duration; + } + + this.play(clipName, playTimes); + this._time = time; + this._currentTime = time; + } + /** + * 将动画停止到指定时间。 + * @param clipName 动画剪辑的名称。 + * @param time 指定时间。(以秒为单位) + * @version DragonBones 5.0 + * @language zh_CN + */ + public gotoAndStop(clipName: string | null = null, time: number): void { + time %= this._clipConfig.duration; + if (time < 0) { + time += this._clipConfig.duration; + } + + this.play(clipName, 1); + this._time = time; + this._currentTime = time; + + this.advanceTime(0.001); + this.stop(); + } + /** + * 是否包含指定动画剪辑。 + * @param clipName 动画剪辑的名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public hasClip(clipName: string): boolean { + for (let i = 0, l = this._config.clip.length; i < l; ++i) { + const clip = this._config.clip[i]; + if (clip.name === clipName) { + return true; + } + } + + return false; + } + /** + * 动画剪辑是否处正在播放。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public get isPlaying(): boolean { + return this._isPlaying && !this._isCompleted; + } + /** + * 动画剪辑是否均播放完毕。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public get isComplete(): boolean { + return this._isCompleted; + } + /** + * 当前动画剪辑的播放时间。 (以秒为单位) + * @version DragonBones 4.7 + * @language zh_CN + */ + public get currentTime(): number { + return this._currentTime; + } + /** + * 当前动画剪辑的总时间。 (以秒为单位) + * @version DragonBones 4.7 + * @language zh_CN + */ + public get totalTime(): number { + return this._clipConfig ? this._clipConfig.duration : 0; + } + /** + * 当前动画剪辑的播放次数。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public get currentPlayTimes(): number { + return this._currentPlayTimes; + } + /** + * 当前动画剪辑需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 4.7 + * @language zh_CN + */ + public get playTimes(): number { + return this._playTimes; + } + + public get groupName(): string { + return this._groupConfig.name; + } + /** + * 正在播放的动画剪辑名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public get clipName(): string { + return this._clipConfig ? this._clipConfig.name : ""; + } + /** + * 所有动画剪辑的名称。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public get clipNames(): string[] { + return this._clipNames; + } + /** + * @inheritDoc + */ + public get clock(): WorldClock | null { + return this._clock; + } + public set clock(value: WorldClock | null) { + if (this._clock === value) { + return; + } + + const prevClock = this._clock; + if (prevClock) { + prevClock.remove(this); + } + + this._clock = value; + if (this._clock) { + this._clock.add(this); + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Movie#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Movie#timescale + * @see dragonBones.Movie#stop() + */ + public advanceTimeBySelf(on: boolean): void { + if (on) { + this.clock = EgretFactory.clock; + } + else { + this.clock = null; + } + } + + //========================================= // 兼容旧数据 + /** + * @private + */ + public get display(): any { + return this; + } + /** + * @private + */ + public get animation(): any { + return this; + } + /** + * @private + */ + public get armature(): any { + return this; + } + /** + * @private + */ + public getAnimation(): any { + return this; + } + /** + * @private + */ + public getArmature(): any { + return this; + } + /** + * @private + */ + public getDisplay(): any { + return this; + } + /** + * @private + */ + public hasAnimation(name: string): boolean { + return this.hasClip(name); + } + /** + * @private + */ + public invalidUpdate(...args: any[]): void { + args; + } + /** + * @private + */ + public get lastAnimationName(): string { + return this.clipName; + } + /** + * @private + */ + public get animationNames(): string[] { + return this.clipNames; + } + /** + * @private + */ + public get animationList(): string[] { + return this.clipNames; + } + //========================================= + } +} \ No newline at end of file diff --git a/reference/Egret/4.x/tsconfig.json b/reference/Egret/4.x/tsconfig.json new file mode 100644 index 0000000..44d448e --- /dev/null +++ b/reference/Egret/4.x/tsconfig.json @@ -0,0 +1,78 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": false, + "declaration": true, + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "outFile": "out/dragonBones.js", + "lib": [ + "es5", + "dom", + "es2015.promise" + ] + }, + "exclude": [ + "node_modules", + "out" + ], + "files": [ + "./libs/egret.d.ts", + "../../DragonBones/src/dragonBones/modules.ts", + + "../../DragonBones/src/dragonBones/core/DragonBones.ts", + "../../DragonBones/src/dragonBones/core/BaseObject.ts", + + "../../DragonBones/src/dragonBones/geom/Matrix.ts", + "../../DragonBones/src/dragonBones/geom/Transform.ts", + "../../DragonBones/src/dragonBones/geom/ColorTransform.ts", + "../../DragonBones/src/dragonBones/geom/Point.ts", + "../../DragonBones/src/dragonBones/geom/Rectangle.ts", + + "../../DragonBones/src/dragonBones/model/UserData.ts", + "../../DragonBones/src/dragonBones/model/DragonBonesData.ts", + "../../DragonBones/src/dragonBones/model/ArmatureData.ts", + "../../DragonBones/src/dragonBones/model/ConstraintData.ts", + "../../DragonBones/src/dragonBones/model/DisplayData.ts", + "../../DragonBones/src/dragonBones/model/BoundingBoxData.ts", + "../../DragonBones/src/dragonBones/model/AnimationData.ts", + "../../DragonBones/src/dragonBones/model/AnimationConfig.ts", + "../../DragonBones/src/dragonBones/model/TextureAtlasData.ts", + + "../../DragonBones/src/dragonBones/armature/IArmatureProxy.ts", + "../../DragonBones/src/dragonBones/armature/Armature.ts", + "../../DragonBones/src/dragonBones/armature/TransformObject.ts", + "../../DragonBones/src/dragonBones/armature/Bone.ts", + "../../DragonBones/src/dragonBones/armature/Slot.ts", + "../../DragonBones/src/dragonBones/armature/Constraint.ts", + + "../../DragonBones/src/dragonBones/animation/IAnimatable.ts", + "../../DragonBones/src/dragonBones/animation/WorldClock.ts", + "../../DragonBones/src/dragonBones/animation/Animation.ts", + "../../DragonBones/src/dragonBones/animation/AnimationState.ts", + "../../DragonBones/src/dragonBones/animation/BaseTimelineState.ts", + "../../DragonBones/src/dragonBones/animation/TimelineState.ts", + + "../../DragonBones/src/dragonBones/event/EventObject.ts", + "../../DragonBones/src/dragonBones/event/IEventDispatcher.ts", + + "../../DragonBones/src/dragonBones/parser/DataParser.ts", + "../../DragonBones/src/dragonBones/parser/ObjectDataParser.ts", + "../../DragonBones/src/dragonBones/parser/BinaryDataParser.ts", + + "../../DragonBones/src/dragonBones/factory/BaseFactory.ts", + + "./src/dragonBones/egret/EgretTextureAtlasData.ts", + "./src/dragonBones/egret/EgretArmatureDisplay.ts", + "./src/dragonBones/egret/EgretSlot.ts", + "./src/dragonBones/egret/EgretFactory.ts", + "./src/dragonBones/egret/Movie.ts" + ] +} \ No newline at end of file diff --git a/reference/Egret/4.x/tslint.json b/reference/Egret/4.x/tslint.json new file mode 100644 index 0000000..eeb58d1 --- /dev/null +++ b/reference/Egret/4.x/tslint.json @@ -0,0 +1,15 @@ +{ + "rules": { + "no-unused-expression": true, + "no-unreachable": true, + "no-duplicate-variable": true, + "no-duplicate-key": true, + "no-unused-variable": true, + "curly": false, + "class-name": true, + "triple-equals": true, + "semicolon": [ + true + ] + } +} \ No newline at end of file diff --git a/reference/Egret/5.x/README.md b/reference/Egret/5.x/README.md new file mode 100644 index 0000000..161b092 --- /dev/null +++ b/reference/Egret/5.x/README.md @@ -0,0 +1,8 @@ +## How to build +``` +$npm install +$npm run build +``` + +## Egret declaration +[egret.d.ts](https://github.com/egret-labs/egret-core/blob/master/build/egret/egret.d.ts) \ No newline at end of file diff --git a/reference/Egret/5.x/out/dragonBones.d.ts b/reference/Egret/5.x/out/dragonBones.d.ts new file mode 100644 index 0000000..3286440 --- /dev/null +++ b/reference/Egret/5.x/out/dragonBones.d.ts @@ -0,0 +1,4942 @@ +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + FFDTimelineMeshOffset = 0, + FFDTimelineFFDCount = 1, + FFDTimelineValueCount = 2, + FFDTimelineValueOffset = 3, + FFDTimelineFloatOffset = 4, + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * @language zh_CN + * 包围盒类型。 + * @version DragonBones 5.0 + */ + 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, + BoneT = 11, + BoneR = 12, + BoneS = 13, + BoneX = 14, + BoneY = 15, + BoneRotate = 16, + BoneSkew = 17, + BoneScaleX = 18, + BoneScaleY = 19, + SlotVisible = 23, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * @private + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * @language zh_CN + * 动画混合的淡出方式。 + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + None = 0, + /** + * 淡出同层的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer = 1, + /** + * 淡出同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup = 2, + /** + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * 淡出所有动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + All = 4, + /** + * 不替换同名动画。 + * @version DragonBones 5.1 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + static readonly VERSION: string; + 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 namespace 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); + /** + * @private + */ + static toString(): string; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * 对象的唯一标识。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +declare namespace dragonBones { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * 转换为单位矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: 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; + constructor( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x?: number, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y?: number, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew?: number, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation?: number, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX?: number, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fromMatrix(matrix: Matrix): Transform; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + toMatrix(matrix: Matrix): Transform; + } +} +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; + } +} +declare namespace dragonBones { + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * 自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * 获取自定义字符串。 + * @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; + } +} +declare namespace dragonBones { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly frameIndices: Array; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatures: Map; + /** + * @private + */ + intArray: Array | Int16Array; + /** + * @private + */ + floatArray: Array | Float32Array; + /** + * @private + */ + frameIntArray: Array | Int16Array; + /** + * @private + */ + frameFloatArray: Array | Float32Array; + /** + * @private + */ + frameArray: Array | Int16Array; + /** + * @private + */ + timelineArray: Array | Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addArmature(value: ArmatureData): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + /** + * @private + */ + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * 所有动画数据名称。 + * @see #armatures + * @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; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly bones: Map; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly slots: Map; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly skins: Map; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animations: Map; + /** + * 获取默认皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * 获取默认动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的龙骨数据。 + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parent: DragonBonesData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + sortBones(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @private + */ + addBone(value: BoneData): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + length: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + readonly constraints: Array; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static createColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + target: BoneData; + bone: BoneData; + root: BoneData | null; + protected _onClear(): void; + } + /** + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: ArmatureData; + 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 + */ + class MeshDisplayData extends ImageDisplayData { + static toString(): string; + inheritAnimation: boolean; + offset: number; + weight: WeightData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * 边界框颜色。 + * @version DragonBones 5.0 + * @language zh_CN + */ + color: number; + /** + * 边界框宽。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + width: number; + /** + * 边界框高。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * 是否包含点。 + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * 是否与线段相交。 + * @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; + } + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 多边形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array | Float32Array, offset: number, count: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + count: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + vertices: Array | Float32Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } +} +declare namespace dragonBones { + /** + * 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + frameIntOffset: number; + /** + * @private + */ + frameFloatOffset: number; + /** + * @private + */ + frameOffset: number; + /** + * 持续的帧数。 ([1~N]) + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * 淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimeline(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * 是否暂停淡出的动画。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeOut: boolean; + /** + * 淡出模式。 + * @default dragonBones.AnimationFadeOutMode.All + * @see dragonBones.AnimationFadeOutMode + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * 淡出缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTweenType: TweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTime: number; + /** + * 否能触发行为。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 是否以增加的方式混合。 + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeIn: boolean; + /** + * 是否将没有动画的对象重置为初始值。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 淡入缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTweenType: TweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + playTimes: number; + /** + * 混合图层,图层高会优先获取混合权重。 + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * 开始时间。 (以秒为单位) + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * 混合权重。 + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * 动画状态名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * 动画数据名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + clear(): void; + copyFrom(value: AnimationConfig): void; + containsBoneMask(name: string): boolean; + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * 贴图集缩放系数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scale: number; + /** + * 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + abstract createTexture(): TextureData; + /** + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: 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; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架代理接口。 + * @version DragonBones 5.0 + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + init(armature: Armature): void; + /** + * @private + */ + clear(): void; + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + dispose(disposeProxy: boolean): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @language zh_CN + * 获取骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + readonly armature: Armature; + /** + * @language zh_CN + * 获取动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + readonly animation: Animation; + } +} +declare namespace dragonBones { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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); + /** + * 是否继承父骨架的动画状态。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + debugDraw: boolean; + /** + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + */ + armatureData: ArmatureData; + /** + * 用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + private _debugDraw; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + /** + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlotDisplay?: boolean): void; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string | null): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + flipX: boolean; + flipY: boolean; + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * @pivate + */ + readonly eventDispatcher: IEventDispatcher; + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + replaceTexture(texture: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + hasEventListener(type: EventStringType): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + enableAnimationCache(frameRate: number): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + } +} +declare namespace dragonBones { + /** + * 基础变换对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * 对象的名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + */ + origin: Transform; + /** + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * @private + */ + updateGlobalTransform(): void; + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +declare namespace dragonBones { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * @private + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + readonly constraints: Array; + /** + * @readonly + */ + boneData: BoneData; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + /** + * @internal + * @private + */ + _blendDirty: boolean; + private _localDirty; + private _visible; + private _cachedFrameIndex; + /** + * @internal + * @private + */ + _blendLayer: number; + /** + * @internal + * @private + */ + _blendLeftWeight: number; + /** + * @internal + * @private + */ + _blendLayerWeight: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(isCache); + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * @internal + * @private + */ + addConstraint(constraint: Constraint): void; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(child: TransformObject): boolean; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + readonly length: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + readonly slot: Slot | null; + } +} +declare namespace dragonBones { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 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; + /** + * @readonly + */ + slotData: SlotData; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + _colorDirty: boolean; + /** + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @private + */ + readonly _ffdVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @internal + * @private + */ + _rawDisplayDatas: Array; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @private + */ + init(slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + * @internal + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + target: Bone; + bone: Bone; + root: Bone | null; + protected _onClear(): void; + abstract update(): void; + } + /** + * @private + * @internal + */ + class IKConstraint extends Constraint { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + update(): void; + } +} +declare namespace dragonBones { + /** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * 更新时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 当前所属的 WordClock 实例。 + * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * 添加 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * 移除 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _animationDirty; + /** + * @internal + * @private + */ + _timelineDirty: boolean; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * 清除所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 上一个正在播放的动画状态名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationList: Array; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 是否以增加的方式混合。 + * @version DragonBones 3.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否能触发行为。 + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 混合图层。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + layer: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 混合权重。 + * @version DragonBones 3.0 + * @language zh_CN + */ + weight: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * @version DragonBones 3.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * 动画名称。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + name: string; + /** + * 混合组。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + group: string; + /** + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + animationData: AnimationData; + private _timelineDirty; + /** + * @internal + * @private + * xx: Play Enabled, Fade Play Enabled + */ + _playheadState: number; + /** + * @internal + * @private + * -1: Fade in, 0: Fade complete, 1: Fade out; + */ + _fadeState: number; + /** + * @internal + * @private + * -1: Fade start, 0: Fading, 1: Fade complete; + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + private _weightResult; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _slotTimelines; + private readonly _bonePoses; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @private + */ + protected _onClear(): void; + private _isDisabled(slot); + private _advanceFadeTime(passedTime); + private _blendBoneTimline(timeline); + /** + * @private + * @internal + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @private + * @internal + */ + updateTimelines(): void; + /** + * @private + * @internal + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + readonly clip: AnimationData; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class SlotDislayIndexTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _ffdCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } +} +declare namespace dragonBones { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + time: number; + /** + * 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * 发出事件的骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * 发出事件的骨骼。 + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * 发出事件的插槽。 + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * 发出事件的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * 自定义数据 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * 事件接口。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } +} +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: 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 BONE: string; + protected static readonly IK: string; + protected static readonly SLOT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly VISIBLE_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 CANVAS: 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 SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_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_FFD: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: 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_TYPE: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: 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_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 GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + private _intArrayJson; + private _floatArrayJson; + private _frameIntArrayJson; + private _frameFloatArrayJson; + private _frameArrayJson; + private _timelineArrayJson; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + 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 _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defalultColorOffset; + private _prevTweenRotate; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _weightBoneIndices; + private readonly _cacheBones; + private readonly _meshs; + private readonly _slotChildActions; + /** + * @private + */ + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + /** + * @private + */ + private _samplingEasingCurve(curve, samples); + private _sortActionFrame(a, b); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + private _parseCacheActionFrame(frame); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIKConstraint(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData | null; + /** + * @private + */ + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseTimeline(rawData: any, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): void; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): void; + /** + * @private + */ + protected _parseFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseBoneFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotDisplayIndexFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, type: ActionType, bone: BoneData | null, slot: SlotData | null): number; + /** + * @private + */ + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + /** + * @private + */ + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @private + */ + protected _parseWASMArray(): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + /** + * @private + */ + private static _objectDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binary; + private _binaryOffset; + private _intArray; + private _floatArray; + private _frameIntArray; + private _frameFloatArray; + private _frameArray; + private _timelineArray; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @private + */ + private static _binaryDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): BinaryDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * 清除所有的数据。 + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): Armature | null; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string | null, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): void; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): void; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string | null, fromDragonBonesDataName?: string | null, replaceOriginalAnimation?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} +declare namespace dragonBones { + /** + * Egret 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretTextureAtlasData extends TextureAtlasData { + /** + * @private + */ + static toString(): string; + private _renderTexture; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + createTexture(): TextureData; + /** + * Egret 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + renderTexture: egret.Texture | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + dispose(): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + readonly texture: egret.Texture | null; + } + /** + * @private + */ + class EgretTextureData extends TextureData { + static toString(): string; + renderTexture: egret.Texture | null; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * Egret 事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EgretEvent extends egret.Event { + /** + * 事件对象。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventObject: EventObject; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + readonly animationName: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#armature + */ + readonly armature: Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#bone + */ + readonly bone: Bone | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#slot + */ + readonly slot: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + readonly animationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + readonly frameLabel: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + readonly sound: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationName + */ + readonly movementID: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.START + */ + static START: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + static LOOP_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.COMPLETE + */ + static COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN + */ + static FADE_IN: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + static FADE_IN_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT + */ + static FADE_OUT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + static FADE_OUT_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static ANIMATION_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static BONE_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static MOVEMENT_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND: string; + } + /** + * @inheritDoc + */ + class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureProxy, IEventDispatcher { + private _disposeProxy; + private _armature; + private _debugDrawer; + /** + * @inheritDoc + */ + init(armature: Armature): void; + /** + * @inheritDoc + */ + clear(): void; + /** + * @inheritDoc + */ + dispose(disposeProxy?: boolean): void; + /** + * @inheritDoc + */ + debugUpdate(isEnabled: boolean): void; + /** + * @inheritDoc + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * @inheritDoc + */ + hasEvent(type: EventStringType): boolean; + /** + * @inheritDoc + */ + addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * @inheritDoc + */ + removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * @inheritDoc + */ + readonly armature: Armature; + /** + * @inheritDoc + */ + readonly animation: Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + advanceTimeBySelf(on: boolean): void; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature + */ + type FastArmature = Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Bone + */ + type FastBone = Bone; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Slot + */ + type FastSlot = Slot; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Animation + */ + type FastAnimation = Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.AnimationState + */ + type FastAnimationState = AnimationState; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class Event extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class ArmatureEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class AnimationEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class FrameEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + class SoundEvent extends EgretEvent { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + class EgretTextureAtlas extends EgretTextureAtlasData { + /** + * @private + */ + static toString(): string; + constructor(texture: egret.Texture, rawData: any, scale?: number); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + class EgretSheetAtlas extends EgretTextureAtlas { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + class SoundEventManager { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + static getInstance(): EgretArmatureDisplay; + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + class AnimationCacheManager { + } +} +declare namespace dragonBones { + /** + * Egret 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretSlot extends Slot { + static toString(): string; + /** + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 + * @language zh_CN + */ + transformUpdateEnabled: boolean; + private _renderDisplay; + private _colorFilter; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected _initDisplay(value: any): void; + /** + * @private + */ + protected _disposeDisplay(value: any): void; + /** + * @private + */ + protected _onUpdateDisplay(): void; + /** + * @private + */ + protected _addDisplay(): void; + /** + * @private + */ + protected _replaceDisplay(value: any): void; + /** + * @private + */ + protected _removeDisplay(): void; + /** + * @private + */ + protected _updateZOrder(): void; + /** + * @internal + * @private + */ + _updateVisible(): void; + /** + * @private + */ + protected _updateBlendMode(): void; + /** + * @private + */ + protected _updateColor(): void; + /** + * @private + */ + protected _updateFrame(): void; + /** + * @private + */ + protected _updateMesh(): void; + /** + * @private + */ + protected _updateTransform(isSkinnedMesh: boolean): void; + } +} +declare namespace dragonBones { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretFactory extends BaseFactory { + private static _time; + private static _dragonBones; + private static _factory; + private static _clockHandler(time); + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + static readonly factory: EgretFactory; + /** + * @inheritDoc + */ + constructor(); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: EgretTextureAtlasData | null, textureAtlas: egret.Texture): EgretTextureAtlasData; + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + buildArmatureDisplay(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): EgretArmatureDisplay | null; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureDisplay(textureName: string, textureAtlasName?: string | null): egret.Bitmap | null; + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly soundEventManager: EgretArmatureDisplay; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName?: string | null): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getDragonBonesData() + */ + getSkeletonData(dragonBonesName: string): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + removeSkeletonData(dragonBonesName: string): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addTextureAtlasData() + */ + addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName?: string | null): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getTextureAtlasData() + */ + getTextureAtlas(dragonBonesName: string): TextureAtlasData[] | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + removeTextureAtlas(dragonBonesName: string): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#buildArmature() + */ + buildFastArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null): FastArmature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#clear() + */ + dispose(): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager() + */ + readonly soundEventManater: EgretArmatureDisplay; + } +} diff --git a/reference/Egret/5.x/out/dragonBones.js b/reference/Egret/5.x/out/dragonBones.js new file mode 100644 index 0000000..d19fd65 --- /dev/null +++ b/reference/Egret/5.x/out/dragonBones.js @@ -0,0 +1,11720 @@ +"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 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; + } + 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; + armature.eventDispatcher._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(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.yDown = true; + DragonBones.debug = false; + DragonBones.debugDraw = false; + DragonBones.webAssembly = false; + DragonBones.VERSION = "5.1.0"; + return DragonBones; + }()); + dragonBones.DragonBones = DragonBones; + if (!console.warn) { + console.warn = function () { }; + } + if (!console.assert) { + console.assert = function () { }; + } +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var BaseObject = (function () { + function BaseObject() { + /** + * 对象的唯一标识。 + * @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._defaultMaxCount : BaseObject._maxCountMap[classType]; + var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.push(object); + } + else { + console.assert(false, "The object is already in the pool."); + } + } + else { + } + }; + /** + * @private + */ + BaseObject.toString = function () { + throw new Error(); + }; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @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) { + if (classType in BaseObject._maxCountMap) { + continue; + } + var pool = BaseObject._poolsMap[classType]; + if (pool.length > maxCount) { + pool.length = maxCount; + } + BaseObject._maxCountMap[classType] = maxCount; + } + } + }; + /** + * 清除对象池缓存的对象。 + * @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; + } + } + }; + /** + * 从对象池中创建指定对象。 + * @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; + }; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseObject.prototype.returnToPool = function () { + this._onClear(); + BaseObject._returnObject(this); + }; + BaseObject._hashCode = 0; + BaseObject._defaultMaxCount = 1000; + BaseObject._maxCountMap = {}; + BaseObject._poolsMap = {}; + return BaseObject; + }()); + dragonBones.BaseObject = BaseObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Matrix = (function () { + 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; + } + /** + * @private + */ + 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; + }; + /** + * 转换为单位矩阵。 + * @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; + }; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @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; + }; + /** + * 转换为逆矩阵。 + * @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; + }; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params 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; + } + }; + return Matrix; + }()); + dragonBones.Matrix = Matrix; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Transform = (function () { + function Transform( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Transform.prototype.toMatrix = function (matrix) { + if (this.skew !== 0.0 || this.rotation !== 0.0) { + 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; + } + } + else { + matrix.a = this.scaleX; + matrix.b = 0.0; + matrix.c = 0.0; + matrix.d = this.scaleY; + } + matrix.tx = this.x; + matrix.ty = this.y; + return this; + }; + /** + * @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 = {})); +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 = {})); +var dragonBones; +(function (dragonBones) { + var Point = (function () { + function Point(x, y) { + if (x === void 0) { x = 0.0; } + if (y === void 0) { y = 0.0; } + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function () { + this.x = this.y = 0.0; + }; + return Point; + }()); + dragonBones.Point = Point; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + var Rectangle = (function () { + 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; + } + Rectangle.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function () { + this.x = this.y = 0.0; + this.width = this.height = 0.0; + }; + return Rectangle; + }()); + dragonBones.Rectangle = Rectangle; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 自定义数据。 + * @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; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.ints = []; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.floats = []; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.strings = []; + return _this; + } + /** + * @private + */ + UserData.toString = function () { + return "[class dragonBones.UserData]"; + }; + /** + * @private + */ + UserData.prototype._onClear = function () { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + /** + * 获取自定义整数。 + * @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; + }; + /** + * 获取自定义浮点数。 + * @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; + }; + /** + * 获取自定义字符串。 + * @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 = {})); +var dragonBones; +(function (dragonBones) { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @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; + /** + * @private + */ + _this.frameIndices = []; + /** + * @private + */ + _this.cachedFrames = []; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatureNames = []; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatures = {}; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + DragonBonesData.toString = function () { + return "[class dragonBones.DragonBonesData]"; + }; + /** + * @private + */ + 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.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + //this.armatures.clear(); + this.intArray = null; // + this.floatArray = null; // + this.frameIntArray = null; // + this.frameFloatArray = null; // + this.frameArray = null; // + this.timelineArray = null; // + this.userData = null; + }; + /** + * @private + */ + DragonBonesData.prototype.addArmature = function (value) { + if (value.name in this.armatures) { + console.warn("Replace armature: " + value.name); + this.armatures[value.name].returnToPool(); + } + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + DragonBonesData.prototype.getArmature = function (name) { + return name in this.armatures ? this.armatures[name] : null; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + DragonBonesData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + return DragonBonesData; + }(dragonBones.BaseObject)); + dragonBones.DragonBonesData = DragonBonesData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var CanvasData = (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + /** + * @private + */ + 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; + /** + * 骨架数据。 + * @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(); + /** + * 所有动画数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.bones = {}; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.slots = {}; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.skins = {}; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + /** + * @private + */ + 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.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.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + 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; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @private + */ + 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); + } + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Replace bone: " + value.name); + this.bones[value.name].returnToPool(); + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Replace slot: " + value.name); + this.slots[value.name].returnToPool(); + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Replace skin: " + value.name); + this.skins[value.name].returnToPool(); + } + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + }; + /** + * @private + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Replace animation: " + value.name); + this.animations[value.name].returnToPool(); + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (name) { + return name in this.bones ? this.bones[name] : null; + }; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (name) { + return name in this.slots ? this.slots[name] : null; + }; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (name) { + return name in this.skins ? this.skins[name] : null; + }; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (name) { + return name in this.animations ? this.animations[name] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * 骨骼数据。 + * @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.constraints = []; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + /** + * @private + */ + BoneData.prototype._onClear = function () { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0.0; + this.name = ""; + this.transform.identity(); + this.constraints.length = 0; + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * 插槽数据。 + * @see dragonBones.Slot + * @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; + } + /** + * @private + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + /** + * @private + */ + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + /** + * @private + */ + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @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]"; + }; + /** + * @private + */ + 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(); + }; + /** + * @private + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + 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 = {})); +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.target = null; // + this.bone = null; // + this.root = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @private + */ + 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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @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; + }; + 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.weight = null; // Initial value. + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Mesh */; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + }; + return MeshDisplayData; + }(ImageDisplayData)); + 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 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; + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 边界框数据基类。 + * @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; + } + /** + * @private + */ + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 多边形边界框。 + * @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; + /** + * @private + */ + _this.weight = null; // Initial value. + return _this; + } + /** + * @private + */ + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, offset, count, 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 dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[offset + count - 2]; + var yC = vertices[offset + 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[offset + i]; + var yD = vertices[offset + 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; + }; + /** + * @private + */ + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Polygon */; + this.count = 0; + this.offset = 0; + this.x = 0.0; + this.y = 0.0; + this.vertices = null; // + this.weight = null; + }; + /** + * @inherDoc + */ + 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.count, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[this.offset + iP + 1]; + var yB = this.vertices[this.offset + i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[this.offset + iP]; + var xB = this.vertices[this.offset + i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inherDoc + */ + 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.width, this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, this.offset, this.count, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画数据。 + * @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.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + /** + * @private + */ + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var kA in this.boneTimelines[k]) { + this.boneTimelines[k][kA].returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var kA in this.slotTimelines[k]) { + this.slotTimelines[k][kA].returnToPool(); + } + delete this.slotTimelines[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.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.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @private + */ + 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 (bone, timeline) { + var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (slot, timeline) { + var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (name) { + return name in this.boneTimelines ? this.boneTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimeline = function (name) { + return name in this.slotTimelines ? this.slotTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (name) { + return name in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (name) { + return name in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[name] : 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; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + var AnimationConfig = (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + /** + * @private + */ + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additiveBlending = 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.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.weight = 1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + 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.additiveBlending = value.additiveBlending; + 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]; + } + }; + AnimationConfig.prototype.containsBoneMask = function (name) { + return this.boneMask.length === 0 || this.boneMask.indexOf(name) >= 0; + }; + AnimationConfig.prototype.addBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = armature.getBone(name); + if (currentBone === null) { + return; + } + if (this.boneMask.indexOf(name) < 0) { + this.boneMask.push(name); + } + if (recursive) { + for (var _i = 0, _a = 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); + } + } + } + }; + AnimationConfig.prototype.removeBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this.boneMask.indexOf(name); + if (index >= 0) { + this.boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = armature.getBone(name); + if (currentBone !== null) { + if (this.boneMask.length > 0) { + for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_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 _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 贴图集数据。 + * @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; + } + /** + * @private + */ + 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; + } + }; + /** + * @private + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Replace texture: " + value.name); + this.textures[value.name].returnToPool(); + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (name) { + return name in this.textures ? this.textures[name] : 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 = {})); +var dragonBones; +(function (dragonBones_1) { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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 = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @private + */ + _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._zOrder > b._zOrder ? 1 : -1; + }; + /** + * @private + */ + 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._actions; _d < _e.length; _d++) { + var action = _e[_d]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.clear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null; // + this.userData = null; + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._actions.length = 0; + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + Armature.prototype._sortBones = function () { + var total = this._bones.length; + if (total <= 0) { + return; + } + var sortHelper = this._bones.concat(); + var index = 0; + var count = 0; + this._bones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this._bones.indexOf(bone) >= 0) { + continue; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this._bones.indexOf(bone.parent) < 0) { + continue; + } + this._bones.push(bone); + count++; + } + }; + Armature.prototype._sortSlots = function () { + this._slots.sort(Armature._onSortSlots); + }; + /** + * @internal + * @private + */ + 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 + * @private + */ + Armature.prototype._addBoneToBoneList = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeBoneFromBoneList = function (value) { + var index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._addSlotToSlotList = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeSlotFromSlotList = function (value) { + var index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this.armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @private + */ + 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.init(this); + this._animation.init(this); + this._animation.animations = this.armatureData.animations; + }; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + if (this.armatureData === null) { + console.assert(false, "The armature has been disposed."); + return; + } + else if (this.armatureData.parent === null) { + console.assert(false, "The armature data has been disposed."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update nimation. + this._animation.advanceTime(passedTime); + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + // 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); + } + } + if (this._actions.length > 0) { + this._lockUpdate = true; + for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { + var action = _a[_i]; + if (action.type === 0 /* Play */) { + this._animation.fadeIn(action.name); + } + } + this._actions.length = 0; + this._lockUpdate = false; + } + // + var drawed = this.debugDraw || dragonBones_1.DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + }; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlotDisplay) { + 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 (updateSlotDisplay) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @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; + }; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + }; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @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; + }; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @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; + }; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @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; + }; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @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; + }; + /** + * @deprecated + */ + Armature.prototype.addBone = function (value, parentName) { + if (parentName === void 0) { parentName = null; } + console.assert(value !== null); + value._setArmature(this); + value._setParent(parentName !== null ? this.getBone(parentName) : null); + }; + /** + * @deprecated + */ + Armature.prototype.removeBone = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * @deprecated + */ + Armature.prototype.addSlot = function (value, parentName) { + var bone = this.getBone(parentName); + console.assert(value !== null && bone !== null); + value._setArmature(this); + value._setParent(bone); + }; + /** + * @deprecated + */ + Armature.prototype.removeSlot = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + 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", { + 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", { + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @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", { + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this.armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * 获得动画控制器。 + * @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", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + 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", { + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + Armature.prototype.replaceTexture = function (texture) { + this.replacedTexture = texture; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.hasEventListener = function (type) { + return this._proxy.hasEvent(type); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.addEventListener = function (type, listener, target) { + this._proxy.addEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.removeEventListener = function (type, listener, target) { + this._proxy.removeEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + Armature.prototype.enableAnimationCache = function (frameRate) { + this.cacheFrameRate = frameRate; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础变换对象。 + * @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; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + * @private + */ + TransformObject.prototype._onClear = function () { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; // + this.userData = null; + this._globalDirty = false; + this._armature = null; // + this._parent = null; // + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setArmature = function (value) { + this._armature = value; + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setParent = function (value) { + this._parent = value; + }; + /** + * @private + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransformObject.prototype, "parent", { + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + TransformObject._helpMatrix = new dragonBones.Matrix(); + /** + * @private + */ + TransformObject._helpTransform = new dragonBones.Transform(); + /** + * @private + */ + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @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 + * @private + */ + _this.animationPose = new dragonBones.Transform(); + /** + * @internal + * @private + */ + _this.constraints = []; + _this._bones = []; + _this._slots = []; + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + /** + * @private + */ + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this.constraints.length = 0; + this.boneData = null; // + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1.0; + this._blendLayerWeight = 0.0; + this._bones.length = 0; + this._slots.length = 0; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var inherit = this._parent !== null; + var dR = 0.0; + if (this.offsetMode === 1 /* Additive */) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } + else if (this.offsetMode === 0 /* None */) { + global.copyFrom(this.origin).add(this.animationPose); + } + else { + inherit = false; + global.copyFrom(this.offset); + } + if (inherit) { + var parentMatrix = this._parent.globalTransformMatrix; + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (this.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 (this.boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + if (this._parent.global.scaleX < 0.0) { + dR += Math.PI; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + dR -= global.rotation * 2.0; + if (flipX !== flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + global.rotation += dR; + } + else if (flipX || flipY) { + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + * @private + */ + Bone.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + var oldSlots = null; + var oldBones = null; + if (this._armature !== null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + this._armature = value; // + if (this._armature !== null) { + this._armature._addBoneToBoneList(this); + } + if (oldSlots !== null) { + for (var _i = 0, oldSlots_1 = oldSlots; _i < oldSlots_1.length; _i++) { + var slot = oldSlots_1[_i]; + if (slot.parent === this) { + slot._setArmature(this._armature); + } + } + } + if (oldBones !== null) { + for (var _a = 0, oldBones_1 = oldBones; _a < oldBones_1.length; _a++) { + var bone = oldBones_1[_a]; + if (bone.parent === this) { + bone._setArmature(this._armature); + } + } + } + }; + /** + * @internal + * @private + */ + Bone.prototype.init = function (boneData) { + if (this.boneData !== null) { + return; + } + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + }; + /** + * @internal + * @private + */ + Bone.prototype.update = function (cacheFrameIndex) { + this._blendDirty = false; + 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.constraints.length > 0) { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + 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.constraints.length > 0) { + for (var _b = 0, _c = this.constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + 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 + * @private + */ + 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; + } + }; + /** + * @internal + * @private + */ + Bone.prototype.addConstraint = function (constraint) { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.push(constraint); + } + }; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (child) { + if (child === this) { + return false; + } + var ancestor = child; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getBones = function () { + this._bones.length = 0; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.parent === this) { + this._bones.push(bone); + } + } + return this._bones; + }; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getSlots = function () { + this._slots.length = 0; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + this._slots.push(slot); + } + } + return this._slots; + }; + Object.defineProperty(Bone.prototype, "visible", { + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @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, "length", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + get: function () { + return this.boneData.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + get: function () { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + return slot; + } + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @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; + /** + * @private + */ + _this._localMatrix = new dragonBones.Matrix(); + /** + * @private + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @private + */ + _this._ffdVertices = []; + /** + * @private + */ + _this._displayDatas = []; + /** + * @private + */ + _this._displayList = []; + /** + * @private + */ + _this._meshBones = []; + /** + * @private + */ + _this._rawDisplay = null; // Initial value. + /** + * @private + */ + _this._meshDisplay = null; // Initial value. + return _this; + } + /** + * @private + */ + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { + var eachDisplay = _a[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + 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); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { + this._disposeDisplay(this._meshDisplay); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay); + } + this.displayController = null; + this.slotData = null; // + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.length = 0; + this._displayList.length = 0; + this._displayDatas.length = 0; + this._meshBones.length = 0; + this._rawDisplayDatas = null; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Slot.prototype._updateDisplayData = function () { + var prevDisplayData = this._displayData; + var prevTextureData = this._textureData; + var prevMeshData = this._meshData; + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.length) { + this._displayData = this._displayDatas[this._displayIndex]; + } + else { + this._displayData = null; + } + // Update texture and mesh data. + if (this._displayData !== null) { + if (this._displayData.type === 0 /* Image */ || this._displayData.type === 2 /* Mesh */) { + this._textureData = this._displayData.texture; + if (this._displayData.type === 2 /* Mesh */) { + this._meshData = this._displayData; + } + else if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */) { + this._meshData = rawDisplayData; + } + else { + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + // Update bounding box data. + if (this._displayData !== null && this._displayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = this._displayData.boundingBox; + } + else if (rawDisplayData !== null && rawDisplayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = rawDisplayData.boundingBox; + } + else { + this._boundingBoxData = null; + } + if (this._displayData !== prevDisplayData || this._textureData !== prevTextureData || this._meshData !== prevMeshData) { + // Update pivot offset. + if (this._meshData !== null) { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + else if (this._textureData !== null) { + var imageDisplayData = this._displayData; + var 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 * scale; + var height = rect.height * scale; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width; + this._pivotY *= height; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update mesh bones and ffd vertices. + if (this._meshData !== prevMeshData) { + if (this._meshData !== null) { + if (this._meshData.weight !== null) { + this._ffdVertices.length = this._meshData.weight.count * 2; + this._meshBones.length = this._meshData.weight.bones.length; + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.weight.bones[i].name); + } + } + else { + var vertexCount = this._meshData.parent.parent.intArray[this._meshData.offset + 0 /* MeshVertexCount */]; + this._ffdVertices.length = vertexCount * 2; + this._meshBones.length = 0; + } + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0.0; + } + this._meshDirty = true; + } + else { + this._ffdVertices.length = 0; + this._meshBones.length = 0; + } + } + else if (this._meshData !== null && this._textureData !== prevTextureData) { + this._meshDirty = true; + } + if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData && this._meshData === null) { + 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; + this._displayData.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; + } + // Update original transform. + if (rawDisplayData !== null) { + this.origin = rawDisplayData.transform; + } + else if (this._displayData !== null) { + this.origin = this._displayData.transform; + } + this._displayDirty = true; + this._transformDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + 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._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + // Update frame. + if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { + this._updateFrame(); + } + // 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. + var actions = null; + if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { + actions = this._displayData.actions; + } + else { + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { + actions = rawDisplayData.actions; + } + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + }; + /** + * @private + */ + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._isMeshBonesUpdate = function () { + for (var _i = 0, _a = this._meshBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + * @private + */ + Slot.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + if (this._armature !== null) { + this._armature._removeSlotFromSlotList(this); + } + this._armature = value; // + this._onUpdateDisplay(); + if (this._armature !== null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); + } + }; + /** + * @internal + * @private + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return false; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return false; + } + this._displayIndex = value; + this._displayDirty = true; + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setZorder = function (value) { + if (this._zOrder === value) { + //return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return this._colorDirty; + }; + /** + * @private + */ + Slot.prototype._setDisplayList = function (value) { + if (value !== null && value.length > 0) { + if (this._displayList.length !== value.length) { + this._displayList.length = value.length; + } + for (var i = 0, l = value.length; i < l; ++i) { + var eachDisplay = value[i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { + this._initDisplay(eachDisplay); + } + this._displayList[i] = eachDisplay; + } + } + else if (this._displayList.length > 0) { + this._displayList.length = 0; + } + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display !== this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display !== null; + } + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @private + */ + Slot.prototype.init = function (slotData, displayDatas, rawDisplay, meshDisplay) { + if (this.slotData !== null) { + return; + } + this.slotData = slotData; + this.name = this.slotData.name; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._displayDatas.length = this._rawDisplayDatas.length; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) { + this._displayDatas[i] = this._rawDisplayDatas[i]; + } + }; + /** + * @internal + * @private + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + if (this._transformDirty) { + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + 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._display === null) { + return; + } + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + if (this._meshData !== null && this._display === this._meshDisplay) { + var isSkinned = this._meshData.weight !== null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + return; + } + } + if (this._transformDirty) { + this._transformDirty = false; + 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(false); + } + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + }; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @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); + }; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + }; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDirty = true; + this._transformDirty = true; + }; + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._displayList.concat(); + }, + set: function (value) { + var backupDisplayList = this._displayList.concat(); // Copy. + var disposeDisplayList = new Array(); + if (this._setDisplayList(value)) { + this.update(-1); + } + // Release replaced displays. + for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { + var eachDisplay = backupDisplayList_1[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { + var eachDisplay = disposeDisplayList_2[_a]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + 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", { + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + var displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength === 0) { + this._displayIndex = 0; + } + if (this._displayIndex < 0) { + return; + } + else { + var replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @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 + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + * @internal + */ + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this.target = null; // + this.bone = null; // + this.root = null; // + }; + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @private + * @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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this.target.global; + var global = this.bone.global; + var globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + var ikRadian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadian += Math.PI; + } + global.rotation += (ikRadian - 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 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 ikRadianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + ikRadianA += 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; + if (parent._parent !== null) { + var parentParentMatrix = parent._parent.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; + } + ikRadianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + var parentRadian = rawRadianA + dR; + global.x = parentGlobal.x + Math.cos(parentRadian) * lP; + global.y = parentGlobal.y + Math.sin(parentRadian) * lP; + var ikRadianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadianB += Math.PI; + } + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.update = function () { + if (this.root === null) { + this.bone.updateByConstraint(); + this._computeA(); + } + else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = (function () { + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = -1.0; } + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._animatebles = []; + this._clock = null; + if (time < 0.0) { + this.time = new Date().getTime() * 0.001; + } + else { + this.time = time; + } + } + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + if (passedTime < 0.0) { + passedTime = new Date().getTime() * 0.001 - this.time; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + if (passedTime === 0.0) { + return; + } + 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; + } + }; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + return this._animatebles.indexOf(value) >= 0; + }; + /** + * 添加 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; + } + }; + /** + * 移除 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; + } + }; + /** + * 清除所有的 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 + }); + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.clock = new WorldClock(); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @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._animationConfig = null; // Initial value. + return _this; + } + /** + * @private + */ + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + /** + * @private + */ + 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]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._timelineDirty = false; + 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.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.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.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]; + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 0 /* None */: + case 5 /* Single */: + default: + break; + } + }; + /** + * @internal + * @private + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + * @private + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { + passedTime *= this._armature._parent._armature.animation.timeScale; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + 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]; + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + this._timelineDirty = false; + }; + /** + * 清除所有动画状态。 + * @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._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * 暂停播放动画。 + * @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(); + } + } + }; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @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.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 > 1) { + 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) { + } + else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + // Child armature play same name animation. + 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); // + } + } + if (animationConfig.fadeInTime <= 0.0) { + this._armature.advanceTime(0.0); + } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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.duration * frame / animationData.frameCount; + } + return this.playConfig(this._animationConfig); + }; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName) { + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName) { + return animationState; + } + } + return null; + }; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * 动画是否处于播放状态。 + * @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", { + /** + * 所有动画状态是否均已播放完毕。 + * @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", { + /** + * 上一个正在播放的动画状态名称。 + * @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", { + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @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._animations[k] = value[k]; + this._animationNames.push(k); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * 一个可以快速使用的动画配置实例。 + * @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", { + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (duration === void 0) { duration = -1; } + 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 */; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + var animationData = this._animations[animationName]; + if (animationData && duration > 0.0) { + this._animationConfig.timeScale = animationData.duration / duration; + } + return this.playConfig(this._animationConfig); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + Animation.prototype.gotoAndStop = function (animationName, time) { + if (time === void 0) { time = 0; } + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); + } + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var BonePose = (function (_super) { + __extends(BonePose, _super); + function BonePose() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.current = new dragonBones.Transform(); + _this.delta = new dragonBones.Transform(); + _this.result = new dragonBones.Transform(); + return _this; + } + BonePose.toString = function () { + return "[class dragonBones.BonePose]"; + }; + BonePose.prototype._onClear = function () { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return BonePose; + }(dragonBones.BaseObject)); + dragonBones.BonePose = BonePose; + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @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._slotTimelines = []; + _this._bonePoses = {}; + /** + * @internal + * @private + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + /** + * @private + */ + 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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1.0; + this.weight = 1.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this.animationData = null; // + this._timelineDirty = true; + 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._slotTimelines.length = 0; + // this._bonePoses.clear(); + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + }; + AnimationState.prototype._isDisabled = function (slot) { + if (this.displayControl) { + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + return false; + } + } + return true; + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasEvent(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 eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + }; + AnimationState.prototype._blendBoneTimline = function (timeline) { + var bone = timeline.bone; + var bonePose = timeline.bonePose.result; + var animationPose = bone.animationPose; + var boneWeight = this._weightResult > 0.0 ? this._weightResult : -this._weightResult; + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1.0; + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1.0) * boneWeight + 1.0; + animationPose.scaleY = (bonePose.scaleY - 1.0) * boneWeight + 1.0; + } + else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1.0) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1.0) * boneWeight; + } + if (this._fadeState !== 0 || this._subFadeState !== 0) { + bone._transformDirty = true; + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + 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); + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.updateTimelines = function () { + var boneTimelines = {}; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.bone.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + var timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (timelineName in boneTimelines) { + delete boneTimelines[timelineName]; + } + else { + var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); + if (timelineDatas !== null) { + for (var _d = 0, timelineDatas_1 = timelineDatas; _d < timelineDatas_1.length; _d++) { + var timelineData = timelineDatas_1[_d]; + switch (timelineData.type) { + case 10 /* BoneAll */: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + case 11 /* BoneT */: + case 12 /* BoneR */: + case 13 /* BoneS */: + // TODO + break; + case 14 /* BoneX */: + case 15 /* BoneY */: + case 16 /* BoneRotate */: + case 17 /* BoneSkew */: + case 18 /* BoneScaleX */: + case 19 /* BoneScaleY */: + // TODO + break; + } + } + } + else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + for (var k in boneTimelines) { + for (var _e = 0, _f = boneTimelines[k]; _e < _f.length; _e++) { + var timeline = _f[_e]; + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + var slotTimelines = {}; + var ffdFlags = []; + for (var _g = 0, _h = this._slotTimelines; _g < _h.length; _g++) { + var timeline = _h[_g]; + var timelineName = timeline.slot.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _j = 0, _k = this._armature.getSlots(); _j < _k.length; _j++) { + var slot = _k[_j]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + var timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (timelineName in slotTimelines) { + delete slotTimelines[timelineName]; + } + else { + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + if (timelineDatas !== null) { + for (var _l = 0, timelineDatas_2 = timelineDatas; _l < timelineDatas_2.length; _l++) { + var timelineData = timelineDatas_2[_l]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 21 /* SlotColor */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotFFD */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + if (this.resetToPose) { + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + for (var _m = 0, _o = slot._rawDisplayDatas; _m < _o.length; _m++) { + var displayData = _o[_m]; + if (displayData !== null && displayData.type === 2 /* Mesh */ && ffdFlags.indexOf(displayData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { + for (var _p = 0, _q = slotTimelines[k]; _p < _q.length; _p++) { + var timeline = _q[_p]; + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + }; + /** + * @private + * @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; + } + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + if (this.weight === 0.0) { + return; + } + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this.weight * this._fadeProgress; + this._actionTimeline.update(time); // Update main timeline. + if (isCacheEnabled) { + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null) { + 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) { + if (isUpdateBoneTimeline) { + var bone = null; + var prevTimeline = null; // + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (bone !== timeline.bone) { + if (bone !== null) { + this._blendBoneTimline(prevTimeline); + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0.0) { + if (bone._blendLayer !== this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0.0; + bone = null; + } + else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0.0; + } + } + } + else { + bone = null; + } + } + } + bone = timeline.bone; + } + if (bone !== null) { + timeline.update(time); + if (i === l - 1) { + this._blendBoneTimline(timeline); + } + else { + prevTimeline = timeline; + } + } + } + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (this._isDisabled(timeline.slot)) { + continue; + } + timeline.update(time); + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * 淡出动画。 + * @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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (name) { + return this._boneMask.length === 0 || this._boneMask.indexOf(name) >= 0; + }; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(name); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(name) < 0) { + this._boneMask.push(name); + } + 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 = true; + }; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(name); + if (index >= 0) { + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(name); + 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_2 = this._boneMask.indexOf(bone.name); + if (index_2 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_2, 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 = true; + }; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = true; + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * 是否正在播放。 + * @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", { + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * 当前播放的时间。 (以秒为单位) + * @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) { + 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, "clip", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + get: function () { + return this.animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var TimelineState = (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this._tweenState = 0 /* None */; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 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._dragonBonesData = null; // + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._frameIntArray = null; // + this._frameFloatArray = 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._duration; + } + } + 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._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + if (this._timelineData !== null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._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 () { }; + TimelineState.prototype.update = function (passedTime) { + if (this.playState <= 0 && 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._tweenState !== 0 /* None */) { + this._onUpdateFrame(); + } + } + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + * @private + */ + 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 segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : 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._tweenProgress = 0.0; + this._tweenEasing = 0.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 */]; // TODO recode ture tween type. + this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; + 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; + } + 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]; + this._frameDurationR = 1.0 / (this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition); + } + } + else { + this._tweenState = 1 /* Once */; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._tweenState === 2 /* Always */) { + 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); + } + } + else { + this._tweenProgress = 0.0; + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + * @private + */ + var BoneTimelineState = (function (_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.bone = null; // + this.bonePose = null; // + }; + return BoneTimelineState; + }(TweenTimelineState)); + dragonBones.BoneTimelineState = BoneTimelineState; + /** + * @internal + * @private + */ + var SlotTimelineState = (function (_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.slot = null; // + }; + return SlotTimelineState; + }(TweenTimelineState)); + dragonBones.SlotTimelineState = SlotTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + 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._armature.armatureData.actions; + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + if (action.slot !== null) { + var slot = this._armature.getSlot(action.slot.name); + if (slot !== null) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature._bufferAction(action, true); + } + } + } + else if (action.bone !== null) { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null && slot.parent.boneData === action.bone) { + childArmature._bufferAction(action, true); + } + } + } + else { + this._armature._bufferAction(action, true); + } + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasEvent(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.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + if (action.bone !== null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + if (action.slot !== null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + 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.playState <= 0 && this._setCurrentTime(passedTime)) { + 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 (eventDispatcher.hasEvent(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 (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasEvent(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.hasEvent(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 + * @private + */ + 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 + * @private + */ + 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._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + current.x = frameFloatArray[valueOffset++]; + current.y = frameFloatArray[valueOffset++]; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + delta.x = frameFloatArray[valueOffset++] - current.x; + delta.y = frameFloatArray[valueOffset++] - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } + // else { + // delta.x = 0.0; + // delta.y = 0.0; + // delta.rotation = 0.0; + // delta.skew = 0.0; + // delta.scaleX = 0.0; + // delta.scaleY = 0.0; + // } + } + else { + var current = this.bonePose.current; + current.x = 0.0; + current.y = 0.0; + current.rotation = 0.0; + current.skew = 0.0; + current.scaleX = 1.0; + current.scaleY = 1.0; + } + }; + BoneAllTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + var scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneAllTimelineState; + }(dragonBones.BoneTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + * @private + */ + var SlotDislayIndexTimelineState = (function (_super) { + __extends(SlotDislayIndexTimelineState, _super); + function SlotDislayIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDislayIndexTimelineState.toString = function () { + return "[class dragonBones.SlotDislayIndexTimelineState]"; + }; + SlotDislayIndexTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot.slotData.displayIndex; + if (this.slot.displayIndex !== displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + }; + return SlotDislayIndexTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotDislayIndexTimelineState = SlotDislayIndexTimelineState; + /** + * @internal + * @private + */ + 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._delta = [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._onClear = function () { + _super.prototype._onClear.call(this); + this._dirty = false; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var intArray = this._dragonBonesData.intArray; + var frameIntArray = this._dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + var colorOffset = frameIntArray[valueOffset]; + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1 * 1]; + } + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } + else { + var color = this.slot.slotData.color; + this._current[0] = color.alphaMultiplier * 100.0; + this._current[1] = color.redMultiplier * 100.0; + this._current[2] = color.greenMultiplier * 100.0; + this._current[3] = color.blueMultiplier * 100.0; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.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; + this.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]; + this.slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + * @private + */ + var SlotFFDTimelineState = (function (_super) { + __extends(SlotFFDTimelineState, _super); + function SlotFFDTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + SlotFFDTimelineState.toString = function () { + return "[class dragonBones.SlotFFDTimelineState]"; + }; + SlotFFDTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.meshOffset = 0; + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + SlotFFDTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var isTween = this._tweenState === 2 /* Always */; + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + if (isTween) { + var nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex === this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = frameFloatArray[nextValueOffset + i] - (this._current[i] = frameFloatArray[valueOffset + i]); + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = frameFloatArray[valueOffset + i]; + } + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = 0.0; + } + } + }; + SlotFFDTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + for (var i = 0; i < this._valueCount; ++i) { + this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + } + }; + SlotFFDTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntArray = this._dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this.meshOffset = frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */]; + this._ffdCount = frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */]; + this._valueOffset = frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */]; + this._frameFloatOffset = frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] + this._animationData.frameFloatOffset; + } + else { + this._valueCount = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = 0.0; + } + }; + SlotFFDTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotFFDTimelineState.prototype.update = function (passedTime) { + if (this.slot._meshData === null || (this._timelineData !== null && this.slot._meshData.offset !== this.meshOffset)) { + return; + } + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.slot._ffdVertices; + if (this._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] += (frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; + } + else { + result[i] += (frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + } + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] = frameFloatArray[this._frameFloatOffset + i]; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] = this._result[i - this._valueOffset]; + } + else { + result[i] = frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + } + } + this.slot._meshDirty = true; + } + } + else { + this._ffdCount = result.length; // + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + result[i] += (0.0 - result[i]) * fadeProgress; + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + result[i] = 0.0; + } + this.slot._meshDirty = true; + } + } + } + }; + return SlotFFDTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotFFDTimelineState = SlotFFDTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + /** + * @private + */ + 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.data = null; + }; + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(dragonBones || (dragonBones = {})); +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._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 */; + 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._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._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 */; + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + DataParser.parseDragonBonesData = function (rawData) { + if (rawData instanceof ArrayBuffer) { + return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); + } + else { + return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + DataParser.parseTextureAtlasData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.warn("已废弃,请参考 @see"); + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + } + return textureAtlasData; + }; + 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 = DataParser.DATA_VERSION_5_0; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + ]; + 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.BONE = "bone"; + DataParser.IK = "ik"; + DataParser.SLOT = "slot"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.Z_ORDER = "zOrder"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.VISIBLE_FRAME = "visibleFrame"; + 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.CANVAS = "canvas"; + 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.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + 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_FFD = "inheritFFD"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_TYPE = "tweenType"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + 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_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.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var ObjectDataParser = (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + /** + * @private + */ + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._intArrayJson = []; + _this._floatArrayJson = []; + _this._frameIntArrayJson = []; + _this._frameFloatArrayJson = []; + _this._frameArrayJson = []; + _this._timelineArrayJson = []; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._defalultColorOffset = -1; + _this._prevTweenRotate = 0; + _this._prevRotation = 0.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._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._weightBoneIndices = {}; + _this._cacheBones = {}; + _this._meshs = {}; + _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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + if (dragonBones.DragonBones.webAssembly) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + } + return value; + } + return String(value); + } + return defaultValue; + }; + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); + 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; + } + }; + ObjectDataParser.prototype._sortActionFrame = function (a, b) { + return a.frameStart > b.frameStart ? 1 : -1; + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (ObjectDataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (ObjectDataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (ObjectDataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + var frame = null; + if (this._actionFrames.length === 0) { + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _i = 0, _a = this._actionFrames; _i < _a.length; _i++) { + var eachFrame = _a[_i]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + } + if (frame === null) { + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.push(frame); + } + for (var i = 0; i < actionCount; ++i) { + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseCacheActionFrame = function (frame) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = frameArray.length; + var actionCount = frame.actions.length; + frameArray.length += 1 + 1 + actionCount; + frameArray[frameOffset + 0 /* FramePosition */] = frame.frameStart; + frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { + frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + // const armature = BaseObject.borrowObject(ArmatureData); + var armature = dragonBones.DragonBones.webAssembly ? new Module["ArmatureData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { + armature.frameRate = 24; + } + this._armature = armature; + if (ObjectDataParser.AABB in rawData) { + var rawAABB = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.X, 0.0); + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.Y, 0.0); + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.WIDTH, 0.0); + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.HEIGHT, 0.0); + } + if (ObjectDataParser.CANVAS in rawData) { + var rawCanvas = rawData[ObjectDataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (ObjectDataParser.COLOR in rawCanvas) { + ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.X, 0); + canvas.y = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.HEIGHT, 0); + armature.canvas = canvas; + } + if (ObjectDataParser.BONE in rawData) { + var rawBones = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, ObjectDataParser.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 { + (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); // Raw bone sort. + } + } + if (ObjectDataParser.IK in rawData) { + var rawIKS = rawData[ObjectDataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + this._parseIKConstraint(rawIK); + } + } + armature.sortBones(); + if (ObjectDataParser.SLOT in rawData) { + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot)); + } + } + if (ObjectDataParser.SKIN in rawData) { + var rawSkins = rawData[ObjectDataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (ObjectDataParser.ANIMATION in rawData) { + var rawAnimations = rawData[ObjectDataParser.ANIMATION]; + for (var _f = 0, rawAnimations_1 = rawAnimations; _f < rawAnimations_1.length; _f++) { + var rawAnimation = rawAnimations_1[_f]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (ObjectDataParser.DEFAULT_ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.DEFAULT_ACTIONS], armature.defaultActions, 0 /* Play */, null, null); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armature.actions, 0 /* Play */, null, null); + } + // for (const action of armature.defaultActions) { // Set default animation from default action. + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? armature.defaultActions.size() : armature.defaultActions.length); ++i) { + var action = dragonBones.DragonBones.webAssembly ? armature.defaultActions.get(i) : armature.defaultActions[i]; + if (action.type === 0 /* Play */) { + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + break; + } + } + // Clear helper. + this._rawBones.length = 0; + this._armature = null; + for (var k in this._meshs) { + delete this._meshs[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + 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._weightBoneIndices) { + delete this._weightBoneIndices[k]; + } + return armature; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBone = function (rawData) { + // const bone = BaseObject.borrowObject(BoneData); + var bone = dragonBones.DragonBones.webAssembly ? new Module["BoneData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform, this._armature.scale); + } + return bone; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, "")); + if (target === null) { + return; + } + // const constraint = BaseObject.borrowObject(IKConstraintData); + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraintData"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, ObjectDataParser.SCALE, false); + constraint.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1.0); + constraint.bone = bone; + constraint.target = target; + var chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + if (dragonBones.DragonBones.webAssembly) { + bone.constraints.push_back(constraint); + } + else { + bone.constraints.push(constraint); + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlot = function (rawData) { + // const slot = BaseObject.borrowObject(SlotData); + var slot = dragonBones.DragonBones.webAssembly ? new Module["SlotData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = dragonBones.DragonBones.webAssembly ? this._armature.sortedSlots.size() : this._armature.sortedSlots.length; + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, "")); // + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] === "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); + } + if (ObjectDataParser.COLOR in rawData) { + // slot.color = SlotData.createColor(); + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].createColor() : dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].DEFAULT_COLOR : dragonBones.SlotData.DEFAULT_COLOR; + } + if (ObjectDataParser.ACTIONS in rawData) { + var actions = this._slotChildActions[slot.name] = []; + this._parseActionData(rawData[ObjectDataParser.ACTIONS], actions, 0 /* Play */, null, null); + } + return slot; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSkin = function (rawData) { + // const skin = BaseObject.borrowObject(SkinData); + var skin = dragonBones.DragonBones.webAssembly ? new Module["SkinData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (ObjectDataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[ObjectDataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var display = null; + var name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, ObjectDataParser.PATH, ""); + var type = 0 /* Image */; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: + // const imageDisplay = display = BaseObject.borrowObject(ImageDisplayData); + var imageDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ImageDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + case 1 /* Armature */: + // const armatureDisplay = display = BaseObject.borrowObject(ArmatureDisplayData); + var armatureDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ArmatureDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armatureDisplay.actions, 0 /* Play */, null, null); + } + 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 _i = 0, _a = this._slotChildActions[this._slot.name]; _i < _a.length; _i++) { + var action = _a[_i]; + if (dragonBones.DragonBones.webAssembly) { + armatureDisplay.actions.push_back(action); + } + else { + armatureDisplay.actions.push(action); + } + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + case 2 /* Mesh */: + // const meshDisplay = display = BaseObject.borrowObject(MeshDisplayData); + var meshDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["MeshDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.inheritAnimation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + var shareName = ObjectDataParser._getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length > 0) { + var shareMesh = this._meshs[shareName]; + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } + else { + this._parseMesh(rawData, meshDisplay); + this._meshs[meshDisplay.name] = meshDisplay; + } + break; + case 3 /* BoundingBox */: + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + // const boundingBoxDisplay = display = BaseObject.borrowObject(BoundingBoxDisplayData); + var boundingBoxDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["BoundingBoxDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + if (display !== null) { + display.parent = this._armature; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform, this._armature.scale); + } + } + return display; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (ObjectDataParser.PIVOT in rawData) { + var rawPivot = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var rawUVs = rawData[ObjectDataParser.UVS]; + var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = Math.floor(rawTriangles.length / 3); // uint + var vertexOffset = floatArray.length; + var uvOffset = vertexOffset + vertexCount * 2; + mesh.offset = intArray.length; + intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; + intArray[mesh.offset + 0 /* MeshVertexCount */] = vertexCount; + intArray[mesh.offset + 1 /* MeshTriangleCount */] = triangleCount; + intArray[mesh.offset + 2 /* MeshFloatOffset */] = vertexOffset; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + intArray[mesh.offset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; + } + floatArray.length += vertexCount * 2 + vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray[vertexOffset + i] = rawVertices[i]; + floatArray[uvOffset + i] = rawUVs[i]; + } + if (ObjectDataParser.WEIGHTS in rawData) { + var rawWeights = rawData[ObjectDataParser.WEIGHTS]; + var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; + var rawBonePoses = rawData[ObjectDataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + var floatOffset = floatArray.length; + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = (rawWeights.length - vertexCount) / 2; + weight.offset = intArray.length; + weight.bones.length = weightBoneCount; + weightBoneIndices.length = weightBoneCount; + intArray.length += 1 + 1 + weightBoneCount + vertexCount + weight.count; + intArray[weight.offset + 1 /* WeigthFloatOffset */] = floatOffset; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.bones[i] = bone; + weightBoneIndices[i] = rawBoneIndex; + if (dragonBones.DragonBones.webAssembly) { + for (var j = 0; j < this._armature.sortedBones.size(); j++) { + if (this._armature.sortedBones.get(j) === bone) { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = j; + } + } + } + else { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = this._armature.sortedBones.indexOf(bone); + } + } + floatArray.length += weight.count * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = intArray[iB++] = rawWeights[iW++]; // uint + var x = floatArray[vertexOffset + iD]; + var y = floatArray[vertexOffset + 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 bone = this._rawBones[rawBoneIndex]; + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray[iB++] = weight.bones.indexOf(bone); + floatArray[iV++] = rawWeights[iW++]; + floatArray[iV++] = this._helpPoint.x; + floatArray[iV++] = this._helpPoint.y; + } + } + mesh.weight = weight; + // + this._weightSlotPose[mesh.name] = rawSlotPose; + this._weightBonePoses[mesh.name] = rawBonePoses; + this._weightBoneIndices[mesh.name] = weightBoneIndices; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (ObjectDataParser.SUB_TYPE in rawData && typeof rawData[ObjectDataParser.SUB_TYPE] === "string") { + type = ObjectDataParser._getBoundingBoxType(rawData[ObjectDataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["RectangleBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["EllipseBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, ObjectDataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = floatArray.length; + polygonBoundingBox.count = rawVertices.length; + polygonBoundingBox.vertices = floatArray; + floatArray.length += polygonBoundingBox.count; + for (var i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + var iN = i + 1; + var x = rawVertices[i]; + var y = rawVertices[iN]; + floatArray[polygonBoundingBox.offset + i] = x; + floatArray[polygonBoundingBox.offset + iN] = 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; + } + } + } + return polygonBoundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + if (dragonBones.DragonBones.webAssembly) { + animation.frameIntOffset = this._frameIntArrayJson.length; + animation.frameFloatOffset = this._frameFloatArrayJson.length; + animation.frameOffset = this._frameArrayJson.length; + } + else { + animation.frameIntOffset = this._data.frameIntArray.length; + animation.frameFloatOffset = this._data.frameFloatArray.length; + animation.frameOffset = this._data.frameArray.length; + } + this._animation = animation; + if (ObjectDataParser.FRAME in rawData) { + var rawFrames = rawData[ObjectDataParser.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, ObjectDataParser.DURATION, 1); + } + } + } + if (ObjectDataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[ObjectDataParser.Z_ORDER], 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); + } + if (ObjectDataParser.BONE in rawData) { + var rawTimelines = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (ObjectDataParser.SLOT in rawData) { + var rawTimelines = rawData[ObjectDataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (ObjectDataParser.FFD in rawData) { + var rawTimelines = rawData[ObjectDataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var slotName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot === null) { + continue; + } + this._slot = slot; + this._mesh = this._meshs[displayName]; + var timelineFFD = this._parseTimeline(rawTimeline, 22 /* SlotFFD */, false, true, 0, this._parseSlotFFDFrame); + if (timelineFFD !== null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + this._slot = null; // + this._mesh = null; // + } + } + if (this._actionFrames.length > 0) { + this._actionFrames.sort(this._sortActionFrame); + // const timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData); + var timeline = this._animation.actionTimeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var keyFrameCount = this._actionFrames.length; + timeline.type = 0 /* Action */; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = 100; + timelineArray[timeline.offset + 1 /* TimelineOffset */] = 0; + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = 0; + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = this._parseCacheActionFrame(this._actionFrames[0]) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + //(frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var frame = this._actionFrames[iK]; + frameStart = frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = this._parseCacheActionFrame(frame) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + this._actionFrames.length = 0; + } + this._animation = null; // + return animation; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTimeline = function (rawData, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { + if (!(ObjectDataParser.FRAME in rawData)) { + return null; + } + var rawFrames = rawData[ObjectDataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntArrayLength = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson.length : this._data.frameIntArray.length; + var frameFloatArrayLength = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson.length : this._data.frameFloatArray.length; + // const timeline = BaseObject.borrowObject(TimelineData); + var timeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0) * 100); + timelineArray[timeline.offset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0.0) * 100); + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = frameValueCount; + if (addIntOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + } + else if (addFloatOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + } + else { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + } + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var frameIndices = this._data.frameIndices; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // frameIndices.resize( frameIndices.size() + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + 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; + frameCount = ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + var timeline = this._parseTimeline(rawData, 10 /* BoneAll */, false, true, 6, this._parseBoneFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone, timeline); + } + this._bone = null; // + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (slot === null) { + return; + } + this._slot = slot; + var displayIndexTimeline = this._parseTimeline(rawData, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayIndexFrame); + if (displayIndexTimeline !== null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + var colorTimeline = this._parseTimeline(rawData, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount, frameArray) { + rawData; + frameCount; + var frameOffset = frameArray.length; + frameArray.length += 1; + frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount, frameArray) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (frameCount > 0) { + if (ObjectDataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[ObjectDataParser.CURVE], this._helpArray); + frameArray.length += 1 + 1 + this._helpArray.length; + frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; + for (var i = 0; i < sampleCount; ++i) { + frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (ObjectDataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (ObjectDataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[ObjectDataParser.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 < slotCount; ++i_1) { + zOrders[i_1] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_2 = 0, l = rawZOrder.length; i_2 < l; i_2 += 2) { + var slotIndex = rawZOrder[i_2]; + var zOrderOffset = rawZOrder[i_2 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + zOrders[originalIndex + zOrderOffset] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + frameArray.length += 1 + slotCount; + frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex]; + } + else { + frameArray[frameOffset + 2 + i] = zOrders[i]; + } + } + return frameOffset; + } + } + frameArray.length += 1; + frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneFrame = function (rawData, frameStart, frameCount) { + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + this._helpTransform.identity(); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevTweenRotate === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevTweenRotate; + } + } + this._prevTweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + var frameFloatOffset = frameFloatArray.length; + frameFloatArray.length += 6; + frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + frameFloatArray[frameFloatOffset++] = rotation; + frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotDisplayIndexFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + frameArray.length += 1; + frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var colorOffset = -1; + if (ObjectDataParser.COLOR in rawData) { + var rawColor = rawData[ObjectDataParser.COLOR]; + for (var k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + } + colorOffset = this._defalultColorOffset; + } + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1; + frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameFloatOffset = frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var rawVertices = ObjectDataParser.VERTICES in rawData ? rawData[ObjectDataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); // uint + var vertexCount = intArray[this._mesh.offset + 0 /* MeshVertexCount */]; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (this._mesh.weight !== null) { + var rawSlotPose = this._weightSlotPose[this._mesh.name]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.length += this._mesh.weight.count * 2; + iB = this._mesh.weight.offset + 2 /* WeigthBoneIndices */ + this._mesh.weight.bones.length; + } + else { + 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 (this._mesh.weight !== null) { + var rawBonePoses = this._weightBonePoses[this._mesh.name]; + var weightBoneIndices = this._weightBoneIndices[this._mesh.name]; + var vertexBoneCount = 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 = intArray[iB++]; + var bone = this._mesh.weight.bones[boneIndex]; + var rawBoneIndex = this._rawBones.indexOf(bone); + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + frameFloatArray[frameFloatOffset + i] = x; + frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1 + 1 + 1 + 1 + 1; + frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */] = this._mesh.offset; + frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */] = 0; + frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] = frameFloatOffset; + timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseActionData = function (rawData, actions, type, bone, slot) { + var actionCount = 0; + if (typeof rawData === "string") { + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_1 = rawData; _i < rawData_1.length; _i++) { + var rawAction = rawData_1[_i]; + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (ObjectDataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } + else { + if (ObjectDataParser.TYPE in rawAction && typeof rawAction[ObjectDataParser.TYPE] === "string") { + action.type = ObjectDataParser._getActionType(rawAction[ObjectDataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, ObjectDataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.NAME, ""); + } + if (ObjectDataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (ObjectDataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + if (ObjectDataParser.INTS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[ObjectDataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + dragonBones.DragonBones.webAssembly ? action.data.ints.push_back(rawValue) : action.data.ints.push(rawValue); + } + } + if (ObjectDataParser.FLOATS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[ObjectDataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + dragonBones.DragonBones.webAssembly ? action.data.floats.push_back(rawValue) : action.data.floats.push(rawValue); + } + } + if (ObjectDataParser.STRINGS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[ObjectDataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + dragonBones.DragonBones.webAssembly ? action.data.strings.push_back(rawValue) : action.data.strings.push(rawValue); + } + } + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + } + return actionCount; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0.0) * scale; + if (ObjectDataParser.ROTATE in rawData || ObjectDataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (ObjectDataParser.SKEW_X in rawData || ObjectDataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1.0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArray = function (rawData) { + rawData; + if (dragonBones.DragonBones.webAssembly) { + return; + } + this._data.intArray = []; + this._data.floatArray = []; + this._data.frameIntArray = []; + this._data.frameFloatArray = []; + this._data.frameArray = []; + this._data.timelineArray = []; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseWASMArray = function () { + var intArrayBuf = Module._malloc(this._intArrayJson.length * 2); + this._intArrayBuffer = new Int16Array(Module.HEAP16.buffer, intArrayBuf, this._intArrayJson.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + for (var i1 = 0; i1 < this._intArrayJson.length; ++i1) { + this._intArrayBuffer[i1] = this._intArrayJson[i1]; + } + var floatArrayBuf = Module._malloc(this._floatArrayJson.length * 4); + // Module.HEAPF32.set(this._floatArrayJson, floatArrayBuf); + this._floatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, this._floatArrayJson.length); + for (var i2 = 0; i2 < this._floatArrayJson.length; ++i2) { + this._floatArrayBuffer[i2] = this._floatArrayJson[i2]; + } + var frameIntArrayBuf = Module._malloc(this._frameIntArrayJson.length * 2); + // Module.HEAP16.set(this._frameIntArrayJson, frameIntArrayBuf); + this._frameIntArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, this._frameIntArrayJson.length); + for (var i3 = 0; i3 < this._frameIntArrayJson.length; ++i3) { + this._frameIntArrayBuffer[i3] = this._frameIntArrayJson[i3]; + } + var frameFloatArrayBuf = Module._malloc(this._frameFloatArrayJson.length * 4); + // Module.HEAPF32.set(this._frameFloatArrayJson, frameFloatArrayBuf); + this._frameFloatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, this._frameFloatArrayJson.length); + for (var i4 = 0; i4 < this._frameFloatArrayJson.length; ++i4) { + this._frameFloatArrayBuffer[i4] = this._frameFloatArrayJson[i4]; + } + var frameArrayBuf = Module._malloc(this._frameArrayJson.length * 2); + // Module.HEAP16.set(this._frameArrayJson, frameArrayBuf); + this._frameArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, this._frameArrayJson.length); + for (var i5 = 0; i5 < this._frameArrayJson.length; ++i5) { + this._frameArrayBuffer[i5] = this._frameArrayJson[i5]; + } + var timelineArrayBuf = Module._malloc(this._timelineArrayJson.length * 2); + // Module.HEAPU16.set(this._timelineArrayJson, timelineArrayBuf); + this._timelineArrayBuffer = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, this._timelineArrayJson.length); + for (var i6 = 0; i6 < this._timelineArrayJson.length; ++i6) { + this._timelineArrayBuffer[i6] = this._timelineArrayJson[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined); + var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + if (ObjectDataParser.DATA_VERSIONS.indexOf(version) >= 0 || + ObjectDataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + // const data = BaseObject.borrowObject(DragonBonesData); + var data = dragonBones.DragonBones.webAssembly ? new Module["DragonBonesData"]() : dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { + data.frameRate = 24; + } + if (ObjectDataParser.ARMATURE in rawData) { + this._defalultColorOffset = -1; + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[ObjectDataParser.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._intArrayJson.length > 0) { + this._parseWASMArray(); + } + this._data = null; + } + this._rawTextureAtlasIndex = 0; + if (ObjectDataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[ObjectDataParser.TEXTURE_ATLAS]; + } + else { + this._rawTextureAtlases = null; + } + return data; + } + else { + console.assert(false, "Nonsupport data version."); + } + return null; + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 0.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null) { + 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, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + if (scale > 0.0) { + textureAtlasData.scale = scale; + } + else { + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + scale = 1.0 / scale; // + if (ObjectDataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[ObjectDataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.X, 0.0) * scale; + textureData.region.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.Y, 0.0) * scale; + textureData.region.width = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.WIDTH, 0.0) * scale; + textureData.region.height = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.HEIGHT, 0.0) * scale; + var frameWidth = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.DragonBones.webAssembly ? Module["TextureData"].createRectangle() : dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_X, 0.0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_Y, 0.0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + /** + * @private + */ + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + var ActionFrame = (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); +})(dragonBones || (dragonBones = {})); +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._getUTF16Key = function (value) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + return value; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + // const timeline = timelineData !== null ? timelineData : BaseObject.borrowObject(TimelineData); + var timeline = timelineData !== null ? timelineData : (dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData)); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // (frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { + mesh.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + var weightOffset = this._intArray[mesh.offset + 3 /* MeshWeightOffset */]; + if (weightOffset >= 0) { + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArray[mesh.offset + 0 /* MeshVertexCount */]; + var boneCount = this._intArray[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + if (dragonBones.DragonBones.webAssembly) { + weight.bones.resize(boneCount, null); + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones.set(i, this._rawBones[boneIndex]); + } + } + else { + weight.bones.length = boneCount; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones[i] = this._rawBones[boneIndex]; + } + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArray[boneIndicesOffset++]; + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + mesh.weight = weight; + } + }; + /** + * @private + */ + BinaryDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + polygonBoundingBox.vertices = this._floatArray; + return polygonBoundingBox; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.DURATION, 1), 1); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.ObjectDataParser.NAME, dragonBones.ObjectDataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.ObjectDataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.ObjectDataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.ObjectDataParser.ACTION]); + } + if (dragonBones.ObjectDataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.ObjectDataParser.Z_ORDER]); + } + if (dragonBones.ObjectDataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + if (dragonBones.ObjectDataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + this._animation = null; + return animation; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + if (dragonBones.DragonBones.webAssembly) { + var tmpIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + var tmpFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + var tmpFrameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + var tmpTimelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + var intArrayBuf = Module._malloc(tmpIntArray.length * tmpIntArray.BYTES_PER_ELEMENT); + var floatArrayBuf = Module._malloc(tmpFloatArray.length * tmpFloatArray.BYTES_PER_ELEMENT); + var frameIntArrayBuf = Module._malloc(tmpFrameIntArray.length * tmpFrameIntArray.BYTES_PER_ELEMENT); + var frameFloatArrayBuf = Module._malloc(tmpFrameFloatArray.length * tmpFrameFloatArray.BYTES_PER_ELEMENT); + var frameArrayBuf = Module._malloc(tmpFrameArray.length * tmpFrameArray.BYTES_PER_ELEMENT); + var timelineArrayBuf = Module._malloc(tmpTimelineArray.length * tmpTimelineArray.BYTES_PER_ELEMENT); + this._intArray = new Int16Array(Module.HEAP16.buffer, intArrayBuf, tmpIntArray.length); + this._floatArray = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, tmpFloatArray.length); + this._frameIntArray = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, tmpFrameIntArray.length); + this._frameFloatArray = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, tmpFrameFloatArray.length); + this._frameArray = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, tmpFrameArray.length); + this._timelineArray = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, tmpTimelineArray.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + // Module.HEAPF32.set(tmpFloatArray, floatArrayBuf); + // Module.HEAP16.set(tmpFrameIntArray, frameIntArrayBuf); + // Module.HEAPF32.set(tmpFrameFloatArray, frameFloatArrayBuf); + // Module.HEAP16.set(tmpFrameArray, frameArrayBuf); + // Module.HEAPU16.set(tmpTimelineArray, timelineArrayBuf); + for (var i1 = 0; i1 < tmpIntArray.length; ++i1) { + this._intArray[i1] = tmpIntArray[i1]; + } + for (var i2 = 0; i2 < tmpFloatArray.length; ++i2) { + this._floatArray[i2] = tmpFloatArray[i2]; + } + for (var i3 = 0; i3 < tmpFrameIntArray.length; ++i3) { + this._frameIntArray[i3] = tmpFrameIntArray[i3]; + } + for (var i4 = 0; i4 < tmpFrameFloatArray.length; ++i4) { + this._frameFloatArray[i4] = tmpFrameFloatArray[i4]; + } + for (var i5 = 0; i5 < tmpFrameArray.length; ++i5) { + this._frameArray[i5] = tmpFrameArray[i5]; + } + for (var i6 = 0; i6 < tmpTimelineArray.length; ++i6) { + this._timelineArray[i6] = tmpTimelineArray[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + } + else { + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + } + }; + /** + * @inheritDoc + */ + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer); + 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._binary = rawData; + this._binaryOffset = 8 + 4 + headerLength; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + /** + * @private + */ + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var BuildArmaturePackage = (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = (function () { + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + this.autoSearch = false; + /** + * @private + */ + this._dragonBonesDataMap = {}; + /** + * @private + */ + this._textureAtlasDataMap = {}; + /** + * @private + */ + this._dragonBones = null; + /** + * @private + */ + 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; + } + /** + * @private + */ + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + var bones = dataPackage.armature.sortedBones; + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? bones.size() : bones.length); ++i) { + var boneData = dragonBones.DragonBones.webAssembly ? bones.get(i) : bones[i]; + var bone = dragonBones.DragonBones.webAssembly ? new Module["Bone"]() : dragonBones.BaseObject.borrowObject(dragonBones.Bone); + bone.init(boneData); + if (boneData.parent !== null) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + var constraints = boneData.constraints; + for (var j = 0; j < (dragonBones.DragonBones.webAssembly ? constraints.size() : constraints.length); ++j) { + var constraintData = dragonBones.DragonBones.webAssembly ? constraints.get(j) : constraints[j]; + var target = armature.getBone(constraintData.target.name); + if (target === null) { + continue; + } + // TODO more constraint type. + var ikConstraintData = constraintData; + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraint"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + var root = ikConstraintData.root !== null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + if (root !== null) { + root.addConstraint(constraint); + } + else { + bone.addConstraint(constraint); + } + } + } + }; + /** + * @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.displays[k]; + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.displays[k]; + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + if (!(slotData.name in skinSlots)) { + continue; + } + var displays = skinSlots[slotData.name]; + var slot = this._buildSlot(dataPackage, slotData, displays, armature); + var displayList = new Array(); + for (var _b = 0, displays_1 = displays; _b < displays_1.length; _b++) { + var displayData = displays_1[_b]; + if (displayData !== null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.push(null); + } + } + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + /** + * @private + */ + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.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); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 2 /* Mesh */: + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 1 /* Armature */: + var armatureDisplayData = displayData; + var childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + 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_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + childArmature._bufferAction(action, true); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + return display; + }; + /** + * @private + */ + BaseFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + var displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + for (var i = 0, l = displayList.length; i < l; ++i) { + if (!displayList[i]) { + displayList[i] = null; + } + } + } + if (slot._displayDatas.length <= displayIndex) { + slot._displayDatas.length = displayIndex + 1; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + if (!slot._displayDatas[i]) { + slot._displayDatas[i] = null; + } + } + } + slot._displayDatas[displayIndex] = displayData; + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay(dataPackage, displayData, displayIndex < slot._rawDisplayDatas.length ? slot._rawDisplayDatas[displayIndex] : null, slot); + } + else { + displayList[displayIndex] = null; + } + slot.displayList = displayList; + }; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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 dragonBonesData = null; + if (rawData instanceof ArrayBuffer) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } + else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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 = 0.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { + 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]); + } + } + } + }; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @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; + }; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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("Replace data: " + name); + this._dragonBonesDataMap[name].returnToPool(); + } + this._dragonBonesDataMap[name] = data; + }; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @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]; + } + }; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @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; + }; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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); + } + }; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @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]; + } + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @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; + }; + /** + * 清除所有的数据。 + * @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]; + } + }; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + 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); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + for (var _i = 0, displays_2 = displays; _i < displays_2.length; _i++) { + var display = displays_2[_i]; + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + }; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + var displayIndex = 0; + for (var _i = 0, displays_3 = displays; _i < displays_3.length; _i++) { + var displayData = displays_3[_i]; + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + }; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { + if (exclude === void 0) { exclude = null; } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (!(slot.name in skin.displays) || (exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + var displays = skin.displays[slot.name]; + var displayList = slot.displayList; // Copy. + displayList.length = displays.length; // Modify displayList length. + for (var i = 0, l = displays.length; i < l; ++i) { + var displayData = displays[i]; + if (displayData !== null) { + displayList[i] = this._getSlotDisplay(null, displayData, null, slot); + } + else { + displayList[i] = null; + } + } + slot._rawDisplayDatas = displays; + slot._displayDatas.length = displays.length; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + slot._displayDatas[i] = displays[i]; + } + slot.displayList = displayList; + } + }; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { + if (fromSkinName === void 0) { fromSkinName = null; } + if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } + if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } + var dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage(dataPackage, fromDragonBonesDataName || "", fromArmatreName, fromSkinName || "", "")) { + var fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.animation.animations = fromArmatureData.animations; + } + else { + var animations = {}; + for (var animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + for (var animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + toArmature.animation.animations = animations; + } + if (dataPackage.skin) { + var slots = toArmature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var toSlot = slots[i]; + var toSlotDisplayList = toSlot.displayList; + for (var j = 0, lJ = toSlotDisplayList.length; j < lJ; ++j) { + var toDisplayObject = toSlotDisplayList[j]; + if (toDisplayObject instanceof dragonBones.Armature) { + var displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays !== null && j < displays.length) { + var fromDisplayData = displays[j]; + if (fromDisplayData !== null && fromDisplayData.type === 1 /* Armature */) { + this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + return true; + } + } + return false; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + /** + * @private + */ + BaseFactory._objectParser = null; + /** + * @private + */ + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretTextureAtlasData = (function (_super) { + __extends(EgretTextureAtlasData, _super); + function EgretTextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._renderTexture = null; // Initial value. + return _this; + } + /** + * @private + */ + EgretTextureAtlasData.toString = function () { + return "[class dragonBones.EgretTextureAtlasData]"; + }; + /** + * @private + */ + EgretTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this._renderTexture !== null) { + //this.texture.dispose(); + } + this._renderTexture = null; + }; + /** + * @private + */ + EgretTextureAtlasData.prototype.createTexture = function () { + return dragonBones.BaseObject.borrowObject(EgretTextureData); + }; + Object.defineProperty(EgretTextureAtlasData.prototype, "renderTexture", { + /** + * Egret 贴图。 + * @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) { + var bitmapData = this._renderTexture.bitmapData; + var textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; + var textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; + for (var k in this.textures) { + var textureData = this.textures[k]; + var subTextureWidth = Math.min(textureData.region.width, textureAtlasWidth - textureData.region.x); // TODO need remove + var subTextureHeight = Math.min(textureData.region.height, textureAtlasHeight - textureData.region.y); // TODO need remove + if (textureData.renderTexture === null) { + textureData.renderTexture = new egret.Texture(); + if (textureData.rotated) { + textureData.renderTexture.$initData(textureData.region.x, textureData.region.y, subTextureHeight, subTextureWidth, 0, 0, subTextureHeight, subTextureWidth, textureAtlasWidth, textureAtlasHeight); + } + else { + textureData.renderTexture.$initData(textureData.region.x, textureData.region.y, subTextureWidth, subTextureHeight, 0, 0, subTextureWidth, subTextureHeight, textureAtlasWidth, textureAtlasHeight); + } + } + textureData.renderTexture._bitmapData = bitmapData; + } + } + else { + for (var k in this.textures) { + var textureData = this.textures[k]; + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + EgretTextureAtlasData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + Object.defineProperty(EgretTextureAtlasData.prototype, "texture", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + get: function () { + return this.renderTexture; + }, + enumerable: true, + configurable: true + }); + return EgretTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.EgretTextureAtlasData = EgretTextureAtlasData; + /** + * @private + */ + var EgretTextureData = (function (_super) { + __extends(EgretTextureData, _super); + function EgretTextureData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.renderTexture = null; // Initial value. + return _this; + } + EgretTextureData.toString = function () { + return "[class dragonBones.EgretTextureData]"; + }; + EgretTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + //this.texture.dispose(); + } + this.renderTexture = null; + }; + return EgretTextureData; + }(dragonBones.TextureData)); + dragonBones.EgretTextureData = EgretTextureData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EgretEvent = (function (_super) { + __extends(EgretEvent, _super); + function EgretEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(EgretEvent.prototype, "eventObject", { + /** + * 事件对象。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationName", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + get: function () { + var animationState = this.eventObject.animationState; + return animationState !== null ? animationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "armature", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#armature + */ + get: function () { + return this.eventObject.armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "bone", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#bone + */ + get: function () { + return this.eventObject.bone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#slot + */ + get: function () { + return this.eventObject.slot; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationState", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + get: function () { + return this.eventObject.animationState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "frameLabel", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "sound", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "movementID", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationName + */ + get: function () { + return this.animationName; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.START + */ + EgretEvent.START = dragonBones.EventObject.START; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.COMPLETE + */ + EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN + */ + EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT + */ + EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND = dragonBones.EventObject.SOUND_EVENT; + return EgretEvent; + }(egret.Event)); + dragonBones.EgretEvent = EgretEvent; + /** + * @inheritDoc + */ + var EgretArmatureDisplay = (function (_super) { + __extends(EgretArmatureDisplay, _super); + function EgretArmatureDisplay() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._disposeProxy = false; + _this._armature = null; // + _this._debugDrawer = null; + return _this; + } + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.init = function (armature) { + this._armature = armature; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.clear = function () { + this._disposeProxy = false; + this._armature = null; + this._debugDrawer = null; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.dispose = function (disposeProxy) { + if (disposeProxy === void 0) { disposeProxy = true; } + this._disposeProxy = disposeProxy; + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.debugUpdate = function (isEnabled) { + if (isEnabled) { + if (this._debugDrawer === null) { + this._debugDrawer = new egret.Sprite(); + } + this.addChild(this._debugDrawer); + this._debugDrawer.graphics.clear(); + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + var boneLength = bone.boneData.length; + var startX = bone.globalTransformMatrix.tx; + var startY = bone.globalTransformMatrix.ty; + var endX = startX + bone.globalTransformMatrix.a * boneLength; + var endY = startY + bone.globalTransformMatrix.b * boneLength; + this._debugDrawer.graphics.lineStyle(2.0, 0x00FFFF, 0.7); + this._debugDrawer.graphics.moveTo(startX, startY); + this._debugDrawer.graphics.lineTo(endX, endY); + this._debugDrawer.graphics.lineStyle(0.0, 0, 0); + this._debugDrawer.graphics.beginFill(0x00FFFF, 0.7); + this._debugDrawer.graphics.drawCircle(startX, startY, 3.0); + this._debugDrawer.graphics.endFill(); + } + for (var _b = 0, _c = this._armature.getSlots(); _b < _c.length; _b++) { + var slot = _c[_b]; + var boundingBoxData = slot.boundingBoxData; + if (boundingBoxData !== null) { + var child = this._debugDrawer.getChildByName(slot.name); + if (child === null) { + child = new egret.Shape(); + child.name = slot.name; + this._debugDrawer.addChild(child); + } + child.graphics.clear(); + child.graphics.beginFill(boundingBoxData.color ? boundingBoxData.color : 0xFF00FF, 0.3); + switch (boundingBoxData.type) { + case 0 /* Rectangle */: + child.graphics.drawRect(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); + break; + case 1 /* Ellipse */: + child.graphics.drawEllipse(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); + break; + case 2 /* Polygon */: + var polygon = boundingBoxData; + var vertices = polygon.vertices; + for (var j = 0; j < polygon.count; j += 2) { + if (j === 0) { + child.graphics.moveTo(vertices[polygon.offset + j], vertices[polygon.offset + j + 1]); + } + else { + child.graphics.lineTo(vertices[polygon.offset + j], vertices[polygon.offset + j + 1]); + } + } + break; + default: + break; + } + child.graphics.endFill(); + slot.updateTransformAndMatrix(); + slot.updateGlobalTransform(); + child.$setMatrix(slot.globalTransformMatrix, true); + } + else { + var child = this._debugDrawer.getChildByName(slot.name); + if (child !== null) { + this._debugDrawer.removeChild(child); + } + } + } + } + else if (this._debugDrawer !== null && this._debugDrawer.parent === this) { + this.removeChild(this._debugDrawer); + } + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype._dispatchEvent = function (type, eventObject) { + var event = egret.Event.create(EgretEvent, type); + event.data = eventObject; + _super.prototype.dispatchEvent.call(this, event); + egret.Event.release(event); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.hasEvent = function (type) { + return this.hasEventListener(type); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.addEvent = function (type, listener, target) { + this.addEventListener(type, listener, target); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.removeEvent = function (type, listener, target) { + this.removeEventListener(type, listener, target); + }; + Object.defineProperty(EgretArmatureDisplay.prototype, "armature", { + /** + * @inheritDoc + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretArmatureDisplay.prototype, "animation", { + /** + * @inheritDoc + */ + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + EgretArmatureDisplay.prototype.advanceTimeBySelf = function (on) { + if (on) { + this._armature.clock = dragonBones.EgretFactory.clock; + } + else { + this._armature.clock = null; + } + }; + return EgretArmatureDisplay; + }(egret.DisplayObjectContainer)); + dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var Event = (function (_super) { + __extends(Event, _super); + function Event() { + return _super !== null && _super.apply(this, arguments) || this; + } + return Event; + }(EgretEvent)); + dragonBones.Event = Event; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var ArmatureEvent = (function (_super) { + __extends(ArmatureEvent, _super); + function ArmatureEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return ArmatureEvent; + }(EgretEvent)); + dragonBones.ArmatureEvent = ArmatureEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var AnimationEvent = (function (_super) { + __extends(AnimationEvent, _super); + function AnimationEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return AnimationEvent; + }(EgretEvent)); + dragonBones.AnimationEvent = AnimationEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var FrameEvent = (function (_super) { + __extends(FrameEvent, _super); + function FrameEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return FrameEvent; + }(EgretEvent)); + dragonBones.FrameEvent = FrameEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + var SoundEvent = (function (_super) { + __extends(SoundEvent, _super); + function SoundEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + return SoundEvent; + }(EgretEvent)); + dragonBones.SoundEvent = SoundEvent; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + var EgretTextureAtlas = (function (_super) { + __extends(EgretTextureAtlas, _super); + function EgretTextureAtlas(texture, rawData, scale) { + if (scale === void 0) { scale = 1; } + var _this = _super.call(this) || this; + console.warn("已废弃,请参考 @see"); + _this._onClear(); + dragonBones.ObjectDataParser.getInstance().parseTextureAtlasData(rawData, _this, scale); + _this.renderTexture = texture; + return _this; + } + /** + * @private + */ + EgretTextureAtlas.toString = function () { + return "[class dragonBones.EgretTextureAtlas]"; + }; + return EgretTextureAtlas; + }(dragonBones.EgretTextureAtlasData)); + dragonBones.EgretTextureAtlas = EgretTextureAtlas; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + var EgretSheetAtlas = (function (_super) { + __extends(EgretSheetAtlas, _super); + function EgretSheetAtlas() { + return _super !== null && _super.apply(this, arguments) || this; + } + return EgretSheetAtlas; + }(EgretTextureAtlas)); + dragonBones.EgretSheetAtlas = EgretSheetAtlas; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + var SoundEventManager = (function () { + function SoundEventManager() { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + SoundEventManager.getInstance = function () { + console.warn("已废弃,请参考 @see"); + return dragonBones.EgretFactory.factory.soundEventManager; + }; + return SoundEventManager; + }()); + dragonBones.SoundEventManager = SoundEventManager; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + var AnimationCacheManager = (function () { + function AnimationCacheManager() { + } + return AnimationCacheManager; + }()); + dragonBones.AnimationCacheManager = AnimationCacheManager; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretSlot = (function (_super) { + __extends(EgretSlot, _super); + function EgretSlot() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.transformUpdateEnabled = false; + _this._renderDisplay = null; + _this._colorFilter = null; + return _this; + } + EgretSlot.toString = function () { + return "[class dragonBones.EgretSlot]"; + }; + /** + * @private + */ + EgretSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._renderDisplay = null; // + this._colorFilter = null; + }; + /** + * @private + */ + EgretSlot.prototype._initDisplay = function (value) { + value; + }; + /** + * @private + */ + EgretSlot.prototype._disposeDisplay = function (value) { + value; + }; + /** + * @private + */ + EgretSlot.prototype._onUpdateDisplay = function () { + this._renderDisplay = (this._display !== null ? this._display : this._rawDisplay); + }; + /** + * @private + */ + EgretSlot.prototype._addDisplay = function () { + var container = this._armature.display; + container.addChild(this._renderDisplay); + }; + /** + * @private + */ + EgretSlot.prototype._replaceDisplay = function (value) { + var container = this._armature.display; + var prevDisplay = value; + container.addChild(this._renderDisplay); + container.swapChildren(this._renderDisplay, prevDisplay); + container.removeChild(prevDisplay); + }; + /** + * @private + */ + EgretSlot.prototype._removeDisplay = function () { + this._renderDisplay.parent.removeChild(this._renderDisplay); + }; + /** + * @private + */ + EgretSlot.prototype._updateZOrder = function () { + var container = this._armature.display; + var index = container.getChildIndex(this._renderDisplay); + if (index === this._zOrder) { + return; + } + container.addChildAt(this._renderDisplay, this._zOrder); + }; + /** + * @internal + * @private + */ + EgretSlot.prototype._updateVisible = function () { + this._renderDisplay.visible = this._parent.visible; + }; + /** + * @private + */ + EgretSlot.prototype._updateBlendMode = function () { + switch (this._blendMode) { + case 0 /* Normal */: + this._renderDisplay.blendMode = egret.BlendMode.NORMAL; + break; + case 1 /* Add */: + this._renderDisplay.blendMode = egret.BlendMode.ADD; + break; + case 5 /* Erase */: + this._renderDisplay.blendMode = egret.BlendMode.ERASE; + break; + default: + break; + } + }; + /** + * @private + */ + EgretSlot.prototype._updateColor = function () { + if (this._colorTransform.redMultiplier !== 1.0 || + this._colorTransform.greenMultiplier !== 1.0 || + this._colorTransform.blueMultiplier !== 1.0 || + this._colorTransform.redOffset !== 0 || + this._colorTransform.greenOffset !== 0 || + this._colorTransform.blueOffset !== 0 || + this._colorTransform.alphaOffset !== 0) { + if (this._colorFilter === null) { + this._colorFilter = new egret.ColorMatrixFilter(); + } + var colorMatrix = this._colorFilter.matrix; + colorMatrix[0] = this._colorTransform.redMultiplier; + colorMatrix[6] = this._colorTransform.greenMultiplier; + colorMatrix[12] = this._colorTransform.blueMultiplier; + colorMatrix[18] = this._colorTransform.alphaMultiplier; + colorMatrix[4] = this._colorTransform.redOffset; + colorMatrix[9] = this._colorTransform.greenOffset; + colorMatrix[14] = this._colorTransform.blueOffset; + colorMatrix[19] = this._colorTransform.alphaOffset; + this._colorFilter.matrix = colorMatrix; + var filters = this._renderDisplay.filters; + if (!filters) { + filters = []; + } + if (filters.indexOf(this._colorFilter) < 0) { + filters.push(this._colorFilter); + } + this._renderDisplay.$setAlpha(1.0); + this._renderDisplay.filters = filters; + } + else { + if (this._colorFilter !== null) { + this._colorFilter = null; + this._renderDisplay.filters = null; + } + this._renderDisplay.$setAlpha(this._colorTransform.alphaMultiplier); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateFrame = function () { + var meshData = this._display === this._meshDisplay ? this._meshData : null; + var currentTextureData = this._textureData; + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + if (this._armature.replacedTexture !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { + var currentTextureAtlasData = currentTextureData.parent; + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData; + } + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name); + } + if (currentTextureData.renderTexture !== null) { + if (meshData !== null) { + var data = meshData.parent.parent; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var triangleCount = intArray[meshData.offset + 1 /* MeshTriangleCount */]; + var verticesOffset = intArray[meshData.offset + 2 /* MeshFloatOffset */]; + var uvOffset = verticesOffset + vertexCount * 2; + var meshDisplay = this._renderDisplay; + var meshNode = meshDisplay.$renderNode; + meshNode.uvs.length = vertexCount * 2; + meshNode.vertices.length = vertexCount * 2; + meshNode.indices.length = triangleCount * 3; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[verticesOffset + i]; + meshNode.uvs[i] = floatArray[uvOffset + i]; + } + for (var i = 0; i < triangleCount * 3; ++i) { + meshNode.indices[i] = intArray[meshData.offset + 4 /* MeshVertexIndices */ + i]; + } + meshDisplay.texture = currentTextureData.renderTexture; + meshDisplay.$setAnchorOffsetX(this._pivotX); + meshDisplay.$setAnchorOffsetY(this._pivotY); + meshDisplay.$updateVertices(); + } + else { + var normalDisplay = this._renderDisplay; + normalDisplay.texture = currentTextureData.renderTexture; + normalDisplay.$setAnchorOffsetX(this._pivotX); + normalDisplay.$setAnchorOffsetY(this._pivotY); + } + return; + } + } + if (meshData !== null) { + var meshDisplay = this._renderDisplay; + meshDisplay.texture = null; + meshDisplay.x = 0.0; + meshDisplay.y = 0.0; + } + else { + var normalDisplay = this._renderDisplay; + normalDisplay.texture = null; + normalDisplay.x = 0.0; + normalDisplay.y = 0.0; + } + }; + /** + * @private + */ + EgretSlot.prototype._updateMesh = function () { + var hasFFD = this._ffdVertices.length > 0; + var meshData = this._meshData; + var weightData = meshData.weight; + var meshDisplay = this._renderDisplay; + var meshNode = meshDisplay.$renderNode; + if (weightData !== null) { + var data = meshData.parent.parent; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var weightFloatOffset = intArray[weightData.offset + 1 /* WeigthFloatOffset */]; + for (var i = 0, iD = 0, iB = weightData.offset + 2 /* WeigthBoneIndices */ + weightData.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 = this._meshBones[boneIndex]; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + var weight = floatArray[iV++]; + var xL = floatArray[iV++]; + var yL = floatArray[iV++]; + if (hasFFD) { + xL += this._ffdVertices[iF++]; + yL += this._ffdVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + meshNode.vertices[iD++] = xG; + meshNode.vertices[iD++] = yG; + } + meshDisplay.$updateVertices(); + } + else if (hasFFD) { + var data = meshData.parent.parent; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var vertexOffset = intArray[meshData.offset + 2 /* MeshFloatOffset */]; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[vertexOffset + i] + this._ffdVertices[i]; + } + meshDisplay.$updateVertices(); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateTransform = function (isSkinnedMesh) { + if (isSkinnedMesh) { + var transformationMatrix = this._renderDisplay.matrix; + transformationMatrix.identity(); + this._renderDisplay.$setMatrix(transformationMatrix, this.transformUpdateEnabled); + } + else { + var globalTransformMatrix = this.globalTransformMatrix; + this._renderDisplay.$setMatrix(globalTransformMatrix, this.transformUpdateEnabled); + } + }; + return EgretSlot; + }(dragonBones.Slot)); + dragonBones.EgretSlot = EgretSlot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretFactory = (function (_super) { + __extends(EgretFactory, _super); + /** + * @inheritDoc + */ + function EgretFactory() { + var _this = _super.call(this) || this; + if (EgretFactory._dragonBones === null) { + var eventManager = new dragonBones.EgretArmatureDisplay(); + EgretFactory._dragonBones = new dragonBones.DragonBones(eventManager); + EgretFactory._dragonBones.clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretFactory._clockHandler, EgretFactory); + } + _this._dragonBones = EgretFactory._dragonBones; + return _this; + } + EgretFactory._clockHandler = function (time) { + time *= 0.001; + var passedTime = time - EgretFactory._time; + EgretFactory._dragonBones.advanceTime(passedTime); + EgretFactory._time = time; + return false; + }; + Object.defineProperty(EgretFactory, "clock", { + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return EgretFactory._dragonBones.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretFactory, "factory", { + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + if (EgretFactory._factory === null) { + EgretFactory._factory = new EgretFactory(); + } + return EgretFactory._factory; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + EgretFactory.prototype._isSupportMesh = function () { + if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { + return true; + } + console.warn("Canvas can not support mesh, please change renderMode to webgl."); + return false; + }; + /** + * @private + */ + EgretFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); + } + return textureAtlasData; + }; + /** + * @private + */ + EgretFactory.prototype._buildArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplay = new dragonBones.EgretArmatureDisplay(); + armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones); + return armature; + }; + /** + * @private + */ + EgretFactory.prototype._buildSlot = function (dataPackage, slotData, displays, armature) { + dataPackage; + armature; + var slot = dragonBones.BaseObject.borrowObject(dragonBones.EgretSlot); + slot.init(slotData, displays, new egret.Bitmap(), new egret.Mesh()); + return slot; + }; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + EgretFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + var armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.display; + } + return null; + }; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + EgretFactory.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) { + return new egret.Bitmap(textureData.renderTexture); + } + return null; + }; + Object.defineProperty(EgretFactory.prototype, "soundEventManager", { + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._dragonBones.eventManager; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + EgretFactory.prototype.addSkeletonData = function (dragonBonesData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + console.warn("已废弃,请参考 @see"); + this.addDragonBonesData(dragonBonesData, dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getDragonBonesData() + */ + EgretFactory.prototype.getSkeletonData = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + return this.getDragonBonesData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + EgretFactory.prototype.removeSkeletonData = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + this.removeDragonBonesData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addTextureAtlasData() + */ + EgretFactory.prototype.addTextureAtlas = function (textureAtlasData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + console.warn("已废弃,请参考 @see"); + this.addTextureAtlasData(textureAtlasData, dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getTextureAtlasData() + */ + EgretFactory.prototype.getTextureAtlas = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + return this.getTextureAtlasData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + EgretFactory.prototype.removeTextureAtlas = function (dragonBonesName) { + console.warn("已废弃,请参考 @see"); + this.removeTextureAtlasData(dragonBonesName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#buildArmature() + */ + EgretFactory.prototype.buildFastArmature = function (armatureName, dragonBonesName, skinName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + console.warn("已废弃,请参考 @see"); + return this.buildArmature(armatureName, dragonBonesName, skinName); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#clear() + */ + EgretFactory.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.clear(); + }; + Object.defineProperty(EgretFactory.prototype, "soundEventManater", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager() + */ + get: function () { + return this.soundEventManager; + }, + enumerable: true, + configurable: true + }); + EgretFactory._time = 0; + EgretFactory._dragonBones = null; + EgretFactory._factory = null; + return EgretFactory; + }(dragonBones.BaseFactory)); + dragonBones.EgretFactory = EgretFactory; +})(dragonBones || (dragonBones = {})); diff --git a/reference/Egret/5.x/out/dragonBones.min.js b/reference/Egret/5.x/out/dragonBones.min.js new file mode 100644 index 0000000..74f2b97 --- /dev/null +++ b/reference/Egret/5.x/out/dragonBones.min.js @@ -0,0 +1 @@ +"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]};return function(e,i){t(e,i);function a(){this.constructor=e}e.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}}();var dragonBones;(function(t){var e=function(){function e(e){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=e}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var i=0,a=this._objects;i0){for(var n=0;ni){r.length=i}t._maxCountMap[a]=i}else{t._defaultMaxCount=i;for(var a in t._poolsMap){if(a in t._maxCountMap){continue}var r=t._poolsMap[a];if(r.length>i){r.length=i}t._maxCountMap[a]=i}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in t._poolsMap){var a=t._poolsMap[r];a.length=0}}};t.borrowObject=function(e){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=1e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=1}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=1}if(r===void 0){r=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=i;this.d=a;this.tx=r;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 i=0;var a=0;var r=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;i+=this.b*t.d;a+=this.c*t.a;r+=this.c*t.b}if(t.b!==0||t.c!==0){i+=this.a*t.b;a+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=i;this.c=a;this.d=r;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var i=this.c;var a=this.d;var r=this.tx;var n=this.ty;if(e===0&&i===0){this.b=this.c=0;if(t===0||a===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;a=this.d=1/a;this.tx=-t*r;this.ty=-a*n}return this}var s=t*a-e*i;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=a*s;e=this.b=-e*s;i=this.c=-i*s;a=this.d=t*s;this.tx=-(o*r+i*n);this.ty=-(e*r+a*n);return this};t.prototype.transformPoint=function(t,e,i,a){if(a===void 0){a=false}i.x=this.a*t+this.c*e;i.y=this.b*t+this.d*e;if(!a){i.x+=this.tx;i.y+=this.ty}};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}if(r===void 0){r=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=i;this.rotation=a;this.scaleX=r;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.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};t.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};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.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};t.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};t.prototype.fromMatrix=function(e){var i=this.scaleX,a=this.scaleY;var r=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-r&&this.rotation-r&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.skew!==0||this.rotation!==0){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}}else{t.a=this.scaleX;t.b=0;t.c=0;t.d=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(i===void 0){i=1}if(a===void 0){a=1}if(r===void 0){r=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=i;this.blueMultiplier=a;this.alphaOffset=r;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,i,a){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}this.x=t;this.y=e;this.width=i;this.height=a}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(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){i=0}if(this.sortedBones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames;var a=i.length;i.length+=10;i[a]=t.a;i[a+1]=t.b;i[a+2]=t.c;i[a+3]=t.d;i[a+4]=t.tx;i[a+5]=t.ty;i[a+6]=e.rotation;i[a+7]=e.skew;i[a+8]=e.scaleX;i[a+9]=e.scaleY;return a};i.prototype.getCacheFrame=function(t,e,i){var a=this.parent.cachedFrames;t.a=a[i];t.b=a[i+1];t.c=a[i+2];t.d=a[i+3];t.tx=a[i+4];t.ty=a[i+5];e.rotation=a[i+6];e.skew=a[i+7];e.scaleX=a[i+8];e.scaleY=a[i+9];e.x=t.tx;e.y=t.ty};i.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Replace bone: "+t.name);this.bones[t.name].returnToPool()}this.bones[t.name]=t;this.sortedBones.push(t)};i.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Replace slot: "+t.name);this.slots[t.name].returnToPool()}this.slots[t.name]=t;this.sortedSlots.push(t)};i.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Replace skin: "+t.name);this.skins[t.name].returnToPool()}this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}};i.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Replace animation: "+t.name);this.animations[t.name].returnToPool()}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return i}(t.BaseObject);t.ArmatureData=i;var a=function(e){__extends(i,e);function i(){var i=e!==null&&e.apply(this,arguments)||this;i.transform=new t.Transform;i.constraints=[];i.userData=null;return i}i.toString=function(){return"[class dragonBones.BoneData]"};i.prototype._onClear=function(){for(var t=0,e=this.constraints;tr){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,i,a,r,n,s,o,l,h,u,f){if(h===void 0){h=null}if(u===void 0){u=null}if(f===void 0){f=null}var _=t>n&&ts&&in&&as&&r=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){return true}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var u=e.rectangleIntersectsSegment(t,i,a,r,-l,-h,l,h,n,s,o);return u};return e}(e);t.RectangleBoundingBoxData=i;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,i,a,r,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;a*=f;var m=i-t;var c=a-e;var p=Math.sqrt(m*m+c*c);var d=m/p;var y=c/p;var g=(r-t)*d+(n-e)*y;var v=g*g;var b=t*t+e*e;var D=s*s;var T=D-b+v;var A=0;if(T>=0){var O=Math.sqrt(T);var x=g-O;var B=g+O;var S=x<0?-1:x<=p?0:1;var E=B<0?-1:B<=p?0:1;var M=S*E;if(M<0){return-1}else if(M===0){if(S===-1){A=2;i=t+B*d;a=(e+B*y)/f;if(l!==null){l.x=i;l.y=a}if(h!==null){h.x=i;h.y=a}if(u!==null){u.x=Math.atan2(a/D*_,i/D);u.y=u.x+Math.PI}}else if(E===1){A=1;t=t+x*d;e=(e+x*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/D*_,t/D);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+x*d;l.y=(e+x*y)/f;if(u!==null){u.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+B*d;h.y=(e+B*y)/f;if(u!==null){u.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var i=this.width*.5;if(t>=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){e*=i/a;return Math.sqrt(t*t+e*e)<=i}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,i,a,r,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.weight=null;return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,i,a,r,n,s,o,l,h){if(o===void 0){o=null}if(l===void 0){l=null}if(h===void 0){h=null}if(t===i){t=i+1e-6}if(e===a){e=a+1e-6}var u=t-i;var f=e-a;var _=t*a-e*i;var m=0;var c=r[n+s-2];var p=r[n+s-1];var d=0;var y=0;var g=0;var v=0;var b=0;var D=0;for(var T=0;T=c&&M<=A||M>=A&&M<=c)&&(u===0||M>=t&&M<=i||M>=i&&M<=t)){var w=(_*B-f*S)/E;if((w>=p&&w<=O||w>=O&&w<=p)&&(f===0||w>=e&&w<=a||w>=a&&w<=e)){if(l!==null){var P=M-t;if(P<0){P=-P}if(m===0){d=P;y=P;g=M;v=w;b=M;D=w;if(h!==null){h.x=Math.atan2(O-p,A-c)-Math.PI*.5;h.y=h.x}}else{if(Py){y=P;b=M;D=w;if(h!==null){h.y=Math.atan2(O-p,A-c)-Math.PI*.5}}}m++}else{g=M;v=w;b=M;D=w;m++;if(h!==null){h.x=Math.atan2(O-p,A-c)-Math.PI*.5;h.y=h.x}break}}}c=A;p=O}if(m===1){if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=g;l.y=v}if(h!==null){h.y=h.x+Math.PI}}else if(m>1){m++;if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=b;l.y=D}}return m};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.weight!==null){this.weight.returnToPool()}this.type=2;this.count=0;this.offset=0;this.x=0;this.y=0;this.vertices=null;this.weight=null};e.prototype.containsPoint=function(t,e){var i=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var a=0,r=this.count,n=r-2;a=e||s=e){var l=this.vertices[this.offset+n];var h=this.vertices[this.offset+a];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 i=0,a=this.cacheFrames.length;i=0};e.prototype.addBoneMask=function(t,e,i){if(i===void 0){i=true}var a=t.getBone(e);if(a===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(i){for(var r=0,n=t.getBones();r=0){this.boneMask.splice(a,1)}if(i){var r=t.getBone(e);if(r!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&r.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,u=t.getBones();he._zOrder?1:-1};i.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=t){i=0}if(this._bones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s=n){continue}var o=i[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(r)}}this._slotsDirty=true;this._zOrderDirty=!a}};i.prototype._addBoneToBoneList=function(t){if(this._bones.indexOf(t)<0){this._bonesDirty=true;this._bones.push(t);this._animation._timelineDirty=true}};i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);if(e>=0){this._bones.splice(e,1);this._animation._timelineDirty=true}};i.prototype._addSlotToSlotList=function(t){if(this._slots.indexOf(t)<0){this._slotsDirty=true;this._slots.push(t);this._animation._timelineDirty=true}};i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);if(e>=0){this._slots.splice(e,1);this._animation._timelineDirty=true}};i.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};i.prototype.dispose=function(){if(this.armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};i.prototype.init=function(e,i,a,r){if(this.armatureData!==null){return}this.armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=i;this._display=a;this._dragonBones=r;this._proxy.init(this);this._animation.init(this);this._animation.animations=this.armatureData.animations};i.prototype.advanceTime=function(e){if(this._lockUpdate){return}if(this.armatureData===null){console.assert(false,"The armature has been disposed.");return}else if(this.armatureData.parent===null){console.assert(false,"The armature data has been disposed.");return}var i=this._cacheFrameIndex;this._animation.advanceTime(e);if(this._bonesDirty){this._bonesDirty=false;this._sortBones()}if(this._slotsDirty){this._slotsDirty=false;this._sortSlots()}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==i){var a=0,r=0;for(a=0,r=this._bones.length;a0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var i=this.getBone(t);if(i!==null){i.invalidUpdate();if(e){for(var a=0,r=this._slots;a0){if(r!==null||n!==null){if(r!==null){var T=o?r.y-e:r.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;m=n.y;y=b;if(s!==null){p=s.y}}}}else{d=b;break}}}if(d!==null&&r!==null){r.x=u;r.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};i.prototype.getBone=function(t){for(var e=0,i=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.constraints.length>0){for(var i=0,a=this.constraints;i=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this.constraints.length>0){for(var n=0,s=this.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};i.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};i.prototype.addConstraint=function(t){if(this.constraints.indexOf(t)<0){this.constraints.push(t)}};i.prototype.invalidUpdate=function(){this._transformDirty=true};i.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};i.prototype.getBones=function(){this._bones.length=0;for(var t=0,e=this._armature.getBones();t=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var i=0,a=e.length;i0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=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._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._display===null){return}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._meshData!==null&&this._display===this._meshDisplay){var i=this._meshData.weight!==null;if(this._meshDirty||i&&this._isMeshBonesUpdate()){this._meshDirty=false;this._updateMesh()}if(i){if(this._transformDirty){this._transformDirty=false;this._updateTransform(true)}return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var a=t>=0;this._updateGlobalTransformMatrix(a);if(a&&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(false)}};i.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};i.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);return this._boundingBoxData.containsPoint(i._helpPoint.x,i._helpPoint.y)};i.prototype.intersectsSegment=function(t,e,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);t=i._helpPoint.x;e=i._helpPoint.y;i._helpMatrix.transformPoint(a,r,i._helpPoint);a=i._helpPoint.x;r=i._helpPoint.y;var l=this._boundingBoxData.intersectsSegment(t,e,a,r,n,s,o);if(l>0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,true);o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,true);o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x)}}return l};i.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat();var a=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var r=0,n=i;r0){this._animatebles[e-i]=r;this._animatebles[e]=null}r.advanceTime(t)}else{i++}}if(i>0){a=this._animatebles.length;for(;e=0};t.prototype.add=function(t){if(this._animatebles.indexOf(t)<0){this._animatebles.push(t);t.clock=this}};t.prototype.remove=function(t){var e=this._animatebles.indexOf(t);if(e>=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&i._subFadeState>0){this._armature._dragonBones.bufferObject(i);this._animationStates.length=0;this._lastAnimationState=null}else{var a=i.animationData;var r=a.cacheFrameRate;if(this._animationDirty&&r>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n1){for(var f=0,_=0;f0&&i._subFadeState>0){_++;this._armature._dragonBones.bufferObject(i);this._animationDirty=true;if(this._lastAnimationState===i){this._lastAnimationState=null}}else{if(_>0){this._animationStates[f-_]=i}if(this._timelineDirty){i.updateTimelines()}i.advanceTime(t,0)}if(f===e-1&&_>0){this._animationStates.length-=_;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}this._timelineDirty=false};i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=a.duration;e.position=a.duration-e.position}else if(e.position===a.duration){e.position-=1e-6}else if(e.position>a.duration){e.position%=a.duration}if(e.duration>0&&e.position+e.duration>a.duration){e.duration=a.duration-e.position}if(e.playTimes<0){e.playTimes=a.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,a,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,u=this._animationStates.length;h=this._animationStates[h].layer){}else{l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var f=0,_=this._armature.getSlots();f<_.length;f++){var m=_[f];var c=m.childArmature;if(c!==null&&c.inheritAnimation&&c.animation.hasAnimation(i)&&c.animation.getState(i)===null){c.animation.fadeIn(i)}}if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o;return o};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var i=this._armature.armatureData.defaultAnimation;if(i!==null){this._animationConfig.animation=i.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};i.prototype.fadeIn=function(t,e,i,a,r,n){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=0}if(r===void 0){r=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=i;this._animationConfig.layer=a;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=r!==null?r:"";return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByTime=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByFrame=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*e/a.frameCount}return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByProgress=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByTime(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByFrame(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByProgress(t,e,1);if(i!==null){i.stop()}return i};i.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var i=this._animationStates[e];if(i.name===t){return i}}return null};i.prototype.hasAnimation=function(t){return t in this._animations};i.prototype.getStates=function(){return this._animationStates};Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.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._animations[e]=t[e];this._animationNames.push(e)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});i.prototype.gotoAndPlay=function(t,e,i,a,r,n,s,o,l){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&i>0){this._animationConfig.timeScale=h.duration/i}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}return this.gotoAndStopByTime(t,e)};Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationDataList",{get:function(){var t=[];for(var e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var a=i?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=i?0:1}else if(this._fadeTime>0){this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=i?1:0}if(this._subFadeState>0){if(!i){this._playheadState|=1;this._fadeState=0}var a=i?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}};a.prototype._blendBoneTimline=function(t){var e=t.bone;var i=t.bonePose.result;var a=e.animationPose;var r=this._weightResult>0?this._weightResult:-this._weightResult;if(!e._blendDirty){e._blendDirty=true;e._blendLayer=this.layer;e._blendLayerWeight=r;e._blendLeftWeight=1;a.x=i.x*r;a.y=i.y*r;a.rotation=i.rotation*r;a.skew=i.skew*r;a.scaleX=(i.scaleX-1)*r+1;a.scaleY=(i.scaleY-1)*r+1}else{r*=e._blendLeftWeight;e._blendLayerWeight+=r;a.x+=i.x*r;a.y+=i.y*r;a.rotation+=i.rotation*r;a.skew+=i.skew*r;a.scaleX+=(i.scaleX-1)*r;a.scaleY+=(i.scaleY-1)*r}if(this._fadeState!==0||this._subFadeState!==0){e._transformDirty=true}};a.prototype.init=function(e,i,a){if(this._armature!==null){return}this._armature=e;this.animationData=i;this.resetToPose=a.resetToPose;this.additiveBlending=a.additiveBlending;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.weight=a.weight;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;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,n=this._boneMask.length;r0;var a=true;var r=true;var n=this._time;this._weightResult=this.weight*this._fadeProgress;this._actionTimeline.update(n);if(i){var s=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*s)/s}if(this._zOrderTimeline!==null){this._zOrderTimeline.update(n)}if(i){var o=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===o){a=false;r=false}else{this._armature._cacheFrameIndex=o;if(this.animationData.cachedFrames[o]){r=false}else{this.animationData.cachedFrames[o]=true}}}if(a){if(r){var l=null;var h=null;for(var u=0,f=this._boneTimelines.length;u0){if(l._blendLayer!==this.layer){if(l._blendLayerWeight>=l._blendLeftWeight){l._blendLeftWeight=0;l=null}else{l._blendLayer=this.layer;l._blendLeftWeight-=l._blendLayerWeight;l._blendLayerWeight=0}}}else{l=null}}}l=_.bone}if(l!==null){_.update(n);if(u===f-1){this._blendBoneTimline(_)}else{h=_}}}}for(var u=0,f=this._slotTimelines.length;u0){this._subFadeState=0}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};a.prototype.play=function(){this._playheadState=3};a.prototype.stop=function(){this._playheadState&=1};a.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 i=0,a=this._boneTimelines;i1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};a.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};a.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var i=this._armature.getBone(t);if(i===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var a=0,r=this._armature.getBones();a=0){this._boneMask.splice(i,1)}if(e){var a=this._armature.getBone(t);if(a!==null){var r=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=r;n=0&&a.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=r;h0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(a.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){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 i=0,a=this._boneTimelines;i=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var r=this._animationState.playTimes;var n=r*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(r>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=r;if(t<0){this.currentTime=0}else{this.currentTime=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===i&&this.currentTime===a){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i){this._frameIndex=-1}return true};e.prototype.init=function(t,e,i){this._armature=t;this._animationState=e;this._timelineData=i;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._frameRate=this._armature.armatureData.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._armature.armatureData.parent;this._animationData=this._animationState.animationData;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.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(){};e.prototype.update=function(t){if(this.playState<=0&&this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var i=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==i){this._frameIndex=i;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._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,i){var a=e;switch(t){case 3:a=Math.pow(e,2);break;case 4:a=1-Math.pow(1-e,2);break;case 5:a=.5*(1-Math.cos(e*Math.PI));break}return(a-e)*i+e};e._getEasingCurveValue=function(t,e,i,a){if(t<=0){return 0}else if(t>=1){return 1}var r=i+1;var n=Math.floor(t*r);var s=n===0?0:e[a+n-1];var o=n===r-1?1e4:e[a+n];return(s+(o-s)*(t*r-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){if(n.hasEvent(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.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}(t.TimelineState);t.ZOrderTimelineState=i;var a=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};i.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._dragonBonesData.frameFloatArray;var i=this.bonePose.current;var a=this.bonePose.delta;var r=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;i.x=t[r++];i.y=t[r++];i.rotation=t[r++];i.skew=t[r++];i.scaleX=t[r++];i.scaleY=t[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}a.x=t[r++]-i.x;a.y=t[r++]-i.y;a.rotation=t[r++]-i.rotation;a.skew=t[r++]-i.skew;a.scaleX=t[r++]-i.scaleX;a.scaleY=t[r++]-i.scaleY}}else{var i=this.bonePose.current;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1}};i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var i=this.bonePose.delta;var a=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}var r=this._armature.armatureData.scale;a.x=(t.x+i.x*this._tweenProgress)*r;a.y=(t.y+i.y*this._tweenProgress)*r;a.rotation=t.rotation+i.rotation*this._tweenProgress;a.skew=t.skew+i.skew*this._tweenProgress;a.scaleX=t.scaleX+i.scaleX*this._tweenProgress;a.scaleY=t.scaleY+i.scaleY*this._tweenProgress};i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return i}(t.BoneTimelineState);t.BoneAllTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDislayIndexTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot.slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayIndexTimelineState=r;var n=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var i=this._dragonBonesData.frameIntArray;var a=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var r=i[a];this._current[0]=e[r++];this._current[1]=e[r++];this._current[2]=e[r++];this._current[3]=e[r++];this._current[4]=e[r++];this._current[5]=e[r++];this._current[6]=e[r++];this._current[7]=e[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=i[this._animationData.frameIntOffset+this._frameValueOffset]}else{r=i[a+1*1]}this._delta[0]=e[r++]-this._current[0];this._delta[1]=e[r++]-this._current[1];this._delta[2]=e[r++]-this._current[2];this._delta[3]=e[r++]-this._current[3];this._delta[4]=e[r++]-this._current[4];this._delta[5]=e[r++]-this._current[5];this._delta[6]=e[r++]-this._current[6];this._delta[7]=e[r++]-this._current[7]}}else{var n=this.slot.slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var i=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var a=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*a;i.redMultiplier+=(this._result[1]-i.redMultiplier)*a;i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*a;i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*a;i.alphaOffset+=(this._result[4]-i.alphaOffset)*a;i.redOffset+=(this._result[5]-i.redOffset)*a;i.greenOffset+=(this._result[6]-i.greenOffset)*a;i.blueOffset+=(this._result[7]-i.blueOffset)*a;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){i.alphaMultiplier=this._result[0];i.redMultiplier=this._result[1];i.greenMultiplier=this._result[2];i.blueMultiplier=this._result[3];i.alphaOffset=this._result[4];i.redOffset=this._result[5];i.greenOffset=this._result[6];i.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=n;var s=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SlotFFDTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.meshOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._ffdCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._tweenState===2;var i=this._dragonBonesData.frameFloatArray;var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;if(e){var r=a+this._valueCount;if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n255){return encodeURI(r)}}}return r}return String(r)}return a};a.prototype._getCurvePoint=function(t,e,i,a,r,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*i+p*r+d*s;h.y=m*e+c*a+p*n+d*o};a.prototype._samplingEasingCurve=function(t,e){var i=t.length;var a=-2;for(var r=0,n=e.length;r=0&&a+61e-4){var g=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,c,p,g,this._helpPoint);if(s-this._helpPoint.x>0){d=g}else{y=g}}e[r]=this._helpPoint.y}};a.prototype._sortActionFrame=function(t,e){return t.frameStart>e.frameStart?1:-1};a.prototype._parseActionDataInFrame=function(t,e,i,r){if(a.EVENT in t){this._mergeActionFrame(t[a.EVENT],e,10,i,r)}if(a.SOUND in t){this._mergeActionFrame(t[a.SOUND],e,11,i,r)}if(a.ACTION in t){this._mergeActionFrame(t[a.ACTION],e,0,i,r)}if(a.EVENTS in t){this._mergeActionFrame(t[a.EVENTS],e,10,i,r)}if(a.ACTIONS in t){this._mergeActionFrame(t[a.ACTIONS],e,0,i,r)}};a.prototype._mergeActionFrame=function(e,a,r,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,this._armature.actions,r,n,s);var h=null;if(this._actionFrames.length===0){h=new i;h.frameStart=0;this._actionFrames.push(h);h=null}for(var u=0,f=this._actionFrames;u0){var c=r.getBone(_);if(c!==null){m.parent=c}else{(this._cacheBones[_]=this._cacheBones[_]||[]).push(m)}}if(m.name in this._cacheBones){for(var p=0,d=this._cacheBones[m.name];p0){n.root=i.parent}if(t.DragonBones.webAssembly){i.constraints.push_back(n)}else{i.constraints.push(n)}};a.prototype._parseSlot=function(e){var i=t.DragonBones.webAssembly?new Module["SlotData"]:t.BaseObject.borrowObject(t.SlotData);i.displayIndex=a._getNumber(e,a.DISPLAY_INDEX,0);i.zOrder=t.DragonBones.webAssembly?this._armature.sortedSlots.size():this._armature.sortedSlots.length;i.name=a._getString(e,a.NAME,"");i.parent=this._armature.getBone(a._getString(e,a.PARENT,""));if(a.BLEND_MODE in e&&typeof e[a.BLEND_MODE]==="string"){i.blendMode=a._getBlendMode(e[a.BLEND_MODE])}else{i.blendMode=a._getNumber(e,a.BLEND_MODE,0)}if(a.COLOR in e){i.color=t.DragonBones.webAssembly?Module["SlotData"].createColor():t.SlotData.createColor();this._parseColorTransform(e[a.COLOR],i.color)}else{i.color=t.DragonBones.webAssembly?Module["SlotData"].DEFAULT_COLOR:t.SlotData.DEFAULT_COLOR}if(a.ACTIONS in e){var r=this._slotChildActions[i.name]=[];this._parseActionData(e[a.ACTIONS],r,0,null,null)}return i};a.prototype._parseSkin=function(e){var i=t.DragonBones.webAssembly?new Module["SkinData"]:t.BaseObject.borrowObject(t.SkinData);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length===0){i.name=a.DEFAULT_NAME}if(a.SLOT in e){this._skin=i;var r=e[a.SLOT];for(var n=0,s=r;n0?n:r;this._parsePivot(e,o);break;case 1:var l=i=t.DragonBones.webAssembly?new Module["ArmatureDisplayData"]:t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=r;l.path=n.length>0?n:r;l.inheritAnimation=true;if(a.ACTIONS in e){this._parseActionData(e[a.ACTIONS],l.actions,0,null,null)}else if(this._slot.name in this._slotChildActions){var h=this._skin.getDisplays(this._slot.name);if(h===null?this._slot.displayIndex===0:this._slot.displayIndex===h.length){for(var u=0,f=this._slotChildActions[this._slot.name];u0?n:r;m.inheritAnimation=a._getBoolean(e,a.INHERIT_FFD,true);this._parsePivot(e,m);var c=a._getString(e,a.SHARE,"");if(c.length>0){var p=this._meshs[c];m.offset=p.offset;m.weight=p.weight}else{this._parseMesh(e,m);this._meshs[m.name]=m}break;case 3:var d=this._parseBoundingBox(e);if(d!==null){var y=i=t.DragonBones.webAssembly?new Module["BoundingBoxDisplayData"]:t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=r;y.path=n.length>0?n:r;y.boundingBox=d}break}if(i!==null){i.parent=this._armature;if(a.TRANSFORM in e){this._parseTransform(e[a.TRANSFORM],i.transform,this._armature.scale)}}return i};a.prototype._parsePivot=function(t,e){if(a.PIVOT in t){var i=t[a.PIVOT];e.pivot.x=a._getNumber(i,a.X,0);e.pivot.y=a._getNumber(i,a.Y,0)}else{e.pivot.x=.5;e.pivot.y=.5}};a.prototype._parseMesh=function(e,i){var r=e[a.VERTICES];var n=e[a.UVS];var s=e[a.TRIANGLES];var o=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var l=t.DragonBones.webAssembly?this._floatArrayJson:this._data.floatArray;var h=Math.floor(r.length/2);var u=Math.floor(s.length/3);var f=l.length;var _=f+h*2;i.offset=o.length;o.length+=1+1+1+1+u*3;o[i.offset+0]=h;o[i.offset+1]=u;o[i.offset+2]=f;for(var m=0,c=u*3;mn.width){n.width=h}if(un.height){n.height=u}}}return n};a.prototype._parseAnimation=function(e){var i=t.DragonBones.webAssembly?new Module["AnimationData"]:t.BaseObject.borrowObject(t.AnimationData);i.frameCount=Math.max(a._getNumber(e,a.DURATION,1),1);i.playTimes=a._getNumber(e,a.PLAY_TIMES,1);i.duration=i.frameCount/this._armature.frameRate;i.fadeInTime=a._getNumber(e,a.FADE_IN_TIME,0);i.scale=a._getNumber(e,a.SCALE,1);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length<1){i.name=a.DEFAULT_NAME}if(t.DragonBones.webAssembly){i.frameIntOffset=this._frameIntArrayJson.length;i.frameFloatOffset=this._frameFloatArrayJson.length;i.frameOffset=this._frameArrayJson.length}else{i.frameIntOffset=this._data.frameIntArray.length;i.frameFloatOffset=this._data.frameFloatArray.length;i.frameOffset=this._data.frameArray.length}this._animation=i;if(a.FRAME in e){var r=e[a.FRAME];var n=r.length;if(n>0){for(var s=0,o=0;s0){this._actionFrames.sort(this._sortActionFrame);var D=this._animation.actionTimeline=t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);var T=t.DragonBones.webAssembly?this._timelineArrayJson:this._data.timelineArray;var n=this._actionFrames.length;D.type=0;D.offset=T.length;T.length+=1+1+1+1+1+n;T[D.offset+0]=100;T[D.offset+1]=0;T[D.offset+2]=n;T[D.offset+3]=0;T[D.offset+4]=0;this._timeline=D;if(n===1){D.frameIndicesOffset=-1;T[D.offset+5+0]=this._parseCacheActionFrame(this._actionFrames[0])-this._animation.frameOffset}else{var A=this._animation.frameCount+1;var O=this._data.frameIndices;if(t.DragonBones.webAssembly){D.frameIndicesOffset=O.size();for(var x=0;x0){if(a.CURVE in t){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(t[a.CURVE],this._helpArray);r.length+=1+1+this._helpArray.length;r[n+1]=2;r[n+2]=s;for(var o=0;o0){var l=this._armature.sortedSlots.length;var h=new Array(l-o.length/2);var u=new Array(l);for(var f=0;f0?l>=this._prevRotation:l<=this._prevRotation){this._prevTweenRotate=this._prevTweenRotate>0?this._prevTweenRotate-1:this._prevTweenRotate+1}l=this._prevRotation+l-this._prevRotation+t.Transform.PI_D*this._prevTweenRotate}}this._prevTweenRotate=a._getNumber(e,a.TWEEN_ROTATE,0);this._prevRotation=l;var h=n.length;n.length+=6;n[h++]=this._helpTransform.x;n[h++]=this._helpTransform.y;n[h++]=l;n[h++]=this._helpTransform.skew;n[h++]=this._helpTransform.scaleX;n[h++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,i,this._bone,this._slot);return o};a.prototype._parseSlotDisplayIndexFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var s=this._parseFrame(e,i,r,n);n.length+=1;n[s+1]=a._getNumber(e,a.DISPLAY_INDEX,0);this._parseActionDataInFrame(e,i,this._slot.parent,this._slot);return s};a.prototype._parseSlotColorFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameIntArrayJson:this._data.frameIntArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=this._parseTweenFrame(e,i,r,o);var h=-1;if(a.COLOR in e){var u=e[a.COLOR];for(var f in u){f;this._parseColorTransform(u,this._helpColorTransform);h=n.length;n.length+=8;n[h++]=Math.round(this._helpColorTransform.alphaMultiplier*100);n[h++]=Math.round(this._helpColorTransform.redMultiplier*100);n[h++]=Math.round(this._helpColorTransform.greenMultiplier*100);n[h++]=Math.round(this._helpColorTransform.blueMultiplier*100);n[h++]=Math.round(this._helpColorTransform.alphaOffset);n[h++]=Math.round(this._helpColorTransform.redOffset);n[h++]=Math.round(this._helpColorTransform.greenOffset);n[h++]=Math.round(this._helpColorTransform.blueOffset);h-=8;break}}if(h<0){if(this._defalultColorOffset<0){this._defalultColorOffset=h=n.length;n.length+=8;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=0;n[h++]=0;n[h++]=0;n[h++]=0}h=this._defalultColorOffset}var _=s.length;s.length+=1;s[_]=h;return l};a.prototype._parseSlotFFDFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameFloatArrayJson:this._data.frameFloatArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=s.length;var h=this._parseTweenFrame(e,i,r,o);var u=a.VERTICES in e?e[a.VERTICES]:null;var f=a._getNumber(e,a.OFFSET,0);var _=n[this._mesh.offset+0];var m=0;var c=0;var p=0;var d=0;if(this._mesh.weight!==null){var y=this._weightSlotPose[this._mesh.name];this._helpMatrixA.copyFromArray(y,0);s.length+=this._mesh.weight.count*2;p=this._mesh.weight.offset+2+this._mesh.weight.bones.length}else{s.length+=_*2}for(var g=0;g<_*2;g+=2){if(u===null){m=0;c=0}else{if(g=u.length){m=0}else{m=u[g-f]}if(g+1=u.length){c=0}else{c=u[g+1-f]}}if(this._mesh.weight!==null){var v=this._weightBonePoses[this._mesh.name];var b=this._weightBoneIndices[this._mesh.name];var D=n[p++];this._helpMatrixA.transformPoint(m,c,this._helpPoint,true);m=this._helpPoint.x;c=this._helpPoint.y;for(var T=0;T=0||a.DATA_VERSIONS.indexOf(n)>=0){var s=t.DragonBones.webAssembly?new Module["DragonBonesData"]:t.BaseObject.borrowObject(t.DragonBonesData);s.version=r;s.name=a._getString(e,a.NAME,"");s.frameRate=a._getNumber(e,a.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(a.ARMATURE in e){this._defalultColorOffset=-1;this._data=s;this._parseArray(e);var o=e[a.ARMATURE];for(var l=0,h=o;l0){this._parseWASMArray()}this._data=null}this._rawTextureAtlasIndex=0;if(a.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[a.TEXTURE_ATLAS]}else{this._rawTextureAtlases=null}return s}else{console.assert(false,"Nonsupport data version.")}return null};a.prototype.parseTextureAtlasData=function(e,i,r){if(r===void 0){r=0}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,i,r);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}i.width=a._getNumber(e,a.WIDTH,0);i.height=a._getNumber(e,a.HEIGHT,0);i.name=a._getString(e,a.NAME,"");i.imagePath=a._getString(e,a.IMAGE_PATH,"");if(r>0){i.scale=r}else{r=i.scale=a._getNumber(e,a.SCALE,i.scale)}r=1/r;if(a.SUB_TEXTURE in e){var s=e[a.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){u.frame=t.DragonBones.webAssembly?Module["TextureData"].createRectangle():t.TextureData.createRectangle();u.frame.x=a._getNumber(h,a.FRAME_X,0)*r;u.frame.y=a._getNumber(h,a.FRAME_Y,0)*r;u.frame.width=f*r;u.frame.height=_*r}i.addTexture(u)}}return true};a.getInstance=function(){if(a._objectDataParserInstance===null){a._objectDataParserInstance=new a}return a._objectDataParserInstance};a._objectDataParserInstance=null;return a}(t.DataParser);t.ObjectDataParser=e;var i=function(){function t(){this.frameStart=0;this.actions=[]}return t}()})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.prototype._inRange=function(t,e,i){return e<=t&&t<=i};i.prototype._decodeUTF8=function(t){var e=-1;var i=-1;var a=65533;var r=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>r){var f=t[r++];if(f===e){if(l!==0){s=a}else{s=i}}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;r--;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!==i){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};i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255){return encodeURI(t)}}return t};i.prototype._parseBinaryTimeline=function(e,i,a){if(a===void 0){a=null}var r=a!==null?a:t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);r.type=e;r.offset=i;this._timeline=r;var n=this._timelineArray[r.offset+2];if(n===1){r.frameIndicesOffset=-1}else{var s=this._animation.frameCount+1;var o=this._data.frameIndices;if(t.DragonBones.webAssembly){r.frameIndicesOffset=o.size();for(var l=0;l=0){var r=t.DragonBones.webAssembly?new Module["WeightData"]:t.BaseObject.borrowObject(t.WeightData);var n=this._intArray[i.offset+0];var s=this._intArray[a+0];r.offset=a;if(t.DragonBones.webAssembly){r.bones.resize(s,null);for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(i)}}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(i);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=r;t.data=n;t.armature=s;t.skin=null;if(a.length>0){t.skin=s.getSkin(a);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(a);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};i.prototype._buildBones=function(e,i){var a=e.armature.sortedBones;for(var r=0;r<(t.DragonBones.webAssembly?a.size():a.length);++r){var n=t.DragonBones.webAssembly?a.get(r):a[r];var s=t.DragonBones.webAssembly?new Module["Bone"]:t.BaseObject.borrowObject(t.Bone);s.init(n);if(n.parent!==null){i.addBone(s,n.parent.name)}else{i.addBone(s)}var o=n.constraints;for(var l=0;l<(t.DragonBones.webAssembly?o.size():o.length);++l){var h=t.DragonBones.webAssembly?o.get(l):o[l];var u=i.getBone(h.target.name);if(u===null){continue}var f=h;var _=t.DragonBones.webAssembly?new Module["IKConstraint"]:t.BaseObject.borrowObject(t.IKConstraint);var m=f.root!==null?i.getBone(f.root.name):null;_.target=u;_.bone=s;_.root=m;_.bendPositive=f.bendPositive;_.scaleEnabled=f.scaleEnabled;_.weight=f.weight;if(m!==null){m.addConstraint(_)}else{s.addConstraint(_)}}}};i.prototype._buildSlots=function(t,e){var i=t.skin;var a=t.armature.defaultSkin;if(i===null||a===null){return}var r={};for(var n in a.displays){var s=a.displays[n];r[n]=s}if(i!==a){for(var n in i.displays){var s=i.displays[n];r[n]=s}}for(var o=0,l=t.armature.sortedSlots;o0){s.texture=this._getTextureData(t.textureAtlasName,e.path)}if(i!==null&&i.type===2&&this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 2:var o=e;if(o.texture===null){o.texture=this._getTextureData(r,o.path)}else if(t!==null&&t.textureAtlasName.length>0){o.texture=this._getTextureData(t.textureAtlasName,o.path)}if(this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 1:var l=e;var h=this.buildArmature(l.path,r,null,t!==null?t.textureAtlasName:null);if(h!==null){h.inheritAnimation=l.inheritAnimation;if(!h.inheritAnimation){var u=l.actions.length>0?l.actions:h.armatureData.defaultActions;if(u.length>0){for(var f=0,_=u;f<_.length;f++){var m=_[f];h._bufferAction(m,true)}}else{h.animation.play()}}l.armature=h.armatureData}n=h;break}return n};i.prototype._replaceSlotDisplay=function(t,e,i,a){if(a<0){a=i.displayIndex}if(a<0){a=0}var r=i.displayList;if(r.length<=a){r.length=a+1;for(var n=0,s=r.length;n=0){continue}var s=e.displays[n.name];var o=n.displayList;o.length=s.length;for(var l=0,h=s.length;l0?this.width:e.width;var a=this.height>0?this.height:e.height;for(var r in this.textures){var n=this.textures[r];var s=Math.min(n.region.width,i-n.region.x);var o=Math.min(n.region.height,a-n.region.y);if(n.renderTexture===null){n.renderTexture=new egret.Texture;if(n.rotated){n.renderTexture.$initData(n.region.x,n.region.y,o,s,0,0,o,s,i,a)}else{n.renderTexture.$initData(n.region.x,n.region.y,s,o,0,0,s,o,i,a)}}n.renderTexture._bitmapData=e}}else{for(var r in this.textures){var n=this.textures[r];n.renderTexture=null}}},enumerable:true,configurable:true});a.prototype.dispose=function(){console.warn("已废弃,请参考 @see");this.returnToPool()};Object.defineProperty(a.prototype,"texture",{get:function(){return this.renderTexture},enumerable:true,configurable:true});return a}(t.TextureAtlasData);t.EgretTextureAtlasData=e;var i=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.renderTexture=null;return e}e.toString=function(){return"[class dragonBones.EgretTextureData]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.renderTexture!==null){}this.renderTexture=null};return e}(t.TextureData);t.EgretTextureData=i})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}Object.defineProperty(i.prototype,"eventObject",{get:function(){return this.data},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationName",{get:function(){var t=this.eventObject.animationState;return t!==null?t.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"armature",{get:function(){return this.eventObject.armature},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"bone",{get:function(){return this.eventObject.bone},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"slot",{get:function(){return this.eventObject.slot},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationState",{get:function(){return this.eventObject.animationState},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"frameLabel",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"sound",{get:function(){return this.eventObject.name},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"movementID",{get:function(){return this.animationName},enumerable:true,configurable:true});i.START=t.EventObject.START;i.LOOP_COMPLETE=t.EventObject.LOOP_COMPLETE;i.COMPLETE=t.EventObject.COMPLETE;i.FADE_IN=t.EventObject.FADE_IN;i.FADE_IN_COMPLETE=t.EventObject.FADE_IN_COMPLETE;i.FADE_OUT=t.EventObject.FADE_OUT;i.FADE_OUT_COMPLETE=t.EventObject.FADE_OUT_COMPLETE;i.FRAME_EVENT=t.EventObject.FRAME_EVENT;i.SOUND_EVENT=t.EventObject.SOUND_EVENT;i.ANIMATION_FRAME_EVENT=t.EventObject.FRAME_EVENT;i.BONE_FRAME_EVENT=t.EventObject.FRAME_EVENT;i.MOVEMENT_FRAME_EVENT=t.EventObject.FRAME_EVENT;i.SOUND=t.EventObject.SOUND_EVENT;return i}(egret.Event);t.EgretEvent=e;var i=function(i){__extends(a,i);function a(){var t=i!==null&&i.apply(this,arguments)||this;t._disposeProxy=false;t._armature=null;t._debugDrawer=null;return t}a.prototype.init=function(t){this._armature=t};a.prototype.clear=function(){this._disposeProxy=false;this._armature=null;this._debugDrawer=null};a.prototype.dispose=function(t){if(t===void 0){t=true}this._disposeProxy=t;if(this._armature!==null){this._armature.dispose();this._armature=null}};a.prototype.debugUpdate=function(t){if(t){if(this._debugDrawer===null){this._debugDrawer=new egret.Sprite}this.addChild(this._debugDrawer);this._debugDrawer.graphics.clear();for(var e=0,i=this._armature.getBones();e=0&&this._display!==null&&i!==null){if(this._armature.replacedTexture!==null&&this._rawDisplayDatas.indexOf(this._displayData)>=0){var a=i.parent;if(this._armature._replaceTextureAtlasData===null){a=t.BaseObject.borrowObject(t.EgretTextureAtlasData);a.copyFrom(i.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}i=a.getTexture(i.name)}if(i.renderTexture!==null){if(e!==null){var r=e.parent.parent;var n=r.intArray;var s=r.floatArray;var o=n[e.offset+0];var l=n[e.offset+1];var h=n[e.offset+2];var u=h+o*2;var f=this._renderDisplay;var _=f.$renderNode;_.uvs.length=o*2;_.vertices.length=o*2;_.indices.length=l*3;for(var m=0,c=o*2;m0;var e=this._meshData;var i=e.weight;var a=this._renderDisplay;var r=a.$renderNode;if(i!==null){var n=e.parent.parent;var s=n.intArray;var o=n.floatArray;var l=s[e.offset+0];var h=s[i.offset+1];for(var u=0,f=0,_=i.offset+2+i.bones.length,m=h,c=0;u void, target: any): void { + this.addEventListener(type, listener, target); + } + /** + * @inheritDoc + */ + public removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void { + this.removeEventListener(type, listener, target); + } + /** + * @inheritDoc + */ + public get armature(): Armature { + return this._armature; + } + /** + * @inheritDoc + */ + public get animation(): Animation { + return this._armature.animation; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.EgretFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + public advanceTimeBySelf(on: boolean): void { + if (on) { + this._armature.clock = EgretFactory.clock; + } + else { + this._armature.clock = null; + } + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature + */ + export type FastArmature = Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Bone + */ + export type FastBone = Bone; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Slot + */ + export type FastSlot = Slot; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Animation + */ + export type FastAnimation = Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.AnimationState + */ + export type FastAnimationState = AnimationState; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class Event extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class ArmatureEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class AnimationEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class FrameEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretEvent + */ + export class SoundEvent extends EgretEvent { } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + export class EgretTextureAtlas extends EgretTextureAtlasData { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.EgretTextureAtlas]"; + } + + public constructor(texture: egret.Texture, rawData: any, scale: number = 1) { + super(); + console.warn("已废弃,请参考 @see"); + + this._onClear(); + + ObjectDataParser.getInstance().parseTextureAtlasData(rawData, this, scale); + this.renderTexture = texture; + } + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretTextureAtlasData + */ + export class EgretSheetAtlas extends EgretTextureAtlas { + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + export class SoundEventManager { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager + */ + public static getInstance(): EgretArmatureDisplay { + console.warn("已废弃,请参考 @see"); + return EgretFactory.factory.soundEventManager; + } + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + export class AnimationCacheManager { + } +} \ No newline at end of file diff --git a/reference/Egret/5.x/src/dragonBones/egret/EgretFactory.ts b/reference/Egret/5.x/src/dragonBones/egret/EgretFactory.ts new file mode 100644 index 0000000..acc587f --- /dev/null +++ b/reference/Egret/5.x/src/dragonBones/egret/EgretFactory.ts @@ -0,0 +1,232 @@ +namespace dragonBones { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretFactory extends BaseFactory { + private static _time: number = 0; + private static _dragonBones: DragonBones = null as any; + private static _factory: EgretFactory | null = null; + private static _clockHandler(time: number): boolean { + time *= 0.001; + const passedTime = time - EgretFactory._time; + EgretFactory._dragonBones.advanceTime(passedTime); + EgretFactory._time = time; + + return false; + } + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + public static get clock(): WorldClock { + return EgretFactory._dragonBones.clock; + } + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public static get factory(): EgretFactory { + if (EgretFactory._factory === null) { + EgretFactory._factory = new EgretFactory(); + } + + return EgretFactory._factory; + } + /** + * @inheritDoc + */ + public constructor() { + super(); + + if (EgretFactory._dragonBones === null) { + const eventManager = new EgretArmatureDisplay(); + EgretFactory._dragonBones = new DragonBones(eventManager); + EgretFactory._dragonBones.clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretFactory._clockHandler, EgretFactory); + } + + this._dragonBones = EgretFactory._dragonBones; + } + /** + * @private + */ + protected _isSupportMesh(): boolean { + if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { + return true; + } + + console.warn("Canvas can not support mesh, please change renderMode to webgl."); + + return false; + } + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: EgretTextureAtlasData | null, textureAtlas: egret.Texture): EgretTextureAtlasData { + if (textureAtlasData !== null) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = BaseObject.borrowObject(EgretTextureAtlasData); + } + + return textureAtlasData; + } + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature { + const armature = BaseObject.borrowObject(Armature); + const armatureDisplay = new EgretArmatureDisplay(); + + armature.init( + dataPackage.armature, + armatureDisplay, armatureDisplay, this._dragonBones + ); + + return armature; + } + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot { + dataPackage; + armature; + const slot = BaseObject.borrowObject(EgretSlot); + slot.init( + slotData, displays, + new egret.Bitmap(), new egret.Mesh() + ); + + return slot; + } + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + public buildArmatureDisplay(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null, textureAtlasName: string | null = null): EgretArmatureDisplay | null { + const armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.display as EgretArmatureDisplay; + } + + return null; + } + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public getTextureDisplay(textureName: string, textureAtlasName: string | null = null): egret.Bitmap | null { + const textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName) as EgretTextureData; + if (textureData !== null && textureData.renderTexture !== null) { + return new egret.Bitmap(textureData.renderTexture); + } + + return null; + } + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public get soundEventManager(): EgretArmatureDisplay { + return this._dragonBones.eventManager as EgretArmatureDisplay; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + public addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName: string | null = null): void { + console.warn("已废弃,请参考 @see"); + this.addDragonBonesData(dragonBonesData, dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getDragonBonesData() + */ + public getSkeletonData(dragonBonesName: string) { + console.warn("已废弃,请参考 @see"); + return this.getDragonBonesData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + public removeSkeletonData(dragonBonesName: string): void { + console.warn("已废弃,请参考 @see"); + this.removeDragonBonesData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#addTextureAtlasData() + */ + public addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName: string | null = null): void { + console.warn("已废弃,请参考 @see"); + this.addTextureAtlasData(textureAtlasData, dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#getTextureAtlasData() + */ + public getTextureAtlas(dragonBonesName: string) { + console.warn("已废弃,请参考 @see"); + return this.getTextureAtlasData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + public removeTextureAtlas(dragonBonesName: string): void { + console.warn("已废弃,请参考 @see"); + this.removeTextureAtlasData(dragonBonesName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#buildArmature() + */ + public buildFastArmature(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null): FastArmature | null { + console.warn("已废弃,请参考 @see"); + return this.buildArmature(armatureName, dragonBonesName, skinName); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#clear() + */ + public dispose(): void { + console.warn("已废弃,请参考 @see"); + this.clear(); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EgretFactory#soundEventManager() + */ + public get soundEventManater(): EgretArmatureDisplay { + return this.soundEventManager; + } + } +} \ No newline at end of file diff --git a/reference/Egret/5.x/src/dragonBones/egret/EgretSlot.ts b/reference/Egret/5.x/src/dragonBones/egret/EgretSlot.ts new file mode 100644 index 0000000..f36c5d5 --- /dev/null +++ b/reference/Egret/5.x/src/dragonBones/egret/EgretSlot.ts @@ -0,0 +1,317 @@ +namespace dragonBones { + /** + * Egret 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretSlot extends Slot { + public static toString(): string { + return "[class dragonBones.EgretSlot]"; + } + /** + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 + * @language zh_CN + */ + public transformUpdateEnabled: boolean = false; + + private _renderDisplay: egret.DisplayObject = null as any; + private _colorFilter: egret.ColorMatrixFilter | null = null; + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + this._renderDisplay = null as any; // + this._colorFilter = null; + } + /** + * @private + */ + protected _initDisplay(value: any): void { + value; + } + /** + * @private + */ + protected _disposeDisplay(value: any): void { + value; + } + /** + * @private + */ + protected _onUpdateDisplay(): void { + this._renderDisplay = (this._display !== null ? this._display : this._rawDisplay) as egret.DisplayObject; + } + /** + * @private + */ + protected _addDisplay(): void { + const container = this._armature.display as EgretArmatureDisplay; + container.addChild(this._renderDisplay); + } + /** + * @private + */ + protected _replaceDisplay(value: any): void { + const container = this._armature.display as EgretArmatureDisplay; + const prevDisplay = value as egret.DisplayObject; + container.addChild(this._renderDisplay); + container.swapChildren(this._renderDisplay, prevDisplay); + container.removeChild(prevDisplay); + } + /** + * @private + */ + protected _removeDisplay(): void { + this._renderDisplay.parent.removeChild(this._renderDisplay); + } + /** + * @private + */ + protected _updateZOrder(): void { + const container = this._armature.display as EgretArmatureDisplay; + const index = container.getChildIndex(this._renderDisplay); + if (index === this._zOrder) { + return; + } + + container.addChildAt(this._renderDisplay, this._zOrder); + } + /** + * @internal + * @private + */ + public _updateVisible(): void { + this._renderDisplay.visible = this._parent.visible; + } + /** + * @private + */ + protected _updateBlendMode(): void { + switch (this._blendMode) { + case BlendMode.Normal: + this._renderDisplay.blendMode = egret.BlendMode.NORMAL; + break; + + case BlendMode.Add: + this._renderDisplay.blendMode = egret.BlendMode.ADD; + break; + + case BlendMode.Erase: + this._renderDisplay.blendMode = egret.BlendMode.ERASE; + break; + + default: + break; + } + } + /** + * @private + */ + protected _updateColor(): void { + if ( + this._colorTransform.redMultiplier !== 1.0 || + this._colorTransform.greenMultiplier !== 1.0 || + this._colorTransform.blueMultiplier !== 1.0 || + this._colorTransform.redOffset !== 0 || + this._colorTransform.greenOffset !== 0 || + this._colorTransform.blueOffset !== 0 || + this._colorTransform.alphaOffset !== 0 + ) { + if (this._colorFilter === null) { + this._colorFilter = new egret.ColorMatrixFilter(); + } + + const colorMatrix = this._colorFilter.matrix; + colorMatrix[0] = this._colorTransform.redMultiplier; + colorMatrix[6] = this._colorTransform.greenMultiplier; + colorMatrix[12] = this._colorTransform.blueMultiplier; + colorMatrix[18] = this._colorTransform.alphaMultiplier; + colorMatrix[4] = this._colorTransform.redOffset; + colorMatrix[9] = this._colorTransform.greenOffset; + colorMatrix[14] = this._colorTransform.blueOffset; + colorMatrix[19] = this._colorTransform.alphaOffset; + this._colorFilter.matrix = colorMatrix; + + let filters = this._renderDisplay.filters; + if (!filters) { // null or undefined? + filters = []; + } + + if (filters.indexOf(this._colorFilter) < 0) { + filters.push(this._colorFilter); + } + + this._renderDisplay.$setAlpha(1.0); + this._renderDisplay.filters = filters; + } + else { + if (this._colorFilter !== null) { + this._colorFilter = null; + this._renderDisplay.filters = null as any; + } + + this._renderDisplay.$setAlpha(this._colorTransform.alphaMultiplier); + } + } + /** + * @private + */ + protected _updateFrame(): void { + const meshData = this._display === this._meshDisplay ? this._meshData : null; + let currentTextureData = this._textureData as (EgretTextureData | null); + + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + if (this._armature.replacedTexture !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { // Update replaced texture atlas. + let currentTextureAtlasData = currentTextureData.parent as EgretTextureAtlasData; + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = BaseObject.borrowObject(EgretTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData as EgretTextureAtlasData; + } + + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name) as EgretTextureData; + } + + if (currentTextureData.renderTexture !== null) { + if (meshData !== null) { // Mesh. + const data = meshData.parent.parent; + const intArray = data.intArray; + const floatArray = data.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const triangleCount = intArray[meshData.offset + BinaryOffset.MeshTriangleCount]; + const verticesOffset = intArray[meshData.offset + BinaryOffset.MeshFloatOffset]; + const uvOffset = verticesOffset + vertexCount * 2; + + const meshDisplay = this._renderDisplay as egret.Mesh; + const meshNode = meshDisplay.$renderNode as egret.sys.MeshNode; + + meshNode.uvs.length = vertexCount * 2; + meshNode.vertices.length = vertexCount * 2; + meshNode.indices.length = triangleCount * 3; + + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[verticesOffset + i]; + meshNode.uvs[i] = floatArray[uvOffset + i]; + } + + for (let i = 0; i < triangleCount * 3; ++i) { + meshNode.indices[i] = intArray[meshData.offset + BinaryOffset.MeshVertexIndices + i]; + } + + meshDisplay.texture = currentTextureData.renderTexture; + meshDisplay.$setAnchorOffsetX(this._pivotX); + meshDisplay.$setAnchorOffsetY(this._pivotY); + meshDisplay.$updateVertices(); + } + else { // Normal texture. + const normalDisplay = this._renderDisplay as egret.Bitmap; + normalDisplay.texture = currentTextureData.renderTexture; + normalDisplay.$setAnchorOffsetX(this._pivotX); + normalDisplay.$setAnchorOffsetY(this._pivotY); + } + + return; + } + } + + if (meshData !== null) { + const meshDisplay = this._renderDisplay as egret.Mesh; + meshDisplay.texture = null as any; + meshDisplay.x = 0.0; + meshDisplay.y = 0.0; + } + else { + const normalDisplay = this._renderDisplay as egret.Bitmap; + normalDisplay.texture = null as any; + normalDisplay.x = 0.0; + normalDisplay.y = 0.0; + } + } + /** + * @private + */ + protected _updateMesh(): void { + const hasFFD = this._ffdVertices.length > 0; + const meshData = this._meshData as MeshDisplayData; + const weightData = meshData.weight; + const meshDisplay = this._renderDisplay as egret.Mesh; + const meshNode = meshDisplay.$renderNode as egret.sys.MeshNode; + + if (weightData !== null) { + const data = meshData.parent.parent; + const intArray = data.intArray; + const floatArray = data.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const weightFloatOffset = intArray[weightData.offset + BinaryOffset.WeigthFloatOffset]; + + for ( + let i = 0, iD = 0, iB = weightData.offset + BinaryOffset.WeigthBoneIndices + weightData.bones.length, iV = weightFloatOffset, iF = 0; + i < vertexCount; + ++i + ) { + const boneCount = intArray[iB++]; + let xG = 0.0, yG = 0.0; + for (let j = 0; j < boneCount; ++j) { + const boneIndex = intArray[iB++]; + const bone = this._meshBones[boneIndex]; + if (bone !== null) { + const matrix = bone.globalTransformMatrix; + const weight = floatArray[iV++]; + let xL = floatArray[iV++]; + let yL = floatArray[iV++]; + + if (hasFFD) { + xL += this._ffdVertices[iF++]; + yL += this._ffdVertices[iF++]; + } + + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + + meshNode.vertices[iD++] = xG; + meshNode.vertices[iD++] = yG; + } + + meshDisplay.$updateVertices(); + } + else if (hasFFD) { + const data = meshData.parent.parent; + const intArray = data.intArray; + const floatArray = data.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const vertexOffset = intArray[meshData.offset + BinaryOffset.MeshFloatOffset]; + + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + meshNode.vertices[i] = floatArray[vertexOffset + i] + this._ffdVertices[i]; + } + + meshDisplay.$updateVertices(); + } + } + /** + * @private + */ + protected _updateTransform(isSkinnedMesh: boolean): void { + if (isSkinnedMesh) { // Identity transform. + const transformationMatrix = this._renderDisplay.matrix; + transformationMatrix.identity(); + this._renderDisplay.$setMatrix(transformationMatrix, this.transformUpdateEnabled); + } + else { + const globalTransformMatrix = this.globalTransformMatrix; + this._renderDisplay.$setMatrix((globalTransformMatrix as any) as egret.Matrix, this.transformUpdateEnabled); + } + } + } +} \ No newline at end of file diff --git a/reference/Egret/5.x/src/dragonBones/egret/EgretTextureAtlasData.ts b/reference/Egret/5.x/src/dragonBones/egret/EgretTextureAtlasData.ts new file mode 100644 index 0000000..9edff5b --- /dev/null +++ b/reference/Egret/5.x/src/dragonBones/egret/EgretTextureAtlasData.ts @@ -0,0 +1,130 @@ +namespace dragonBones { + /** + * Egret 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretTextureAtlasData extends TextureAtlasData { + /** + * @private + */ + public static toString(): string { + return "[class dragonBones.EgretTextureAtlasData]"; + } + + private _renderTexture: egret.Texture | null = null; // Initial value. + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + if (this._renderTexture !== null) { + //this.texture.dispose(); + } + + this._renderTexture = null; + } + /** + * @private + */ + public createTexture(): TextureData { + return BaseObject.borrowObject(EgretTextureData); + } + /** + * Egret 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get renderTexture(): egret.Texture | null { + return this._renderTexture; + } + public set renderTexture(value: egret.Texture | null) { + if (this._renderTexture === value) { + return; + } + + this._renderTexture = value; + + if (this._renderTexture !== null) { + const bitmapData = this._renderTexture.bitmapData; + const textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; + const textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; + + for (let k in this.textures) { + const textureData = this.textures[k] as EgretTextureData; + const subTextureWidth = Math.min(textureData.region.width, textureAtlasWidth - textureData.region.x); // TODO need remove + const subTextureHeight = Math.min(textureData.region.height, textureAtlasHeight - textureData.region.y); // TODO need remove + + if (textureData.renderTexture === null) { + textureData.renderTexture = new egret.Texture(); + if (textureData.rotated) { + textureData.renderTexture.$initData( + textureData.region.x, textureData.region.y, + subTextureHeight, subTextureWidth, + 0, 0, + subTextureHeight, subTextureWidth, + textureAtlasWidth, textureAtlasHeight + ); + } + else { + textureData.renderTexture.$initData( + textureData.region.x, textureData.region.y, + subTextureWidth, subTextureHeight, + 0, 0, + subTextureWidth, subTextureHeight, + textureAtlasWidth, textureAtlasHeight + ); + } + } + + textureData.renderTexture._bitmapData = bitmapData; + } + } + else { + for (let k in this.textures) { + const textureData = this.textures[k] as EgretTextureData; + textureData.renderTexture = null; + } + } + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + public dispose(): void { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + } + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeTextureAtlasData() + */ + public get texture() { + return this.renderTexture; + } + } + /** + * @private + */ + export class EgretTextureData extends TextureData { + public static toString(): string { + return "[class dragonBones.EgretTextureData]"; + } + + public renderTexture: egret.Texture | null = null; // Initial value. + + protected _onClear(): void { + super._onClear(); + + if (this.renderTexture !== null) { + //this.texture.dispose(); + } + + this.renderTexture = null; + } + } +} \ No newline at end of file diff --git a/reference/Egret/5.x/tsconfig.json b/reference/Egret/5.x/tsconfig.json new file mode 100644 index 0000000..19797f3 --- /dev/null +++ b/reference/Egret/5.x/tsconfig.json @@ -0,0 +1,76 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": false, + "declaration": true, + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "outFile": "out/dragonBones.js", + "lib": [ + "es5", + "dom", + "es2015.promise" + ] + }, + "exclude": [ + "node_modules", + "out" + ], + "files": [ + "./libs/egret-wasm.d.ts", + + "../../DragonBones/src/dragonBones/core/DragonBones.ts", + "../../DragonBones/src/dragonBones/core/BaseObject.ts", + + "../../DragonBones/src/dragonBones/geom/Matrix.ts", + "../../DragonBones/src/dragonBones/geom/Transform.ts", + "../../DragonBones/src/dragonBones/geom/ColorTransform.ts", + "../../DragonBones/src/dragonBones/geom/Point.ts", + "../../DragonBones/src/dragonBones/geom/Rectangle.ts", + + "../../DragonBones/src/dragonBones/model/UserData.ts", + "../../DragonBones/src/dragonBones/model/DragonBonesData.ts", + "../../DragonBones/src/dragonBones/model/ArmatureData.ts", + "../../DragonBones/src/dragonBones/model/ConstraintData.ts", + "../../DragonBones/src/dragonBones/model/DisplayData.ts", + "../../DragonBones/src/dragonBones/model/BoundingBoxData.ts", + "../../DragonBones/src/dragonBones/model/AnimationData.ts", + "../../DragonBones/src/dragonBones/model/AnimationConfig.ts", + "../../DragonBones/src/dragonBones/model/TextureAtlasData.ts", + + "../../DragonBones/src/dragonBones/armature/IArmatureProxy.ts", + "../../DragonBones/src/dragonBones/armature/Armature.ts", + "../../DragonBones/src/dragonBones/armature/TransformObject.ts", + "../../DragonBones/src/dragonBones/armature/Bone.ts", + "../../DragonBones/src/dragonBones/armature/Slot.ts", + "../../DragonBones/src/dragonBones/armature/Constraint.ts", + + "../../DragonBones/src/dragonBones/animation/IAnimatable.ts", + "../../DragonBones/src/dragonBones/animation/WorldClock.ts", + "../../DragonBones/src/dragonBones/animation/Animation.ts", + "../../DragonBones/src/dragonBones/animation/AnimationState.ts", + "../../DragonBones/src/dragonBones/animation/BaseTimelineState.ts", + "../../DragonBones/src/dragonBones/animation/TimelineState.ts", + + "../../DragonBones/src/dragonBones/event/EventObject.ts", + "../../DragonBones/src/dragonBones/event/IEventDispatcher.ts", + + "../../DragonBones/src/dragonBones/parser/DataParser.ts", + "../../DragonBones/src/dragonBones/parser/ObjectDataParser.ts", + "../../DragonBones/src/dragonBones/parser/BinaryDataParser.ts", + + "../../DragonBones/src/dragonBones/factory/BaseFactory.ts", + + "./src/dragonBones/egret/EgretTextureAtlasData.ts", + "./src/dragonBones/egret/EgretArmatureDisplay.ts", + "./src/dragonBones/egret/EgretSlot.ts", + "./src/dragonBones/egret/EgretFactory.ts" + ] +} \ No newline at end of file diff --git a/reference/Egret/5.x/tslint.json b/reference/Egret/5.x/tslint.json new file mode 100644 index 0000000..eeb58d1 --- /dev/null +++ b/reference/Egret/5.x/tslint.json @@ -0,0 +1,15 @@ +{ + "rules": { + "no-unused-expression": true, + "no-unreachable": true, + "no-duplicate-variable": true, + "no-duplicate-key": true, + "no-unused-variable": true, + "curly": false, + "class-name": true, + "triple-equals": true, + "semicolon": [ + true + ] + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/.wing/launch.json b/reference/Egret/Demos/.wing/launch.json new file mode 100644 index 0000000..2c157d6 --- /dev/null +++ b/reference/Egret/Demos/.wing/launch.json @@ -0,0 +1,30 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Wing 内置播放器调试", + "type": "chrome", + "request": "launch", + "file": "index.html", + //"url": "http://mysite.com/index.html", + "runtimeExecutable": "${execPath}", + "sourceMaps": true, + "webRoot": "${workspaceRoot}", + "preLaunchTask":"build", + "port":5010 + }, + { + "name": "使用本机 Chrome 调试", + "type": "chrome", + "request": "launch", + "file": "index.html", + //"url": "http://mysite.com/index.html", + "runtimeExecutable": "", + "sourceMaps": true, + "webRoot": "${workspaceRoot}", + "preLaunchTask":"build", + "userDataDir":"${tmpdir}", + "port":5010 + } + ] +} \ No newline at end of file diff --git a/reference/Egret/Demos/.wing/settings.json b/reference/Egret/Demos/.wing/settings.json new file mode 100644 index 0000000..ccdda08 --- /dev/null +++ b/reference/Egret/Demos/.wing/settings.json @@ -0,0 +1,3 @@ +{ + "typescript.check.workspaceVersion": false +} \ No newline at end of file diff --git a/reference/Egret/Demos/.wing/tasks.json b/reference/Egret/Demos/.wing/tasks.json new file mode 100644 index 0000000..efae716 --- /dev/null +++ b/reference/Egret/Demos/.wing/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "0.1.0", + "command": "egret", + "isShellCommand": true, + "tasks": [ + { + "taskName": "build", + "showOutput": "always", + "args": [ + "build", + "-sourcemap" + ], + "problemMatcher": "$tsc" + }, + { + "taskName": "clean", + "showOutput": "always", + "args": [ + "build", + "-e" + ], + "problemMatcher": "$tsc" + }, + { + "taskName": "publish", + "showOutput": "always", + "args": [ + "publish" + ], + "problemMatcher": "$tsc" + } + ] +} \ No newline at end of file diff --git a/reference/Egret/Demos/README.md b/reference/Egret/Demos/README.md new file mode 100644 index 0000000..1fb3a4c --- /dev/null +++ b/reference/Egret/Demos/README.md @@ -0,0 +1,4 @@ +## How to run +1. Make sure you have installed Egret Wing(3.0) and EgretLauncher (installed Egret engine such as 5.0.4). +2. Open the demo with Egret wing. +3. Build project and have fun. \ No newline at end of file diff --git a/reference/Egret/Demos/egretProperties.json b/reference/Egret/Demos/egretProperties.json new file mode 100644 index 0000000..d56e463 --- /dev/null +++ b/reference/Egret/Demos/egretProperties.json @@ -0,0 +1,27 @@ +{ + "native": { + "path_ignore": [] + }, + "publish": { + "web": 0, + "native": 1, + "path": "bin-release" + }, + "egret_version": "5.0.2", + "modules": [ + { + "name": "egret" + }, + { + "name": "dragonBones", + "path": "../4.x/out/" + }, + { + "name": "res" + }, + { + "name": "promise", + "path": "./libs/promise/" + } + ] +} \ No newline at end of file diff --git a/reference/Egret/Demos/index.html b/reference/Egret/Demos/index.html new file mode 100644 index 0000000..bda5bcd --- /dev/null +++ b/reference/Egret/Demos/index.html @@ -0,0 +1,88 @@ + + + + + + Egret + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/animation_base_test_ske.json b/reference/Egret/Demos/resource/assets/animation_base_test_ske.json new file mode 100644 index 0000000..067c964 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/animation_base_test_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"armature":[{"aabb":{"width":611,"y":-82.37399983406067,"height":97.37399983406067,"x":-300},"type":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"idle"}],"skin":[{"name":"","slot":[{"display":[{"path":"_texture/track","type":"image","name":"_texture/track","transform":{}}],"name":"track"},{"display":[{"path":"_texture/thrmb","type":"image","name":"_texture/thrmb","transform":{"x":-33}}],"name":"thrmb"},{"display":[{"transform":{"skX":-0.8115,"skY":-0.8115},"path":"loading","type":"armature","name":"loading","filterType":"armature"}],"name":"loading"},{"display":[{"path":"_texture/bar","type":"image","name":"_texture/bar","transform":{"x":300}}],"name":"bar"}]}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{},"name":"track","parent":"root"},{"inheritScale":0,"transform":{"x":-300},"name":"bar","parent":"root"},{"inheritScale":0,"transform":{"x":300},"name":"thrmb","parent":"root"},{"transform":{"skX":0.8115,"y":-50,"skY":0.8115},"name":"loading","parent":"root"}],"slot":[{"name":"track","parent":"track","color":{}},{"z":1,"name":"bar","parent":"bar","color":{}},{"z":2,"name":"thrmb","parent":"thrmb","color":{}},{"z":3,"name":"loading","parent":"loading","color":{}}],"animation":[{"frame":[{"duration":50,"tweenEasing":null,"events":[{"name":"startEvent"}]},{"duration":50,"tweenEasing":null,"events":[{"name":"middleEvent"}]},{"duration":0,"tweenEasing":null,"events":[{"name":"completeEvent"}]}],"duration":100,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":100}],"name":"track"},{"frame":[{"transform":{"scX":0.01},"tweenEasing":0,"duration":100},{"transform":{},"tweenEasing":null,"duration":0}],"name":"bar"},{"frame":[{"transform":{"scX":0.5,"scY":0.5,"x":-600},"tweenEasing":0,"duration":5},{"transform":{"x":-565},"tweenEasing":0,"duration":90},{"transform":{"x":-30},"tweenEasing":0,"duration":5},{"transform":{"scX":0.5,"scY":0.5},"tweenEasing":null,"duration":0}],"name":"thrmb"},{"frame":[{"transform":{},"tweenEasing":null,"duration":100}],"name":"root"},{"frame":[{"transform":{},"tweenEasing":null,"duration":100}],"name":"loading"}],"slot":[{"frame":[{"tweenEasing":null,"duration":100}],"name":"track"},{"frame":[{"tweenEasing":null,"duration":100}],"name":"bar"},{"frame":[{"color":{"aM":0},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":90},{"tweenEasing":0,"duration":5},{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"thrmb"},{"frame":[{"duration":100,"actions":[{"gotoAndPlay":"idle"}],"tweenEasing":0},{"duration":0,"actions":[{"gotoAndPlay":"hide"}],"tweenEasing":null}],"name":"loading"}],"ffd":[],"name":"idle"}],"frameRate":24,"name":"progressBar"},{"aabb":{"width":108,"y":-51.950005000000004,"height":104,"x":-54},"type":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"idle"}],"skin":[{"name":"","slot":[{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"1"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"3"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"4"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"6"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"5"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"2"}]}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-11,"scX":0.3329,"scY":0.3333,"x":-19},"name":"6","parent":"root"},{"inheritScale":0,"transform":{"y":11,"scX":0.3329,"scY":0.3333,"x":-19},"name":"5","parent":"root"},{"inheritScale":0,"transform":{"y":22,"scX":0.3329,"scY":0.3333},"name":"4","parent":"root"},{"inheritScale":0,"transform":{"y":11,"scX":0.3329,"scY":0.3333,"x":19},"name":"3","parent":"root"},{"inheritScale":0,"transform":{"y":-11,"scX":0.3329,"scY":0.3333,"x":19},"name":"2","parent":"root"},{"inheritScale":0,"transform":{"y":-22,"scX":0.3329,"scY":0.3333},"name":"1","parent":"root"}],"slot":[{"name":"6","parent":"6","color":{}},{"z":1,"name":"5","parent":"5","color":{}},{"z":2,"name":"4","parent":"4","color":{}},{"z":3,"name":"3","parent":"3","color":{}},{"z":4,"name":"2","parent":"2","color":{}},{"z":5,"name":"1","parent":"1","color":{}}],"animation":[{"playTimes":0,"frame":[],"duration":30,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":30}],"name":"root"},{"frame":[{"transform":{"y":-2,"x":-4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":20},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-2,"x":-4},"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"transform":{},"tweenEasing":0,"duration":20},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":3,"x":-4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"transform":{},"tweenEasing":0,"duration":15},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":null,"duration":0}],"name":"4"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":2,"x":4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"3"},{"frame":[{"transform":{},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-2,"x":4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":15},{"transform":{},"tweenEasing":null,"duration":0}],"name":"2"},{"frame":[{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":20},{"transform":{},"tweenEasing":null,"duration":0}],"name":"1"}],"slot":[{"frame":[{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":0,"duration":20},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":20},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":15},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":5}],"name":"4"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":10},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":10}],"name":"3"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":15}],"name":"2"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":20}],"name":"1"}],"ffd":[],"name":"idle","fadeInTime":0.2},{"playTimes":0,"frame":[],"duration":0,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":0}],"name":"root"},{"frame":[{"transform":{"y":11,"x":19},"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"transform":{"y":-11,"x":19},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"transform":{"y":-22},"tweenEasing":null,"duration":0}],"name":"4"},{"frame":[{"transform":{"y":-11,"x":-19},"tweenEasing":null,"duration":0}],"name":"3"},{"frame":[{"transform":{"y":11,"x":-19},"tweenEasing":null,"duration":0}],"name":"2"},{"frame":[{"transform":{"y":22},"tweenEasing":null,"duration":0}],"name":"1"}],"slot":[{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"4"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"3"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"2"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"1"}],"ffd":[],"name":"hide","fadeInTime":0.2}],"frameRate":24,"name":"loading"}],"name":"AnimationBaseTest","version":"5.0"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/animation_base_test_tex.json b/reference/Egret/Demos/resource/assets/animation_base_test_tex.json new file mode 100644 index 0000000..e53778e --- /dev/null +++ b/reference/Egret/Demos/resource/assets/animation_base_test_tex.json @@ -0,0 +1 @@ +{"imagePath":"animation_base_test_tex.png","width":1024,"SubTexture":[{"width":600,"y":1,"height":4,"name":"_texture/track","x":73},{"width":600,"y":7,"height":4,"name":"_texture/bar","x":73},{"width":88,"y":1,"height":30,"name":"_texture/thrmb","x":675},{"width":70,"y":1,"height":60,"name":"_texture/_diamond","x":1}],"height":64,"name":"AnimationBaseTest"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/animation_base_test_tex.png b/reference/Egret/Demos/resource/assets/animation_base_test_tex.png new file mode 100644 index 0000000..f24f5ee Binary files /dev/null and b/reference/Egret/Demos/resource/assets/animation_base_test_tex.png differ diff --git a/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_ske.json b/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_ske.json new file mode 100644 index 0000000..8d98c7e --- /dev/null +++ b/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_ske.json @@ -0,0 +1,7232 @@ +{ + "frameRate": 24, + "isGlobal": 0, + "armature": [ + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "bullet_01_f/bullet_01", + "transform": { + "x": -27 + } + } + ], + "name": "b" + } + ] + } + ], + "bone": [ + { + "inheritScale": 0, + "length": 20, + "name": "b", + "transform": {} + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 74, + "y": -10, + "height": 20, + "x": -64 + }, + "slot": [ + { + "name": "b", + "parent": "b", + "color": { + "aM": 50 + } + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "bullet_01", + "ik": [], + "animation": [ + { + "duration": 4, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 4, + "transform": { + "scX": 0.1, + "scY": 0.3 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "scX": 1.8 + }, + "tweenEasing": null + } + ], + "name": "b" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 4, + "tweenEasing": 0, + "color": { + "aM": 50 + } + }, + { + "duration": 0, + "tweenEasing": null + } + ], + "name": "b" + } + ], + "name": "idle" + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "fire_effect_01_f/fireEffect", + "transform": { + "scX": 1.5, + "x": 21 + } + } + ], + "name": "root" + } + ] + } + ], + "bone": [ + { + "inheritScale": 0, + "length": 30, + "name": "root", + "transform": {} + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 48, + "y": -19, + "height": 38, + "x": -3 + }, + "slot": [ + { + "name": "root", + "parent": "root", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "fire_effect_01", + "ik": [], + "animation": [ + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + }, + { + "duration": 0, + "displayIndex": -1, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "name": "idle" + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "flame_01_f/bbb", + "transform": { + "skX": -90, + "skY": -90, + "x": 95 + } + } + ], + "blendMode": "add", + "name": "b2" + }, + { + "display": [ + { + "type": "image", + "name": "flame_01_f/ba_bu_flame1", + "transform": { + "y": 85, + "skX": -90, + "skY": -90 + } + } + ], + "name": "b1" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "length": 30, + "transform": { + "skX": 90, + "skY": 90 + }, + "parent": "root", + "inheritScale": 0, + "name": "b2" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 180, + "y": -22, + "height": 234, + "x": -90 + }, + "slot": [ + { + "name": "b1", + "parent": "root", + "color": {} + }, + { + "blendMode": "add", + "z": 1, + "parent": "b2", + "name": "b2", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "flame_01", + "ik": [], + "animation": [ + { + "duration": 2, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "b2" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": 0 + }, + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 30 + } + } + ], + "name": "b2" + } + ], + "name": "idle", + "playTimes": 0 + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/calf_r", + "transform": { + "y": 2.05, + "skX": 0.1784, + "skY": 0.1784, + "x": 16.95 + } + } + ], + "name": "calf_r" + }, + { + "display": [ + { + "transform": { + "skX": -90, + "skY": -90, + "scX": 0.8, + "scY": 0.8 + }, + "type": "armature", + "name": "flame_01", + "filterType": null + } + ], + "name": "effects_f" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/foot_l_0", + "transform": { + "y": 6.4707, + "skX": 89.9982, + "skY": 89.9982, + "scX": 0.9955, + "scY": 1.0045, + "x": 0.0002 + } + } + ], + "name": "foot_l" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/shouder_r_1", + "transform": { + "y": -3.0591, + "skX": -50.3304, + "skY": -50.3127, + "scX": 0.9998, + "scY": 1.0002, + "x": 1.8548 + } + } + ], + "name": "shouder_r" + }, + { + "display": [ + { + "transform": { + "skX": -90, + "skY": -90 + }, + "type": "armature", + "name": "flame_01", + "filterType": null + } + ], + "name": "effects_b" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/calf_l", + "transform": { + "y": 0.95, + "skX": -0.1967, + "skY": -0.1976, + "x": 15 + } + } + ], + "name": "calf_l" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_1_r_1", + "transform": { + "y": -1.9, + "skX": 0.438, + "skY": 0.438, + "x": 21.55 + } + } + ], + "name": "thigh_1_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/pelvis", + "transform": { + "y": 7.5, + "x": 3.5 + } + } + ], + "name": "pelvis" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/shouder_l_0", + "transform": { + "y": -3.2345, + "skX": 129.6702, + "skY": 129.6875, + "scX": 0.9998, + "scY": 1.0002, + "x": 0.7822 + } + } + ], + "name": "shouder_l" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_r", + "transform": { + "y": -11.55, + "skX": -0.1635, + "skY": -0.1626, + "x": 12.45 + } + } + ], + "name": "thigh_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/chest", + "transform": { + "y": 29.4658, + "skX": 89.9994, + "skY": 90.0004, + "x": -17.0277 + } + } + ], + "name": "chest" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_1_l_0", + "transform": { + "y": -2.95, + "skX": 0.1119, + "skY": 0.1128, + "x": 23 + } + } + ], + "name": "thigh_1_l" + }, + { + "display": [ + { + "transform": {}, + "type": "armature", + "name": "weapon_1502b_r", + "filterType": null + } + ], + "name": "weapon_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/foot_r", + "transform": { + "y": 7.4165, + "skX": 89.9982, + "skY": 89.9982, + "scX": 0.9955, + "scY": 1.0045, + "x": -0.502 + } + } + ], + "name": "foot_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_l", + "transform": { + "y": -5.55, + "skX": 0.0463, + "skY": 0.0455, + "x": 13.45 + } + } + ], + "name": "thigh_l" + }, + { + "display": [ + { + "transform": {}, + "type": "armature", + "name": "weapon_1502b_l", + "filterType": null + } + ], + "name": "weapon_l" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "length": 20, + "transform": { + "y": -25, + "scX": 0.9955, + "x": 62.85 + }, + "parent": "root", + "inheritScale": 0, + "name": "foot_l" + }, + { + "length": 40, + "transform": { + "y": -133.55, + "skX": 21.9887, + "skY": 21.9887, + "scX": 0.9995, + "scY": 0.9977, + "x": 8.3 + }, + "parent": "root", + "inheritScale": 0, + "name": "thigh_l" + }, + { + "length": 42, + "transform": { + "y": -112.45, + "skX": 69.8809, + "skY": 69.8854, + "scX": 0.9876, + "scY": 0.9979, + "x": -8.55 + }, + "parent": "root", + "inheritScale": 0, + "name": "thigh_r" + }, + { + "length": 20, + "transform": { + "y": -123.15, + "skX": -89.9991, + "skY": -89.9991 + }, + "parent": "root", + "inheritScale": 0, + "name": "pelvis" + }, + { + "length": 20, + "transform": { + "y": -4, + "scX": 0.9955, + "x": -43.8 + }, + "parent": "root", + "inheritScale": 0, + "name": "foot_r" + }, + { + "length": 50, + "transform": { + "y": -0.04, + "skX": 97.9614, + "skY": 97.9621, + "scX": 0.9894, + "scY": 0.9971, + "x": 40.11 + }, + "parent": "thigh_l", + "inheritScale": 0, + "name": "thigh_1_l" + }, + { + "length": 20, + "transform": { + "skX": -90, + "skY": -90, + "x": 13.75 + }, + "parent": "pelvis", + "inheritScale": 0, + "name": "chest" + }, + { + "length": 53, + "transform": { + "y": -0.01, + "skX": 105.4235, + "skY": 105.423, + "scX": 0.9984, + "scY": 0.9995, + "x": 41.52 + }, + "parent": "thigh_r", + "inheritScale": 0, + "name": "thigh_1_r" + }, + { + "length": 20, + "transform": { + "y": 31.28, + "scX": 0.9965, + "scY": 0.9969, + "x": 13.74 + }, + "parent": "chest", + "inheritScale": 0, + "name": "shouder_r" + }, + { + "length": 20, + "transform": { + "y": 46.59, + "scX": 0.9965, + "scY": 0.9969, + "x": -2.41 + }, + "parent": "chest", + "inheritScale": 0, + "name": "shouder_l" + }, + { + "inheritRotation": 0, + "length": 100, + "transform": { + "y": 3.13, + "skX": 130, + "skY": 130, + "x": 11.65 + }, + "parent": "chest", + "inheritScale": 0, + "name": "effects_b" + }, + { + "length": 64, + "transform": { + "y": 0.01, + "skX": -70.8583, + "skY": -70.864, + "scX": 1.0149, + "scY": 0.9967, + "x": 50.91 + }, + "parent": "thigh_1_l", + "inheritScale": 0, + "name": "calf_l" + }, + { + "inheritRotation": 0, + "length": 100, + "transform": { + "y": -13.37, + "skX": 90, + "skY": 90, + "x": -20.82 + }, + "parent": "chest", + "inheritScale": 0, + "name": "effects_f" + }, + { + "length": 66, + "transform": { + "y": -0.02, + "skX": -88.4874, + "skY": -88.4933, + "scX": 0.9852, + "scY": 0.9996, + "x": 53.26 + }, + "parent": "thigh_1_r", + "inheritScale": 0, + "name": "calf_r" + }, + { + "length": 100, + "transform": { + "skX": 180, + "skY": 180, + "scX": 0.9982, + "scY": 0.9994, + "x": 5.98 + }, + "parent": "shouder_r", + "inheritScale": 0, + "name": "weapon_r" + }, + { + "length": 100, + "transform": { + "y": 0.04, + "skX": 180, + "skY": 180, + "scX": 0.998, + "scY": 0.9993, + "x": 5.6 + }, + "parent": "shouder_l", + "inheritScale": 0, + "name": "weapon_l" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 202.6571337556091, + "y": -262.3655325241823, + "height": 320.2820325241823, + "x": -111.39678584090109 + }, + "slot": [ + { + "name": "weapon_l", + "parent": "weapon_l", + "color": {} + }, + { + "z": 1, + "name": "shouder_l", + "parent": "shouder_l", + "color": {} + }, + { + "z": 2, + "name": "foot_l", + "parent": "foot_l", + "color": {} + }, + { + "z": 3, + "name": "thigh_1_l", + "parent": "thigh_1_l", + "color": {} + }, + { + "z": 4, + "name": "calf_l", + "parent": "calf_l", + "color": {} + }, + { + "z": 5, + "name": "thigh_l", + "parent": "thigh_l", + "color": {} + }, + { + "z": 6, + "name": "pelvis", + "parent": "pelvis", + "color": {} + }, + { + "z": 7, + "name": "effects_f", + "parent": "effects_f", + "color": { + "aM": 0 + } + }, + { + "z": 8, + "name": "chest", + "parent": "chest", + "color": {} + }, + { + "z": 9, + "name": "effects_b", + "parent": "effects_b", + "color": { + "aM": 0 + } + }, + { + "z": 10, + "name": "foot_r", + "parent": "foot_r", + "color": {} + }, + { + "z": 11, + "name": "thigh_1_r", + "parent": "thigh_1_r", + "color": {} + }, + { + "z": 12, + "name": "calf_r", + "parent": "calf_r", + "color": {} + }, + { + "z": 13, + "name": "thigh_r", + "parent": "thigh_r", + "color": {} + }, + { + "z": 14, + "name": "shouder_r", + "parent": "shouder_r", + "color": {} + }, + { + "z": 15, + "name": "weapon_r", + "parent": "weapon_r", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "mecha_1502b", + "ik": [ + { + "bone": "calf_l", + "chain": 1, + "bendPositive": "false", + "name": "calf_l", + "target": "foot_l" + }, + { + "bone": "calf_r", + "chain": 1, + "bendPositive": "false", + "name": "calf_r", + "target": "foot_r" + } + ], + "animation": [ + { + "duration": 60, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -0.04, + "skY": 0.0009, + "scX": 1.0004, + "x": -0.01 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -0.61, + "skX": 3.5176, + "skY": 3.5176, + "x": -0.46 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -3.95, + "skX": 3.2612, + "skY": 3.2619, + "scX": 1.0008, + "scY": 0.9998 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -4 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "skX": -3.4867, + "skY": -3.5176, + "scX": 0.9996, + "scY": 1.0027 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -4.05, + "skX": 2.2559, + "skY": 2.2558, + "scX": 0.9985, + "scY": 1.0002 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": 0.55, + "skX": 3.5176, + "skY": 3.5176, + "x": 0.49 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": 0.06, + "skY": -0.0009, + "scX": 1.0002, + "x": 0.01 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.2, + "name": "idle", + "playTimes": 0 + }, + { + "duration": 30, + "frame": [ + { + "duration": 14, + "tweenEasing": null + }, + { + "duration": 16, + "tweenEasing": null, + "events": [ + { + "name": "step", + "bone": "foot_r" + } + ] + }, + { + "duration": 0, + "tweenEasing": null, + "events": [ + { + "name": "step" + } + ] + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 4, + "transform": { + "y": 0.21, + "skX": -13.2798, + "skY": -13.279, + "x": 0.32 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.2, + "skX": -12.4984, + "skY": -12.4984, + "scX": 0.9998, + "x": 0.25 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.28, + "skX": -12.29, + "skY": -12.2892, + "scX": 0.9997, + "x": 0.14 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.21, + "skX": -16.0776, + "skY": -16.0767, + "scX": 0.9996, + "scY": 0.9998, + "x": 0.33 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.14, + "skX": -15.1996, + "skY": -15.1996, + "scX": 0.9997, + "x": 0.52 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.15, + "skX": -13.4429, + "skY": -13.442, + "x": 0.87 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.21, + "skX": -13.2798, + "skY": -13.279, + "x": 0.32 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": -0.49, + "skX": 11.6982, + "skY": 10.0384, + "scX": 1.1315, + "scY": 1.0017, + "x": -1.93 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -1.58, + "skX": 9.3988, + "skY": 9.2902, + "scX": 1.0079, + "x": -0.43 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -2.37, + "skX": 8.1528, + "skY": 9.1018, + "scX": 0.9313, + "scY": 0.9988, + "x": 0.46 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -1.99, + "skX": 13.6189, + "skY": 13.1293, + "scX": 1.037, + "scY": 1.0004, + "x": -1.3 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.1, + "skX": 14.9031, + "skY": 12.4457, + "scX": 1.2006, + "scY": 1.0028, + "x": -3.33 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 1.08, + "skX": 13.1082, + "skY": 10.6515, + "scX": 1.2005, + "scY": 1.0028, + "x": -3.69 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.49, + "skX": 11.6982, + "skY": 10.0384, + "scX": 1.1315, + "scY": 1.0017, + "x": -1.93 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.3, + "scX": 0.999, + "x": 16.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.3, + "scX": 0.9981, + "x": 12.15 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -1.15, + "scX": 0.9994, + "x": -7.15 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -2.5, + "scX": 1.0021, + "x": -39.35 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -5.1, + "skX": 1.0018, + "skY": 1.0018, + "scX": 1.0028, + "x": -81.1 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -10.25, + "skX": 8.0065, + "skY": 8.0073, + "scX": 0.9898, + "scY": 0.9991, + "x": -102.2 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -13.45, + "skX": 14.0174, + "skY": 14.0174, + "scX": 1.0146, + "scY": 0.9985, + "x": -108.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -20.4, + "skX": 28.3082, + "skY": 28.3075, + "scX": 0.9856, + "scY": 0.9973, + "x": -111.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -29.65, + "skX": 37.8443, + "skY": 37.847, + "scX": 0.9987, + "scY": 0.9968, + "x": -86.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -33.25, + "skX": 38.3489, + "skY": 38.3494, + "scX": 1.0058, + "scY": 0.9968, + "x": -71.8 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -35.1, + "skX": 26.0511, + "skY": 26.0511, + "scX": 1.004, + "scY": 0.9974, + "x": -49.45 + }, + "tweenEasing": 0 + }, + { + "duration": 6, + "transform": { + "y": -33.55, + "skX": 18.2766, + "skY": 18.2774, + "scX": 1.0066, + "scY": 0.998, + "x": -39.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -12.45, + "skX": -15.7668, + "skY": -15.7676, + "scX": 1.0049, + "scY": 0.9982, + "x": 14.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.3, + "scX": 0.999, + "x": 16.75 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -10.85, + "skX": 1.7556, + "skY": 1.7583, + "scX": 1.0008, + "x": -4.15 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2.8, + "skX": 8.7821, + "skY": 8.7805, + "scX": 0.9991, + "scY": 0.9994, + "x": -5.75 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -8.05, + "skX": 15.0552, + "skY": 15.0559, + "scX": 0.9974, + "scY": 0.9992, + "x": -7.55 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -17.85, + "skX": 28.8664, + "skY": 28.8666, + "scX": 0.9897, + "scY": 0.9991, + "x": -10.55 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -24.1, + "skX": 47.6881, + "skY": 47.6814, + "scX": 0.9656, + "scY": 1.0002, + "x": -15.45 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -14.5, + "skX": 56.4569, + "skY": 56.4521, + "scX": 0.9566, + "scY": 1.001, + "x": -15.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -10.05, + "skX": 54.9538, + "skY": 54.9501, + "scX": 0.9602, + "scY": 1.0009, + "x": -15.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 1.6, + "skX": 48.189, + "skY": 48.1838, + "scX": 0.9672, + "scY": 1.0002, + "x": -14.9 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.85, + "skX": 39.9103, + "skY": 39.9075, + "scX": 0.9635, + "scY": 0.9996, + "x": -14.4 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.75, + "skX": 32.1298, + "skY": 32.1271, + "scX": 0.971, + "scY": 0.9992, + "x": -13.8 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -6.1, + "skX": 12.5454, + "skY": 12.5447, + "scX": 0.993, + "scY": 0.9993, + "x": -11.95 + }, + "tweenEasing": 0 + }, + { + "duration": 6, + "transform": { + "y": -9.45, + "skX": 5.0166, + "skY": 5.0169, + "scX": 0.9989, + "scY": 0.9996, + "x": -10.85 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -15.3, + "skX": -4.2618, + "skY": -4.2608, + "scX": 1.0018, + "scY": 1.0004, + "x": -4.9 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -10.85, + "skX": 1.7556, + "skY": 1.7583, + "scX": 1.0008, + "x": -4.15 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": -11.35, + "skX": 8.7547, + "skY": 8.7549, + "scX": 0.9864, + "scY": 0.999, + "x": -10.5 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -6.75, + "skX": 8.5031, + "skY": 8.5048, + "scX": 0.9816, + "scY": 0.999, + "x": -9.3 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -16.4, + "skX": 8.7549, + "skY": 8.7555, + "scX": 0.984, + "scY": 0.999, + "x": -8.75 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -11.35, + "skX": 9.0056, + "skY": 9.0057, + "scX": 1.0044, + "scY": 0.999, + "x": -10.5 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -2.3, + "skX": 9.2556, + "skY": 9.2542, + "scX": 1.0118, + "scY": 0.999, + "x": -12.45 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -9.95, + "skX": 9.5045, + "skY": 9.5052, + "scX": 1.0123, + "scY": 0.9989, + "x": -12.45 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -11.35, + "skX": 8.7547, + "skY": 8.7549, + "scX": 0.9864, + "scY": 0.999, + "x": -10.5 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": -0.18, + "skX": -5.5, + "skY": -5.5135, + "scX": 0.9997, + "scY": 1.001, + "x": -0.09 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.05, + "skX": -5.2163, + "skY": -5.2966, + "scX": 0.9997, + "scY": 1.0072, + "x": 0.14 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.03, + "skX": -5.4472, + "skY": -5.5673, + "scX": 0.9998, + "scY": 1.0109, + "x": 0.3 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.01, + "skX": -5.9558, + "skY": -6.0573, + "scX": 0.9997, + "scY": 1.0092, + "x": 0.12 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.12, + "skX": -6.5087, + "skY": -6.5003, + "scX": 0.9997, + "scY": 0.9991, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -0.25, + "skX": -6.7986, + "skY": -6.7138, + "scX": 0.9996, + "scY": 0.992, + "x": -0.27 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.18, + "skX": -5.5, + "skY": -5.5135, + "scX": 0.9997, + "scY": 1.001, + "x": -0.09 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.4, + "skX": 7.0054, + "skY": 7.0071, + "scX": 0.9748, + "scY": 0.9992, + "x": -16.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -17.5, + "skX": 28.5597, + "skY": 28.5583, + "scX": 1.0043, + "scY": 0.9972, + "x": -20.95 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -24.25, + "skX": 21.5371, + "skY": 21.5363, + "scX": 1.0169, + "scY": 0.9977, + "x": 2.05 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -26.2, + "skX": 16.5221, + "skY": 16.5229, + "scX": 1.0189, + "scY": 0.9982, + "x": 15.95 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -30.85, + "skX": 11.2628, + "skY": 11.2628, + "scX": 1.0148, + "scY": 0.9987, + "x": 43.9 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -30.5, + "skX": 8.2592, + "skY": 8.2575, + "scX": 1.0131, + "scY": 0.9991, + "x": 56 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -6.25, + "skX": -15.0159, + "skY": -15.0143, + "scX": 1.017, + "scY": 0.9984, + "x": 101.45 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 7.85, + "skX": -1.25, + "skY": -1.2509, + "scX": 1.0029, + "scY": 0.9998, + "x": 102.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 7.8, + "skX": -0.625, + "skY": -0.6254, + "scX": 1.0016, + "x": 101.125 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 7.75, + "scX": 1.0003, + "x": 99.65 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 7.05, + "skX": 0.0035, + "skY": 0.0035, + "scX": 0.9988, + "x": 76.2 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 6.35, + "scX": 0.9979, + "x": 50.75 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 4.35, + "skX": 0.7527, + "skY": 0.7518, + "scX": 0.9933, + "x": 7.9 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.4, + "skX": 7.0054, + "skY": 7.0071, + "scX": 0.9748, + "scY": 0.9992, + "x": -16.75 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -11.8, + "skX": 23.2823, + "skY": 23.2807, + "scX": 1.0012, + "scY": 1.0018, + "x": -17.1 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.75, + "skX": 12.2765, + "skY": 12.2735, + "scX": 1.0078, + "scY": 1.0012, + "x": -14.2 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -5.4, + "skX": 5.5145, + "skY": 5.5127, + "scX": 1.0083, + "scY": 1.0005, + "x": -11.15 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -8.25, + "skX": -1.0013, + "skY": -1.0056, + "scX": 1.0099, + "scY": 0.9998, + "x": -9.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -14.85, + "skX": -15.3018, + "skY": -15.3079, + "scX": 1.0115, + "scY": 0.999, + "x": -6.85 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -18.05, + "skX": -21.8297, + "skY": -21.8354, + "scX": 1.0114, + "scY": 0.9988, + "x": -5.75 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -21.25, + "skX": -32.626, + "skY": -32.632, + "scX": 1.0082, + "scY": 0.999, + "x": -3.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -17, + "skX": -20.5755, + "skY": -20.5791, + "scX": 1.0115, + "scY": 0.9988, + "x": -4.5 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -12.7, + "skX": -15.0502, + "skY": -15.0562, + "scX": 1.0109, + "scY": 0.999, + "x": -5.55 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -6.3, + "skX": -20.0717, + "skY": -20.0779, + "scX": 1.0114, + "scY": 0.9989, + "x": -6.7 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -5.55, + "skX": -19.0685, + "skY": -19.0725, + "scX": 1.0093, + "scY": 0.9989, + "x": -10.45 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -13.95, + "skX": -5.767, + "skY": -5.77, + "scX": 1.0024, + "scY": 0.9995, + "x": -13 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -22.55, + "skX": 15.5262, + "skY": 15.5271, + "scX": 0.9958, + "scY": 1.0016, + "x": -16.3 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -11.8, + "skX": 23.2823, + "skY": 23.2807, + "scX": 1.0012, + "scY": 1.0018, + "x": -17.1 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": 0.66, + "skX": 9.4644, + "skY": 9.6617, + "scX": 0.9857, + "scY": 0.9996, + "x": 1.86 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 1.24, + "skX": 6.8557, + "skY": 8.4041, + "scX": 0.8951, + "scY": 0.9983, + "x": 0.3 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 1.82, + "skX": 5.8718, + "skY": 7.4208, + "scX": 0.8951, + "scY": 0.9983, + "x": -0.57 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 1.85, + "skX": 11.6349, + "skY": 13.1834, + "scX": 0.8952, + "scY": 0.9984, + "x": 1.19 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.6, + "skX": 13.0119, + "skY": 12.1388, + "scX": 1.0644, + "scY": 1.0008, + "x": 3.01 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -0.16, + "skX": 11.7217, + "skY": 9.922, + "scX": 1.1373, + "scY": 1.0019, + "x": 3.6 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.66, + "skX": 9.4644, + "skY": 9.6617, + "scX": 0.9857, + "scY": 0.9996, + "x": 1.86 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": 0.27, + "skX": -12.9031, + "skY": -12.9031, + "scX": 0.9997, + "x": 0.2 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.3, + "skX": -11.6123, + "skY": -11.6123, + "scX": 0.9996, + "scY": 0.9998, + "x": -0.16 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.42, + "skX": -10.609, + "skY": -10.6081, + "scX": 0.9995, + "scY": 0.9998, + "x": -0.9 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.35, + "skX": -16.1317, + "skY": -16.1317, + "scX": 0.9993, + "scY": 0.9998, + "x": 0.14 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.17, + "skX": -14.8927, + "skY": -14.8927, + "scX": 0.9995, + "scY": 0.9998, + "x": 0.41 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.19, + "skX": -12.7133, + "skY": -12.7133, + "scX": 0.9996, + "x": 0.41 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.27, + "skX": -12.9031, + "skY": -12.9031, + "scX": 0.9997, + "x": 0.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.2, + "name": "walk", + "playTimes": 0 + }, + { + "duration": 3, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.08, + "skX": -0.0054, + "skY": -0.0046, + "scX": 1.002, + "scY": 1.0006, + "x": 0.19 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.1, + "skX": -0.0054, + "skY": -0.0046, + "scX": 1.002, + "scY": 1.0006, + "x": 0.18 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.48, + "skX": 4.4951, + "skY": 4.5075, + "scX": 1.0004, + "scY": 1.0015, + "x": -0.78 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.86, + "skX": 7.4976, + "skY": 7.5101, + "scX": 1.0004, + "scY": 1.0015, + "x": -1.1 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 13.534, + "skX": -7.269, + "skY": -7.269, + "scX": 0.9988, + "scY": 1.0015, + "x": -17.524 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 15.434, + "skX": -7.269, + "skY": -7.269, + "scX": 0.9988, + "scY": 1.0015, + "x": -17.524 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 13.834, + "skX": -1.7543, + "skY": -1.7543, + "scX": 0.9998, + "x": -17.574 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 15.734, + "skX": -1.7543, + "skY": -1.7543, + "scX": 0.9998, + "x": -17.574 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.1, + "skX": -4.5063, + "skY": -4.5021, + "scX": 0.9997, + "scY": 0.9995, + "x": -0.05 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.33, + "skX": -5.7548, + "skY": -5.7494, + "scX": 0.9996, + "scY": 0.9992, + "x": -0.03 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 14.134, + "skX": 8.2707, + "skY": 8.2663, + "scX": 1.0112, + "scY": 1.0015, + "x": -17.674 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 16.034, + "skX": 8.2707, + "skY": 8.2663, + "scX": 1.0112, + "scY": 1.0015, + "x": -17.674 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.37, + "skX": 4.4953, + "skY": 4.5082, + "scX": 1.0005, + "scY": 1.0015, + "x": 0.66 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.89, + "skX": 7.4979, + "skY": 7.5107, + "scX": 1.0005, + "scY": 1.0015, + "x": 1.13 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.05, + "skX": -0.0061, + "skY": -0.0061, + "scX": 1.0017, + "scY": 1.0005, + "x": 0.15 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.06, + "skX": -0.0061, + "skY": -0.0061, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.21 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_r" + } + ], + "fadeInTime": 0.2, + "name": "attack_01", + "playTimes": 5 + }, + { + "duration": 9, + "frame": [ + { + "duration": 4, + "tweenEasing": null + }, + { + "duration": 5, + "tweenEasing": null, + "events": [ + { + "name": "step", + "bone": "foot_l" + } + ] + }, + { + "duration": 0, + "action": "attack_02_1", + "tweenEasing": null + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.19, + "skY": 0.0009, + "scX": 0.9998 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.19, + "skY": 0.0009, + "scX": 1.0011, + "scY": 1.0003, + "x": 0.37 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.34 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -1.27, + "skX": 6.0331, + "skY": 6.0331, + "x": -0.86 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.89, + "skX": 4.524, + "skY": 4.524, + "x": -1.17 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.16, + "skX": 0.0044, + "skY": 0.0044, + "x": -0.45 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -15.75, + "x": -60.15 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -4.85, + "x": -110.7 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -4.85, + "x": -110.7 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -28.65, + "skX": 47.9363, + "skY": 47.934, + "scX": 0.9793, + "scY": 1.0002, + "x": -19.85 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -17.3, + "skX": 92.2581, + "skY": 92.2557, + "scX": 0.9465, + "x": -39.65 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 18.95, + "skX": 48.1876, + "skY": 48.1844, + "scX": 0.9767, + "scY": 1.0002, + "x": -55.2 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 19.15, + "x": -56 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -1.55, + "skX": -5.9764, + "skY": -6.0331, + "scX": 0.9994, + "scY": 1.0047, + "x": 35.55 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.1, + "skX": -4.4827, + "skY": -4.524, + "scX": 0.9995, + "scY": 1.0035, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.1, + "skX": -0.0026, + "skY": -0.0044, + "scY": 1.0002, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -29.5, + "skX": 9.5199, + "skY": 9.5204, + "scX": 0.9925, + "scY": 1.0009, + "x": -20.5 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 19.4, + "skX": -35.3872, + "skY": -35.392, + "scX": 1.0113, + "scY": 0.999, + "x": -56.8 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 1.38, + "skX": 6.0331, + "skY": 6.0331, + "x": 1.16 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.32, + "skX": 4.524, + "skY": 4.524, + "x": 1.44 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.43, + "skX": 0.0044, + "skY": 0.0044, + "x": 0.93 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.23, + "skY": -0.0009, + "scX": 0.9996, + "scY": 0.9998 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.22, + "scX": 1.0008, + "scY": 1.0003, + "x": 0.38 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.24, + "scX": 1.0016, + "scY": 1.0005, + "x": 0.37 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 9, + "actions": [ + { + "gotoAndPlay": "prepare_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 9, + "actions": [ + { + "gotoAndPlay": "prepare_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_r" + } + ], + "fadeInTime": 0.2, + "name": "attack_02" + }, + { + "duration": 3, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.34 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "action": "fire_01", + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.33 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.16, + "skX": 0.0044, + "skY": 0.0044, + "x": -0.45 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.72, + "skX": 3.5184, + "skY": 3.5184, + "x": -0.9 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": { + "y": -4.85, + "x": -110.7 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 18.95, + "skX": 48.1876, + "skY": 48.1844, + "scX": 0.9767, + "scY": 1.0002, + "x": -55.2 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 22, + "skX": 46.6831, + "skY": 46.6806, + "scX": 0.9778, + "x": -56.4 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 19.15, + "x": -56 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 22.25, + "x": -57.2 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.1, + "skX": -0.0026, + "skY": -0.0044, + "scY": 1.0002, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.1, + "skX": -3.4856, + "skY": -3.5184, + "scX": 0.9996, + "scY": 1.0029, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 19.4, + "skX": -35.3872, + "skY": -35.392, + "scX": 1.0113, + "scY": 0.999, + "x": -56.8 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 22.55, + "skX": -39.4031, + "skY": -39.4078, + "scX": 1.0107, + "scY": 0.9992, + "x": -58 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.43, + "skX": 0.0044, + "skY": 0.0044, + "x": 0.93 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.12, + "skX": 3.5184, + "skY": 3.5184, + "x": 1.51 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.24, + "scX": 1.0016, + "scY": 1.0005, + "x": 0.37 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "action": "fire_01", + "transform": { + "y": 0.18, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.39 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_r" + } + ], + "fadeInTime": 0.1, + "name": "attack_02_1", + "playTimes": 10 + }, + { + "duration": 10, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.04, + "scX": 1.0015, + "scY": 1.0005, + "x": -0.02 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.36, + "skX": -20.7464, + "skY": -20.7456, + "scX": 0.9988, + "scY": 0.9996, + "x": 0.2 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.14, + "skX": 8.9426, + "skY": 8.9434, + "scX": 0.9982, + "scY": 0.9994, + "x": 0.44 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.19, + "skX": 5.5746, + "skY": 5.5754, + "scX": 0.9974, + "scY": 0.9991, + "x": 0.49 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.13, + "skX": 47.427, + "skY": 47.4278, + "scX": 0.9977, + "scY": 0.9992, + "x": 0.56 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.09, + "skX": 52.6335, + "skY": 52.6343, + "scX": 0.9973, + "scY": 0.9991, + "x": 0.51 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -2.07, + "skX": 12.0717, + "skY": 12.0717, + "x": -1.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2.5, + "skX": -1.9074, + "skY": -1.9139, + "x": -1.87 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 2.88, + "skX": -8.0387, + "skY": -8.0452, + "x": 3.68 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 1.72, + "skX": -1.6311, + "skY": -1.6376, + "x": 1.42 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 3.09, + "skX": -28.3747, + "skY": -28.3747, + "x": 4.47 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 3.2, + "skX": -16.7919, + "skY": -16.7984, + "x": 5.39 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 6, + "transform": { + "y": -5, + "x": -114.2 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -5, + "x": -114.2 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -14.05, + "skX": 10.0352, + "skY": 10.0352, + "scX": 1.0014, + "scY": 0.9993, + "x": 15.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -24.4, + "skX": 54.7039, + "skY": 54.6998, + "scX": 0.9738, + "scY": 1.0008, + "x": -51.9 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 45, + "skX": 31.1254, + "skY": 31.1262, + "scX": 0.9895, + "scY": 0.9991, + "x": -81.7 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 35.8, + "skX": 28.1119, + "skY": 28.1111, + "scX": 0.993, + "scY": 0.9991, + "x": -81.75 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 44.8, + "skX": 17.8174, + "skY": 17.8178, + "scX": 0.9986, + "scY": 0.9991, + "x": -87.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 45.8, + "skX": 16.3115, + "skY": 16.3114, + "scX": 0.9993, + "scY": 0.9991, + "x": -87.9 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 44.8, + "skX": 16.8133, + "skY": 16.8129, + "scX": 0.9992, + "scY": 0.9991, + "x": -87.3 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -14.25, + "skX": -1.7519, + "skY": -1.7533, + "scX": 1.0015, + "scY": 0.9997, + "x": 15.55 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -24.75, + "skX": 12.2581, + "skY": 12.2593, + "scX": 0.9907, + "scY": 0.9986, + "x": -52.7 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 45.6, + "skX": -6.5047, + "skY": -6.5058, + "scX": 1.0051, + "scY": 0.9993, + "x": -82.85 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 36.25, + "skX": -6.5047, + "skY": -6.5058, + "scX": 1.0051, + "scY": 0.9993, + "x": -82.9 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 45.35, + "skX": -6.5047, + "skY": -6.5058, + "scX": 1.0051, + "scY": 0.9993, + "x": -88.5 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.08, + "skX": -10.2014, + "skY": -10.3185, + "scX": 0.9988, + "scY": 1.0096 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.12, + "skX": -24.2129, + "skY": -24.3318, + "scX": 0.9988, + "scY": 1.0097, + "x": 0.06 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.13, + "skX": 30.9807, + "skY": 31.1144, + "scX": 0.9974, + "scY": 0.985, + "x": -0.12 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.17, + "skX": 19.224, + "skY": 19.3108, + "scX": 0.9985, + "scY": 0.9906, + "x": -0.12 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.07, + "skX": 25.9728, + "skY": 26.0924, + "scX": 0.9978, + "scY": 0.9869, + "x": -0.09 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.84, + "skX": 34.7399, + "skY": 34.8805, + "scX": 0.9972, + "scY": 0.9841, + "x": -1.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.07, + "skX": 38.5028, + "skY": 38.6462, + "scX": 0.9969, + "scY": 0.9836, + "x": -0.09 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.2, + "x": -26.7 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -2, + "x": -43.6 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2, + "x": -43.6 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 10, + "transform": { + "y": -0.21, + "skX": -23.7864, + "skY": -23.7989, + "scX": 0.9872, + "scY": 0.9984, + "x": 0.12 + }, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 10, + "transform": { + "y": -0.04, + "skX": 28.5439, + "skY": 28.5391, + "scX": 0.9903, + "scY": 0.9993, + "x": 0.32 + }, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -14.4, + "skX": 7.7667, + "skY": 7.7665, + "scX": 0.9946, + "scY": 1.0007, + "x": 15.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -25.15, + "skX": -4.7653, + "skY": -4.7658, + "scX": 1.0019, + "scY": 0.9996, + "x": -53.5 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 46.15, + "skX": 8.5209, + "skY": 8.5185, + "scX": 0.9989, + "scY": 1.0008, + "x": -84 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 36.7, + "skX": -12.0389, + "skY": -12.0428, + "scX": 1.008, + "scY": 0.9992, + "x": -84.1 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 45.95, + "skX": -5.2656, + "skY": -5.2681, + "scX": 1.0059, + "scY": 0.9996, + "x": -89.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 46.95, + "skX": 0.7538, + "skY": 0.7506, + "scX": 1.0032, + "x": -90.35 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 45.95, + "skX": 0.5035, + "skY": 0.5004, + "scX": 1.0031, + "x": -89.75 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 1.98, + "skX": 12.0717, + "skY": 12.0717, + "x": 1.21 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 2.32, + "skX": -26.7681, + "skY": -26.7747, + "scX": 0.7204, + "scY": 0.9983, + "x": 2.18 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -4.33, + "skX": 1.9651, + "skY": 1.9585, + "scX": 0.8952, + "scY": 0.9985, + "x": -2.87 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2.65, + "skX": -10.8838, + "skY": -10.8904, + "scX": 0.9907, + "scY": 1.0009, + "x": -0.64 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -4.74, + "skX": -32.6458, + "skY": -32.6387, + "scX": 0.9997, + "scY": 1.0002, + "x": -3.51 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -5.12, + "skX": -24.7198, + "skY": -24.7264, + "scX": 1.0003, + "x": -4.15 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.02, + "skY": -0.0009, + "scX": 1.0013, + "scY": 1.0004, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.22, + "skX": 11.8408, + "skY": 11.8408, + "scX": 0.9986, + "scY": 0.9996, + "x": 9.24 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.14, + "skX": 7.9952, + "skY": 7.9952, + "scX": 0.9993, + "scY": 0.9998, + "x": 0.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.56, + "skX": 19.4318, + "skY": 19.4318, + "scX": 0.9968, + "scY": 0.999, + "x": 11.53 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.54, + "skX": 48.2468, + "skY": 48.2468, + "scX": 0.9976, + "scY": 0.9992, + "x": 11.64 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -1.55, + "skX": 57.4615, + "skY": 57.4615, + "scX": 0.9969, + "scY": 0.999, + "x": 11.65 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "death" + }, + { + "duration": 8, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.04, + "scX": 0.9989, + "scY": 0.9996, + "x": -0.02 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 0.17, + "skY": 0.0009, + "scX": 1.0013, + "scY": 1.0004, + "x": 0.26 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.23, + "skY": 0.0017, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.28 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.21 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.07, + "skX": 12.0717, + "skY": 12.0717, + "x": -1.35 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 0.18, + "skX": -3.0111, + "skY": -3.0111, + "x": 0.04 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.36, + "skX": -9.4689, + "skY": -9.4689, + "x": 9.94 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 1.45, + "skX": -12.052, + "skY": -12.052, + "x": 1.5 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -8.45, + "x": -53 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -1.25, + "x": -78.8 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -14.05, + "skX": 10.0352, + "skY": 10.0352, + "scX": 1.0014, + "scY": 0.9993, + "x": 15.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.35, + "skX": -8.0191, + "skY": -8.0191, + "scX": 0.9964, + "scY": 1.0008, + "x": -51.85 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 2, + "skX": 1.003, + "skY": 1.0023, + "scX": 1.0002, + "x": -61.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 7.1, + "skX": 6.0193, + "skY": 6.02, + "scX": 1.0013, + "scY": 0.9996, + "x": -54.65 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -14.25, + "skX": -1.7519, + "skY": -1.7533, + "scX": 1.0015, + "scY": 0.9997, + "x": 15.55 + }, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -1.4, + "skX": 12.2581, + "skY": 12.2593, + "scX": 0.9907, + "scY": 0.9986, + "x": -52.6 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 7.15, + "skX": 10.5078, + "skY": 10.507, + "scX": 0.9919, + "scY": 0.9989, + "x": -55.45 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.08, + "skX": -10.2014, + "skY": -10.3185, + "scX": 0.9988, + "scY": 1.0096 + }, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -0.09, + "skX": -9.2713, + "skY": -9.2481, + "scX": 0.9996, + "scY": 0.9976, + "x": -0.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.09, + "skX": 1.4611, + "skY": 1.5451, + "scX": 0.9986, + "scY": 0.991, + "x": -0.05 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -1.2, + "x": -26.7 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -14.4, + "skX": 7.7667, + "skY": 7.7665, + "scX": 0.9946, + "scY": 1.0007, + "x": 15.75 + }, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -1.45, + "skX": -7.5225, + "skY": -7.525, + "scX": 1.0041, + "scY": 0.9994, + "x": -53.35 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 7.25, + "skX": -1.0033, + "skY": -1.0035, + "scX": 1.0007, + "scY": 0.9998, + "x": -56.25 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 1.98, + "skX": 12.0717, + "skY": 12.0717, + "x": 1.21 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -0.54, + "skX": -3.0111, + "skY": -3.0111, + "x": 0.42 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -3.08, + "skX": -9.4689, + "skY": -9.4689, + "x": 8.58 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -1.98, + "skX": -12.052, + "skY": -12.052, + "x": -0.92 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.02, + "skY": -0.0009, + "scX": 0.9986, + "scY": 0.9995, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 0.24, + "scX": 1.001, + "scY": 1.0004, + "x": 0.17 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.29, + "scX": 1.0014, + "scY": 1.0005, + "x": 0.27 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.18, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.26 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "hit" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.24, + "skY": 0.0009, + "scX": 0.9983, + "scY": 0.9994, + "x": 0.18 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 2.18, + "skX": -17.0743, + "skY": -17.0743, + "x": 3.04 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.25, + "x": -51.4 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 32.95, + "skX": 28.6151, + "skY": 28.6146, + "scX": 0.9929, + "scY": 0.9991, + "x": -5.9 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 33.35, + "x": -5.95 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": 16.9669, + "skY": 17.0743, + "scX": 0.9981, + "scY": 0.9882, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -23.137, + "skY": -23.137, + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.95, + "x": 20.4 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 33.85, + "skX": -1.0021, + "skY": -1.0039, + "scX": 1.002, + "scY": 0.9998, + "x": -6 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.82, + "skX": -17.0743, + "skY": -17.0743, + "x": -2.45 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.18, + "skY": 0.0009, + "scX": 0.9985, + "scY": 0.9995, + "x": 0.18 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_1" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.01, + "skY": 0.0009, + "scX": 1.0016, + "scY": 1.0005, + "x": 0.05 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.03, + "skX": 12.0717, + "skY": 12.0717, + "x": -1.6 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 10.8, + "skX": 57.6806, + "skY": 57.68, + "scX": 0.9907, + "scY": 0.997, + "x": -83.05 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.2, + "skX": 46.6827, + "skY": 46.6812, + "scX": 0.9819, + "x": -5.9 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": 25.2948, + "skY": 25.2935, + "scX": 0.9847, + "scY": 0.9974, + "x": -5.95 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.71, + "skX": -37.2482, + "skY": -37.3652, + "scX": 0.9988, + "scY": 1.0096, + "x": -0.2 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": 1.2365, + "skY": 1.2365 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -8.75, + "skX": 57.68, + "skY": 57.6793, + "scX": 0.9908, + "scY": 0.997, + "x": -44.3 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": 31.0364, + "skY": 31.0434, + "scX": 0.9759, + "scY": 1.0009, + "x": -6.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 1.82, + "skX": 12.0717, + "skY": 12.0717, + "x": 1.49 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.08, + "scX": 0.9997, + "x": 0.11 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_2" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 3.11, + "skX": -29.9982, + "skY": -29.9974, + "scX": 1.002, + "scY": 1.0007, + "x": -2.66 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.01, + "skX": 12.0701, + "skY": 12.0703, + "x": -1.62 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 29.9, + "skX": -16.3344, + "skY": -16.3344, + "scX": 0.9907, + "scY": 0.997, + "x": -20.7 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.2, + "skX": 27.2191, + "skY": 27.2173, + "scX": 0.9818, + "x": -5.9 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": 25.2948, + "skY": 25.2935, + "scX": 0.9847, + "scY": 0.9974, + "x": -5.95 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -16.22, + "skY": -16.22 + }, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.71, + "skX": -7.25, + "skY": -7.3656, + "scX": 0.9988, + "scY": 1.0096, + "x": -0.2 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -11.7614, + "skY": -11.7614 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 34.35, + "skX": -17.8725, + "skY": -17.8709, + "scX": 0.9908, + "scY": 0.997, + "x": 29.95 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": -6.4479, + "skY": -6.4395, + "scX": 0.9759, + "scY": 1.0009, + "x": -6.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 1.84, + "skX": 12.0708, + "skY": 12.071, + "x": 1.48 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.28, + "skX": -29.9989, + "skY": -29.9989, + "scX": 1.0018, + "scY": 1.0006, + "x": 2.58 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_3" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 2.26, + "skX": -24.1896, + "skY": -24.1887, + "scX": 1.002, + "scY": 1.0007, + "x": -2.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.91, + "skX": -5.0202, + "skY": -5.0216, + "x": 0.77 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 37.6, + "skX": 7.7638, + "skY": 7.7638, + "scX": 0.9429, + "scY": 0.9992, + "x": 0.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 38.1, + "x": 0.1 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.05, + "skX": 29.1728, + "skY": 29.2112, + "scX": 0.9994, + "scY": 0.9959, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -22.362, + "skY": -22.362, + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 38.65, + "skX": 11.7477, + "skY": 11.7432, + "scX": 0.9828, + "scY": 1.0009, + "x": 0.15 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -1.46, + "skX": -5.0204, + "skY": -5.0211, + "x": -0.78 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.18, + "skX": -24.1901, + "skY": -24.1901, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + }, + { + "duration": 0, + "displayIndex": -1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + }, + { + "duration": 0, + "displayIndex": -1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_4" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.16, + "skY": 0.0009, + "scX": 1.0015, + "scY": 1.0004, + "x": 0.19 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.9, + "skX": -5.0198, + "skY": -5.0198, + "x": 0.83 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 37.6, + "skX": -6.3646, + "skY": -6.3646, + "scX": 0.9429, + "scY": 0.9992, + "x": 0.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 38.1, + "x": 0.1 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.05, + "skX": 5.0015, + "skY": 5.0013, + "scX": 0.9994, + "scY": 0.9959, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 22.4, + "skX": 19.7978, + "skY": 19.7933, + "scX": 1.0112, + "scY": 1.0015, + "x": -6.7 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -1.38, + "skX": -5.0198, + "skY": -5.0198, + "x": -0.75 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.22, + "scX": 1.001, + "scY": 1.0002, + "x": 0.21 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "squat" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.09, + "skX": -20.5765, + "skY": -20.5756, + "scX": 1.002, + "scY": 1.0007, + "x": 0.13 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.41, + "skX": -16.7092, + "skY": -16.695, + "scX": 1.0004, + "scY": 1.0015, + "x": -0.79 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 20.85, + "skX": -5.0134, + "skY": -5.0141, + "scX": 0.9986, + "scY": 1.0014, + "x": -6.55 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 21.15, + "skX": -23.2231, + "skY": -23.2231, + "x": -6.6 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.11, + "skX": -29.5028, + "skY": -29.5002, + "scX": 0.9997, + "scY": 0.9995, + "x": -0.06 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 21.45, + "skX": 7.2697, + "skY": 7.2648, + "scX": 1.011, + "scY": 1.0014, + "x": -6.7 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.44, + "skX": -16.7003, + "skY": -16.6872, + "scX": 1.0004, + "scY": 1.0015, + "x": 0.69 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.07, + "skX": -20.5843, + "skY": -20.5843, + "scX": 1.0017, + "scY": 1.0005, + "x": 0.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "aim_up" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 7.3, + "skX": 13.8338, + "skY": 13.8346, + "scX": 1.002, + "scY": 1.0007, + "x": -14.03 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 2.72, + "skX": 19.4945, + "skY": 19.5066, + "scX": 1.0004, + "scY": 1.0015, + "x": 9.53 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 29.0164, + "skX": -5.0138, + "skY": -5.0138, + "scX": 0.9986, + "scY": 1.0014, + "x": -3.8279 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 21.15, + "skX": 35.6959, + "skY": 35.6959, + "x": -6.6 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.12, + "skX": 20.9537, + "skY": 20.9586, + "scX": 0.9997, + "scY": 0.9995, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 11.9358, + "skX": 0.0022, + "skY": -0.0022, + "x": -9.3081 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.7, + "skX": 19.494, + "skY": 19.5068, + "scX": 1.0004, + "scY": 1.0015, + "x": -9.69 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.07, + "skX": 13.8335, + "skY": 13.8335, + "scX": 1.0017, + "scY": 1.0005, + "x": 0.14 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "aim_down" + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/back_l", + "transform": { + "y": 0.9655, + "skX": -1.9759, + "skY": -1.9759, + "x": -10.0006 + } + } + ], + "name": "back" + }, + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0001", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0002", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0003", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + } + ], + "name": "front" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "inheritScale": 0, + "transform": { + "y": -8, + "x": 81 + }, + "name": "fire", + "parent": "root" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 151.9727, + "y": -21.0345, + "height": 44, + "x": -68.0006 + }, + "slot": [ + { + "name": "back", + "parent": "root", + "color": {} + }, + { + "z": 1, + "name": "front", + "parent": "root", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "weapon_1502b_l", + "ik": [], + "animation": [ + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [], + "name": "idle" + }, + { + "duration": 2, + "frame": [ + { + "duration": 0, + "tweenEasing": null, + "events": [ + { + "name": "fire", + "bone": "fire" + } + ] + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + }, + { + "duration": 1, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 0, + "displayIndex": 2, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "fire_01" + }, + { + "duration": 6, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 2, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 2, + "tweenEasing": null + }, + { + "duration": 0, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "prepare_01", + "playTimes": 0 + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/back_r", + "transform": { + "y": 1.5324, + "skX": -1.9759, + "skY": -1.9759, + "x": -10.4813 + } + } + ], + "name": "back" + }, + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0001", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0002", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0003", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + } + ], + "name": "front" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "inheritScale": 0, + "transform": { + "y": -7, + "x": 81 + }, + "name": "fire", + "parent": "root" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 154.9534, + "y": -20.9676, + "height": 45, + "x": -70.9813 + }, + "slot": [ + { + "name": "back", + "parent": "root", + "color": {} + }, + { + "z": 1, + "name": "front", + "parent": "root", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "weapon_1502b_r", + "ik": [], + "animation": [ + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [], + "name": "idle" + }, + { + "duration": 2, + "frame": [ + { + "duration": 0, + "tweenEasing": null, + "events": [ + { + "name": "fire", + "bone": "fire" + } + ] + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + }, + { + "duration": 1, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 0, + "displayIndex": 2, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "fire_01" + }, + { + "duration": 6, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 2, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 2, + "tweenEasing": null + }, + { + "duration": 0, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "prepare_01", + "playTimes": 0 + } + ] + } + ], + "name": "mecha_1502b", + "version": "5.0" +} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_tex.json b/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_tex.json new file mode 100644 index 0000000..9452b23 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_tex.json @@ -0,0 +1 @@ +{"width":512,"SubTexture":[{"width":74,"y":93,"height":20,"name":"bullet_01_f/bullet_01","x":307},{"width":48,"y":1,"height":38,"name":"fire_effect_01_f/fireEffect","x":212},{"width":180,"y":430,"height":52,"name":"flame_01_f/ba_bu_flame1","x":1},{"frameY":0,"y":1,"frameWidth":86,"frameX":-2,"frameHeight":234,"width":81,"height":233,"name":"flame_01_f/bbb","x":1},{"width":44,"y":1,"height":39,"name":"mecha_1502b_folder/shouder_l_0","x":319},{"width":29,"y":77,"height":106,"name":"mecha_1502b_folder/foot_l_0","x":434},{"width":50,"y":185,"height":32,"name":"mecha_1502b_folder/thigh_1_l_0","x":434},{"width":122,"y":177,"height":46,"name":"mecha_1502b_folder/calf_l","x":84},{"width":101,"y":118,"height":57,"name":"mecha_1502b_folder/thigh_l","x":84},{"width":41,"y":77,"height":65,"name":"mecha_1502b_folder/pelvis","x":465},{"width":89,"y":236,"height":192,"name":"mecha_1502b_folder/chest","x":1},{"width":29,"y":77,"height":109,"name":"mecha_1502b_folder/foot_r","x":403},{"width":55,"y":1,"height":32,"name":"mecha_1502b_folder/thigh_1_r_1","x":262},{"width":126,"y":1,"height":52,"name":"mecha_1502b_folder/calf_r","x":84},{"width":103,"y":55,"height":61,"name":"mecha_1502b_folder/thigh_r","x":84},{"width":43,"y":144,"height":39,"name":"mecha_1502b_folder/shouder_r_1","x":465},{"width":116,"y":55,"height":44,"name":"weapon_1502b_folder/back_l","x":189},{"frameY":0,"y":39,"frameWidth":94,"frameX":0,"frameHeight":36,"width":93,"height":36,"name":"weapon_1502b_folder/image/paoguan_0002","x":403},{"width":94,"y":1,"height":36,"name":"weapon_1502b_folder/image/paoguan_0003","x":403},{"width":94,"y":55,"height":36,"name":"weapon_1502b_folder/image/paoguan_0001","x":307},{"width":121,"y":118,"height":45,"name":"weapon_1502b_folder/back_r","x":187}],"height":512,"name":"mecha_1502b","imagePath":"mecha_1502b_tex.png"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_tex.png b/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_tex.png new file mode 100644 index 0000000..368d0f3 Binary files /dev/null and b/reference/Egret/Demos/resource/assets/core_element/mecha_1502b_tex.png differ diff --git a/reference/Egret/Demos/resource/assets/core_element/skin_1502b_ske.json b/reference/Egret/Demos/resource/assets/core_element/skin_1502b_ske.json new file mode 100644 index 0000000..532c09f --- /dev/null +++ b/reference/Egret/Demos/resource/assets/core_element/skin_1502b_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"armature":[{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"mecha_1003_folder/calf_r_0","transform":{"y":1.8721,"x":27.7907}}],"name":"calf_r"},{"display":[{"type":"image","name":"mecha_1003d_folder/thigh_l_0","transform":{"y":2.8796,"x":19.1837}}],"name":"thigh_l"},{"display":[{"type":"image","name":"mecha_1002_folder/upperarm_r_2","transform":{"y":2.5661,"skX":-99.6918,"skY":-99.6918}}],"name":"shouder_r"},{"display":[{"type":"image","name":"mecha_1004_folder/chest_1","transform":{"y":46.4064,"skX":89.5694,"skY":89.5694,"x":-8.7784}}],"name":"chest"},{"display":[{"type":"image","name":"mecha_1004d_folder/foot_l_0","transform":{"y":7.7385,"skX":90,"skY":90,"x":2.3128}}],"name":"foot_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_r_1","transform":{"y":-1.9,"skX":0.438,"skY":0.438,"x":21.55}}],"name":"thigh_1_r"},{"display":[{"type":"image","name":"mecha_1003_folder/calf_l_0","transform":{"y":4.1499,"x":26.8604}}],"name":"calf_l"},{"display":[{"type":"image","name":"mecha_1003d_folder/thigh_r_0","transform":{"y":-7.6009,"x":15.0357}}],"name":"thigh_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/pelvis","transform":{"y":7.5,"x":3.5}}],"name":"pelvis"},{"display":[{"type":"image","name":"mecha_1002_folder/upperarm_l_2","transform":{"y":-3.8492,"skX":-105.7978,"skY":-105.7978,"x":-0.8558}}],"name":"shouder_l"},{"display":[{"type":"image","name":"mecha_1004d_folder/foot_r_1","transform":{"y":9.2478,"skX":90,"skY":90,"x":2.5697}}],"name":"foot_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_l_0","transform":{"y":-2.95,"skX":0.1119,"skY":0.1128,"x":23}}],"name":"thigh_1_l"}]}],"bone":[{"transform":{},"name":"root"},{"length":20,"transform":{"y":-25,"scX":0.9955,"x":62.85},"parent":"root","inheritScale":0,"name":"foot_l"},{"length":40,"transform":{"y":-133.55,"skX":21.9887,"skY":21.9887,"scX":0.9995,"scY":0.9977,"x":8.3},"parent":"root","inheritScale":0,"name":"thigh_l"},{"length":42,"transform":{"y":-112.45,"skX":69.8809,"skY":69.8854,"scX":0.9876,"scY":0.9979,"x":-8.55},"parent":"root","inheritScale":0,"name":"thigh_r"},{"length":20,"transform":{"y":-123.15,"skX":-89.9991,"skY":-89.9991},"parent":"root","inheritScale":0,"name":"pelvis"},{"length":20,"transform":{"y":-4,"scX":0.9955,"x":-43.8},"parent":"root","inheritScale":0,"name":"foot_r"},{"length":50,"transform":{"y":-0.04,"skX":97.9614,"skY":97.9621,"scX":0.9894,"scY":0.9971,"x":40.11},"parent":"thigh_l","inheritScale":0,"name":"thigh_1_l"},{"length":20,"transform":{"skX":-90,"skY":-90,"x":13.75},"parent":"pelvis","inheritScale":0,"name":"chest"},{"length":53,"transform":{"y":-0.01,"skX":105.4235,"skY":105.423,"scX":0.9984,"scY":0.9995,"x":41.52},"parent":"thigh_r","inheritScale":0,"name":"thigh_1_r"},{"length":20,"transform":{"y":31.28,"scX":0.9965,"scY":0.9969,"x":13.74},"parent":"chest","inheritScale":0,"name":"shouder_r"},{"length":20,"transform":{"y":46.59,"scX":0.9965,"scY":0.9969,"x":-2.41},"parent":"chest","inheritScale":0,"name":"shouder_l"},{"inheritRotation":0,"length":100,"transform":{"y":3.13,"skX":130,"skY":130,"x":11.65},"parent":"chest","inheritScale":0,"name":"effects_b"},{"length":64,"transform":{"y":0.01,"skX":-70.8583,"skY":-70.864,"scX":1.0149,"scY":0.9967,"x":50.91},"parent":"thigh_1_l","inheritScale":0,"name":"calf_l"},{"inheritRotation":0,"length":100,"transform":{"y":-13.37,"skX":90,"skY":90,"x":-20.82},"parent":"chest","inheritScale":0,"name":"effects_f"},{"length":66,"transform":{"y":-0.02,"skX":-88.4874,"skY":-88.4933,"scX":0.9852,"scY":0.9996,"x":53.26},"parent":"thigh_1_r","inheritScale":0,"name":"calf_r"},{"length":100,"transform":{"skX":180,"skY":180,"scX":0.9982,"scY":0.9994,"x":5.98},"parent":"shouder_r","inheritScale":0,"name":"weapon_r"},{"length":100,"transform":{"y":0.04,"skX":180,"skY":180,"scX":0.998,"scY":0.9993,"x":5.6},"parent":"shouder_l","inheritScale":0,"name":"weapon_l"}],"type":"Armature","frameRate":24,"aabb":{"width":176.64362862645802,"y":-233.80623389915854,"height":281.5540549156089,"x":-95.10679917154837},"slot":[{"name":"shouder_l","parent":"shouder_l","color":{}},{"z":1,"name":"foot_l","parent":"foot_l","color":{}},{"z":2,"name":"thigh_1_l","parent":"thigh_1_l","color":{}},{"z":3,"name":"calf_l","parent":"calf_l","color":{}},{"z":4,"name":"thigh_l","parent":"thigh_l","color":{}},{"z":5,"name":"pelvis","parent":"pelvis","color":{}},{"z":6,"name":"chest","parent":"chest","color":{}},{"z":7,"name":"foot_r","parent":"foot_r","color":{}},{"z":8,"name":"thigh_1_r","parent":"thigh_1_r","color":{}},{"z":9,"name":"calf_r","parent":"calf_r","color":{}},{"z":10,"name":"thigh_r","parent":"thigh_r","color":{}},{"z":11,"name":"shouder_r","parent":"shouder_r","color":{}}],"defaultActions":[{"gotoAndPlay":"empty"}],"name":"skin_a","ik":[{"bone":"calf_l","chain":1,"bendPositive":"false","name":"calf_l","target":"foot_l"},{"bone":"calf_r","chain":1,"bendPositive":"false","name":"calf_r","target":"foot_r"}],"animation":[{"duration":0,"frame":[],"ffd":[],"bone":[{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"root"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"pelvis"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"chest"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_b"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_f"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_l"}],"slot":[],"name":"empty","playTimes":0}]},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"mecha_1003_folder/calf_r_0","transform":{"y":2.1179,"x":27.5723}}],"name":"calf_r"},{"display":[{"type":"image","name":"mecha_1008d_folder/thigh_r_0","transform":{"y":0.8121,"x":21.8806}}],"name":"thigh_r"},{"display":[{"type":"image","name":"mecha_1003_folder/foot_r_0","transform":{"y":10.5628,"skX":90,"skY":90}}],"name":"foot_r"},{"display":[{"type":"image","name":"mecha_1008d_folder/thigh_l_0","transform":{"y":-0.794,"x":21.2746}}],"name":"thigh_l"},{"display":[{"type":"image","name":"mecha_1003_folder/calf_l_0","transform":{"y":3.7974,"x":25.8031}}],"name":"calf_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_r_1","transform":{"y":-1.9,"skX":0.438,"skY":0.438,"x":21.55}}],"name":"thigh_1_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_l_0","transform":{"y":-2.95,"skX":0.1119,"skY":0.1128,"x":23}}],"name":"thigh_1_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/pelvis","transform":{"y":7.5,"x":3.5}}],"name":"pelvis"},{"display":[{"type":"image","name":"mecha_1003_folder/foot_l_0","transform":{"y":10.132,"skX":90,"skY":90,"x":-0.2792}}],"name":"foot_l"}]}],"bone":[{"transform":{},"name":"root"},{"length":20,"transform":{"y":-25,"scX":0.9955,"x":62.85},"parent":"root","inheritScale":0,"name":"foot_l"},{"length":40,"transform":{"y":-133.55,"skX":21.9887,"skY":21.9887,"scX":0.9995,"scY":0.9977,"x":8.3},"parent":"root","inheritScale":0,"name":"thigh_l"},{"length":42,"transform":{"y":-112.45,"skX":69.8809,"skY":69.8854,"scX":0.9876,"scY":0.9979,"x":-8.55},"parent":"root","inheritScale":0,"name":"thigh_r"},{"length":20,"transform":{"y":-123.15,"skX":-89.9991,"skY":-89.9991},"parent":"root","inheritScale":0,"name":"pelvis"},{"length":20,"transform":{"y":-4,"scX":0.9955,"x":-43.8},"parent":"root","inheritScale":0,"name":"foot_r"},{"length":50,"transform":{"y":-0.04,"skX":97.9614,"skY":97.9621,"scX":0.9894,"scY":0.9971,"x":40.11},"parent":"thigh_l","inheritScale":0,"name":"thigh_1_l"},{"length":20,"transform":{"skX":-90,"skY":-90,"x":13.75},"parent":"pelvis","inheritScale":0,"name":"chest"},{"length":53,"transform":{"y":-0.01,"skX":105.4235,"skY":105.423,"scX":0.9984,"scY":0.9995,"x":41.52},"parent":"thigh_r","inheritScale":0,"name":"thigh_1_r"},{"length":20,"transform":{"y":31.28,"scX":0.9965,"scY":0.9969,"x":13.74},"parent":"chest","inheritScale":0,"name":"shouder_r"},{"length":20,"transform":{"y":46.59,"scX":0.9965,"scY":0.9969,"x":-2.41},"parent":"chest","inheritScale":0,"name":"shouder_l"},{"inheritRotation":0,"length":100,"transform":{"y":3.13,"skX":130,"skY":130,"x":11.65},"parent":"chest","inheritScale":0,"name":"effects_b"},{"length":64,"transform":{"y":0.01,"skX":-70.8583,"skY":-70.864,"scX":1.0149,"scY":0.9967,"x":50.91},"parent":"thigh_1_l","inheritScale":0,"name":"calf_l"},{"inheritRotation":0,"length":100,"transform":{"y":-13.37,"skX":90,"skY":90,"x":-20.82},"parent":"chest","inheritScale":0,"name":"effects_f"},{"length":66,"transform":{"y":-0.02,"skX":-88.4874,"skY":-88.4933,"scX":0.9852,"scY":0.9996,"x":53.26},"parent":"thigh_1_r","inheritScale":0,"name":"calf_r"},{"length":100,"transform":{"skX":180,"skY":180,"scX":0.9982,"scY":0.9994,"x":5.98},"parent":"shouder_r","inheritScale":0,"name":"weapon_r"},{"length":100,"transform":{"y":0.04,"skX":180,"skY":180,"scX":0.998,"scY":0.9993,"x":5.6},"parent":"shouder_l","inheritScale":0,"name":"weapon_l"}],"type":"Armature","frameRate":24,"aabb":{"width":181.67820326799887,"y":-159.1498821898437,"height":216.2126923697017,"x":-95.3644576640574},"slot":[{"name":"foot_l","parent":"foot_l","color":{}},{"z":1,"name":"thigh_1_l","parent":"thigh_1_l","color":{}},{"z":2,"name":"calf_l","parent":"calf_l","color":{}},{"z":3,"name":"thigh_l","parent":"thigh_l","color":{}},{"z":4,"name":"pelvis","parent":"pelvis","color":{}},{"z":5,"name":"foot_r","parent":"foot_r","color":{}},{"z":6,"name":"thigh_1_r","parent":"thigh_1_r","color":{}},{"z":7,"name":"calf_r","parent":"calf_r","color":{}},{"z":8,"name":"thigh_r","parent":"thigh_r","color":{}}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"name":"skin_b","ik":[{"bone":"calf_l","chain":1,"bendPositive":"false","name":"calf_l","target":"foot_l"},{"bone":"calf_r","chain":1,"bendPositive":"false","name":"calf_r","target":"foot_r"}],"animation":[{"duration":0,"frame":[],"ffd":[],"bone":[{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"root"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"pelvis"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"chest"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_b"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_f"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_l"}],"slot":[],"name":"newAnimation","playTimes":0}]},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"mecha_1003d_folder/calf_l_0","transform":{"y":1.8851,"x":27.6888}}],"name":"calf_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_r_1","transform":{"y":-1.9,"skX":0.438,"skY":0.438,"x":21.55}}],"name":"thigh_1_r"},{"display":[{"type":"image","name":"mecha_1007d_folder/foot_l_1","transform":{"y":9.6443,"skX":90,"skY":90,"x":6.2003}}],"name":"foot_l"},{"display":[{"type":"image","name":"mecha_1004d_folder/chest_1","transform":{"y":52.0796,"skX":90,"skY":90,"x":-10.0293}}],"name":"chest"},{"display":[{"type":"image","name":"mecha_1004d_folder/shouder_r_2","transform":{"y":-3.0957,"skX":-90,"skY":-90,"x":-5.4198}}],"name":"shouder_r"},{"display":[{"type":"image","name":"mecha_1007d_folder/thigh_l_0","transform":{"y":-0.447,"x":26.8758}}],"name":"thigh_l"},{"display":[{"type":"image","name":"mecha_1003d_folder/calf_r_0","transform":{"y":1.2965,"x":29.7327}}],"name":"calf_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_l_0","transform":{"y":-2.95,"skX":0.1119,"skY":0.1128,"x":23}}],"name":"thigh_1_l"},{"display":[{"type":"image","name":"mecha_1007d_folder/foot_r_0","transform":{"y":11.1489,"skX":90,"skY":90,"x":7.3628}}],"name":"foot_r"},{"display":[{"type":"image","name":"mecha_1004d_folder/shouder_l_2","transform":{"y":-1.1608,"skX":-90,"skY":-90,"x":-7.7426}}],"name":"shouder_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/pelvis","transform":{"y":7.5,"x":3.5}}],"name":"pelvis"},{"display":[{"type":"image","name":"mecha_1007d_folder/thigh_r_0","transform":{"y":1.6378,"x":22.6896}}],"name":"thigh_r"}]}],"bone":[{"transform":{},"name":"root"},{"length":20,"transform":{"y":-25,"scX":0.9955,"x":62.85},"parent":"root","inheritScale":0,"name":"foot_l"},{"length":40,"transform":{"y":-133.55,"skX":21.9887,"skY":21.9887,"scX":0.9995,"scY":0.9977,"x":8.3},"parent":"root","inheritScale":0,"name":"thigh_l"},{"length":42,"transform":{"y":-112.45,"skX":69.8809,"skY":69.8854,"scX":0.9876,"scY":0.9979,"x":-8.55},"parent":"root","inheritScale":0,"name":"thigh_r"},{"length":20,"transform":{"y":-123.15,"skX":-89.9991,"skY":-89.9991},"parent":"root","inheritScale":0,"name":"pelvis"},{"length":20,"transform":{"y":-4,"scX":0.9955,"x":-43.8},"parent":"root","inheritScale":0,"name":"foot_r"},{"length":50,"transform":{"y":-0.04,"skX":97.9614,"skY":97.9621,"scX":0.9894,"scY":0.9971,"x":40.11},"parent":"thigh_l","inheritScale":0,"name":"thigh_1_l"},{"length":20,"transform":{"skX":-90,"skY":-90,"x":13.75},"parent":"pelvis","inheritScale":0,"name":"chest"},{"length":53,"transform":{"y":-0.01,"skX":105.4235,"skY":105.423,"scX":0.9984,"scY":0.9995,"x":41.52},"parent":"thigh_r","inheritScale":0,"name":"thigh_1_r"},{"length":20,"transform":{"y":31.28,"scX":0.9965,"scY":0.9969,"x":13.74},"parent":"chest","inheritScale":0,"name":"shouder_r"},{"length":20,"transform":{"y":46.59,"scX":0.9965,"scY":0.9969,"x":-2.41},"parent":"chest","inheritScale":0,"name":"shouder_l"},{"inheritRotation":0,"length":100,"transform":{"y":3.13,"skX":130,"skY":130,"x":11.65},"parent":"chest","inheritScale":0,"name":"effects_b"},{"length":64,"transform":{"y":0.01,"skX":-70.8583,"skY":-70.864,"scX":1.0149,"scY":0.9967,"x":50.91},"parent":"thigh_1_l","inheritScale":0,"name":"calf_l"},{"inheritRotation":0,"length":100,"transform":{"y":-13.37,"skX":90,"skY":90,"x":-20.82},"parent":"chest","inheritScale":0,"name":"effects_f"},{"length":66,"transform":{"y":-0.02,"skX":-88.4874,"skY":-88.4933,"scX":0.9852,"scY":0.9996,"x":53.26},"parent":"thigh_1_r","inheritScale":0,"name":"calf_r"},{"length":100,"transform":{"skX":180,"skY":180,"scX":0.9982,"scY":0.9994,"x":5.98},"parent":"shouder_r","inheritScale":0,"name":"weapon_r"},{"length":100,"transform":{"y":0.04,"skX":180,"skY":180,"scX":0.998,"scY":0.9993,"x":5.6},"parent":"shouder_l","inheritScale":0,"name":"weapon_l"}],"type":"Armature","frameRate":24,"aabb":{"width":187.45307710983226,"y":-280.97944052980597,"height":328.6282985398831,"x":-95.92274665260345},"slot":[{"name":"shouder_l","parent":"shouder_l","color":{}},{"z":1,"name":"foot_l","parent":"foot_l","color":{}},{"z":2,"name":"thigh_1_l","parent":"thigh_1_l","color":{}},{"z":3,"name":"calf_l","parent":"calf_l","color":{}},{"z":4,"name":"thigh_l","parent":"thigh_l","color":{}},{"z":5,"name":"pelvis","parent":"pelvis","color":{}},{"z":6,"name":"chest","parent":"chest","color":{}},{"z":7,"name":"foot_r","parent":"foot_r","color":{}},{"z":8,"name":"thigh_1_r","parent":"thigh_1_r","color":{}},{"z":9,"name":"calf_r","parent":"calf_r","color":{}},{"z":10,"name":"thigh_r","parent":"thigh_r","color":{}},{"z":11,"name":"shouder_r","parent":"shouder_r","color":{}}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"name":"skin_c","ik":[{"bone":"calf_l","chain":1,"bendPositive":"false","name":"calf_l","target":"foot_l"},{"bone":"calf_r","chain":1,"bendPositive":"false","name":"calf_r","target":"foot_r"}],"animation":[{"duration":0,"frame":[],"ffd":[],"bone":[{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"root"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"pelvis"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"chest"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_b"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_f"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_l"}],"slot":[],"name":"newAnimation","playTimes":0}]}],"name":"skin_1502b","version":"5.0"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/core_element/skin_1502b_tex.json b/reference/Egret/Demos/resource/assets/core_element/skin_1502b_tex.json new file mode 100644 index 0000000..2e82d63 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/core_element/skin_1502b_tex.json @@ -0,0 +1 @@ +{"width":512,"SubTexture":[{"width":63,"y":240,"height":42,"name":"mecha_1002_folder/upperarm_l_2","x":121},{"width":29,"y":88,"height":83,"name":"mecha_1004d_folder/foot_l_0","x":360},{"width":50,"y":348,"height":32,"name":"mecha_1502b_folder/thigh_1_l_0","x":101},{"width":92,"y":187,"height":51,"name":"mecha_1003_folder/calf_l_0","x":121},{"frameY":0,"y":449,"frameWidth":103,"frameX":-1,"frameHeight":57,"width":102,"height":56,"name":"mecha_1003d_folder/thigh_l_0","x":308},{"width":41,"y":245,"height":65,"name":"mecha_1502b_folder/pelvis","x":341},{"width":118,"y":187,"height":101,"name":"mecha_1004_folder/chest_1","x":1},{"width":30,"y":1,"height":85,"name":"mecha_1004d_folder/foot_r_1","x":360},{"width":55,"y":478,"height":32,"name":"mecha_1502b_folder/thigh_1_r_1","x":1},{"frameY":-1,"y":346,"frameWidth":95,"frameX":0,"frameHeight":52,"width":95,"height":51,"name":"mecha_1003_folder/calf_r_0","x":208},{"width":105,"y":449,"height":58,"name":"mecha_1003d_folder/thigh_r_0","x":98},{"width":67,"y":399,"height":38,"name":"mecha_1002_folder/upperarm_r_2","x":208},{"width":32,"y":348,"height":98,"name":"mecha_1003_folder/foot_l_0","x":390},{"frameY":0,"y":384,"frameWidth":116,"frameX":-3,"frameHeight":63,"width":108,"height":63,"name":"mecha_1008d_folder/thigh_l_0","x":98},{"width":34,"y":245,"height":101,"name":"mecha_1003_folder/foot_r_0","x":305},{"frameY":0,"y":290,"frameWidth":96,"frameX":-3,"frameHeight":54,"width":92,"height":54,"name":"mecha_1008d_folder/thigh_r_0","x":203},{"width":69,"y":187,"height":56,"name":"mecha_1004d_folder/shouder_l_2","x":289},{"width":40,"y":348,"height":80,"name":"mecha_1007d_folder/foot_l_1","x":348},{"frameY":0,"y":384,"frameWidth":96,"frameX":0,"frameHeight":92,"width":95,"height":92,"name":"mecha_1003d_folder/calf_l_0","x":1},{"width":100,"y":290,"height":56,"name":"mecha_1007d_folder/thigh_l_0","x":101},{"width":163,"y":1,"height":184,"name":"mecha_1004d_folder/chest_1","x":1},{"width":41,"y":348,"height":81,"name":"mecha_1007d_folder/foot_r_0","x":305},{"width":98,"y":290,"height":92,"name":"mecha_1003d_folder/calf_r_0","x":1},{"width":101,"y":449,"height":58,"name":"mecha_1007d_folder/thigh_r_0","x":205},{"width":72,"y":187,"height":59,"name":"mecha_1004d_folder/shouder_r_2","x":215}],"height":512,"name":"skin_1502b","imagePath":"skin_1502b_tex.png"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/core_element/skin_1502b_tex.png b/reference/Egret/Demos/resource/assets/core_element/skin_1502b_tex.png new file mode 100644 index 0000000..eb1afbb Binary files /dev/null and b/reference/Egret/Demos/resource/assets/core_element/skin_1502b_tex.png differ diff --git a/reference/Egret/Demos/resource/assets/core_element/weapon_1000_ske.json b/reference/Egret/Demos/resource/assets/core_element/weapon_1000_ske.json new file mode 100644 index 0000000..4ec2ae2 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/core_element/weapon_1000_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"armature":[{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_0","transform":{"y":-1,"x":-29.5}}],"name":"back"},{"display":[{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0001","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0002","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0003","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0004","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0005","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}}],"name":"front"}]}],"aabb":{"width":150.05171561035348,"y":-21,"height":40,"x":-67},"type":"Armature","name":"weapon_1005","slot":[{"name":"back","parent":"root","color":{}},{"z":1,"name":"front","parent":"root","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-11,"x":81},"name":"fire","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/b_folder/0","transform":{"skX":0.0009,"x":0.05,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/1","transform":{"skX":0.0009,"x":0.05,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/2","transform":{"skX":0.0009,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/3","transform":{"skX":0.0009,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/4","transform":{"y":-0.5,"skX":0.0009,"skY":0.0009}}],"name":"front"},{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_1","transform":{"y":-2,"x":-23.5}}],"name":"back"}]}],"aabb":{"width":184.0499391617343,"y":-32,"height":60,"x":-76},"type":"Armature","name":"weapon_1005b","slot":[{"name":"back","parent":"root","color":{}},{"z":1,"name":"front","parent":"front","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":0.05,"x":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":0.05,"x":0.1}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.95}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.45}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":0.05,"x":0.1}},{"tweenEasing":null,"duration":0,"transform":{"y":-0.45}}],"name":"front"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-13,"x":104},"name":"fire","parent":"root"},{"inheritScale":0,"transform":{"y":-1.4,"skX":-2.7082,"x":53,"skY":-2.7082},"name":"front","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_2","transform":{"y":-2,"x":-29}}],"name":"back"},{"display":[{"type":"image","name":"weapon_1005_folder/c_folder/0","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/1","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/2","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/3","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/4","transform":{"y":0.05,"skX":-0.0009,"x":0.05,"skY":-0.0009}}],"name":"front"}]}],"aabb":{"width":219.10213580747967,"y":-34,"height":64,"x":-83},"type":"Armature","name":"weapon_1005c","slot":[{"name":"back","parent":"root","color":{}},{"z":1,"name":"front","parent":"front","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5,"x":-0.05}},{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-1.4,"skX":-2.4482,"x":68.1,"skY":-2.4482},"name":"front","parent":"root"},{"inheritScale":0,"transform":{"y":-12,"x":133},"name":"fire","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_3","transform":{"y":-5.5,"x":-38}}],"name":"back"},{"display":[{"type":"image","name":"weapon_1005_folder/c_folder/0","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/1","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/2","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/3","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/4","transform":{"y":0.05,"skX":-0.0009,"x":0.05,"skY":-0.0009}}],"name":"front"}]}],"aabb":{"width":275.10213580747967,"y":-40,"height":69,"x":-139},"type":"Armature","name":"weapon_1005d","slot":[{"name":"front","parent":"front","color":{}},{"z":1,"name":"back","parent":"root","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5,"x":-0.05}},{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-1.4,"skX":-2.4482,"x":68.1,"skY":-2.4482},"name":"front","parent":"root"},{"inheritScale":0,"transform":{"y":-12,"x":133},"name":"fire","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/c_folder/0","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/1","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/2","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/3","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/4","transform":{"y":0.05,"skX":-0.0009,"x":0.05,"skY":-0.0009}}],"name":"front"},{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_4","transform":{"y":-2,"x":-18}}],"name":"back"}]}],"aabb":{"width":352.10213580747967,"y":-40,"height":76,"x":-158},"type":"Armature","name":"weapon_1005e","slot":[{"name":"front","parent":"front","color":{}},{"z":1,"name":"back","parent":"root","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5,"x":-0.05}},{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-0.4,"skX":-2.4482,"x":126.1,"skY":-2.4482},"name":"front","parent":"root"},{"inheritScale":0,"transform":{"y":-11,"x":191},"name":"fire","parent":"root"}],"frameRate":24}],"isGlobal":0,"name":"weapon_1000","version":"5.0"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/core_element/weapon_1000_tex.json b/reference/Egret/Demos/resource/assets/core_element/weapon_1000_tex.json new file mode 100644 index 0000000..94b339f --- /dev/null +++ b/reference/Egret/Demos/resource/assets/core_element/weapon_1000_tex.json @@ -0,0 +1 @@ +{"SubTexture":[{"width":75,"y":266,"height":40,"name":"weapon_1005_folder/weapon_r_0","x":111},{"frameHeight":37,"y":270,"frameX":0,"width":81,"frameY":0,"height":36,"name":"weapon_1005_folder/a_folder/boss_zhl.0002","frameWidth":81,"x":1},{"frameHeight":37,"y":237,"frameX":0,"width":81,"frameY":0,"height":36,"name":"weapon_1005_folder/a_folder/boss_zhl.0003","frameWidth":81,"x":277},{"width":81,"y":237,"height":37,"name":"weapon_1005_folder/a_folder/boss_zhl.0001","x":194},{"width":81,"y":227,"height":37,"name":"weapon_1005_folder/a_folder/boss_zhl.0005","x":111},{"width":81,"y":72,"height":37,"name":"weapon_1005_folder/a_folder/boss_zhl.0004","x":421},{"width":105,"y":128,"height":60,"name":"weapon_1005_folder/weapon_r_1","x":387},{"width":110,"y":178,"height":47,"name":"weapon_1005_folder/b_folder/0","x":1},{"width":108,"y":227,"height":41,"name":"weapon_1005_folder/b_folder/3","x":1},{"width":108,"y":180,"height":45,"name":"weapon_1005_folder/b_folder/2","x":113},{"width":108,"y":194,"height":41,"name":"weapon_1005_folder/b_folder/4","x":223},{"width":109,"y":190,"height":49,"name":"weapon_1005_folder/b_folder/1","x":387},{"width":108,"y":128,"height":64,"name":"weapon_1005_folder/weapon_r_2","x":277},{"width":136,"y":72,"height":54,"name":"weapon_1005_folder/c_folder/1","x":283},{"width":136,"y":132,"height":46,"name":"weapon_1005_folder/c_folder/4","x":139},{"width":136,"y":133,"height":43,"name":"weapon_1005_folder/c_folder/3","x":1},{"width":136,"y":79,"height":52,"name":"weapon_1005_folder/c_folder/0","x":1},{"width":136,"y":79,"height":51,"name":"weapon_1005_folder/c_folder/2","x":139},{"width":202,"y":1,"height":69,"name":"weapon_1005_folder/weapon_r_3","x":283},{"width":280,"y":1,"height":76,"name":"weapon_1005_folder/weapon_r_4","x":1}],"name":"weapon_1000","imagePath":"weapon_1000_tex.png"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/core_element/weapon_1000_tex.png b/reference/Egret/Demos/resource/assets/core_element/weapon_1000_tex.png new file mode 100644 index 0000000..0d6c927 Binary files /dev/null and b/reference/Egret/Demos/resource/assets/core_element/weapon_1000_tex.png differ diff --git a/reference/Egret/Demos/resource/assets/dragon_boy_ske.dbbin b/reference/Egret/Demos/resource/assets/dragon_boy_ske.dbbin new file mode 100644 index 0000000..87418d4 Binary files /dev/null and b/reference/Egret/Demos/resource/assets/dragon_boy_ske.dbbin differ diff --git a/reference/Egret/Demos/resource/assets/dragon_boy_ske.json b/reference/Egret/Demos/resource/assets/dragon_boy_ske.json new file mode 100644 index 0000000..5d2ce0d --- /dev/null +++ b/reference/Egret/Demos/resource/assets/dragon_boy_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"armature":[{"aabb":{"width":693.2805749826739,"y":-702.3605101048755,"height":769.5863484320666,"x":-240.9677870990554},"type":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"stand"}],"skin":[{"name":"","slot":[{"display":[{"path":"parts/tail","type":"image","name":"parts/tail","transform":{"skX":45.2229,"y":-0.0768,"skY":45.2229,"x":30.247025}}],"name":"tail"},{"display":[{"path":"parts/armUpperR","type":"image","name":"parts/armUpperR","transform":{"skX":13.9232,"y":1.1848,"skY":13.9232,"x":14.130075}}],"name":"armUpperR"},{"display":[{"path":"parts/beardL","type":"image","name":"parts/beardL","transform":{"skX":-174.0434,"y":-1.088575,"skY":-174.0434,"x":12.496175}}],"name":"beardL"},{"display":[{"path":"parts/eyeL","type":"image","name":"parts/eyeL","transform":{"y":0.1,"x":0.075}}],"name":"eyeL"},{"display":[{"path":"parts/armL","type":"image","name":"parts/armL","transform":{"skX":98.2989,"y":-0.719275,"skY":98.2989,"x":6.6737}}],"name":"armL"},{"display":[{"path":"parts/body","type":"image","name":"parts/body","transform":{"skX":94.9653,"y":0.154875,"skY":94.9653,"x":-0.2393}}],"name":"body"},{"display":[{"path":"parts/armR","type":"image","name":"parts/armR","transform":{"skX":-85.2356,"y":0.697625,"skY":-85.2356,"x":3.554325}}],"name":"armR"},{"display":[{"path":"parts/clothes1","type":"image","name":"parts/clothes1","transform":{"skX":132.4995,"y":4.012475,"skY":132.4995,"x":8.099525}}],"name":"clothes"},{"display":[{"path":"parts/legR","type":"image","name":"parts/legR","transform":{"skX":-94.0239,"y":-1.50245,"skY":-94.0239,"x":20.645475}}],"name":"legR"},{"display":[{"path":"parts/handL","type":"image","name":"parts/handL","transform":{"skX":146.6156,"y":-0.362775,"skY":146.6156,"x":8.683125}}],"name":"handL"},{"display":[{"path":"parts/tailTip","type":"image","name":"parts/tailTip","transform":{"skX":82.7421,"y":-0.205475,"skY":82.7421,"x":20.4126}}],"name":"tailTip"},{"display":[{"path":"parts/hair","type":"image","name":"parts/hair","transform":{"skX":-4.9086,"y":0.099375,"skY":-4.9086,"x":0.01125}}],"name":"hair"},{"display":[{"path":"parts/eyeR","type":"image","name":"parts/eyeR","transform":{"y":-0.125,"x":0.375}}],"name":"eyeR"},{"display":[{"path":"parts/legL","type":"image","name":"parts/legL","transform":{"skX":-146.9135,"y":-1.6115,"skY":-146.9135,"x":25.27875}}],"name":"legL"},{"display":[{"path":"parts/handR","type":"image","name":"parts/handR","transform":{"skX":-88.1106,"y":1.26565,"skY":-88.1106,"x":5.7614}}],"name":"handR"},{"display":[{"path":"parts/head","type":"image","name":"parts/head","transform":{"skX":80.4531,"y":-2.634675,"skY":80.4531,"x":30.73875}}],"name":"head"},{"display":[{"path":"parts/armUpperL","type":"image","name":"parts/armUpperL","transform":{"skX":-148.2623,"y":1.080425,"skY":-148.2623,"x":6.9746}}],"name":"armUpperL"},{"display":[{"path":"parts/beardR","type":"image","name":"parts/beardR","transform":{"y":0.05,"x":15.4}}],"name":"beardR"}]}],"bone":[{"name":"root","transform":{"y":-67.63665,"x":-1.639675}},{"length":37.5,"transform":{"skX":-94.9653,"y":12.635475,"skY":-94.9653,"x":6.523525},"parent":"root","name":"body"},{"length":30,"transform":{"skX":-156.0107,"y":11.725,"skY":-156.0107,"x":-23.90455},"parent":"body","name":"legR"},{"length":37.5,"transform":{"skX":159.9921,"y":7.848175,"skY":159.9921,"x":20.146325},"parent":"body","name":"armUpperR"},{"length":37.5,"transform":{"skX":-154.3312,"y":-15.06895,"skY":-154.3312,"x":-17.7624},"parent":"body","name":"legL"},{"length":37.5,"transform":{"skX":11.4957,"y":-1.450925,"skY":11.4957,"x":40.778625},"parent":"body","name":"head"},{"length":17.5,"transform":{"skX":-171.7742,"y":-23.401175,"skY":-171.7742,"x":18.620325},"parent":"body","name":"armUpperL"},{"length":62.5,"transform":{"skX":79.7425,"y":17.53175,"skY":79.7425,"x":-29.2773},"parent":"body","name":"tail"},{"length":20,"transform":{"skX":-37.5342,"y":-7.9354,"skY":-37.5342,"x":0.35575},"parent":"body","name":"clothes"},{"length":15,"transform":{"skX":30.7088,"y":0.5564,"skY":30.7088,"x":16.6908},"parent":"armUpperL","name":"armL"},{"transform":{"skX":80.4531,"y":-5.998925,"skY":80.4531,"x":35.0657},"name":"eyeR","parent":"head"},{"length":37.5,"transform":{"skX":-37.5192,"y":-0.7752,"skY":-37.5192,"x":64.465525},"parent":"tail","name":"tailTip"},{"transform":{"skX":80.4531,"y":-25.297,"skY":80.4531,"x":33.442525},"name":"eyeL","parent":"head"},{"length":20,"transform":{"skX":-105.5036,"y":-33.4062,"skY":-105.5036,"x":1.8647},"parent":"head","name":"beardL"},{"length":12.5,"transform":{"skX":35.2088,"y":0.132125,"skY":35.2088,"x":34.6873},"parent":"armUpperR","name":"armR"},{"length":20,"transform":{"skX":80.4531,"y":-8.96425,"skY":80.4531,"x":5.818825},"parent":"head","name":"beardR"},{"length":12.5,"transform":{"skX":86.9099,"y":20.157725,"skY":86.9099,"x":26.206225},"parent":"head","name":"hair"},{"length":10,"transform":{"skX":17.875,"y":0.276975,"skY":17.875,"x":10.84685},"parent":"armR","name":"handR"},{"length":20,"transform":{"skX":4.4133,"y":-0.106825,"skY":4.4133,"x":16.657725},"parent":"armL","name":"handL"}],"slot":[{"name":"tailTip","parent":"tailTip","color":{}},{"z":1,"name":"armUpperL","parent":"armUpperL","color":{}},{"z":2,"name":"armL","parent":"armL","color":{}},{"z":3,"name":"handL","parent":"handL","color":{}},{"z":4,"name":"legL","parent":"legL","color":{}},{"z":5,"name":"body","parent":"body","color":{}},{"z":6,"name":"tail","parent":"tail","color":{}},{"z":7,"name":"clothes","parent":"clothes","color":{}},{"z":8,"name":"hair","parent":"hair","color":{}},{"z":9,"name":"head","parent":"head","color":{}},{"z":10,"name":"eyeL","parent":"eyeL","color":{}},{"z":11,"name":"eyeR","parent":"eyeR","color":{}},{"z":12,"name":"legR","parent":"legR","color":{}},{"z":13,"name":"armUpperR","parent":"armUpperR","color":{}},{"z":14,"name":"armR","parent":"armR","color":{}},{"z":15,"name":"handR","parent":"handR","color":{}},{"z":16,"name":"beardL","parent":"beardL","color":{}},{"z":17,"name":"beardR","parent":"beardR","color":{}}],"animation":[{"playTimes":0,"frame":[],"duration":30,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":30}],"name":"root"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"skX":4.95,"skY":4.95,"x":-1},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{},"tweenEasing":0,"duration":12},{"transform":{"y":-0.5,"x":-0.5},"tweenEasing":0,"duration":18},{"transform":{},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"y":-0.5},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"skX":-12.64,"y":-2.01435,"skY":-12.64,"x":1.2837},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"y":-0.5},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{"skX":9.6205,"skY":9.6205},"tweenEasing":0,"duration":15},{"transform":{"skX":-1.4848,"skY":-1.4848},"tweenEasing":0,"duration":15},{"transform":{"skX":9.6205,"skY":9.6205},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":15},{"transform":{"skX":5.44,"skY":5.44},"tweenEasing":0,"duration":15},{"transform":{},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":12},{"transform":{"y":-1,"x":0.5},"tweenEasing":0,"duration":18},{"transform":{},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":17},{"tweenEasing":null,"duration":1},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":7},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":1},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":7},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":1},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"stand"},{"playTimes":0,"frame":[],"duration":20,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":20},{"transform":{},"tweenEasing":null,"duration":0}],"name":"root"},{"frame":[{"transform":{"y":-1},"tweenEasing":0,"duration":10},{"transform":{"y":-0.5},"tweenEasing":0,"duration":10},{"transform":{"y":-1},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{"skX":-30,"y":-3.5,"skY":-30,"x":-1.5},"tweenEasing":0,"duration":10},{"transform":{"skX":30,"y":-0.5,"skY":30,"x":-0.975},"tweenEasing":0,"duration":10},{"transform":{"skX":-30,"y":-3.5,"skY":-30,"x":-1.5},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{"skX":45.5,"y":3.5,"skY":45.5,"x":-1.5},"tweenEasing":0,"duration":10},{"transform":{"skX":-22.15,"y":0.5,"skY":-22.15},"tweenEasing":0,"duration":10},{"transform":{"skX":45.5,"y":3.5,"skY":45.5,"x":-1.5},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{"skX":49.67,"y":7.100275,"skY":49.67,"x":-10.08605},"tweenEasing":0,"duration":10},{"transform":{"skX":-19.23,"y":-2.23195,"skY":-19.23,"x":-5.63015},"tweenEasing":0,"duration":10},{"transform":{"skX":49.67,"y":7.100275,"skY":49.67,"x":-10.08605},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{"y":1},"tweenEasing":0,"duration":10},{"transform":{"skX":2.95,"y":0.5,"skY":2.95},"tweenEasing":0,"duration":10},{"transform":{"y":1},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{"skX":-21.2,"y":1,"skY":-21.2},"tweenEasing":0,"duration":10},{"transform":{"skX":30,"y":0.5,"skY":30},"tweenEasing":0,"duration":10},{"transform":{"skX":-21.2,"y":1,"skY":-21.2},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{"x":-2},"tweenEasing":0,"duration":10},{"transform":{"skX":-8.7,"y":-1.5,"skY":-8.7,"x":-3},"tweenEasing":0,"duration":10},{"transform":{"x":-2},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-0.5,"x":-0.5},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-0.5,"x":-0.5},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{"skX":-38.8,"y":-0.5503,"skY":-38.8,"x":-3.259675},"tweenEasing":0,"duration":10},{"transform":{"skX":38.55,"y":-1.461275,"skY":38.55,"x":0.976075},"tweenEasing":0,"duration":10},{"transform":{"skX":-38.8,"y":-0.5503,"skY":-38.8,"x":-3.259675},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{"y":0.125,"x":0.425},"tweenEasing":0,"duration":10},{"transform":{"skX":-2.95,"y":-0.069325,"skY":-2.95,"x":-1.0284},"tweenEasing":0,"duration":10},{"transform":{"y":0.125,"x":0.425},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{"y":-0.133975,"x":2.23205},"tweenEasing":0,"duration":10},{"transform":{"skX":17.93,"y":2.519025,"skY":17.93,"x":-0.749225},"tweenEasing":0,"duration":10},{"transform":{"y":-0.133975,"x":2.23205},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":-2.95,"y":1.047675,"skY":-2.95,"x":-1.887475},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":6.04,"y":-1.37935,"skY":6.04,"x":-0.879675},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{"skX":21.72,"y":2.488875,"skY":21.72,"x":-0.64355},"tweenEasing":0,"duration":5},{"transform":{"skX":31.7897,"y":1.249725,"skY":31.7897,"x":-0.683125},"tweenEasing":0,"duration":5},{"transform":{"skX":-15.63,"y":0.0106,"skY":-15.63,"x":-0.722675},"tweenEasing":0,"duration":5},{"transform":{"skX":-19.6672,"y":-1.40275,"skY":-19.6672,"x":-0.056175},"tweenEasing":0,"duration":5},{"transform":{"skX":21.72,"y":2.488875,"skY":21.72,"x":-0.64355},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":-10.45,"y":0.41485,"skY":-10.45,"x":-0.3614},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":-2.95,"y":-1.79345,"skY":-2.95,"x":0.282225},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{"skX":-45.48,"y":0.506125,"skY":-45.48,"x":-4.066475},"tweenEasing":0,"duration":10},{"transform":{"skX":-0.48,"y":0.541625,"skY":-0.48,"x":0.374075},"tweenEasing":0,"duration":10},{"transform":{"skX":-45.48,"y":0.506125,"skY":-45.48,"x":-4.066475},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{"skX":15,"y":0.225675,"skY":15,"x":-0.416425},"tweenEasing":0,"duration":10},{"transform":{"skX":6.45,"y":0.8498,"skY":6.45,"x":-0.69405},"tweenEasing":0,"duration":10},{"transform":{"skX":15,"y":0.225675,"skY":15,"x":-0.416425},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"walk"},{"playTimes":0,"frame":[],"duration":5,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":5}],"name":"root"},{"frame":[{"transform":{"y":-16.5},"tweenEasing":0,"duration":5},{"transform":{"y":-16.5},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{"skX":-27.69,"y":0.2582,"skY":-27.69,"x":0.293925},"tweenEasing":0,"duration":2},{"transform":{"skX":-27.69,"y":0.16485,"skY":-27.69,"x":-0.7805},"tweenEasing":0,"duration":3},{"transform":{"skX":-27.69,"y":0.2582,"skY":-27.69,"x":0.293925},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{"skX":-24.65,"y":2.5,"skY":-24.65},"tweenEasing":0,"duration":2},{"transform":{"skX":-23.1904,"y":2.437775,"skY":-23.1904,"x":-0.716275},"tweenEasing":0,"duration":3},{"transform":{"skX":-24.65,"y":2.5,"skY":-24.65},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{"skX":-15.2954,"y":9.571825,"skY":-15.2954,"x":-5.1551},"tweenEasing":0,"duration":2},{"transform":{"skX":-15.2954,"y":9.44735,"skY":-15.2954,"x":-6.587675},"tweenEasing":0,"duration":3},{"transform":{"skX":-15.2954,"y":9.571825,"skY":-15.2954,"x":-5.1551},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{"skX":10,"y":0.475,"skY":10,"x":0.9},"tweenEasing":0,"duration":5},{"transform":{"skX":10,"y":0.475,"skY":10,"x":0.9},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{"skX":15,"y":1,"skY":15},"tweenEasing":0,"duration":2},{"transform":{"skX":15,"y":0.90665,"skY":15,"x":-1.074425},"tweenEasing":0,"duration":3},{"transform":{"skX":15,"y":1,"skY":15},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{"skX":9.3457,"y":-2.5,"skY":9.3457,"x":-6},"tweenEasing":0,"duration":2},{"transform":{"skX":13.7283,"y":-2.5,"skY":13.7283,"x":-6},"tweenEasing":0,"duration":3},{"transform":{"skX":9.3457,"y":-2.5,"skY":9.3457,"x":-6},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{"y":-1.1277,"x":-1.19205},"tweenEasing":0,"duration":2},{"transform":{"y":-1.22105,"x":-2.266475},"tweenEasing":0,"duration":3},{"transform":{"y":-1.1277,"x":-1.19205},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{"skX":8.55,"y":0.6382,"skY":8.55,"x":-0.149475},"tweenEasing":0,"duration":5},{"transform":{"skX":8.55,"y":0.6382,"skY":8.55,"x":-0.149475},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{"skX":-10,"y":-2.1757,"skY":-10,"x":2.220375},"tweenEasing":0,"duration":2},{"transform":{"skX":-10,"y":-2.264625,"skY":-10,"x":2.0302},"tweenEasing":0,"duration":3},{"transform":{"skX":-10,"y":-1.931525,"skY":-10,"x":2.25325},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{"skX":2.89,"y":1.575025,"skY":2.89,"x":0.54245},"tweenEasing":0,"duration":2},{"transform":{"skX":8.91,"y":-0.224,"skY":8.91,"x":0.159375},"tweenEasing":0,"duration":3},{"transform":{"skX":2.89,"y":1.575025,"skY":2.89,"x":0.54245},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{"skX":-10,"y":-1.57535,"skY":-10,"x":2.234775},"tweenEasing":0,"duration":2},{"transform":{"skX":-10,"y":-2.264625,"skY":-10,"x":2.0302},"tweenEasing":0,"duration":3},{"transform":{"skX":-10,"y":-1.57535,"skY":-10,"x":2.234775},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{"skX":-50.29,"y":4.806675,"skY":-50.29,"x":-4.944425},"tweenEasing":0,"duration":2},{"transform":{"skX":-58.5649,"y":4.806675,"skY":-58.5649,"x":-4.944425},"tweenEasing":0,"duration":3},{"transform":{"skX":-50.29,"y":4.806675,"skY":-50.29,"x":-4.944425},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{"skX":-13.13,"y":0.289775,"skY":-13.13,"x":-2.020225},"tweenEasing":0,"duration":5},{"transform":{"skX":-13.13,"y":0.289775,"skY":-13.13,"x":-2.020225},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{"skX":42.5,"y":1.6871,"skY":42.5,"x":-2.037225},"tweenEasing":0,"duration":2},{"transform":{"skX":50.23,"y":1.707375,"skY":50.23,"x":-2.008275},"tweenEasing":0,"duration":3},{"transform":{"skX":42.5,"y":1.6871,"skY":42.5,"x":-2.037225},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{"skX":-10,"y":-1.5109,"skY":-10,"x":-0.204525},"tweenEasing":0,"duration":2},{"transform":{"skX":-10,"y":-0.699725,"skY":-10,"x":0.953925},"tweenEasing":0,"duration":3},{"transform":{"skX":-10,"y":-1.5109,"skY":-10,"x":-0.204525},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{"skX":-0.48,"y":0.541625,"skY":-0.48,"x":0.374075},"tweenEasing":0,"duration":5},{"transform":{"skX":-0.48,"y":0.541625,"skY":-0.48,"x":0.374075},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{"skX":-8.55,"y":-0.962825,"skY":-8.55,"x":-3.527325},"tweenEasing":0,"duration":5},{"transform":{"skX":-8.55,"y":-0.962825,"skY":-8.55,"x":-3.527325},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"jump"},{"playTimes":0,"frame":[],"duration":5,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":5}],"name":"root"},{"frame":[{"transform":{"y":-16.5},"tweenEasing":0,"duration":5},{"transform":{"y":-16.5},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{"skX":27.76,"y":2.2411,"skY":27.76,"x":1.544925},"tweenEasing":0,"duration":2},{"transform":{"skX":27.76,"y":2.144,"skY":27.76,"x":0.427375},"tweenEasing":0,"duration":3},{"transform":{"skX":27.76,"y":2.2411,"skY":27.76,"x":1.544925},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{"skX":-69.64,"y":2.5,"skY":-69.64},"tweenEasing":0,"duration":2},{"transform":{"skX":-66.683,"y":2.467625,"skY":-66.683,"x":-0.3725},"tweenEasing":0,"duration":3},{"transform":{"skX":-69.64,"y":2.5,"skY":-69.64},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{"skX":50.73,"y":1.975,"skY":50.73,"x":5.65},"tweenEasing":0,"duration":2},{"transform":{"skX":50.73,"y":1.910275,"skY":50.73,"x":4.904975},"tweenEasing":0,"duration":3},{"transform":{"skX":50.73,"y":1.975,"skY":50.73,"x":5.65},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{"skX":-8.73,"y":-0.85,"skY":-8.73,"x":2.75},"tweenEasing":0,"duration":5},{"transform":{"skX":-8.73,"y":-0.85,"skY":-8.73,"x":2.75},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{"skX":92.45,"y":1,"skY":92.45},"tweenEasing":0,"duration":2},{"transform":{"skX":89.9735,"y":1.064725,"skY":89.9735,"x":0.745025},"tweenEasing":0,"duration":3},{"transform":{"skX":92.45,"y":1,"skY":92.45},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{"skX":-18.47,"y":-1.525,"skY":-18.47,"x":-0.975},"tweenEasing":0,"duration":2},{"transform":{"skX":-22.44,"y":-1.525,"skY":-22.44,"x":-0.975},"tweenEasing":0,"duration":3},{"transform":{"skX":-18.47,"y":-1.525,"skY":-18.47,"x":-0.975},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{"y":-1.215525,"x":-1.50165},"tweenEasing":0,"duration":2},{"transform":{"y":-1.118425,"x":-0.384125},"tweenEasing":0,"duration":3},{"transform":{"y":-1.215525,"x":-1.50165},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{"skX":-53.9,"y":1.45345,"skY":-53.9,"x":1.087275},"tweenEasing":0,"duration":5},{"transform":{"skX":-53.9,"y":1.45345,"skY":-53.9,"x":1.087275},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{"skX":8.73,"y":-1.153625,"skY":8.73,"x":-4.44015},"tweenEasing":0,"duration":2},{"transform":{"skX":8.73,"y":-0.7513,"skY":8.73,"x":-3.707225},"tweenEasing":0,"duration":3},{"transform":{"skX":8.73,"y":-1.153625,"skY":8.73,"x":-4.44015},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{"skX":0.14,"y":-0.289,"skY":0.14,"x":0.699575},"tweenEasing":0,"duration":2},{"transform":{"skX":-0.83,"y":0.44715,"skY":-0.83,"x":0.45425},"tweenEasing":0,"duration":3},{"transform":{"skX":0.14,"y":-0.289,"skY":0.14,"x":0.699575},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{"skX":8.73,"y":-2.0383,"skY":8.73,"x":-3.25035},"tweenEasing":0,"duration":2},{"transform":{"skX":8.73,"y":-1.484225,"skY":8.73,"x":-3.304875},"tweenEasing":0,"duration":3},{"transform":{"skX":8.73,"y":-2.0383,"skY":8.73,"x":-3.25035},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{"skX":-2.54,"y":1.945425,"skY":-2.54,"x":0.081175},"tweenEasing":0,"duration":2},{"transform":{"skX":25.1339,"y":1.945425,"skY":25.1339,"x":0.081175},"tweenEasing":0,"duration":3},{"transform":{"skX":-2.54,"y":1.945425,"skY":-2.54,"x":0.081175},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{"skX":-13.14,"y":-0.799125,"skY":-13.14,"x":-2.801725},"tweenEasing":0,"duration":5},{"transform":{"skX":-13.14,"y":-0.799125,"skY":-13.14,"x":-2.801725},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{"skX":8.96,"y":1.31275,"skY":8.96,"x":-1.966675},"tweenEasing":0,"duration":2},{"transform":{"skX":-6.04,"y":1.31275,"skY":-6.04,"x":-1.966675},"tweenEasing":0,"duration":3},{"transform":{"skX":8.96,"y":1.31275,"skY":8.96,"x":-1.966675},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{"skX":-6.27,"y":1.80955,"skY":-6.27,"x":0.147725},"tweenEasing":0,"duration":2},{"transform":{"skX":-7.09,"y":0.051875,"skY":-7.09,"x":-1.580525},"tweenEasing":0,"duration":3},{"transform":{"skX":-6.27,"y":1.80955,"skY":-6.27,"x":0.147725},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{"skX":29.52,"y":-0.3423,"skY":29.52,"x":-0.984675},"tweenEasing":0,"duration":5},{"transform":{"skX":29.52,"y":-0.3423,"skY":29.52,"x":-0.984675},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{"skX":21.45,"y":0.367025,"skY":21.45,"x":-0.899625},"tweenEasing":0,"duration":5},{"transform":{"skX":21.45,"y":0.367025,"skY":21.45,"x":-0.899625},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"fall"}],"frameRate":24,"name":"DragonBoy"}],"name":"Dragon_1","version":"5.0"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/dragon_boy_tex.json b/reference/Egret/Demos/resource/assets/dragon_boy_tex.json new file mode 100644 index 0000000..9021b7b --- /dev/null +++ b/reference/Egret/Demos/resource/assets/dragon_boy_tex.json @@ -0,0 +1 @@ +{"imagePath":"dragon_boy_tex.png","width":256,"SubTexture":[{"frameX":0,"y":174,"frameY":0,"frameWidth":28,"width":28,"frameHeight":53,"height":52,"name":"parts/tailTip","x":196},{"width":28,"y":174,"height":22,"name":"parts/armUpperL","x":226},{"width":12,"y":234,"height":20,"name":"parts/armL","x":90},{"width":24,"y":198,"height":20,"name":"parts/handL","x":226},{"frameX":0,"y":191,"frameY":0,"frameWidth":51,"width":51,"frameHeight":45,"height":45,"name":"parts/legL","x":1},{"frameX":0,"y":102,"frameY":0,"frameWidth":59,"width":59,"frameHeight":87,"height":87,"name":"parts/body","x":1},{"width":54,"y":102,"height":70,"name":"parts/tail","x":62},{"width":52,"y":174,"height":44,"name":"parts/clothes1","x":109},{"width":31,"y":174,"height":71,"name":"parts/hair","x":163},{"frameX":0,"y":1,"frameY":0,"frameWidth":85,"width":84,"frameHeight":99,"height":99,"name":"parts/head","x":1},{"width":7,"y":241,"height":12,"name":"parts/eyeL","x":238},{"frameX":0,"y":220,"frameY":0,"frameWidth":10,"width":9,"frameHeight":15,"height":15,"name":"parts/eyeR","x":136},{"frameX":0,"y":174,"frameY":0,"frameWidth":45,"width":45,"frameHeight":58,"height":58,"name":"parts/legR","x":62},{"width":40,"y":228,"height":24,"name":"parts/armUpperR","x":196},{"frameX":0,"y":220,"frameY":0,"frameWidth":12,"width":11,"frameHeight":20,"height":19,"name":"parts/armR","x":238},{"width":25,"y":220,"height":15,"name":"parts/handR","x":109},{"frameX":0,"y":245,"frameY":0,"frameWidth":30,"width":30,"frameHeight":9,"height":9,"name":"parts/beardL","x":54},{"width":34,"y":234,"height":9,"name":"parts/beardR","x":54}],"height":256,"name":"Dragon_1"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/dragon_boy_tex.png b/reference/Egret/Demos/resource/assets/dragon_boy_tex.png new file mode 100644 index 0000000..02c8677 Binary files /dev/null and b/reference/Egret/Demos/resource/assets/dragon_boy_tex.png differ diff --git a/reference/Egret/Demos/resource/assets/replace_slot_display/main_ske.json b/reference/Egret/Demos/resource/assets/replace_slot_display/main_ske.json new file mode 100644 index 0000000..30eb04e --- /dev/null +++ b/reference/Egret/Demos/resource/assets/replace_slot_display/main_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"name":"main","version":"5.0","armature":[{"animation":[{"slot":[],"playTimes":0,"duration":30,"frame":[],"name":"idle","bone":[{"frame":[{"duration":30,"tweenEasing":null,"transform":{}}],"name":"root"},{"frame":[{"duration":10,"tweenEasing":0,"transform":{}},{"duration":10,"tweenEasing":0,"transform":{"skX":120,"skY":120}},{"duration":10,"tweenEasing":0,"transform":{"skX":-120,"skY":-120}},{"duration":0,"tweenEasing":null,"transform":{}}],"name":"ball"},{"frame":[{"duration":10,"tweenEasing":0,"transform":{}},{"duration":10,"tweenEasing":0,"transform":{"skX":120,"skY":120}},{"duration":10,"tweenEasing":0,"transform":{"skX":-120,"skY":-120}},{"duration":0,"tweenEasing":null,"transform":{}}],"name":"point"}],"ffd":[{"frame":[{"duration":10,"tweenEasing":0,"offset":0,"vertices":[]},{"duration":10,"tweenEasing":0,"offset":0,"vertices":[115.61,54.15,0,0,120.7,-60.04,0,0,0,0,0,0,0,0,0,0,113.3,49.94,119.03,-55.73,1,-5.66,-1.29,7.67,0,0,0,0,0,0,0,0]},{"duration":10,"tweenEasing":0,"offset":0,"vertices":[-36.97,-85.96,0,0,-21.37,108.42,0,0,0,0,0,0,0,0,0,0,-39.88,-82.14,-19.5,95.39,2.53,5.56,0.38,-2.85,0,0,0,0,0,0,0,0]},{"duration":0,"tweenEasing":null,"offset":0,"vertices":[]}],"scale":1,"skin":"","offset":0,"name":"display0005","slot":"mesh"}]}],"defaultActions":[{"gotoAndPlay":"idle"}],"type":"Armature","name":"MyArmature","slot":[{"color":{},"name":"point","parent":"point"},{"z":1,"color":{},"name":"mesh","parent":"point"},{"z":2,"color":{},"name":"ball","parent":"ball"},{"z":3,"color":{},"name":"weapon","parent":"ball"}],"ik":[],"aabb":{"width":674.9445000000001,"y":-80.1317,"height":160.1317,"x":-335},"bone":[{"name":"root","transform":{}},{"length":100,"transform":{},"parent":"root","name":"point"},{"length":100,"transform":{"x":100},"parent":"point","name":"ball"}],"frameRate":24,"skin":[{"name":"","slot":[{"display":[{"width":270,"userEdges":[6,7,7,13,13,4,6,15,15,5,9,10,10,6,7,11,11,8,8,9],"type":"mesh","vertices":[-135,-80,135,-80,-135,80,135,80,134.95,-31.85,134.95,31.45,73.3,31.25,73.2,-31.65,-121.4,-67.5,-122.1,66.7,88.45,66.3,89.25,-65.95,107.1,-80,106.3,-31.76,106.5,80,106.3,31.36],"transform":{"x":-200},"height":160,"edges":[2,0,1,4,4,5,5,3,0,12,12,1,3,14,14,2],"path":"display0005","uvs":[0,0,1,0,0,1,1,1,0.99981,0.30094,0.99981,0.69656,0.77148,0.69531,0.77111,0.30219,0.05037,0.07813,0.04778,0.91687,0.82759,0.91438,0.83056,0.08781,0.89667,0,0.89369,0.30152,0.89444,1,0.89369,0.69598],"name":"display0005","triangles":[9,2,10,0,8,11,0,11,12,10,2,14,15,10,14,12,11,13,12,13,4,12,4,1,14,3,5,15,14,5,4,13,5,13,15,5,6,10,15,11,7,13,6,15,13,7,6,13,6,9,10,8,7,11,8,9,6,8,6,7,8,0,9,0,2,9]}],"name":"mesh"},{"display":[{"path":"weapon_1004_1","type":"image","name":"weapon_1004_1","transform":{"y":5,"x":65}}],"name":"weapon"},{"display":[{"path":"display0001","type":"image","name":"display0001","transform":{}}],"name":"point"},{"display":[{"path":"display0009","type":"image","name":"display0009","transform":{"y":-0.1317,"x":104.9445}}],"name":"ball"}]}]}]} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/replace_slot_display/main_tex.json b/reference/Egret/Demos/resource/assets/replace_slot_display/main_tex.json new file mode 100644 index 0000000..e114583 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/replace_slot_display/main_tex.json @@ -0,0 +1 @@ +{"imagePath":"main_tex.png","width":512,"SubTexture":[{"width":60,"y":325,"height":60,"name":"display0001","x":206},{"width":270,"y":1,"height":160,"name":"display0005","x":1},{"width":270,"y":163,"height":160,"name":"display0009","x":1},{"width":203,"y":325,"height":29,"name":"weapon_1004_1","x":1}],"height":512,"name":"main"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/replace_slot_display/main_tex.png b/reference/Egret/Demos/resource/assets/replace_slot_display/main_tex.png new file mode 100644 index 0000000..3f6d6b2 Binary files /dev/null and b/reference/Egret/Demos/resource/assets/replace_slot_display/main_tex.png differ diff --git a/reference/Egret/Demos/resource/assets/replace_slot_display/replace_ske.json b/reference/Egret/Demos/resource/assets/replace_slot_display/replace_ske.json new file mode 100644 index 0000000..092f090 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/replace_slot_display/replace_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"name":"replace","version":"5.0","armature":[{"animation":[{"slot":[],"playTimes":0,"duration":0,"frame":[],"name":"newAnimation","bone":[{"frame":[{"duration":0,"tweenEasing":null,"transform":{}}],"name":"root"}],"ffd":[]}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"type":"Armature","name":"MyMesh","slot":[{"color":{},"name":"meshA","parent":"root"},{"z":1,"color":{},"name":"meshB","parent":"root"},{"z":2,"color":{},"name":"mesh","parent":"root"}],"ik":[],"aabb":{"width":203,"y":-9.5,"height":29,"x":-36.5},"bone":[{"length":100,"name":"root","transform":{}}],"frameRate":24,"skin":[{"name":"","slot":[{"display":[{"path":"weapon_1004_1","type":"image","name":"weapon_1004_1","transform":{"y":5,"x":65}}],"name":"mesh"},{"display":[{"width":203,"userEdges":[7,4,4,5,5,6,6,7,12,11,10,11,10,13,14,6,7,15,14,15],"type":"mesh","vertices":[-101.35,-12.8,143.75,-70.95,-101.45,6.15,123.05,20,103.85,7,126.85,-44,13.75,-17.9,11.9,7.05,-46.25,-21.7,-44.75,20.2,-47.75,-9.4,-48.35,2.95,-101.5,5.9,-101.5,-12.15,-46.3,-10.75,-45.8,12.95,13.9,-25.51,26.61,16.69],"transform":{"y":5,"x":65},"height":29,"edges":[1,3,0,8,9,2,2,12,12,13,13,0,8,16,16,1,3,17,17,9],"path":"weapon_1004_1","uvs":[0,0,1,0,0,1,1,1,0.84852,0.6931,0.91256,0.26207,0.66034,0.2,0.59384,0.71379,0.27438,0.00172,0.26453,1,0.26478,0.17586,0.26182,0.60172,0,0.70345,0,0.08103,0.27685,0.2569,0.27906,0.67586,0.5734,0.00101,0.58153,1],"name":"weapon_1004_1","triangles":[6,5,1,16,6,1,4,17,3,1,5,3,5,4,3,6,4,5,6,7,4,7,17,4,15,9,17,8,14,16,11,9,15,11,15,14,10,11,14,0,10,8,10,14,8,12,2,9,0,13,10,12,9,11,10,13,11,13,12,11,14,7,6,15,17,7,14,15,7,16,14,6]}],"name":"meshB"},{"display":[{"width":203,"userEdges":[],"type":"mesh","vertices":[-101.5,-14.5,297.95,-14.5,-101.5,14.5,296.75,14.5,29.55,-14.5,29.1,14.5,262.95,-14.5,261.75,14.5],"transform":{"y":5,"x":65},"height":29,"edges":[1,3,2,0,0,4,5,2,4,6,6,1,3,7,7,5],"path":"weapon_1004_1","uvs":[0,0,1,0,0,1,1,1,0.64557,0,0.64335,1,0.83793,0,0.84384,1],"name":"weapon_1004_1","triangles":[6,7,1,1,7,3,4,5,6,6,5,7,0,2,5,0,5,4]}],"name":"meshA"}]}]},{"animation":[{"slot":[{"frame":[{"duration":1,"tweenEasing":null},{"duration":1,"tweenEasing":null,"displayIndex":6},{"duration":1,"tweenEasing":null,"displayIndex":1},{"duration":2,"tweenEasing":null,"displayIndex":5},{"duration":1,"tweenEasing":null,"displayIndex":7},{"duration":1,"tweenEasing":null,"displayIndex":8},{"duration":1,"tweenEasing":null,"displayIndex":2},{"duration":9,"tweenEasing":null,"displayIndex":4},{"duration":0,"tweenEasing":null,"displayIndex":3}],"name":"ball"}],"playTimes":0,"duration":17,"frame":[],"name":"newAnimation","bone":[{"frame":[{"duration":17,"tweenEasing":null,"transform":{}}],"name":"root"},{"frame":[{"duration":1,"tweenEasing":null,"transform":{"y":-70.4221,"x":-83.5006}},{"duration":1,"tweenEasing":null,"transform":{"y":-64.552,"x":0.4446}},{"duration":1,"tweenEasing":null,"transform":{"y":-65.0185,"x":105.0759}},{"duration":2,"tweenEasing":null,"transform":{"y":0.8148,"x":105.4037}},{"duration":1,"tweenEasing":null,"transform":{"y":65.3926,"x":0.2229}},{"duration":1,"tweenEasing":null,"transform":{"y":65.4336,"x":-105.0409}},{"duration":1,"tweenEasing":null,"transform":{"y":0.5252,"x":-104.8163}},{"duration":9,"tweenEasing":null,"transform":{}},{"duration":0,"tweenEasing":null,"transform":{"y":65.668,"x":105.3589}}],"name":"ball"}],"ffd":[]}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"type":"MovieClip","name":"MyDisplay","slot":[{"color":{},"name":"ball","parent":"ball","displayIndex":-1}],"ik":[],"aabb":{"width":270,"y":-151.2369,"height":160,"x":-323.90430000000003},"bone":[{"name":"root","transform":{}},{"transform":{},"name":"ball","parent":"root"}],"frameRate":24,"skin":[{"name":"","slot":[{"display":[{"path":"display0002","type":"image","name":"display0002","transform":{"y":64.6363,"x":104.7465}},{"path":"display0004","type":"image","name":"display0004","transform":{"y":65.0185,"x":-105.0759}},{"path":"display0009","type":"image","name":"display0009","transform":{"y":-0.5252,"x":104.8163}},{"path":"display0006","type":"image","name":"display0006","transform":{"y":-65.668,"x":-105.3589}},{"path":"display0010","type":"image","name":"display0010","transform":{}},{"path":"display0005","type":"image","name":"display0005","transform":{"y":-0.8148,"x":-105.4037}},{"path":"display0003","type":"image","name":"display0003","transform":{"y":64.552,"x":-0.4446}},{"path":"display0007","type":"image","name":"display0007","transform":{"y":-65.3926,"x":-0.2229}},{"path":"display0008","type":"image","name":"display0008","transform":{"y":-65.4336,"x":105.0409}},{"filterType":null,"path":"MyArmature","type":"armature","name":"MyArmature","transform":{}}],"name":"ball"}]}]}]} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/replace_slot_display/replace_tex.json b/reference/Egret/Demos/resource/assets/replace_slot_display/replace_tex.json new file mode 100644 index 0000000..fdc44d1 --- /dev/null +++ b/reference/Egret/Demos/resource/assets/replace_slot_display/replace_tex.json @@ -0,0 +1 @@ +{"imagePath":"replace_tex.png","width":1024,"SubTexture":[{"width":203,"y":1,"height":29,"name":"weapon_1004_1","x":817},{"width":270,"y":1,"height":190,"name":"display0004","x":1},{"width":240,"y":193,"height":160,"name":"display0010","x":757},{"width":240,"y":193,"height":190,"name":"display0003","x":515},{"width":270,"y":1,"height":190,"name":"display0002","x":545},{"width":1,"y":1,"height":1,"name":"MyArmature","x":1022},{"width":270,"y":193,"height":190,"name":"display0008","x":1},{"width":270,"y":385,"height":160,"name":"display0009","x":1},{"width":240,"y":193,"height":190,"name":"display0007","x":273},{"width":270,"y":1,"height":190,"name":"display0006","x":273},{"width":270,"y":385,"height":160,"name":"display0005","x":273}],"height":1024,"name":"replace"} \ No newline at end of file diff --git a/reference/Egret/Demos/resource/assets/replace_slot_display/replace_tex.png b/reference/Egret/Demos/resource/assets/replace_slot_display/replace_tex.png new file mode 100644 index 0000000..0c85ad0 Binary files /dev/null and b/reference/Egret/Demos/resource/assets/replace_slot_display/replace_tex.png differ diff --git a/reference/Egret/Demos/src/Main.ts b/reference/Egret/Demos/src/Main.ts new file mode 100644 index 0000000..00e8f43 --- /dev/null +++ b/reference/Egret/Demos/src/Main.ts @@ -0,0 +1,12 @@ +class Main extends egret.DisplayObjectContainer { + public constructor() { + super(); + + this.addChild(new HelloDragonBones()); + // this.addChild(new ReplaceSlotDisplay()); + // this.addChild(new coreElement.Game()); + + // this.addChild(new PerformanceTest()); + // this.addChild(new AnimationBaseTest()); + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/src/demo/AnimationBaseTest.ts b/reference/Egret/Demos/src/demo/AnimationBaseTest.ts new file mode 100644 index 0000000..d07da44 --- /dev/null +++ b/reference/Egret/Demos/src/demo/AnimationBaseTest.ts @@ -0,0 +1,103 @@ +class AnimationBaseTest extends BaseTest { + private _armatureDisplay: dragonBones.EgretArmatureDisplay; + + public constructor() { + super(); + + this._resources.push( + "resource/assets/animation_base_test_ske.json", + "resource/assets/animation_base_test_tex.json", + "resource/assets/animation_base_test_tex.png" + ); + } + + protected _onStart(): void { + const factory = dragonBones.EgretFactory.factory; + factory.parseDragonBonesData(RES.getRes("resource/assets/animation_base_test_ske.json")); + factory.parseTextureAtlasData(RES.getRes("resource/assets/animation_base_test_tex.json"), RES.getRes("resource/assets/animation_base_test_tex.png")); + + this._armatureDisplay = factory.buildArmatureDisplay("progressBar"); + this._armatureDisplay.x = this.stage.stageWidth * 0.5; + this._armatureDisplay.y = this.stage.stageHeight * 0.5; + this._armatureDisplay.scaleX = this._armatureDisplay.scaleY = this.stage.stageWidth >= 300 ? 1 : this.stage.stageWidth / 330; + this.addChild(this._armatureDisplay); + + // Test animation event + this._armatureDisplay.addEventListener(dragonBones.EventObject.START, this._animationEventHandler, this); + this._armatureDisplay.addEventListener(dragonBones.EventObject.LOOP_COMPLETE, this._animationEventHandler, this); + this._armatureDisplay.addEventListener(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this); + this._armatureDisplay.addEventListener(dragonBones.EventObject.FADE_IN, this._animationEventHandler, this); + this._armatureDisplay.addEventListener(dragonBones.EventObject.FADE_IN_COMPLETE, this._animationEventHandler, this); + this._armatureDisplay.addEventListener(dragonBones.EventObject.FADE_OUT, this._animationEventHandler, this); + this._armatureDisplay.addEventListener(dragonBones.EventObject.FADE_OUT_COMPLETE, this._animationEventHandler, this); + + // Test frame event + this._armatureDisplay.addEventListener(dragonBones.EventObject.FRAME_EVENT, this._animationEventHandler, this); + + // Test animation config. + // const animaitonConfig = this._armatureDisplay.animation.animationConfig; + // animaitonConfig.name = "test"; // Animation state name. + // animaitonConfig.animation = "idle"; // Animation name. + + // animaitonConfig.playTimes = 1; // Play one time. + // animaitonConfig.playTimes = 3; // Play several times. + // animaitonConfig.playTimes = 0; // Loop play. + + // animaitonConfig.timeScale = 1.0; // Play speed. + // animaitonConfig.timeScale = -1.0; // Reverse play. + + // animaitonConfig.position = 1.0; // Goto and play. + // animaitonConfig.duration = 0.0; // Goto and stop. + // animaitonConfig.duration = 3.0; // Interval play. + // this._armatureDisplay.animation.playConfig(animaitonConfig); + + this._armatureDisplay.animation.play("idle", 1); + + // + this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._touchHandler, this); + this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this._touchHandler, this); + this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this._touchHandler, this); + + const text = new egret.TextField(); + text.size = 20; + text.textAlign = egret.HorizontalAlign.CENTER; + text.text = "Click to control animation play progress."; + text.width = this.stage.stageWidth; + text.x = 0; + text.y = this.stage.stageHeight - 60; + this.addChild(text); + } + + private _touchHandler(event: egret.TouchEvent): void { + const progress = Math.min(Math.max((event.stageX - this._armatureDisplay.x + 300 * this._armatureDisplay.scaleX) / 600 * this._armatureDisplay.scaleX, 0), 1); + switch (event.type) { + case egret.TouchEvent.TOUCH_BEGIN: + // this._armatureDisplay.animation.gotoAndPlayByTime("idle", 0.5, 1); + // this._armatureDisplay.animation.gotoAndStopByTime("idle", 1); + + // this._armatureDisplay.animation.gotoAndPlayByFrame("idle", 25, 2); + // this._armatureDisplay.animation.gotoAndStopByFrame("idle", 50); + + // this._armatureDisplay.animation.gotoAndPlayByProgress("idle", progress, 3); + this._armatureDisplay.animation.gotoAndStopByProgress("idle", progress); + break; + + case egret.TouchEvent.TOUCH_END: + this._armatureDisplay.animation.play(); + break; + + case egret.TouchEvent.TOUCH_MOVE: + if (event.touchDown) { + const animationState = this._armatureDisplay.animation.getState("idle"); + if (animationState) { + animationState.currentTime = animationState.totalTime * progress; + } + } + break; + } + } + + private _animationEventHandler(event: dragonBones.EgretEvent): void { + console.log(event.eventObject.animationState.name, event.type, event.eventObject.name ? event.eventObject.name : ""); + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/src/demo/BaseTest.ts b/reference/Egret/Demos/src/demo/BaseTest.ts new file mode 100644 index 0000000..4d1ef46 --- /dev/null +++ b/reference/Egret/Demos/src/demo/BaseTest.ts @@ -0,0 +1,41 @@ +abstract class BaseTest extends egret.DisplayObjectContainer { + private _loadCount: number; + protected readonly _background: egret.Shape = new egret.Shape(); + protected readonly _resources: string[] = []; + protected readonly _resourceMap: any = {}; + + public constructor() { + super(); + + this.addEventListener(egret.Event.ADDED_TO_STAGE, () => { + this._background.graphics.beginFill(0x666666, 1.0); + this._background.graphics.drawRect(0.0, 0.0, this.stage.stageWidth, this.stage.stageHeight); + this.addChild(this._background); + + this._loadResources(); + }, this); + } + + protected abstract _onStart(): void; + + protected _loadResources(): void { + this._loadCount = this._resources.length; + for (const resource of this._resources) { + RES.getResByUrl( + resource, + (data: any, key: string) => { + this._resourceMap[key] = data; + + this._loadCount--; + if (this._loadCount === 0) { + RES.getRes = (name: string) => { // Modify res bug. + return this._resourceMap[name]; + }; + this._onStart(); + } + }, + this, resource.indexOf(".dbbin") > 0 ? RES.ResourceItem.TYPE_BIN : null + ); + } + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/src/demo/CoreElement.ts b/reference/Egret/Demos/src/demo/CoreElement.ts new file mode 100644 index 0000000..9605465 --- /dev/null +++ b/reference/Egret/Demos/src/demo/CoreElement.ts @@ -0,0 +1,562 @@ +namespace coreElement { + type PointType = egret.Point; + type ArmatureDisplayType = dragonBones.EgretArmatureDisplay; + type EventType = dragonBones.EgretEvent; + + export class Game extends BaseTest { + public static STAGE_WIDTH: number; + public static STAGE_HEIGHT: number; + public static GROUND: number; + public static G: number = 0.6; + public static instance: Game; + + private _left: boolean = false; + private _right: boolean = false; + private _player: Mecha; + private readonly _bullets: Array = []; + + public constructor() { + super(); + + this._resources.push( + "resource/assets/core_element/mecha_1502b_ske.json", + "resource/assets/core_element/mecha_1502b_tex.json", + "resource/assets/core_element/mecha_1502b_tex.png", + "resource/assets/core_element/skin_1502b_ske.json", + "resource/assets/core_element/skin_1502b_tex.json", + "resource/assets/core_element/skin_1502b_tex.png", + "resource/assets/core_element/weapon_1000_ske.json", + "resource/assets/core_element/weapon_1000_tex.json", + "resource/assets/core_element/weapon_1000_tex.png" + ); + } + + protected _onStart(): void { + Game.STAGE_WIDTH = this.stage.stageWidth; + Game.STAGE_HEIGHT = this.stage.stageHeight; + Game.GROUND = Game.STAGE_HEIGHT - 150; + Game.instance = this; + + const factory = dragonBones.EgretFactory.factory; + factory.parseDragonBonesData(RES.getRes("resource/assets/core_element/mecha_1502b_ske.json")); + factory.parseTextureAtlasData(RES.getRes("resource/assets/core_element/mecha_1502b_tex.json"), RES.getRes("resource/assets/core_element/mecha_1502b_tex.png")); + factory.parseDragonBonesData(RES.getRes("resource/assets/core_element/skin_1502b_ske.json")); + factory.parseTextureAtlasData(RES.getRes("resource/assets/core_element/skin_1502b_tex.json"), RES.getRes("resource/assets/core_element/skin_1502b_tex.png")); + factory.parseDragonBonesData(RES.getRes("resource/assets/core_element/weapon_1000_ske.json")); + factory.parseTextureAtlasData(RES.getRes("resource/assets/core_element/weapon_1000_tex.json"), RES.getRes("resource/assets/core_element/weapon_1000_tex.png")); + + this._player = new Mecha(); + + // Listener. + this.stage.addEventListener(egret.Event.ENTER_FRAME, this._enterFrameHandler, this); + this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._touchHandler, this); + this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this._touchHandler, this); + document.addEventListener("keydown", this._keyHandler); + document.addEventListener("keyup", this._keyHandler); + const onTouchMove = egret.sys.TouchHandler.prototype.onTouchMove; + egret.sys.TouchHandler.prototype.onTouchMove = function (this: any, x: number, y: number, touchPointID: number): void { + onTouchMove.call(this, x, y, touchPointID); + + Game.instance._player.aim(x, y); + } + + // Info. + const text = new egret.TextField(); + text.size = 20; + text.textAlign = egret.HorizontalAlign.CENTER; + text.text = "Press W/A/S/D to move. Press Q/E to switch weapons. Press SPACE to switch skin.\nMouse Move to aim. Click to fire."; + text.width = Game.STAGE_WIDTH; + text.x = 0; + text.y = Game.STAGE_HEIGHT - 60; + this.addChild(text); + } + + private _touchHandler(event: egret.TouchEvent): void { + this._player.aim(event.stageX, event.stageY); + if (event.type === egret.TouchEvent.TOUCH_BEGIN) { + this._player.attack(true); + } + else { + this._player.attack(false); + } + } + + private _keyHandler(event: KeyboardEvent): void { + const isDown = event.type === "keydown"; + switch (event.keyCode) { + case 37: + case 65: + Game.instance._left = isDown; + Game.instance._updateMove(-1); + break; + + case 39: + case 68: + Game.instance._right = isDown; + Game.instance._updateMove(1); + break; + + case 38: + case 87: + if (isDown) { + Game.instance._player.jump(); + } + break; + + case 83: + case 40: + Game.instance._player.squat(isDown); + break; + + case 81: + if (isDown) { + Game.instance._player.switchWeaponR(); + } + break; + + case 69: + if (isDown) { + Game.instance._player.switchWeaponL(); + } + break; + + case 32: + if (isDown) { + Game.instance._player.switchSkin(); + } + break; + } + } + + private _enterFrameHandler(event: egret.Event): void { + this._player.update(); + + let i = this._bullets.length; + while (i--) { + const bullet = this._bullets[i]; + if (bullet.update()) { + this._bullets.splice(i, 1); + } + } + } + + private _updateMove(dir: number): void { + if (this._left && this._right) { + this._player.move(dir); + } + else if (this._left) { + this._player.move(-1); + } + else if (this._right) { + this._player.move(1); + } + else { + this._player.move(0); + } + } + + public addBullet(bullet: Bullet): void { + this._bullets.push(bullet); + } + } + + class Mecha { + private static readonly JUMP_SPEED: number = 20; + private static readonly NORMALIZE_MOVE_SPEED: number = 3.6; + private static readonly MAX_MOVE_SPEED_FRONT: number = Mecha.NORMALIZE_MOVE_SPEED * 1.4; + private static readonly MAX_MOVE_SPEED_BACK: number = Mecha.NORMALIZE_MOVE_SPEED * 1.0; + private static readonly NORMAL_ANIMATION_GROUP: string = "normal"; + private static readonly AIM_ANIMATION_GROUP: string = "aim"; + private static readonly ATTACK_ANIMATION_GROUP: string = "attack"; + private static readonly WEAPON_L_LIST: Array = ["weapon_1502b_l", "weapon_1005", "weapon_1005b", "weapon_1005c", "weapon_1005d", "weapon_1005e"]; + private static readonly WEAPON_R_LIST: Array = ["weapon_1502b_r", "weapon_1005", "weapon_1005b", "weapon_1005c", "weapon_1005d"]; + private static readonly SKINS: Array = ["mecha_1502b", "skin_a", "skin_b", "skin_c"]; + + private _isJumpingA: boolean = false; + private _isJumpingB: boolean = false; + private _isSquating: boolean = false; + private _isAttackingA: boolean = false; + private _isAttackingB: boolean = false; + private _weaponRIndex: number = 0; + private _weaponLIndex: number = 0; + private _skinIndex: number = 0; + private _faceDir: number = 1; + private _aimDir: number = 0; + private _moveDir: number = 0; + private _aimRadian: number = 0.0; + private _speedX: number = 0.0; + private _speedY: number = 0.0; + private _armature: dragonBones.Armature; + private _armatureDisplay: ArmatureDisplayType; + private _weaponL: dragonBones.Armature; + private _weaponR: dragonBones.Armature; + private _aimState: dragonBones.AnimationState | null = null; + private _walkState: dragonBones.AnimationState | null = null; + private _attackState: dragonBones.AnimationState | null = null; + private readonly _target: PointType = new egret.Point(); + private readonly _helpPoint: PointType = new egret.Point(); + + public constructor() { + this._armatureDisplay = dragonBones.EgretFactory.factory.buildArmatureDisplay("mecha_1502b"); + this._armatureDisplay.x = Game.STAGE_WIDTH * 0.5; + this._armatureDisplay.y = Game.GROUND; + this._armature = this._armatureDisplay.armature; + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.FADE_IN_COMPLETE, this._animationEventHandler, this); + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.FADE_OUT_COMPLETE, this._animationEventHandler, this); + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this); + + // Get weapon childArmature. + this._weaponL = this._armature.getSlot("weapon_l").childArmature; + this._weaponR = this._armature.getSlot("weapon_r").childArmature; + this._weaponL.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + this._weaponR.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + + Game.instance.addChild(this._armatureDisplay); + this._updateAnimation(); + } + + public move(dir: number): void { + if (this._moveDir === dir) { + return; + } + + this._moveDir = dir; + this._updateAnimation(); + } + + public jump(): void { + if (this._isJumpingA) { + return; + } + + this._isJumpingA = true; + this._armature.animation.fadeIn( + "jump_1", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + + this._walkState = null; + } + + public squat(isSquating: boolean): void { + if (this._isSquating === isSquating) { + return; + } + + this._isSquating = isSquating; + this._updateAnimation(); + } + + public attack(isAttacking: boolean): void { + if (this._isAttackingA === isAttacking) { + return; + } + + this._isAttackingA = isAttacking; + } + + public switchWeaponL(): void { + this._weaponL.eventDispatcher.removeEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + + this._weaponLIndex++; + this._weaponLIndex %= Mecha.WEAPON_L_LIST.length; + const weaponName = Mecha.WEAPON_L_LIST[this._weaponLIndex]; + this._weaponL = dragonBones.EgretFactory.factory.buildArmature(weaponName); + this._armature.getSlot("weapon_l").childArmature = this._weaponL; + this._weaponL.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + } + + public switchWeaponR(): void { + this._weaponR.eventDispatcher.removeEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + + this._weaponRIndex++; + this._weaponRIndex %= Mecha.WEAPON_R_LIST.length; + const weaponName = Mecha.WEAPON_R_LIST[this._weaponRIndex]; + this._weaponR = dragonBones.EgretFactory.factory.buildArmature(weaponName); + this._armature.getSlot("weapon_r").childArmature = this._weaponR; + this._weaponR.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + } + + public switchSkin(): void { + this._skinIndex++; + this._skinIndex %= Mecha.SKINS.length; + const skinName = Mecha.SKINS[this._skinIndex]; + const skinData = dragonBones.EgretFactory.factory.getArmatureData(skinName).defaultSkin; + dragonBones.EgretFactory.factory.changeSkin(this._armature, skinData, ["weapon_l", "weapon_r"]); + } + + public aim(x: number, y: number): void { + this._target.x = x; + this._target.y = y; + } + + public update(): void { + this._updatePosition(); + this._updateAim(); + this._updateAttack(); + } + + private _animationEventHandler(event: EventType): void { + switch (event.type) { + case dragonBones.EventObject.FADE_IN_COMPLETE: + if (event.eventObject.animationState.name === "jump_1") { + this._isJumpingB = true; + this._speedY = -Mecha.JUMP_SPEED; + + if (this._moveDir !== 0) { + if (this._moveDir * this._faceDir > 0) { + this._speedX = Mecha.MAX_MOVE_SPEED_FRONT * this._faceDir; + } + else { + this._speedX = -Mecha.MAX_MOVE_SPEED_BACK * this._faceDir; + } + } + + this._armature.animation.fadeIn( + "jump_2", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + } + break; + + case dragonBones.EventObject.FADE_OUT_COMPLETE: + if (event.eventObject.animationState.name === "attack_01") { + this._isAttackingB = false; + this._attackState = null; + } + break; + + case dragonBones.EventObject.COMPLETE: + if (event.eventObject.animationState.name === "jump_4") { + this._isJumpingA = false; + this._isJumpingB = false; + this._updateAnimation(); + } + break; + } + } + + private _frameEventHandler(event: EventType): void { + if (event.eventObject.name === "fire") { + (event.eventObject.armature.display as ArmatureDisplayType).localToGlobal(event.eventObject.bone.global.x, event.eventObject.bone.global.y, this._helpPoint); + this._fire(this._helpPoint); + } + } + + private _fire(firePoint: PointType): void { + const radian = this._faceDir < 0 ? Math.PI - this._aimRadian : this._aimRadian; + const bullet = new Bullet("bullet_01", "fire_effect_01", radian + Math.random() * 0.02 - 0.01, 40, firePoint); + Game.instance.addBullet(bullet); + } + + private _updateAnimation(): void { + if (this._isJumpingA) { + return; + } + + if (this._isSquating) { + this._speedX = 0; + this._armature.animation.fadeIn( + "squat", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + + this._walkState = null; + return; + } + + if (this._moveDir === 0) { + this._speedX = 0; + this._armature.animation.fadeIn( + "idle", -1.0, -1, 0, + Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + + this._walkState = null; + } + else { + if (this._walkState === null) { + this._walkState = this._armature.animation.fadeIn( + "walk", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ); + + this._walkState.resetToPose = false; + } + + if (this._moveDir * this._faceDir > 0) { + this._walkState.timeScale = Mecha.MAX_MOVE_SPEED_FRONT / Mecha.NORMALIZE_MOVE_SPEED; + } + else { + this._walkState.timeScale = -Mecha.MAX_MOVE_SPEED_BACK / Mecha.NORMALIZE_MOVE_SPEED; + } + + if (this._moveDir * this._faceDir > 0) { + this._speedX = Mecha.MAX_MOVE_SPEED_FRONT * this._faceDir; + } + else { + this._speedX = -Mecha.MAX_MOVE_SPEED_BACK * this._faceDir; + } + } + } + + private _updatePosition(): void { + if (this._speedX !== 0.0) { + this._armatureDisplay.x += this._speedX; + if (this._armatureDisplay.x < 0) { + this._armatureDisplay.x = 0; + } + else if (this._armatureDisplay.x > Game.STAGE_WIDTH) { + this._armatureDisplay.x = Game.STAGE_WIDTH; + } + } + + if (this._speedY !== 0.0) { + if (this._speedY < 5.0 && this._speedY + Game.G >= 5.0) { + this._armature.animation.fadeIn( + "jump_3", -1.0, -1, 0 + , Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + } + + this._speedY += Game.G; + this._armatureDisplay.y += this._speedY; + + if (this._armatureDisplay.y > Game.GROUND) { + this._armatureDisplay.y = Game.GROUND; + this._speedY = 0.0; + this._armature.animation.fadeIn( + "jump_4", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + } + } + } + + private _updateAim(): void { + this._faceDir = this._target.x > this._armatureDisplay.x ? 1 : -1; + if (this._armatureDisplay.armature.flipX !== this._faceDir < 0) { + this._armatureDisplay.armature.flipX = !this._armatureDisplay.armature.flipX; + + if (this._moveDir !== 0) { + this._updateAnimation(); + } + } + + const aimOffsetY = this._armature.getBone("chest").global.y * this._armatureDisplay.scaleY; + if (this._faceDir > 0) { + this._aimRadian = Math.atan2(this._target.y - this._armatureDisplay.y - aimOffsetY, this._target.x - this._armatureDisplay.x); + } + else { + this._aimRadian = Math.PI - Math.atan2(this._target.y - this._armatureDisplay.y - aimOffsetY, this._target.x - this._armatureDisplay.x); + if (this._aimRadian > Math.PI) { + this._aimRadian -= Math.PI * 2.0; + } + } + + let aimDir = 0; + if (this._aimRadian > 0.0) { + aimDir = -1; + } + else { + aimDir = 1; + } + + if (this._aimState === null || this._aimDir !== aimDir) { + this._aimDir = aimDir; + + // Animation mixing. + if (this._aimDir >= 0) { + this._aimState = this._armature.animation.fadeIn( + "aim_up", -1.0, -1, + 0, Mecha.AIM_ANIMATION_GROUP + ); + } + else { + this._aimState = this._armature.animation.fadeIn( + "aim_down", -1.0, -1, + 0, Mecha.AIM_ANIMATION_GROUP + ); + } + + this._aimState.resetToPose = false; + } + + this._aimState.weight = Math.abs(this._aimRadian / Math.PI * 2); + this._armature.invalidUpdate(); + } + + private _updateAttack(): void { + if (!this._isAttackingA || this._isAttackingB) { + return; + } + + this._isAttackingB = true; + this._attackState = this._armature.animation.fadeIn( + "attack_01", -1.0, -1, + 0, Mecha.ATTACK_ANIMATION_GROUP + ); + + this._attackState.resetToPose = false; + this._attackState.autoFadeOutTime = this._attackState.fadeTotalTime; + } + } + + class Bullet { + private _speedX: number = 0.0; + private _speedY: number = 0.0; + + private _armatureDisplay: ArmatureDisplayType; + private _effecDisplay: ArmatureDisplayType | null = null; + + public constructor(armatureName: string, effectArmatureName: string | null, radian: number, speed: number, position: PointType) { + this._speedX = Math.cos(radian) * speed; + this._speedY = Math.sin(radian) * speed; + + this._armatureDisplay = dragonBones.EgretFactory.factory.buildArmatureDisplay(armatureName); + this._armatureDisplay.x = position.x + Math.random() * 2 - 1; + this._armatureDisplay.y = position.y + Math.random() * 2 - 1; + this._armatureDisplay.rotation = radian * 180.0 / Math.PI; + + if (effectArmatureName !== null) { + this._effecDisplay = dragonBones.EgretFactory.factory.buildArmatureDisplay(effectArmatureName); + this._effecDisplay.rotation = radian * 180.0 / Math.PI; + this._effecDisplay.x = this._armatureDisplay.x; + this._effecDisplay.y = this._armatureDisplay.y; + this._effecDisplay.scaleX = 1.0 + Math.random() * 1.0; + this._effecDisplay.scaleY = 1.0 + Math.random() * 0.5; + if (Math.random() < 0.5) { + this._effecDisplay.scaleY *= -1.0; + } + + Game.instance.addChild(this._effecDisplay); + this._effecDisplay.animation.play("idle"); + } + + Game.instance.addChild(this._armatureDisplay); + this._armatureDisplay.animation.play("idle"); + } + + public update(): boolean { + this._armatureDisplay.x += this._speedX; + this._armatureDisplay.y += this._speedY; + + if ( + this._armatureDisplay.x < -100.0 || this._armatureDisplay.x >= Game.STAGE_WIDTH + 100.0 || + this._armatureDisplay.y < -100.0 || this._armatureDisplay.y >= Game.STAGE_HEIGHT + 100.0 + ) { + Game.instance.removeChild(this._armatureDisplay); + this._armatureDisplay.dispose(); + + if (this._effecDisplay !== null) { + Game.instance.removeChild(this._effecDisplay); + this._effecDisplay.dispose(); + } + + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/src/demo/HelloDragonBones.ts b/reference/Egret/Demos/src/demo/HelloDragonBones.ts new file mode 100644 index 0000000..370058d --- /dev/null +++ b/reference/Egret/Demos/src/demo/HelloDragonBones.ts @@ -0,0 +1,43 @@ +/** + * How to use + * 1. Load data. + * + * 2. Parse data. + * factory.parseDragonBonesData(); + * factory.parseTextureAtlasData(); + * + * 3. Build armature. + * armatureDisplay = factory.buildArmatureDisplay("armatureName"); + * + * 4. Play animation. + * armatureDisplay.animation.play("animationName"); + * + * 5. Add armature to stage. + * addChild(armatureDisplay); + */ +class HelloDragonBones extends BaseTest { + public constructor() { + super(); + + this._resources.push( + // "resource/assets/dragon_boy_ske.json", + "resource/assets/dragon_boy_ske.dbbin", + "resource/assets/dragon_boy_tex.json", + "resource/assets/dragon_boy_tex.png" + ); + } + + protected _onStart(): void { + const factory = dragonBones.EgretFactory.factory; + // factory.parseDragonBonesData(RES.getRes("resource/assets/dragon_boy_ske.json")); + factory.parseDragonBonesData(RES.getRes("resource/assets/dragon_boy_ske.dbbin")); + factory.parseTextureAtlasData(RES.getRes("resource/assets/dragon_boy_tex.json"), RES.getRes("resource/assets/dragon_boy_tex.png")); + + const armatureDisplay = factory.buildArmatureDisplay("DragonBoy"); + armatureDisplay.animation.play("walk"); + + armatureDisplay.x = this.stage.stageWidth * 0.5; + armatureDisplay.y = this.stage.stageHeight * 0.5 + 100; + this.addChild(armatureDisplay); + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/src/demo/PerformanceTest.ts b/reference/Egret/Demos/src/demo/PerformanceTest.ts new file mode 100644 index 0000000..be15e3f --- /dev/null +++ b/reference/Egret/Demos/src/demo/PerformanceTest.ts @@ -0,0 +1,141 @@ +class PerformanceTest extends BaseTest { + private _addingArmature: boolean = false; + private _removingArmature: boolean = false; + private readonly _text: egret.TextField = new egret.TextField(); + private readonly _armatures: Array = []; + public constructor() { + super(); + + this._resources.push( + "resource/assets/dragon_boy_ske.dbbin", + "resource/assets/dragon_boy_tex.json", + "resource/assets/dragon_boy_tex.png" + ); + } + + protected _onStart(): void { + // + this._text.size = 20; + this._text.textAlign = egret.HorizontalAlign.CENTER; + this._text.text = ""; + this.addChild(this._text); + + for (let i = 0; i < 300; ++i) { + this._addArmature(); + } + + this._resetPosition(); + this._updateText(); + + this.stage.addEventListener(egret.Event.ENTER_FRAME, this._enterFrameHandler, this); + this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this._touchHandler, this); + this.stage.addEventListener(egret.TouchEvent.TOUCH_END, this._touchHandler, this); + } + + private _enterFrameHandler(event: egret.Event): void { + if (this._addingArmature) { + for (let i = 0; i < 10; ++i) { + + this._addArmature(); + } + + this._resetPosition(); + this._updateText(); + } + + if (this._removingArmature) { + for (let i = 0; i < 10; ++i) { + + this._removeArmature(); + } + + this._resetPosition(); + this._updateText(); + } + } + + private _touchHandler(event: egret.TouchEvent): void { + switch (event.type) { + case egret.TouchEvent.TOUCH_BEGIN: + const touchRight = event.stageX > this.stage.stageWidth * 0.5; + this._addingArmature = touchRight; + this._removingArmature = !touchRight; + break; + + case egret.TouchEvent.TOUCH_END: + this._addingArmature = false; + this._removingArmature = false; + break; + } + } + + private _addArmature(): void { + if (this._armatures.length === 0) { + dragonBones.EgretFactory.factory.parseDragonBonesData(RES.getRes("resource/assets/dragon_boy_ske.dbbin")); + dragonBones.EgretFactory.factory.parseTextureAtlasData(RES.getRes("resource/assets/dragon_boy_tex.json"), RES.getRes("resource/assets/dragon_boy_tex.png")); + } + + const armatureDisplay = dragonBones.EgretFactory.factory.buildArmatureDisplay("DragonBoy"); + armatureDisplay.armature.cacheFrameRate = 24; + armatureDisplay.animation.play("walk", 0); + armatureDisplay.scaleX = armatureDisplay.scaleY = 0.7; + this.addChild(armatureDisplay); + + this._armatures.push(armatureDisplay); + } + + private _removeArmature(): void { + if (this._armatures.length === 0) { + return; + } + + const armatureDisplay = this._armatures.pop(); + this.removeChild(armatureDisplay); + armatureDisplay.dispose(); + + if (this._armatures.length === 0) { + dragonBones.EgretFactory.factory.clear(true); + dragonBones.BaseObject.clearPool(); + } + } + + private _resetPosition(): void { + const armatureCount = this._armatures.length; + if (armatureCount === 0) { + return; + } + + const paddingH = 50; + const paddingV = 150; + const gapping = 100; + + const stageWidth = this.stage.stageWidth - paddingH * 2; + const columnCount = Math.floor(stageWidth / gapping); + const paddingHModify = (this.stage.stageWidth - columnCount * gapping) * 0.5; + + const dX = stageWidth / columnCount; + const dY = (this.stage.stageHeight - paddingV * 2) / Math.ceil(armatureCount / columnCount); + + for (let i = 0, l = armatureCount; i < l; ++i) { + const armatureDisplay = this._armatures[i]; + const lineY = Math.floor(i / columnCount); + + paddingHModify; + dX; + dY; + lineY; + // armatureDisplay.x = (i % columnCount) * dX + paddingHModify; + // armatureDisplay.y = lineY * dY + paddingV; + armatureDisplay.x = Math.random() * this.stage.stageWidth; + armatureDisplay.y = Math.random() * this.stage.stageHeight; + } + } + + private _updateText(): void { + this._text.text = "Count: " + this._armatures.length + " \nTouch screen left to decrease count / right to increase count."; + this._text.width = this.stage.stageWidth; + this._text.x = 0; + this._text.y = this.stage.stageHeight - 60; + this.addChild(this._text); + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/src/demo/ReplaceSlotDisplay.ts b/reference/Egret/Demos/src/demo/ReplaceSlotDisplay.ts new file mode 100644 index 0000000..97d2a13 --- /dev/null +++ b/reference/Egret/Demos/src/demo/ReplaceSlotDisplay.ts @@ -0,0 +1,127 @@ +class ReplaceSlotDisplay extends BaseTest { + + private _displayIndex: number = 0; + private readonly _replaceDisplays: string[] = [ + // Replace normal display. + "display0002", "display0003", "display0004", "display0005", "display0006", "display0007", "display0008", "display0009", "display0010", + // Replace mesh display. + "meshA", "meshB", "meshC", + ]; + + private readonly _factory: dragonBones.EgretFactory = dragonBones.EgretFactory.factory; + private _armatureDisplay: dragonBones.EgretArmatureDisplay; + + public constructor() { + super(); + + this._resources.push( + "resource/assets/replace_slot_display/main_ske.json", + "resource/assets/replace_slot_display/main_tex.json", + "resource/assets/replace_slot_display/main_tex.png", + "resource/assets/replace_slot_display/replace_ske.json", + "resource/assets/replace_slot_display/replace_tex.json", + "resource/assets/replace_slot_display/replace_tex.png" + ); + } + + protected _onStart(): void { + this._factory.parseDragonBonesData(RES.getRes("resource/assets/replace_slot_display/main_ske.json")); + this._factory.parseTextureAtlasData(RES.getRes("resource/assets/replace_slot_display/main_tex.json"), RES.getRes("resource/assets/replace_slot_display/main_tex.png")); + this._factory.parseDragonBonesData(RES.getRes("resource/assets/replace_slot_display/replace_ske.json")); + this._factory.parseTextureAtlasData(RES.getRes("resource/assets/replace_slot_display/replace_tex.json"), RES.getRes("resource/assets/replace_slot_display/replace_tex.png")); + + this._armatureDisplay = this._factory.buildArmatureDisplay("MyArmature"); + this._armatureDisplay.animation.timeScale = 0.1; + this._armatureDisplay.animation.play(); + + this._armatureDisplay.x = this.stage.stageWidth * 0.5; + this._armatureDisplay.y = this.stage.stageHeight * 0.5; + this.addChild(this._armatureDisplay); + + this.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, + (event: egret.TouchEvent): void => { + this._replaceDisplay(); + }, + this + ); + } + + private _replaceDisplay(): void { + this._displayIndex = (this._displayIndex + 1) % this._replaceDisplays.length; + + const replaceDisplayName = this._replaceDisplays[this._displayIndex]; + + if (replaceDisplayName.indexOf("mesh") >= 0) { // Replace mesh display. + switch (replaceDisplayName) { + case "meshA": + // Normal to mesh. + this._factory.replaceSlotDisplay( + "replace", + "MyMesh", + "meshA", + "weapon_1004_1", + this._armatureDisplay.armature.getSlot("weapon") + ); + + // Replace mesh texture. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + "display0002", + this._armatureDisplay.armature.getSlot("mesh") + ); + break; + + case "meshB": + // Normal to mesh. + this._factory.replaceSlotDisplay( + "replace", + "MyMesh", + "meshB", + "weapon_1004_1", + this._armatureDisplay.armature.getSlot("weapon") + ); + + // Replace mesh texture. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + "display0003", + this._armatureDisplay.armature.getSlot("mesh") + ); + break; + + case "meshC": + // Back to normal. + this._factory.replaceSlotDisplay( + "replace", + "MyMesh", + "mesh", + "weapon_1004_1", + this._armatureDisplay.armature.getSlot("weapon") + ); + + // Replace mesh texture. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + "display0005", + this._armatureDisplay.armature.getSlot("mesh") + ); + break; + } + } + else { // Replace normal display. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + replaceDisplayName, + this._armatureDisplay.armature.getSlot("ball") + ); + } + } +} \ No newline at end of file diff --git a/reference/Egret/Demos/template/debug/index.html b/reference/Egret/Demos/template/debug/index.html new file mode 100644 index 0000000..7063cf3 --- /dev/null +++ b/reference/Egret/Demos/template/debug/index.html @@ -0,0 +1,88 @@ + + + + + + Egret + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/reference/Egret/Demos/template/runtime/native_loader.js b/reference/Egret/Demos/template/runtime/native_loader.js new file mode 100644 index 0000000..ad94285 --- /dev/null +++ b/reference/Egret/Demos/template/runtime/native_loader.js @@ -0,0 +1,8 @@ +require("launcher/native_require.js"); + +egret_native.egtMain = function () { + egret_native.nativeType = "native"; + + egret_native.egretInit(); + egret_native.egretStart(); +}; diff --git a/reference/Egret/Demos/template/runtime/native_require.js b/reference/Egret/Demos/template/runtime/native_require.js new file mode 100644 index 0000000..045098c --- /dev/null +++ b/reference/Egret/Demos/template/runtime/native_require.js @@ -0,0 +1,51 @@ + +var game_file_list = [ + //以下为自动修改,请勿修改 + //----auto game_file_list start---- + //----auto game_file_list end---- +]; + +var window = this; + +egret_native.setSearchPaths([""]); + +egret_native.requireFiles = function () { + for (var key in game_file_list) { + var src = game_file_list[key]; + require(src); + } +}; + +egret_native.egretInit = function () { + egret_native.requireFiles(); + egret.TextField.default_fontFamily = "/system/fonts/DroidSansFallback.ttf"; + //egret.dom为空实现 + egret.dom = {}; + egret.dom.drawAsCanvas = function () { + }; +}; + +egret_native.egretStart = function () { + var option = { + //以下为自动修改,请勿修改 + //----auto option start---- + entryClassName: "Main", + frameRate: 60, + scaleMode: "fixedHeight", + contentWidth: 800, + contentHeight: 600, + showPaintRect: false, + showFPS: true, + fpsStyles: "x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9", + showLog: false, + logFilter: "", + maxTouches: 2, + textureScaleFactor: 1 + //----auto option end---- + }; + + egret.native.NativePlayer.option = option; + egret.runEgret(); + egret_native.Label.createLabel(egret.TextField.default_fontFamily, 20, "", 0); + egret_native.EGTView.preSetOffScreenBufferEnable(true); +}; \ No newline at end of file diff --git a/reference/Egret/Demos/template/runtime/runtime_loader.js b/reference/Egret/Demos/template/runtime/runtime_loader.js new file mode 100644 index 0000000..5b5f76b --- /dev/null +++ b/reference/Egret/Demos/template/runtime/runtime_loader.js @@ -0,0 +1,8 @@ +require("launcher/native_require.js"); + +egret_native.egtMain = function () { + egret_native.nativeType = "runtime"; + + egret_native.egretInit(); + egret_native.egretStart(); +}; \ No newline at end of file diff --git a/reference/Egret/Demos/template/web/index.html b/reference/Egret/Demos/template/web/index.html new file mode 100644 index 0000000..6eb8e17 --- /dev/null +++ b/reference/Egret/Demos/template/web/index.html @@ -0,0 +1,88 @@ + + + + + + Egret + + + + + + + + + + +
+
+ + + + \ No newline at end of file diff --git a/reference/Egret/Demos/tsconfig.json b/reference/Egret/Demos/tsconfig.json new file mode 100644 index 0000000..6f80508 --- /dev/null +++ b/reference/Egret/Demos/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": false, + "declaration": false, + "alwaysStrict": true, + "noImplicitAny": false, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": false, + "strictNullChecks": false, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "lib": [ + "es5", + "dom", + "es2015.promise" + ] + }, + "exclude": [ + "node_modules", + "out" + ] +} \ No newline at end of file diff --git a/reference/Egret/Demos/wingProperties.json b/reference/Egret/Demos/wingProperties.json new file mode 100644 index 0000000..bfe9073 --- /dev/null +++ b/reference/Egret/Demos/wingProperties.json @@ -0,0 +1,11 @@ +{ + "resourcePlugin": { + "configs": [ + { + "configPath": "resource/default.res.json", + "relativePath": "resource/" + } + ] + }, + "theme": "resource/default.thm.json" +} \ No newline at end of file diff --git a/reference/Egret/README.md b/reference/Egret/README.md new file mode 100644 index 0000000..9e36244 --- /dev/null +++ b/reference/Egret/README.md @@ -0,0 +1,5 @@ +# DragonBones Egret library + +## [Demos](./Demos/) + +## [Egret](http://www.egret.com/) \ No newline at end of file diff --git a/reference/Egret/wasm/README.md b/reference/Egret/wasm/README.md new file mode 100644 index 0000000..161b092 --- /dev/null +++ b/reference/Egret/wasm/README.md @@ -0,0 +1,8 @@ +## How to build +``` +$npm install +$npm run build +``` + +## Egret declaration +[egret.d.ts](https://github.com/egret-labs/egret-core/blob/master/build/egret/egret.d.ts) \ No newline at end of file diff --git a/reference/Egret/wasm/out/dragonBones-wasm.d.ts b/reference/Egret/wasm/out/dragonBones-wasm.d.ts new file mode 100644 index 0000000..67a5b7c --- /dev/null +++ b/reference/Egret/wasm/out/dragonBones-wasm.d.ts @@ -0,0 +1,4698 @@ +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + FFDTimelineMeshOffset = 0, + FFDTimelineFFDCount = 1, + FFDTimelineValueCount = 2, + FFDTimelineValueOffset = 3, + FFDTimelineFloatOffset = 4, + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * @language zh_CN + * 包围盒类型。 + * @version DragonBones 5.0 + */ + 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, + BoneT = 11, + BoneR = 12, + BoneS = 13, + BoneX = 14, + BoneY = 15, + BoneRotate = 16, + BoneSkew = 17, + BoneScaleX = 18, + BoneScaleY = 19, + SlotVisible = 23, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * @private + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * @language zh_CN + * 动画混合的淡出方式。 + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + None = 0, + /** + * 淡出同层的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer = 1, + /** + * 淡出同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup = 2, + /** + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * 淡出所有动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + All = 4, + /** + * 不替换同名动画。 + * @version DragonBones 5.1 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + static readonly VERSION: string; + 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 namespace 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); + /** + * @private + */ + static toString(): string; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * 对象的唯一标识。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +declare namespace dragonBones { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * 转换为单位矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: 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; + constructor( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x?: number, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y?: number, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew?: number, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation?: number, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX?: number, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fromMatrix(matrix: Matrix): Transform; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + toMatrix(matrix: Matrix): Transform; + } +} +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; + } +} +declare namespace dragonBones { + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * 自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * 获取自定义字符串。 + * @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; + } +} +declare namespace dragonBones { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly frameIndices: Array; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatures: Map; + /** + * @private + */ + intArray: Array | Int16Array; + /** + * @private + */ + floatArray: Array | Float32Array; + /** + * @private + */ + frameIntArray: Array | Int16Array; + /** + * @private + */ + frameFloatArray: Array | Float32Array; + /** + * @private + */ + frameArray: Array | Int16Array; + /** + * @private + */ + timelineArray: Array | Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addArmature(value: ArmatureData): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + /** + * @private + */ + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * 所有动画数据名称。 + * @see #armatures + * @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; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly bones: Map; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly slots: Map; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly skins: Map; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animations: Map; + /** + * 获取默认皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * 获取默认动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的龙骨数据。 + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parent: DragonBonesData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + sortBones(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @private + */ + addBone(value: BoneData): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + length: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + readonly constraints: Array; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static createColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + target: BoneData; + bone: BoneData; + root: BoneData | null; + protected _onClear(): void; + } + /** + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: ArmatureData; + 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 + */ + class MeshDisplayData extends ImageDisplayData { + static toString(): string; + inheritAnimation: boolean; + offset: number; + weight: WeightData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * 边界框颜色。 + * @version DragonBones 5.0 + * @language zh_CN + */ + color: number; + /** + * 边界框宽。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + width: number; + /** + * 边界框高。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * 是否包含点。 + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * 是否与线段相交。 + * @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; + } + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 多边形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array | Float32Array, offset: number, count: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + count: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + vertices: Array | Float32Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } +} +declare namespace dragonBones { + /** + * 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + frameIntOffset: number; + /** + * @private + */ + frameFloatOffset: number; + /** + * @private + */ + frameOffset: number; + /** + * 持续的帧数。 ([1~N]) + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * 淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimeline(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * 是否暂停淡出的动画。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeOut: boolean; + /** + * 淡出模式。 + * @default dragonBones.AnimationFadeOutMode.All + * @see dragonBones.AnimationFadeOutMode + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * 淡出缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTweenType: TweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTime: number; + /** + * 否能触发行为。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 是否以增加的方式混合。 + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeIn: boolean; + /** + * 是否将没有动画的对象重置为初始值。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 淡入缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTweenType: TweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + playTimes: number; + /** + * 混合图层,图层高会优先获取混合权重。 + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * 开始时间。 (以秒为单位) + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * 混合权重。 + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * 动画状态名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * 动画数据名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + clear(): void; + copyFrom(value: AnimationConfig): void; + containsBoneMask(name: string): boolean; + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * 贴图集缩放系数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scale: number; + /** + * 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + abstract createTexture(): TextureData; + /** + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: 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; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架代理接口。 + * @version DragonBones 5.0 + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + init(armature: Armature): void; + /** + * @private + */ + clear(): void; + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + dispose(disposeProxy: boolean): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @language zh_CN + * 获取骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + readonly armature: Armature; + /** + * @language zh_CN + * 获取动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + readonly animation: Animation; + } +} +declare namespace dragonBones { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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); + /** + * 是否继承父骨架的动画状态。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + debugDraw: boolean; + /** + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + */ + armatureData: ArmatureData; + /** + * 用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + private _debugDraw; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + /** + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlotDisplay?: boolean): void; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string | null): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + flipX: boolean; + flipY: boolean; + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * @pivate + */ + readonly eventDispatcher: IEventDispatcher; + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + replaceTexture(texture: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + hasEventListener(type: EventStringType): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + enableAnimationCache(frameRate: number): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + } +} +declare namespace dragonBones { + /** + * 基础变换对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * 对象的名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + */ + origin: Transform; + /** + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * @private + */ + updateGlobalTransform(): void; + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +declare namespace dragonBones { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * @private + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + readonly constraints: Array; + /** + * @readonly + */ + boneData: BoneData; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + /** + * @internal + * @private + */ + _blendDirty: boolean; + private _localDirty; + private _visible; + private _cachedFrameIndex; + /** + * @internal + * @private + */ + _blendLayer: number; + /** + * @internal + * @private + */ + _blendLeftWeight: number; + /** + * @internal + * @private + */ + _blendLayerWeight: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(isCache); + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * @internal + * @private + */ + addConstraint(constraint: Constraint): void; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(child: TransformObject): boolean; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + readonly length: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + readonly slot: Slot | null; + } +} +declare namespace dragonBones { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 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; + /** + * @readonly + */ + slotData: SlotData; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + _colorDirty: boolean; + /** + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @private + */ + readonly _ffdVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @internal + * @private + */ + _rawDisplayDatas: Array; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @private + */ + init(slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + * @internal + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + target: Bone; + bone: Bone; + root: Bone | null; + protected _onClear(): void; + abstract update(): void; + } + /** + * @private + * @internal + */ + class IKConstraint extends Constraint { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + update(): void; + } +} +declare namespace dragonBones { + /** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * 更新时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 当前所属的 WordClock 实例。 + * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * 添加 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * 移除 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _animationDirty; + /** + * @internal + * @private + */ + _timelineDirty: boolean; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * 清除所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 上一个正在播放的动画状态名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationList: Array; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 是否以增加的方式混合。 + * @version DragonBones 3.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否能触发行为。 + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 混合图层。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + layer: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 混合权重。 + * @version DragonBones 3.0 + * @language zh_CN + */ + weight: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * @version DragonBones 3.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * 动画名称。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + name: string; + /** + * 混合组。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + group: string; + /** + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + animationData: AnimationData; + private _timelineDirty; + /** + * @internal + * @private + * xx: Play Enabled, Fade Play Enabled + */ + _playheadState: number; + /** + * @internal + * @private + * -1: Fade in, 0: Fade complete, 1: Fade out; + */ + _fadeState: number; + /** + * @internal + * @private + * -1: Fade start, 0: Fading, 1: Fade complete; + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + private _weightResult; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _slotTimelines; + private readonly _bonePoses; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @private + */ + protected _onClear(): void; + private _isDisabled(slot); + private _advanceFadeTime(passedTime); + private _blendBoneTimline(timeline); + /** + * @private + * @internal + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @private + * @internal + */ + updateTimelines(): void; + /** + * @private + * @internal + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + readonly clip: AnimationData; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class SlotDislayIndexTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _ffdCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } +} +declare namespace dragonBones { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + time: number; + /** + * 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * 发出事件的骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * 发出事件的骨骼。 + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * 发出事件的插槽。 + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * 发出事件的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * 自定义数据 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * 事件接口。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } +} +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: 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 BONE: string; + protected static readonly IK: string; + protected static readonly SLOT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly VISIBLE_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 CANVAS: 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 SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_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_FFD: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: 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_TYPE: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: 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_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 GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + private _intArrayJson; + private _floatArrayJson; + private _frameIntArrayJson; + private _frameFloatArrayJson; + private _frameArrayJson; + private _timelineArrayJson; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + 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 _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defalultColorOffset; + private _prevTweenRotate; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _weightBoneIndices; + private readonly _cacheBones; + private readonly _meshs; + private readonly _slotChildActions; + /** + * @private + */ + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + /** + * @private + */ + private _samplingEasingCurve(curve, samples); + private _sortActionFrame(a, b); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + private _parseCacheActionFrame(frame); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIKConstraint(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData | null; + /** + * @private + */ + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseTimeline(rawData: any, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): void; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): void; + /** + * @private + */ + protected _parseFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseBoneFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotDisplayIndexFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, type: ActionType, bone: BoneData | null, slot: SlotData | null): number; + /** + * @private + */ + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + /** + * @private + */ + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @private + */ + protected _parseWASMArray(): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + /** + * @private + */ + private static _objectDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binary; + private _binaryOffset; + private _intArray; + private _floatArray; + private _frameIntArray; + private _frameFloatArray; + private _frameArray; + private _timelineArray; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @private + */ + private static _binaryDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): BinaryDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * 清除所有的数据。 + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): Armature | null; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string | null, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): void; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): void; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string | null, fromDragonBonesDataName?: string | null, replaceOriginalAnimation?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} +declare namespace dragonBones { + /** + * Egret 事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EgretEvent extends egret.Event { + /** + * 事件对象。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly eventObject: EventObject; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#armature + */ + readonly armature: Armature; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#bone + */ + readonly bone: Bone | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#slot + */ + readonly slot: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + readonly animationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + readonly animationName: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#name + */ + readonly frameLabel: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#name + */ + readonly sound: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.START + */ + static START: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + static LOOP_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.COMPLETE + */ + static COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN + */ + static FADE_IN: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + static FADE_IN_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT + */ + static FADE_OUT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + static FADE_OUT_COMPLETE: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static ANIMATION_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static BONE_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + static MOVEMENT_FRAME_EVENT: string; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND: string; + } + /** + * @inheritDoc + */ + class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureProxy { + private _disposeProxy; + private _armature; + private _debugDrawer; + /** + * @inheritDoc + */ + init(armature: Armature): void; + /** + * @inheritDoc + */ + clear(): void; + /** + * @inheritDoc + */ + dispose(disposeProxy?: boolean): void; + /** + * @inheritDoc + */ + debugUpdate(isEnabled: boolean): void; + /** + * @inheritDoc + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * @inheritDoc + */ + hasEvent(type: EventStringType): boolean; + /** + * @inheritDoc + */ + addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * @inheritDoc + */ + removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * @inheritDoc + */ + readonly armature: Armature; + /** + * @inheritDoc + */ + readonly animation: Animation; + } + interface PEgretTextureAtlasData extends TextureAtlasData { + renderTexture: egret.Texture | null; + textures: any; + __parent: any; + _textureNames: Array; + _texture: egret.Texture | null; + } + interface PEgretTextureData extends TextureData { + renderTexture: egret.Texture | null; + __parent: any; + _renderTexture: egret.Texture | null; + } + let EgretArmatureProxy: any; + let EgretSlot: any; + let EgretTextureAtlasData: any; + let EgretTextureData: any; + function createEgretDisplay(display: egret.DisplayObject | Armature | null, type: DisplayType): any; + function egretWASMInit(): void; + function registerGetterSetter(): void; +} +declare namespace dragonBones { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class EgretFactory extends BaseFactory { + private static _time; + private static _dragonBones; + private static _factory; + private static _eventManager; + private static _clockHandler(time); + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 5.0 + * @language zh_CN + */ + static readonly clock: any; + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + static readonly factory: EgretFactory; + /** + * @private + */ + private _rawTextures; + /** + * @inheritDoc + */ + constructor(); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: any | null, textureAtlas: egret.Texture): TextureAtlasData; + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * @private + */ + parseTextureAtlasData(rawData: any, textureAtlas: any, name?: string | null, scale?: number): TextureAtlasData; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + buildArmatureDisplay(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): EgretArmatureDisplay | null; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureDisplay(textureName: string, textureAtlasName?: string | null): egret.Bitmap | null; + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * public + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): void; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void; + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly soundEventManager: egret.EventDispatcher; + } +} diff --git a/reference/Egret/wasm/out/dragonBones-wasm.js b/reference/Egret/wasm/out/dragonBones-wasm.js new file mode 100644 index 0000000..71f9d81 --- /dev/null +++ b/reference/Egret/wasm/out/dragonBones-wasm.js @@ -0,0 +1,11750 @@ +"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 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; + } + 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; + armature.eventDispatcher._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(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.yDown = true; + DragonBones.debug = false; + DragonBones.debugDraw = false; + DragonBones.webAssembly = false; + DragonBones.VERSION = "5.1.0"; + return DragonBones; + }()); + dragonBones.DragonBones = DragonBones; + if (!console.warn) { + console.warn = function () { }; + } + if (!console.assert) { + console.assert = function () { }; + } +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var BaseObject = (function () { + function BaseObject() { + /** + * 对象的唯一标识。 + * @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._defaultMaxCount : BaseObject._maxCountMap[classType]; + var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.push(object); + } + else { + console.assert(false, "The object is already in the pool."); + } + } + else { + } + }; + /** + * @private + */ + BaseObject.toString = function () { + throw new Error(); + }; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @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) { + if (classType in BaseObject._maxCountMap) { + continue; + } + var pool = BaseObject._poolsMap[classType]; + if (pool.length > maxCount) { + pool.length = maxCount; + } + BaseObject._maxCountMap[classType] = maxCount; + } + } + }; + /** + * 清除对象池缓存的对象。 + * @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; + } + } + }; + /** + * 从对象池中创建指定对象。 + * @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; + }; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseObject.prototype.returnToPool = function () { + this._onClear(); + BaseObject._returnObject(this); + }; + BaseObject._hashCode = 0; + BaseObject._defaultMaxCount = 1000; + BaseObject._maxCountMap = {}; + BaseObject._poolsMap = {}; + return BaseObject; + }()); + dragonBones.BaseObject = BaseObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Matrix = (function () { + 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; + } + /** + * @private + */ + 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; + }; + /** + * 转换为单位矩阵。 + * @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; + }; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @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; + }; + /** + * 转换为逆矩阵。 + * @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; + }; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params 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; + } + }; + return Matrix; + }()); + dragonBones.Matrix = Matrix; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Transform = (function () { + function Transform( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Transform.prototype.toMatrix = function (matrix) { + if (this.skew !== 0.0 || this.rotation !== 0.0) { + 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; + } + } + else { + matrix.a = this.scaleX; + matrix.b = 0.0; + matrix.c = 0.0; + matrix.d = this.scaleY; + } + matrix.tx = this.x; + matrix.ty = this.y; + return this; + }; + /** + * @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 = {})); +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 = {})); +var dragonBones; +(function (dragonBones) { + var Point = (function () { + function Point(x, y) { + if (x === void 0) { x = 0.0; } + if (y === void 0) { y = 0.0; } + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function () { + this.x = this.y = 0.0; + }; + return Point; + }()); + dragonBones.Point = Point; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + var Rectangle = (function () { + 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; + } + Rectangle.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function () { + this.x = this.y = 0.0; + this.width = this.height = 0.0; + }; + return Rectangle; + }()); + dragonBones.Rectangle = Rectangle; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 自定义数据。 + * @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; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.ints = []; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.floats = []; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.strings = []; + return _this; + } + /** + * @private + */ + UserData.toString = function () { + return "[class dragonBones.UserData]"; + }; + /** + * @private + */ + UserData.prototype._onClear = function () { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + /** + * 获取自定义整数。 + * @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; + }; + /** + * 获取自定义浮点数。 + * @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; + }; + /** + * 获取自定义字符串。 + * @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 = {})); +var dragonBones; +(function (dragonBones) { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @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; + /** + * @private + */ + _this.frameIndices = []; + /** + * @private + */ + _this.cachedFrames = []; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatureNames = []; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatures = {}; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + DragonBonesData.toString = function () { + return "[class dragonBones.DragonBonesData]"; + }; + /** + * @private + */ + 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.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + //this.armatures.clear(); + this.intArray = null; // + this.floatArray = null; // + this.frameIntArray = null; // + this.frameFloatArray = null; // + this.frameArray = null; // + this.timelineArray = null; // + this.userData = null; + }; + /** + * @private + */ + DragonBonesData.prototype.addArmature = function (value) { + if (value.name in this.armatures) { + console.warn("Replace armature: " + value.name); + this.armatures[value.name].returnToPool(); + } + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + DragonBonesData.prototype.getArmature = function (name) { + return name in this.armatures ? this.armatures[name] : null; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + DragonBonesData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + return DragonBonesData; + }(dragonBones.BaseObject)); + dragonBones.DragonBonesData = DragonBonesData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var CanvasData = (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + /** + * @private + */ + 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; + /** + * 骨架数据。 + * @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(); + /** + * 所有动画数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.bones = {}; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.slots = {}; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.skins = {}; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + /** + * @private + */ + 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.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.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + 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; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @private + */ + 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); + } + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Replace bone: " + value.name); + this.bones[value.name].returnToPool(); + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Replace slot: " + value.name); + this.slots[value.name].returnToPool(); + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Replace skin: " + value.name); + this.skins[value.name].returnToPool(); + } + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + }; + /** + * @private + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Replace animation: " + value.name); + this.animations[value.name].returnToPool(); + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (name) { + return name in this.bones ? this.bones[name] : null; + }; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (name) { + return name in this.slots ? this.slots[name] : null; + }; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (name) { + return name in this.skins ? this.skins[name] : null; + }; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (name) { + return name in this.animations ? this.animations[name] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * 骨骼数据。 + * @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.constraints = []; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + /** + * @private + */ + BoneData.prototype._onClear = function () { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0.0; + this.name = ""; + this.transform.identity(); + this.constraints.length = 0; + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * 插槽数据。 + * @see dragonBones.Slot + * @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; + } + /** + * @private + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + /** + * @private + */ + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + /** + * @private + */ + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @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]"; + }; + /** + * @private + */ + 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(); + }; + /** + * @private + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + 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 = {})); +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.target = null; // + this.bone = null; // + this.root = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @private + */ + 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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @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; + }; + 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.weight = null; // Initial value. + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Mesh */; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + }; + return MeshDisplayData; + }(ImageDisplayData)); + 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 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; + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 边界框数据基类。 + * @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; + } + /** + * @private + */ + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 多边形边界框。 + * @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; + /** + * @private + */ + _this.weight = null; // Initial value. + return _this; + } + /** + * @private + */ + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, offset, count, 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 dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[offset + count - 2]; + var yC = vertices[offset + 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[offset + i]; + var yD = vertices[offset + 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; + }; + /** + * @private + */ + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Polygon */; + this.count = 0; + this.offset = 0; + this.x = 0.0; + this.y = 0.0; + this.vertices = null; // + this.weight = null; + }; + /** + * @inherDoc + */ + 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.count, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[this.offset + iP + 1]; + var yB = this.vertices[this.offset + i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[this.offset + iP]; + var xB = this.vertices[this.offset + i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inherDoc + */ + 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.width, this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, this.offset, this.count, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画数据。 + * @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.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + /** + * @private + */ + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var kA in this.boneTimelines[k]) { + this.boneTimelines[k][kA].returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var kA in this.slotTimelines[k]) { + this.slotTimelines[k][kA].returnToPool(); + } + delete this.slotTimelines[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.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.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @private + */ + 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 (bone, timeline) { + var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (slot, timeline) { + var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (name) { + return name in this.boneTimelines ? this.boneTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimeline = function (name) { + return name in this.slotTimelines ? this.slotTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (name) { + return name in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (name) { + return name in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[name] : 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; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + var AnimationConfig = (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + /** + * @private + */ + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additiveBlending = 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.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.weight = 1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + 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.additiveBlending = value.additiveBlending; + 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]; + } + }; + AnimationConfig.prototype.containsBoneMask = function (name) { + return this.boneMask.length === 0 || this.boneMask.indexOf(name) >= 0; + }; + AnimationConfig.prototype.addBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = armature.getBone(name); + if (currentBone === null) { + return; + } + if (this.boneMask.indexOf(name) < 0) { + this.boneMask.push(name); + } + if (recursive) { + for (var _i = 0, _a = 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); + } + } + } + }; + AnimationConfig.prototype.removeBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this.boneMask.indexOf(name); + if (index >= 0) { + this.boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = armature.getBone(name); + if (currentBone !== null) { + if (this.boneMask.length > 0) { + for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_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 _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 贴图集数据。 + * @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; + } + /** + * @private + */ + 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; + } + }; + /** + * @private + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Replace texture: " + value.name); + this.textures[value.name].returnToPool(); + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (name) { + return name in this.textures ? this.textures[name] : 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 = {})); +var dragonBones; +(function (dragonBones_1) { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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 = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @private + */ + _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._zOrder > b._zOrder ? 1 : -1; + }; + /** + * @private + */ + 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._actions; _d < _e.length; _d++) { + var action = _e[_d]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.clear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null; // + this.userData = null; + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._actions.length = 0; + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + Armature.prototype._sortBones = function () { + var total = this._bones.length; + if (total <= 0) { + return; + } + var sortHelper = this._bones.concat(); + var index = 0; + var count = 0; + this._bones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this._bones.indexOf(bone) >= 0) { + continue; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this._bones.indexOf(bone.parent) < 0) { + continue; + } + this._bones.push(bone); + count++; + } + }; + Armature.prototype._sortSlots = function () { + this._slots.sort(Armature._onSortSlots); + }; + /** + * @internal + * @private + */ + 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 + * @private + */ + Armature.prototype._addBoneToBoneList = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeBoneFromBoneList = function (value) { + var index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._addSlotToSlotList = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeSlotFromSlotList = function (value) { + var index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this.armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @private + */ + 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.init(this); + this._animation.init(this); + this._animation.animations = this.armatureData.animations; + }; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + if (this.armatureData === null) { + console.assert(false, "The armature has been disposed."); + return; + } + else if (this.armatureData.parent === null) { + console.assert(false, "The armature data has been disposed."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update nimation. + this._animation.advanceTime(passedTime); + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + // 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); + } + } + if (this._actions.length > 0) { + this._lockUpdate = true; + for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { + var action = _a[_i]; + if (action.type === 0 /* Play */) { + this._animation.fadeIn(action.name); + } + } + this._actions.length = 0; + this._lockUpdate = false; + } + // + var drawed = this.debugDraw || dragonBones_1.DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + }; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlotDisplay) { + 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 (updateSlotDisplay) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @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; + }; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + }; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @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; + }; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @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; + }; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @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; + }; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @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; + }; + /** + * @deprecated + */ + Armature.prototype.addBone = function (value, parentName) { + if (parentName === void 0) { parentName = null; } + console.assert(value !== null); + value._setArmature(this); + value._setParent(parentName !== null ? this.getBone(parentName) : null); + }; + /** + * @deprecated + */ + Armature.prototype.removeBone = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * @deprecated + */ + Armature.prototype.addSlot = function (value, parentName) { + var bone = this.getBone(parentName); + console.assert(value !== null && bone !== null); + value._setArmature(this); + value._setParent(bone); + }; + /** + * @deprecated + */ + Armature.prototype.removeSlot = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + 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", { + 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", { + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @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", { + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this.armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * 获得动画控制器。 + * @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", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + 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", { + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + Armature.prototype.replaceTexture = function (texture) { + this.replacedTexture = texture; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.hasEventListener = function (type) { + return this._proxy.hasEvent(type); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.addEventListener = function (type, listener, target) { + this._proxy.addEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.removeEventListener = function (type, listener, target) { + this._proxy.removeEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + Armature.prototype.enableAnimationCache = function (frameRate) { + this.cacheFrameRate = frameRate; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础变换对象。 + * @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; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + * @private + */ + TransformObject.prototype._onClear = function () { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; // + this.userData = null; + this._globalDirty = false; + this._armature = null; // + this._parent = null; // + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setArmature = function (value) { + this._armature = value; + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setParent = function (value) { + this._parent = value; + }; + /** + * @private + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransformObject.prototype, "parent", { + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + TransformObject._helpMatrix = new dragonBones.Matrix(); + /** + * @private + */ + TransformObject._helpTransform = new dragonBones.Transform(); + /** + * @private + */ + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @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 + * @private + */ + _this.animationPose = new dragonBones.Transform(); + /** + * @internal + * @private + */ + _this.constraints = []; + _this._bones = []; + _this._slots = []; + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + /** + * @private + */ + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this.constraints.length = 0; + this.boneData = null; // + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1.0; + this._blendLayerWeight = 0.0; + this._bones.length = 0; + this._slots.length = 0; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var inherit = this._parent !== null; + var dR = 0.0; + if (this.offsetMode === 1 /* Additive */) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } + else if (this.offsetMode === 0 /* None */) { + global.copyFrom(this.origin).add(this.animationPose); + } + else { + inherit = false; + global.copyFrom(this.offset); + } + if (inherit) { + var parentMatrix = this._parent.globalTransformMatrix; + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (this.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 (this.boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + if (this._parent.global.scaleX < 0.0) { + dR += Math.PI; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + dR -= global.rotation * 2.0; + if (flipX !== flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + global.rotation += dR; + } + else if (flipX || flipY) { + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + * @private + */ + Bone.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + var oldSlots = null; + var oldBones = null; + if (this._armature !== null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + this._armature = value; // + if (this._armature !== null) { + this._armature._addBoneToBoneList(this); + } + if (oldSlots !== null) { + for (var _i = 0, oldSlots_1 = oldSlots; _i < oldSlots_1.length; _i++) { + var slot = oldSlots_1[_i]; + if (slot.parent === this) { + slot._setArmature(this._armature); + } + } + } + if (oldBones !== null) { + for (var _a = 0, oldBones_1 = oldBones; _a < oldBones_1.length; _a++) { + var bone = oldBones_1[_a]; + if (bone.parent === this) { + bone._setArmature(this._armature); + } + } + } + }; + /** + * @internal + * @private + */ + Bone.prototype.init = function (boneData) { + if (this.boneData !== null) { + return; + } + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + }; + /** + * @internal + * @private + */ + Bone.prototype.update = function (cacheFrameIndex) { + this._blendDirty = false; + 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.constraints.length > 0) { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + 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.constraints.length > 0) { + for (var _b = 0, _c = this.constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + 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 + * @private + */ + 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; + } + }; + /** + * @internal + * @private + */ + Bone.prototype.addConstraint = function (constraint) { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.push(constraint); + } + }; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (child) { + if (child === this) { + return false; + } + var ancestor = child; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getBones = function () { + this._bones.length = 0; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.parent === this) { + this._bones.push(bone); + } + } + return this._bones; + }; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getSlots = function () { + this._slots.length = 0; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + this._slots.push(slot); + } + } + return this._slots; + }; + Object.defineProperty(Bone.prototype, "visible", { + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @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, "length", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + get: function () { + return this.boneData.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + get: function () { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + return slot; + } + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @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; + /** + * @private + */ + _this._localMatrix = new dragonBones.Matrix(); + /** + * @private + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @private + */ + _this._ffdVertices = []; + /** + * @private + */ + _this._displayDatas = []; + /** + * @private + */ + _this._displayList = []; + /** + * @private + */ + _this._meshBones = []; + /** + * @private + */ + _this._rawDisplay = null; // Initial value. + /** + * @private + */ + _this._meshDisplay = null; // Initial value. + return _this; + } + /** + * @private + */ + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { + var eachDisplay = _a[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + 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); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { + this._disposeDisplay(this._meshDisplay); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay); + } + this.displayController = null; + this.slotData = null; // + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.length = 0; + this._displayList.length = 0; + this._displayDatas.length = 0; + this._meshBones.length = 0; + this._rawDisplayDatas = null; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Slot.prototype._updateDisplayData = function () { + var prevDisplayData = this._displayData; + var prevTextureData = this._textureData; + var prevMeshData = this._meshData; + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.length) { + this._displayData = this._displayDatas[this._displayIndex]; + } + else { + this._displayData = null; + } + // Update texture and mesh data. + if (this._displayData !== null) { + if (this._displayData.type === 0 /* Image */ || this._displayData.type === 2 /* Mesh */) { + this._textureData = this._displayData.texture; + if (this._displayData.type === 2 /* Mesh */) { + this._meshData = this._displayData; + } + else if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */) { + this._meshData = rawDisplayData; + } + else { + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + // Update bounding box data. + if (this._displayData !== null && this._displayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = this._displayData.boundingBox; + } + else if (rawDisplayData !== null && rawDisplayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = rawDisplayData.boundingBox; + } + else { + this._boundingBoxData = null; + } + if (this._displayData !== prevDisplayData || this._textureData !== prevTextureData || this._meshData !== prevMeshData) { + // Update pivot offset. + if (this._meshData !== null) { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + else if (this._textureData !== null) { + var imageDisplayData = this._displayData; + var 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 * scale; + var height = rect.height * scale; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width; + this._pivotY *= height; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update mesh bones and ffd vertices. + if (this._meshData !== prevMeshData) { + if (this._meshData !== null) { + if (this._meshData.weight !== null) { + this._ffdVertices.length = this._meshData.weight.count * 2; + this._meshBones.length = this._meshData.weight.bones.length; + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.weight.bones[i].name); + } + } + else { + var vertexCount = this._meshData.parent.parent.intArray[this._meshData.offset + 0 /* MeshVertexCount */]; + this._ffdVertices.length = vertexCount * 2; + this._meshBones.length = 0; + } + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0.0; + } + this._meshDirty = true; + } + else { + this._ffdVertices.length = 0; + this._meshBones.length = 0; + } + } + else if (this._meshData !== null && this._textureData !== prevTextureData) { + this._meshDirty = true; + } + if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData && this._meshData === null) { + 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; + this._displayData.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; + } + // Update original transform. + if (rawDisplayData !== null) { + this.origin = rawDisplayData.transform; + } + else if (this._displayData !== null) { + this.origin = this._displayData.transform; + } + this._displayDirty = true; + this._transformDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + 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._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + // Update frame. + if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { + this._updateFrame(); + } + // 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. + var actions = null; + if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { + actions = this._displayData.actions; + } + else { + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { + actions = rawDisplayData.actions; + } + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + }; + /** + * @private + */ + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._isMeshBonesUpdate = function () { + for (var _i = 0, _a = this._meshBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + * @private + */ + Slot.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + if (this._armature !== null) { + this._armature._removeSlotFromSlotList(this); + } + this._armature = value; // + this._onUpdateDisplay(); + if (this._armature !== null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); + } + }; + /** + * @internal + * @private + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return false; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return false; + } + this._displayIndex = value; + this._displayDirty = true; + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setZorder = function (value) { + if (this._zOrder === value) { + //return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return this._colorDirty; + }; + /** + * @private + */ + Slot.prototype._setDisplayList = function (value) { + if (value !== null && value.length > 0) { + if (this._displayList.length !== value.length) { + this._displayList.length = value.length; + } + for (var i = 0, l = value.length; i < l; ++i) { + var eachDisplay = value[i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { + this._initDisplay(eachDisplay); + } + this._displayList[i] = eachDisplay; + } + } + else if (this._displayList.length > 0) { + this._displayList.length = 0; + } + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display !== this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display !== null; + } + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @private + */ + Slot.prototype.init = function (slotData, displayDatas, rawDisplay, meshDisplay) { + if (this.slotData !== null) { + return; + } + this.slotData = slotData; + this.name = this.slotData.name; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._displayDatas.length = this._rawDisplayDatas.length; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) { + this._displayDatas[i] = this._rawDisplayDatas[i]; + } + }; + /** + * @internal + * @private + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + if (this._transformDirty) { + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + 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._display === null) { + return; + } + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + if (this._meshData !== null && this._display === this._meshDisplay) { + var isSkinned = this._meshData.weight !== null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + return; + } + } + if (this._transformDirty) { + this._transformDirty = false; + 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(false); + } + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + }; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @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); + }; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + }; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDirty = true; + this._transformDirty = true; + }; + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._displayList.concat(); + }, + set: function (value) { + var backupDisplayList = this._displayList.concat(); // Copy. + var disposeDisplayList = new Array(); + if (this._setDisplayList(value)) { + this.update(-1); + } + // Release replaced displays. + for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { + var eachDisplay = backupDisplayList_1[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { + var eachDisplay = disposeDisplayList_2[_a]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + 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", { + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + var displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength === 0) { + this._displayIndex = 0; + } + if (this._displayIndex < 0) { + return; + } + else { + var replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @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 + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + * @internal + */ + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this.target = null; // + this.bone = null; // + this.root = null; // + }; + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @private + * @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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this.target.global; + var global = this.bone.global; + var globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + var ikRadian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadian += Math.PI; + } + global.rotation += (ikRadian - 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 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 ikRadianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + ikRadianA += 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; + if (parent._parent !== null) { + var parentParentMatrix = parent._parent.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; + } + ikRadianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + var parentRadian = rawRadianA + dR; + global.x = parentGlobal.x + Math.cos(parentRadian) * lP; + global.y = parentGlobal.y + Math.sin(parentRadian) * lP; + var ikRadianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadianB += Math.PI; + } + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.update = function () { + if (this.root === null) { + this.bone.updateByConstraint(); + this._computeA(); + } + else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = (function () { + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = -1.0; } + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._animatebles = []; + this._clock = null; + if (time < 0.0) { + this.time = new Date().getTime() * 0.001; + } + else { + this.time = time; + } + } + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + if (passedTime < 0.0) { + passedTime = new Date().getTime() * 0.001 - this.time; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + if (passedTime === 0.0) { + return; + } + 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; + } + }; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + return this._animatebles.indexOf(value) >= 0; + }; + /** + * 添加 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; + } + }; + /** + * 移除 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; + } + }; + /** + * 清除所有的 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 + }); + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.clock = new WorldClock(); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @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._animationConfig = null; // Initial value. + return _this; + } + /** + * @private + */ + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + /** + * @private + */ + 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]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._timelineDirty = false; + 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.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.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.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]; + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 0 /* None */: + case 5 /* Single */: + default: + break; + } + }; + /** + * @internal + * @private + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + * @private + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { + passedTime *= this._armature._parent._armature.animation.timeScale; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + 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]; + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + this._timelineDirty = false; + }; + /** + * 清除所有动画状态。 + * @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._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * 暂停播放动画。 + * @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(); + } + } + }; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @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.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 > 1) { + 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) { + } + else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + // Child armature play same name animation. + 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); // + } + } + if (animationConfig.fadeInTime <= 0.0) { + this._armature.advanceTime(0.0); + } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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.duration * frame / animationData.frameCount; + } + return this.playConfig(this._animationConfig); + }; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName) { + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName) { + return animationState; + } + } + return null; + }; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * 动画是否处于播放状态。 + * @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", { + /** + * 所有动画状态是否均已播放完毕。 + * @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", { + /** + * 上一个正在播放的动画状态名称。 + * @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", { + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @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._animations[k] = value[k]; + this._animationNames.push(k); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * 一个可以快速使用的动画配置实例。 + * @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", { + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (duration === void 0) { duration = -1; } + 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 */; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + var animationData = this._animations[animationName]; + if (animationData && duration > 0.0) { + this._animationConfig.timeScale = animationData.duration / duration; + } + return this.playConfig(this._animationConfig); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + Animation.prototype.gotoAndStop = function (animationName, time) { + if (time === void 0) { time = 0; } + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); + } + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var BonePose = (function (_super) { + __extends(BonePose, _super); + function BonePose() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.current = new dragonBones.Transform(); + _this.delta = new dragonBones.Transform(); + _this.result = new dragonBones.Transform(); + return _this; + } + BonePose.toString = function () { + return "[class dragonBones.BonePose]"; + }; + BonePose.prototype._onClear = function () { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return BonePose; + }(dragonBones.BaseObject)); + dragonBones.BonePose = BonePose; + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @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._slotTimelines = []; + _this._bonePoses = {}; + /** + * @internal + * @private + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + /** + * @private + */ + 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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1.0; + this.weight = 1.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this.animationData = null; // + this._timelineDirty = true; + 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._slotTimelines.length = 0; + // this._bonePoses.clear(); + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + }; + AnimationState.prototype._isDisabled = function (slot) { + if (this.displayControl) { + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + return false; + } + } + return true; + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasEvent(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 eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + }; + AnimationState.prototype._blendBoneTimline = function (timeline) { + var bone = timeline.bone; + var bonePose = timeline.bonePose.result; + var animationPose = bone.animationPose; + var boneWeight = this._weightResult > 0.0 ? this._weightResult : -this._weightResult; + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1.0; + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1.0) * boneWeight + 1.0; + animationPose.scaleY = (bonePose.scaleY - 1.0) * boneWeight + 1.0; + } + else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1.0) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1.0) * boneWeight; + } + if (this._fadeState !== 0 || this._subFadeState !== 0) { + bone._transformDirty = true; + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + 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); + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.updateTimelines = function () { + var boneTimelines = {}; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.bone.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + var timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (timelineName in boneTimelines) { + delete boneTimelines[timelineName]; + } + else { + var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); + if (timelineDatas !== null) { + for (var _d = 0, timelineDatas_1 = timelineDatas; _d < timelineDatas_1.length; _d++) { + var timelineData = timelineDatas_1[_d]; + switch (timelineData.type) { + case 10 /* BoneAll */: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + case 11 /* BoneT */: + case 12 /* BoneR */: + case 13 /* BoneS */: + // TODO + break; + case 14 /* BoneX */: + case 15 /* BoneY */: + case 16 /* BoneRotate */: + case 17 /* BoneSkew */: + case 18 /* BoneScaleX */: + case 19 /* BoneScaleY */: + // TODO + break; + } + } + } + else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + for (var k in boneTimelines) { + for (var _e = 0, _f = boneTimelines[k]; _e < _f.length; _e++) { + var timeline = _f[_e]; + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + var slotTimelines = {}; + var ffdFlags = []; + for (var _g = 0, _h = this._slotTimelines; _g < _h.length; _g++) { + var timeline = _h[_g]; + var timelineName = timeline.slot.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _j = 0, _k = this._armature.getSlots(); _j < _k.length; _j++) { + var slot = _k[_j]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + var timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (timelineName in slotTimelines) { + delete slotTimelines[timelineName]; + } + else { + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + if (timelineDatas !== null) { + for (var _l = 0, timelineDatas_2 = timelineDatas; _l < timelineDatas_2.length; _l++) { + var timelineData = timelineDatas_2[_l]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 21 /* SlotColor */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotFFD */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + if (this.resetToPose) { + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + for (var _m = 0, _o = slot._rawDisplayDatas; _m < _o.length; _m++) { + var displayData = _o[_m]; + if (displayData !== null && displayData.type === 2 /* Mesh */ && ffdFlags.indexOf(displayData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { + for (var _p = 0, _q = slotTimelines[k]; _p < _q.length; _p++) { + var timeline = _q[_p]; + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + }; + /** + * @private + * @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; + } + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + if (this.weight === 0.0) { + return; + } + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this.weight * this._fadeProgress; + this._actionTimeline.update(time); // Update main timeline. + if (isCacheEnabled) { + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null) { + 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) { + if (isUpdateBoneTimeline) { + var bone = null; + var prevTimeline = null; // + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (bone !== timeline.bone) { + if (bone !== null) { + this._blendBoneTimline(prevTimeline); + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0.0) { + if (bone._blendLayer !== this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0.0; + bone = null; + } + else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0.0; + } + } + } + else { + bone = null; + } + } + } + bone = timeline.bone; + } + if (bone !== null) { + timeline.update(time); + if (i === l - 1) { + this._blendBoneTimline(timeline); + } + else { + prevTimeline = timeline; + } + } + } + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (this._isDisabled(timeline.slot)) { + continue; + } + timeline.update(time); + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * 淡出动画。 + * @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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (name) { + return this._boneMask.length === 0 || this._boneMask.indexOf(name) >= 0; + }; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(name); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(name) < 0) { + this._boneMask.push(name); + } + 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 = true; + }; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(name); + if (index >= 0) { + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(name); + 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_2 = this._boneMask.indexOf(bone.name); + if (index_2 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_2, 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 = true; + }; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = true; + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * 是否正在播放。 + * @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", { + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * 当前播放的时间。 (以秒为单位) + * @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) { + 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, "clip", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + get: function () { + return this.animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var TimelineState = (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this._tweenState = 0 /* None */; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 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._dragonBonesData = null; // + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._frameIntArray = null; // + this._frameFloatArray = 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._duration; + } + } + 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._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + if (this._timelineData !== null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._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 () { }; + TimelineState.prototype.update = function (passedTime) { + if (this.playState <= 0 && 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._tweenState !== 0 /* None */) { + this._onUpdateFrame(); + } + } + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + * @private + */ + 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 segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : 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._tweenProgress = 0.0; + this._tweenEasing = 0.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 */]; // TODO recode ture tween type. + this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; + 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; + } + 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]; + this._frameDurationR = 1.0 / (this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition); + } + } + else { + this._tweenState = 1 /* Once */; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._tweenState === 2 /* Always */) { + 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); + } + } + else { + this._tweenProgress = 0.0; + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + * @private + */ + var BoneTimelineState = (function (_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.bone = null; // + this.bonePose = null; // + }; + return BoneTimelineState; + }(TweenTimelineState)); + dragonBones.BoneTimelineState = BoneTimelineState; + /** + * @internal + * @private + */ + var SlotTimelineState = (function (_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.slot = null; // + }; + return SlotTimelineState; + }(TweenTimelineState)); + dragonBones.SlotTimelineState = SlotTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + 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._armature.armatureData.actions; + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + if (action.slot !== null) { + var slot = this._armature.getSlot(action.slot.name); + if (slot !== null) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature._bufferAction(action, true); + } + } + } + else if (action.bone !== null) { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null && slot.parent.boneData === action.bone) { + childArmature._bufferAction(action, true); + } + } + } + else { + this._armature._bufferAction(action, true); + } + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasEvent(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.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + if (action.bone !== null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + if (action.slot !== null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + 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.playState <= 0 && this._setCurrentTime(passedTime)) { + 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 (eventDispatcher.hasEvent(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 (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasEvent(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.hasEvent(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 + * @private + */ + 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 + * @private + */ + 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._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + current.x = frameFloatArray[valueOffset++]; + current.y = frameFloatArray[valueOffset++]; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + delta.x = frameFloatArray[valueOffset++] - current.x; + delta.y = frameFloatArray[valueOffset++] - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } + // else { + // delta.x = 0.0; + // delta.y = 0.0; + // delta.rotation = 0.0; + // delta.skew = 0.0; + // delta.scaleX = 0.0; + // delta.scaleY = 0.0; + // } + } + else { + var current = this.bonePose.current; + current.x = 0.0; + current.y = 0.0; + current.rotation = 0.0; + current.skew = 0.0; + current.scaleX = 1.0; + current.scaleY = 1.0; + } + }; + BoneAllTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + var scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneAllTimelineState; + }(dragonBones.BoneTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + * @private + */ + var SlotDislayIndexTimelineState = (function (_super) { + __extends(SlotDislayIndexTimelineState, _super); + function SlotDislayIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDislayIndexTimelineState.toString = function () { + return "[class dragonBones.SlotDislayIndexTimelineState]"; + }; + SlotDislayIndexTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot.slotData.displayIndex; + if (this.slot.displayIndex !== displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + }; + return SlotDislayIndexTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotDislayIndexTimelineState = SlotDislayIndexTimelineState; + /** + * @internal + * @private + */ + 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._delta = [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._onClear = function () { + _super.prototype._onClear.call(this); + this._dirty = false; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var intArray = this._dragonBonesData.intArray; + var frameIntArray = this._dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + var colorOffset = frameIntArray[valueOffset]; + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1 * 1]; + } + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } + else { + var color = this.slot.slotData.color; + this._current[0] = color.alphaMultiplier * 100.0; + this._current[1] = color.redMultiplier * 100.0; + this._current[2] = color.greenMultiplier * 100.0; + this._current[3] = color.blueMultiplier * 100.0; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.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; + this.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]; + this.slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + * @private + */ + var SlotFFDTimelineState = (function (_super) { + __extends(SlotFFDTimelineState, _super); + function SlotFFDTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + SlotFFDTimelineState.toString = function () { + return "[class dragonBones.SlotFFDTimelineState]"; + }; + SlotFFDTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.meshOffset = 0; + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + SlotFFDTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var isTween = this._tweenState === 2 /* Always */; + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + if (isTween) { + var nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex === this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = frameFloatArray[nextValueOffset + i] - (this._current[i] = frameFloatArray[valueOffset + i]); + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = frameFloatArray[valueOffset + i]; + } + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = 0.0; + } + } + }; + SlotFFDTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + for (var i = 0; i < this._valueCount; ++i) { + this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + } + }; + SlotFFDTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntArray = this._dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this.meshOffset = frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */]; + this._ffdCount = frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */]; + this._valueOffset = frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */]; + this._frameFloatOffset = frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] + this._animationData.frameFloatOffset; + } + else { + this._valueCount = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = 0.0; + } + }; + SlotFFDTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotFFDTimelineState.prototype.update = function (passedTime) { + if (this.slot._meshData === null || (this._timelineData !== null && this.slot._meshData.offset !== this.meshOffset)) { + return; + } + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.slot._ffdVertices; + if (this._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] += (frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; + } + else { + result[i] += (frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + } + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] = frameFloatArray[this._frameFloatOffset + i]; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] = this._result[i - this._valueOffset]; + } + else { + result[i] = frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + } + } + this.slot._meshDirty = true; + } + } + else { + this._ffdCount = result.length; // + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + result[i] += (0.0 - result[i]) * fadeProgress; + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + result[i] = 0.0; + } + this.slot._meshDirty = true; + } + } + } + }; + return SlotFFDTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotFFDTimelineState = SlotFFDTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + /** + * @private + */ + 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.data = null; + }; + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(dragonBones || (dragonBones = {})); +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._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 */; + 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._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._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 */; + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + DataParser.parseDragonBonesData = function (rawData) { + if (rawData instanceof ArrayBuffer) { + return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); + } + else { + return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + DataParser.parseTextureAtlasData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.warn("已废弃,请参考 @see"); + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + } + return textureAtlasData; + }; + 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 = DataParser.DATA_VERSION_5_0; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + ]; + 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.BONE = "bone"; + DataParser.IK = "ik"; + DataParser.SLOT = "slot"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.Z_ORDER = "zOrder"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.VISIBLE_FRAME = "visibleFrame"; + 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.CANVAS = "canvas"; + 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.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + 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_FFD = "inheritFFD"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_TYPE = "tweenType"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + 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_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.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var ObjectDataParser = (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + /** + * @private + */ + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._intArrayJson = []; + _this._floatArrayJson = []; + _this._frameIntArrayJson = []; + _this._frameFloatArrayJson = []; + _this._frameArrayJson = []; + _this._timelineArrayJson = []; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._defalultColorOffset = -1; + _this._prevTweenRotate = 0; + _this._prevRotation = 0.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._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._weightBoneIndices = {}; + _this._cacheBones = {}; + _this._meshs = {}; + _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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + if (dragonBones.DragonBones.webAssembly) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + } + return value; + } + return String(value); + } + return defaultValue; + }; + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); + 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; + } + }; + ObjectDataParser.prototype._sortActionFrame = function (a, b) { + return a.frameStart > b.frameStart ? 1 : -1; + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (ObjectDataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (ObjectDataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (ObjectDataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + var frame = null; + if (this._actionFrames.length === 0) { + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _i = 0, _a = this._actionFrames; _i < _a.length; _i++) { + var eachFrame = _a[_i]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + } + if (frame === null) { + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.push(frame); + } + for (var i = 0; i < actionCount; ++i) { + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseCacheActionFrame = function (frame) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = frameArray.length; + var actionCount = frame.actions.length; + frameArray.length += 1 + 1 + actionCount; + frameArray[frameOffset + 0 /* FramePosition */] = frame.frameStart; + frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { + frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + // const armature = BaseObject.borrowObject(ArmatureData); + var armature = dragonBones.DragonBones.webAssembly ? new Module["ArmatureData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { + armature.frameRate = 24; + } + this._armature = armature; + if (ObjectDataParser.AABB in rawData) { + var rawAABB = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.X, 0.0); + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.Y, 0.0); + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.WIDTH, 0.0); + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.HEIGHT, 0.0); + } + if (ObjectDataParser.CANVAS in rawData) { + var rawCanvas = rawData[ObjectDataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (ObjectDataParser.COLOR in rawCanvas) { + ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.X, 0); + canvas.y = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.HEIGHT, 0); + armature.canvas = canvas; + } + if (ObjectDataParser.BONE in rawData) { + var rawBones = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, ObjectDataParser.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 { + (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); // Raw bone sort. + } + } + if (ObjectDataParser.IK in rawData) { + var rawIKS = rawData[ObjectDataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + this._parseIKConstraint(rawIK); + } + } + armature.sortBones(); + if (ObjectDataParser.SLOT in rawData) { + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot)); + } + } + if (ObjectDataParser.SKIN in rawData) { + var rawSkins = rawData[ObjectDataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (ObjectDataParser.ANIMATION in rawData) { + var rawAnimations = rawData[ObjectDataParser.ANIMATION]; + for (var _f = 0, rawAnimations_1 = rawAnimations; _f < rawAnimations_1.length; _f++) { + var rawAnimation = rawAnimations_1[_f]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (ObjectDataParser.DEFAULT_ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.DEFAULT_ACTIONS], armature.defaultActions, 0 /* Play */, null, null); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armature.actions, 0 /* Play */, null, null); + } + // for (const action of armature.defaultActions) { // Set default animation from default action. + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? armature.defaultActions.size() : armature.defaultActions.length); ++i) { + var action = dragonBones.DragonBones.webAssembly ? armature.defaultActions.get(i) : armature.defaultActions[i]; + if (action.type === 0 /* Play */) { + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + break; + } + } + // Clear helper. + this._rawBones.length = 0; + this._armature = null; + for (var k in this._meshs) { + delete this._meshs[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + 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._weightBoneIndices) { + delete this._weightBoneIndices[k]; + } + return armature; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBone = function (rawData) { + // const bone = BaseObject.borrowObject(BoneData); + var bone = dragonBones.DragonBones.webAssembly ? new Module["BoneData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform, this._armature.scale); + } + return bone; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, "")); + if (target === null) { + return; + } + // const constraint = BaseObject.borrowObject(IKConstraintData); + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraintData"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, ObjectDataParser.SCALE, false); + constraint.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1.0); + constraint.bone = bone; + constraint.target = target; + var chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + if (dragonBones.DragonBones.webAssembly) { + bone.constraints.push_back(constraint); + } + else { + bone.constraints.push(constraint); + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlot = function (rawData) { + // const slot = BaseObject.borrowObject(SlotData); + var slot = dragonBones.DragonBones.webAssembly ? new Module["SlotData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = dragonBones.DragonBones.webAssembly ? this._armature.sortedSlots.size() : this._armature.sortedSlots.length; + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, "")); // + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] === "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); + } + if (ObjectDataParser.COLOR in rawData) { + // slot.color = SlotData.createColor(); + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].createColor() : dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].DEFAULT_COLOR : dragonBones.SlotData.DEFAULT_COLOR; + } + if (ObjectDataParser.ACTIONS in rawData) { + var actions = this._slotChildActions[slot.name] = []; + this._parseActionData(rawData[ObjectDataParser.ACTIONS], actions, 0 /* Play */, null, null); + } + return slot; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSkin = function (rawData) { + // const skin = BaseObject.borrowObject(SkinData); + var skin = dragonBones.DragonBones.webAssembly ? new Module["SkinData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (ObjectDataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[ObjectDataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var display = null; + var name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, ObjectDataParser.PATH, ""); + var type = 0 /* Image */; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: + // const imageDisplay = display = BaseObject.borrowObject(ImageDisplayData); + var imageDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ImageDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + case 1 /* Armature */: + // const armatureDisplay = display = BaseObject.borrowObject(ArmatureDisplayData); + var armatureDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ArmatureDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armatureDisplay.actions, 0 /* Play */, null, null); + } + 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 _i = 0, _a = this._slotChildActions[this._slot.name]; _i < _a.length; _i++) { + var action = _a[_i]; + if (dragonBones.DragonBones.webAssembly) { + armatureDisplay.actions.push_back(action); + } + else { + armatureDisplay.actions.push(action); + } + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + case 2 /* Mesh */: + // const meshDisplay = display = BaseObject.borrowObject(MeshDisplayData); + var meshDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["MeshDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.inheritAnimation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + var shareName = ObjectDataParser._getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length > 0) { + var shareMesh = this._meshs[shareName]; + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } + else { + this._parseMesh(rawData, meshDisplay); + this._meshs[meshDisplay.name] = meshDisplay; + } + break; + case 3 /* BoundingBox */: + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + // const boundingBoxDisplay = display = BaseObject.borrowObject(BoundingBoxDisplayData); + var boundingBoxDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["BoundingBoxDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + if (display !== null) { + display.parent = this._armature; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform, this._armature.scale); + } + } + return display; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (ObjectDataParser.PIVOT in rawData) { + var rawPivot = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var rawUVs = rawData[ObjectDataParser.UVS]; + var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = Math.floor(rawTriangles.length / 3); // uint + var vertexOffset = floatArray.length; + var uvOffset = vertexOffset + vertexCount * 2; + mesh.offset = intArray.length; + intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; + intArray[mesh.offset + 0 /* MeshVertexCount */] = vertexCount; + intArray[mesh.offset + 1 /* MeshTriangleCount */] = triangleCount; + intArray[mesh.offset + 2 /* MeshFloatOffset */] = vertexOffset; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + intArray[mesh.offset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; + } + floatArray.length += vertexCount * 2 + vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray[vertexOffset + i] = rawVertices[i]; + floatArray[uvOffset + i] = rawUVs[i]; + } + if (ObjectDataParser.WEIGHTS in rawData) { + var rawWeights = rawData[ObjectDataParser.WEIGHTS]; + var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; + var rawBonePoses = rawData[ObjectDataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + var floatOffset = floatArray.length; + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = (rawWeights.length - vertexCount) / 2; + weight.offset = intArray.length; + weight.bones.length = weightBoneCount; + weightBoneIndices.length = weightBoneCount; + intArray.length += 1 + 1 + weightBoneCount + vertexCount + weight.count; + intArray[weight.offset + 1 /* WeigthFloatOffset */] = floatOffset; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.bones[i] = bone; + weightBoneIndices[i] = rawBoneIndex; + if (dragonBones.DragonBones.webAssembly) { + for (var j = 0; j < this._armature.sortedBones.size(); j++) { + if (this._armature.sortedBones.get(j) === bone) { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = j; + } + } + } + else { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = this._armature.sortedBones.indexOf(bone); + } + } + floatArray.length += weight.count * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = intArray[iB++] = rawWeights[iW++]; // uint + var x = floatArray[vertexOffset + iD]; + var y = floatArray[vertexOffset + 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 bone = this._rawBones[rawBoneIndex]; + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray[iB++] = weight.bones.indexOf(bone); + floatArray[iV++] = rawWeights[iW++]; + floatArray[iV++] = this._helpPoint.x; + floatArray[iV++] = this._helpPoint.y; + } + } + mesh.weight = weight; + // + this._weightSlotPose[mesh.name] = rawSlotPose; + this._weightBonePoses[mesh.name] = rawBonePoses; + this._weightBoneIndices[mesh.name] = weightBoneIndices; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (ObjectDataParser.SUB_TYPE in rawData && typeof rawData[ObjectDataParser.SUB_TYPE] === "string") { + type = ObjectDataParser._getBoundingBoxType(rawData[ObjectDataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["RectangleBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["EllipseBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, ObjectDataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = floatArray.length; + polygonBoundingBox.count = rawVertices.length; + polygonBoundingBox.vertices = floatArray; + floatArray.length += polygonBoundingBox.count; + for (var i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + var iN = i + 1; + var x = rawVertices[i]; + var y = rawVertices[iN]; + floatArray[polygonBoundingBox.offset + i] = x; + floatArray[polygonBoundingBox.offset + iN] = 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; + } + } + } + return polygonBoundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + if (dragonBones.DragonBones.webAssembly) { + animation.frameIntOffset = this._frameIntArrayJson.length; + animation.frameFloatOffset = this._frameFloatArrayJson.length; + animation.frameOffset = this._frameArrayJson.length; + } + else { + animation.frameIntOffset = this._data.frameIntArray.length; + animation.frameFloatOffset = this._data.frameFloatArray.length; + animation.frameOffset = this._data.frameArray.length; + } + this._animation = animation; + if (ObjectDataParser.FRAME in rawData) { + var rawFrames = rawData[ObjectDataParser.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, ObjectDataParser.DURATION, 1); + } + } + } + if (ObjectDataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[ObjectDataParser.Z_ORDER], 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); + } + if (ObjectDataParser.BONE in rawData) { + var rawTimelines = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (ObjectDataParser.SLOT in rawData) { + var rawTimelines = rawData[ObjectDataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (ObjectDataParser.FFD in rawData) { + var rawTimelines = rawData[ObjectDataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var slotName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot === null) { + continue; + } + this._slot = slot; + this._mesh = this._meshs[displayName]; + var timelineFFD = this._parseTimeline(rawTimeline, 22 /* SlotFFD */, false, true, 0, this._parseSlotFFDFrame); + if (timelineFFD !== null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + this._slot = null; // + this._mesh = null; // + } + } + if (this._actionFrames.length > 0) { + this._actionFrames.sort(this._sortActionFrame); + // const timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData); + var timeline = this._animation.actionTimeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var keyFrameCount = this._actionFrames.length; + timeline.type = 0 /* Action */; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = 100; + timelineArray[timeline.offset + 1 /* TimelineOffset */] = 0; + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = 0; + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = this._parseCacheActionFrame(this._actionFrames[0]) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + //(frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var frame = this._actionFrames[iK]; + frameStart = frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = this._parseCacheActionFrame(frame) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + this._actionFrames.length = 0; + } + this._animation = null; // + return animation; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTimeline = function (rawData, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { + if (!(ObjectDataParser.FRAME in rawData)) { + return null; + } + var rawFrames = rawData[ObjectDataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntArrayLength = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson.length : this._data.frameIntArray.length; + var frameFloatArrayLength = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson.length : this._data.frameFloatArray.length; + // const timeline = BaseObject.borrowObject(TimelineData); + var timeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0) * 100); + timelineArray[timeline.offset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0.0) * 100); + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = frameValueCount; + if (addIntOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + } + else if (addFloatOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + } + else { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + } + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var frameIndices = this._data.frameIndices; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // frameIndices.resize( frameIndices.size() + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + 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; + frameCount = ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + var timeline = this._parseTimeline(rawData, 10 /* BoneAll */, false, true, 6, this._parseBoneFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone, timeline); + } + this._bone = null; // + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (slot === null) { + return; + } + this._slot = slot; + var displayIndexTimeline = this._parseTimeline(rawData, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayIndexFrame); + if (displayIndexTimeline !== null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + var colorTimeline = this._parseTimeline(rawData, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount, frameArray) { + rawData; + frameCount; + var frameOffset = frameArray.length; + frameArray.length += 1; + frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount, frameArray) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (frameCount > 0) { + if (ObjectDataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[ObjectDataParser.CURVE], this._helpArray); + frameArray.length += 1 + 1 + this._helpArray.length; + frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; + for (var i = 0; i < sampleCount; ++i) { + frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (ObjectDataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (ObjectDataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[ObjectDataParser.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 < slotCount; ++i_1) { + zOrders[i_1] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_2 = 0, l = rawZOrder.length; i_2 < l; i_2 += 2) { + var slotIndex = rawZOrder[i_2]; + var zOrderOffset = rawZOrder[i_2 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + zOrders[originalIndex + zOrderOffset] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + frameArray.length += 1 + slotCount; + frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex]; + } + else { + frameArray[frameOffset + 2 + i] = zOrders[i]; + } + } + return frameOffset; + } + } + frameArray.length += 1; + frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneFrame = function (rawData, frameStart, frameCount) { + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + this._helpTransform.identity(); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevTweenRotate === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevTweenRotate; + } + } + this._prevTweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + var frameFloatOffset = frameFloatArray.length; + frameFloatArray.length += 6; + frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + frameFloatArray[frameFloatOffset++] = rotation; + frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotDisplayIndexFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + frameArray.length += 1; + frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var colorOffset = -1; + if (ObjectDataParser.COLOR in rawData) { + var rawColor = rawData[ObjectDataParser.COLOR]; + for (var k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + } + colorOffset = this._defalultColorOffset; + } + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1; + frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameFloatOffset = frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var rawVertices = ObjectDataParser.VERTICES in rawData ? rawData[ObjectDataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); // uint + var vertexCount = intArray[this._mesh.offset + 0 /* MeshVertexCount */]; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (this._mesh.weight !== null) { + var rawSlotPose = this._weightSlotPose[this._mesh.name]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.length += this._mesh.weight.count * 2; + iB = this._mesh.weight.offset + 2 /* WeigthBoneIndices */ + this._mesh.weight.bones.length; + } + else { + 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 (this._mesh.weight !== null) { + var rawBonePoses = this._weightBonePoses[this._mesh.name]; + var weightBoneIndices = this._weightBoneIndices[this._mesh.name]; + var vertexBoneCount = 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 = intArray[iB++]; + var bone = this._mesh.weight.bones[boneIndex]; + var rawBoneIndex = this._rawBones.indexOf(bone); + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + frameFloatArray[frameFloatOffset + i] = x; + frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1 + 1 + 1 + 1 + 1; + frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */] = this._mesh.offset; + frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */] = 0; + frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] = frameFloatOffset; + timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseActionData = function (rawData, actions, type, bone, slot) { + var actionCount = 0; + if (typeof rawData === "string") { + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_1 = rawData; _i < rawData_1.length; _i++) { + var rawAction = rawData_1[_i]; + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (ObjectDataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } + else { + if (ObjectDataParser.TYPE in rawAction && typeof rawAction[ObjectDataParser.TYPE] === "string") { + action.type = ObjectDataParser._getActionType(rawAction[ObjectDataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, ObjectDataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.NAME, ""); + } + if (ObjectDataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (ObjectDataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + if (ObjectDataParser.INTS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[ObjectDataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + dragonBones.DragonBones.webAssembly ? action.data.ints.push_back(rawValue) : action.data.ints.push(rawValue); + } + } + if (ObjectDataParser.FLOATS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[ObjectDataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + dragonBones.DragonBones.webAssembly ? action.data.floats.push_back(rawValue) : action.data.floats.push(rawValue); + } + } + if (ObjectDataParser.STRINGS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[ObjectDataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + dragonBones.DragonBones.webAssembly ? action.data.strings.push_back(rawValue) : action.data.strings.push(rawValue); + } + } + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + } + return actionCount; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0.0) * scale; + if (ObjectDataParser.ROTATE in rawData || ObjectDataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (ObjectDataParser.SKEW_X in rawData || ObjectDataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1.0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArray = function (rawData) { + rawData; + if (dragonBones.DragonBones.webAssembly) { + return; + } + this._data.intArray = []; + this._data.floatArray = []; + this._data.frameIntArray = []; + this._data.frameFloatArray = []; + this._data.frameArray = []; + this._data.timelineArray = []; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseWASMArray = function () { + var intArrayBuf = Module._malloc(this._intArrayJson.length * 2); + this._intArrayBuffer = new Int16Array(Module.HEAP16.buffer, intArrayBuf, this._intArrayJson.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + for (var i1 = 0; i1 < this._intArrayJson.length; ++i1) { + this._intArrayBuffer[i1] = this._intArrayJson[i1]; + } + var floatArrayBuf = Module._malloc(this._floatArrayJson.length * 4); + // Module.HEAPF32.set(this._floatArrayJson, floatArrayBuf); + this._floatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, this._floatArrayJson.length); + for (var i2 = 0; i2 < this._floatArrayJson.length; ++i2) { + this._floatArrayBuffer[i2] = this._floatArrayJson[i2]; + } + var frameIntArrayBuf = Module._malloc(this._frameIntArrayJson.length * 2); + // Module.HEAP16.set(this._frameIntArrayJson, frameIntArrayBuf); + this._frameIntArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, this._frameIntArrayJson.length); + for (var i3 = 0; i3 < this._frameIntArrayJson.length; ++i3) { + this._frameIntArrayBuffer[i3] = this._frameIntArrayJson[i3]; + } + var frameFloatArrayBuf = Module._malloc(this._frameFloatArrayJson.length * 4); + // Module.HEAPF32.set(this._frameFloatArrayJson, frameFloatArrayBuf); + this._frameFloatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, this._frameFloatArrayJson.length); + for (var i4 = 0; i4 < this._frameFloatArrayJson.length; ++i4) { + this._frameFloatArrayBuffer[i4] = this._frameFloatArrayJson[i4]; + } + var frameArrayBuf = Module._malloc(this._frameArrayJson.length * 2); + // Module.HEAP16.set(this._frameArrayJson, frameArrayBuf); + this._frameArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, this._frameArrayJson.length); + for (var i5 = 0; i5 < this._frameArrayJson.length; ++i5) { + this._frameArrayBuffer[i5] = this._frameArrayJson[i5]; + } + var timelineArrayBuf = Module._malloc(this._timelineArrayJson.length * 2); + // Module.HEAPU16.set(this._timelineArrayJson, timelineArrayBuf); + this._timelineArrayBuffer = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, this._timelineArrayJson.length); + for (var i6 = 0; i6 < this._timelineArrayJson.length; ++i6) { + this._timelineArrayBuffer[i6] = this._timelineArrayJson[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined); + var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + if (ObjectDataParser.DATA_VERSIONS.indexOf(version) >= 0 || + ObjectDataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + // const data = BaseObject.borrowObject(DragonBonesData); + var data = dragonBones.DragonBones.webAssembly ? new Module["DragonBonesData"]() : dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { + data.frameRate = 24; + } + if (ObjectDataParser.ARMATURE in rawData) { + this._defalultColorOffset = -1; + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[ObjectDataParser.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._intArrayJson.length > 0) { + this._parseWASMArray(); + } + this._data = null; + } + this._rawTextureAtlasIndex = 0; + if (ObjectDataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[ObjectDataParser.TEXTURE_ATLAS]; + } + else { + this._rawTextureAtlases = null; + } + return data; + } + else { + console.assert(false, "Nonsupport data version."); + } + return null; + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 0.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null) { + 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, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + if (scale > 0.0) { + textureAtlasData.scale = scale; + } + else { + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + scale = 1.0 / scale; // + if (ObjectDataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[ObjectDataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.X, 0.0) * scale; + textureData.region.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.Y, 0.0) * scale; + textureData.region.width = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.WIDTH, 0.0) * scale; + textureData.region.height = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.HEIGHT, 0.0) * scale; + var frameWidth = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.DragonBones.webAssembly ? Module["TextureData"].createRectangle() : dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_X, 0.0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_Y, 0.0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + /** + * @private + */ + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + var ActionFrame = (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); +})(dragonBones || (dragonBones = {})); +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._getUTF16Key = function (value) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + return value; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + // const timeline = timelineData !== null ? timelineData : BaseObject.borrowObject(TimelineData); + var timeline = timelineData !== null ? timelineData : (dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData)); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // (frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { + mesh.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + var weightOffset = this._intArray[mesh.offset + 3 /* MeshWeightOffset */]; + if (weightOffset >= 0) { + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArray[mesh.offset + 0 /* MeshVertexCount */]; + var boneCount = this._intArray[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + if (dragonBones.DragonBones.webAssembly) { + weight.bones.resize(boneCount, null); + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones.set(i, this._rawBones[boneIndex]); + } + } + else { + weight.bones.length = boneCount; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones[i] = this._rawBones[boneIndex]; + } + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArray[boneIndicesOffset++]; + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + mesh.weight = weight; + } + }; + /** + * @private + */ + BinaryDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + polygonBoundingBox.vertices = this._floatArray; + return polygonBoundingBox; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.DURATION, 1), 1); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.ObjectDataParser.NAME, dragonBones.ObjectDataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.ObjectDataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.ObjectDataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.ObjectDataParser.ACTION]); + } + if (dragonBones.ObjectDataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.ObjectDataParser.Z_ORDER]); + } + if (dragonBones.ObjectDataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + if (dragonBones.ObjectDataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + this._animation = null; + return animation; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + if (dragonBones.DragonBones.webAssembly) { + var tmpIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + var tmpFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + var tmpFrameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + var tmpTimelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + var intArrayBuf = Module._malloc(tmpIntArray.length * tmpIntArray.BYTES_PER_ELEMENT); + var floatArrayBuf = Module._malloc(tmpFloatArray.length * tmpFloatArray.BYTES_PER_ELEMENT); + var frameIntArrayBuf = Module._malloc(tmpFrameIntArray.length * tmpFrameIntArray.BYTES_PER_ELEMENT); + var frameFloatArrayBuf = Module._malloc(tmpFrameFloatArray.length * tmpFrameFloatArray.BYTES_PER_ELEMENT); + var frameArrayBuf = Module._malloc(tmpFrameArray.length * tmpFrameArray.BYTES_PER_ELEMENT); + var timelineArrayBuf = Module._malloc(tmpTimelineArray.length * tmpTimelineArray.BYTES_PER_ELEMENT); + this._intArray = new Int16Array(Module.HEAP16.buffer, intArrayBuf, tmpIntArray.length); + this._floatArray = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, tmpFloatArray.length); + this._frameIntArray = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, tmpFrameIntArray.length); + this._frameFloatArray = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, tmpFrameFloatArray.length); + this._frameArray = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, tmpFrameArray.length); + this._timelineArray = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, tmpTimelineArray.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + // Module.HEAPF32.set(tmpFloatArray, floatArrayBuf); + // Module.HEAP16.set(tmpFrameIntArray, frameIntArrayBuf); + // Module.HEAPF32.set(tmpFrameFloatArray, frameFloatArrayBuf); + // Module.HEAP16.set(tmpFrameArray, frameArrayBuf); + // Module.HEAPU16.set(tmpTimelineArray, timelineArrayBuf); + for (var i1 = 0; i1 < tmpIntArray.length; ++i1) { + this._intArray[i1] = tmpIntArray[i1]; + } + for (var i2 = 0; i2 < tmpFloatArray.length; ++i2) { + this._floatArray[i2] = tmpFloatArray[i2]; + } + for (var i3 = 0; i3 < tmpFrameIntArray.length; ++i3) { + this._frameIntArray[i3] = tmpFrameIntArray[i3]; + } + for (var i4 = 0; i4 < tmpFrameFloatArray.length; ++i4) { + this._frameFloatArray[i4] = tmpFrameFloatArray[i4]; + } + for (var i5 = 0; i5 < tmpFrameArray.length; ++i5) { + this._frameArray[i5] = tmpFrameArray[i5]; + } + for (var i6 = 0; i6 < tmpTimelineArray.length; ++i6) { + this._timelineArray[i6] = tmpTimelineArray[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + } + else { + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + } + }; + /** + * @inheritDoc + */ + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer); + 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._binary = rawData; + this._binaryOffset = 8 + 4 + headerLength; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + /** + * @private + */ + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var BuildArmaturePackage = (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = (function () { + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + this.autoSearch = false; + /** + * @private + */ + this._dragonBonesDataMap = {}; + /** + * @private + */ + this._textureAtlasDataMap = {}; + /** + * @private + */ + this._dragonBones = null; + /** + * @private + */ + 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; + } + /** + * @private + */ + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + var bones = dataPackage.armature.sortedBones; + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? bones.size() : bones.length); ++i) { + var boneData = dragonBones.DragonBones.webAssembly ? bones.get(i) : bones[i]; + var bone = dragonBones.DragonBones.webAssembly ? new Module["Bone"]() : dragonBones.BaseObject.borrowObject(dragonBones.Bone); + bone.init(boneData); + if (boneData.parent !== null) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + var constraints = boneData.constraints; + for (var j = 0; j < (dragonBones.DragonBones.webAssembly ? constraints.size() : constraints.length); ++j) { + var constraintData = dragonBones.DragonBones.webAssembly ? constraints.get(j) : constraints[j]; + var target = armature.getBone(constraintData.target.name); + if (target === null) { + continue; + } + // TODO more constraint type. + var ikConstraintData = constraintData; + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraint"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + var root = ikConstraintData.root !== null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + if (root !== null) { + root.addConstraint(constraint); + } + else { + bone.addConstraint(constraint); + } + } + } + }; + /** + * @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.displays[k]; + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.displays[k]; + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + if (!(slotData.name in skinSlots)) { + continue; + } + var displays = skinSlots[slotData.name]; + var slot = this._buildSlot(dataPackage, slotData, displays, armature); + var displayList = new Array(); + for (var _b = 0, displays_1 = displays; _b < displays_1.length; _b++) { + var displayData = displays_1[_b]; + if (displayData !== null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.push(null); + } + } + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + /** + * @private + */ + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.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); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 2 /* Mesh */: + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 1 /* Armature */: + var armatureDisplayData = displayData; + var childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + 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_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + childArmature._bufferAction(action, true); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + return display; + }; + /** + * @private + */ + BaseFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + var displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + for (var i = 0, l = displayList.length; i < l; ++i) { + if (!displayList[i]) { + displayList[i] = null; + } + } + } + if (slot._displayDatas.length <= displayIndex) { + slot._displayDatas.length = displayIndex + 1; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + if (!slot._displayDatas[i]) { + slot._displayDatas[i] = null; + } + } + } + slot._displayDatas[displayIndex] = displayData; + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay(dataPackage, displayData, displayIndex < slot._rawDisplayDatas.length ? slot._rawDisplayDatas[displayIndex] : null, slot); + } + else { + displayList[displayIndex] = null; + } + slot.displayList = displayList; + }; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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 dragonBonesData = null; + if (rawData instanceof ArrayBuffer) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } + else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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 = 0.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { + 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]); + } + } + } + }; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @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; + }; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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("Replace data: " + name); + this._dragonBonesDataMap[name].returnToPool(); + } + this._dragonBonesDataMap[name] = data; + }; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @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]; + } + }; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @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; + }; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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); + } + }; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @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]; + } + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @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; + }; + /** + * 清除所有的数据。 + * @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]; + } + }; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + 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); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + for (var _i = 0, displays_2 = displays; _i < displays_2.length; _i++) { + var display = displays_2[_i]; + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + }; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + var displayIndex = 0; + for (var _i = 0, displays_3 = displays; _i < displays_3.length; _i++) { + var displayData = displays_3[_i]; + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + }; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { + if (exclude === void 0) { exclude = null; } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (!(slot.name in skin.displays) || (exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + var displays = skin.displays[slot.name]; + var displayList = slot.displayList; // Copy. + displayList.length = displays.length; // Modify displayList length. + for (var i = 0, l = displays.length; i < l; ++i) { + var displayData = displays[i]; + if (displayData !== null) { + displayList[i] = this._getSlotDisplay(null, displayData, null, slot); + } + else { + displayList[i] = null; + } + } + slot._rawDisplayDatas = displays; + slot._displayDatas.length = displays.length; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + slot._displayDatas[i] = displays[i]; + } + slot.displayList = displayList; + } + }; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { + if (fromSkinName === void 0) { fromSkinName = null; } + if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } + if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } + var dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage(dataPackage, fromDragonBonesDataName || "", fromArmatreName, fromSkinName || "", "")) { + var fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.animation.animations = fromArmatureData.animations; + } + else { + var animations = {}; + for (var animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + for (var animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + toArmature.animation.animations = animations; + } + if (dataPackage.skin) { + var slots = toArmature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var toSlot = slots[i]; + var toSlotDisplayList = toSlot.displayList; + for (var j = 0, lJ = toSlotDisplayList.length; j < lJ; ++j) { + var toDisplayObject = toSlotDisplayList[j]; + if (toDisplayObject instanceof dragonBones.Armature) { + var displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays !== null && j < displays.length) { + var fromDisplayData = displays[j]; + if (fromDisplayData !== null && fromDisplayData.type === 1 /* Armature */) { + this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + return true; + } + } + return false; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + /** + * @private + */ + BaseFactory._objectParser = null; + /** + * @private + */ + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EgretEvent = (function (_super) { + __extends(EgretEvent, _super); + function EgretEvent() { + return _super !== null && _super.apply(this, arguments) || this; + } + Object.defineProperty(EgretEvent.prototype, "eventObject", { + /** + * 事件对象。 + * @see dragonBones.EventObject + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "armature", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#armature + */ + get: function () { + return this.eventObject.armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "bone", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#bone + */ + get: function () { + return this.eventObject.bone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#slot + */ + get: function () { + return this.eventObject.slot; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationState", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + get: function () { + return this.eventObject.animationState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationName", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#animationState + */ + get: function () { + var animationState = this.eventObject.animationState; + return animationState !== null ? animationState.name : ""; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "frameLabel", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "sound", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #eventObject + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.START + */ + EgretEvent.START = dragonBones.EventObject.START; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.COMPLETE + */ + EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN + */ + EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT + */ + EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND = dragonBones.EventObject.SOUND_EVENT; + return EgretEvent; + }(egret.Event)); + dragonBones.EgretEvent = EgretEvent; + /** + * @inheritDoc + */ + var EgretArmatureDisplay = (function (_super) { + __extends(EgretArmatureDisplay, _super); + function EgretArmatureDisplay() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._disposeProxy = false; + _this._armature = null; // + _this._debugDrawer = null; + return _this; + } + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.init = function (armature) { + this._armature = armature; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.clear = function () { + this._disposeProxy = false; + this._armature = null; + this._debugDrawer = null; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.dispose = function (disposeProxy) { + if (disposeProxy === void 0) { disposeProxy = true; } + this._disposeProxy = disposeProxy; + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.debugUpdate = function (isEnabled) { + isEnabled; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype._dispatchEvent = function (type, eventObject) { + var event = egret.Event.create(EgretEvent, type); + event.data = eventObject; + _super.prototype.dispatchEvent.call(this, event); + egret.Event.release(event); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.hasEvent = function (type) { + return this.hasEventListener(type); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.addEvent = function (type, listener, target) { + this.addEventListener(type, listener, target); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.removeEvent = function (type, listener, target) { + this.removeEventListener(type, listener, target); + }; + Object.defineProperty(EgretArmatureDisplay.prototype, "armature", { + /** + * @inheritDoc + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretArmatureDisplay.prototype, "animation", { + /** + * @inheritDoc + */ + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + return EgretArmatureDisplay; + }(egret.DisplayObjectContainer)); + dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; + function createEgretDisplay(display, type) { + var egretDisplayWrapper = new Module["EgretDisplayWASM"](); // TODO 是否可以将 EgretDisplayWASM 改为 EgretDisplayWrapper + var wasmId; + if (display === null) { + wasmId = -1; + egretDisplayWrapper.setDisplayInfo(wasmId, type); + } + else if (type === 1 /* Armature */) { + wasmId = display.getEgretArmatureId(); + egretDisplayWrapper.setDisplayInfo(wasmId, type); + egretDisplayWrapper.setArmature(display); + } + else { + wasmId = display.$waNode.id; + egretDisplayWrapper.setDisplayInfo(wasmId, type); + } + egretDisplayWrapper._display = display; + return egretDisplayWrapper; + } + dragonBones.createEgretDisplay = createEgretDisplay; + function egretWASMInit() { + /** + * @private + * 扩展 c++ EgretArmatureProxy。(在 js 中构造) + */ + dragonBones.EgretArmatureProxy = Module["EgretArmatureDisplayWASM"].extend("EgretArmatureProxy", { + __construct: function (display) { + this.__parent.__construct.call(this); + this._display = display; + }, + __destruct: function () { + this.__parent.__destruct.call(this); + this._display = null; + }, + clear: function () { + if (this._display) { + this._display.clear(); + } + this._display = null; + }, + debugUpdate: function (isEnabled) { + this._display.debugUpdate(isEnabled); + }, + //extend c++ + _dispatchEvent: function (type, eventObject) { + this._display._dispatchEvent(type, eventObject); + }, + //extend c++ + hasEvent: function (type) { + return this._display.hasEventListener(type); + }, + dispose: function (disposeProxy) { + // TODO lsc + disposeProxy; + // return this._display.dispose(disposeProxy); + }, + addEvent: function (type, listener, target) { + this._display.addEvent(type, listener, target); + }, + removeEvent: function (type, listener, target) { + this._display.removeEvent(type, listener, target); + } + }); + /** + * @private + */ + dragonBones.EgretSlot = Module["EgretSlotWASM"].extend("EgretSlotWrapper", { + __construct: function () { + this.__parent.__construct.call(this); + this._rawDisplay = null; + this._meshDisplay = null; + this._rawDisplayWASM = null; + this._meshDisplayWASM = null; + }, + __destruct: function () { + this.__parent.__destruct.call(this); + this._rawDisplay = null; + this._meshDisplay = null; + }, + init: function (slotData, displayDatas, rawDisplay, meshDisplay) { + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._rawDisplayWASM = createEgretDisplay(this._rawDisplay, 0 /* Image */); + this._meshDisplayWASM = createEgretDisplay(this._meshDisplay, 2 /* Mesh */); + this.__parent.init.call(this, slotData, displayDatas, this._rawDisplayWASM, this._meshDisplayWASM); + }, + getRawDisplay: function () { + return this._rawDisplay; + }, + getMeshDisplay: function () { + return this._meshDisplay; + }, + getRawWASMDisplay: function () { + return this._rawDisplayWASM; + }, + getMeshWASMDisplay: function () { + return this._meshDisplayWASM; + }, + // extend c++ function + getDisplay: function () { + var displayWrapper = this.__parent.getEgretDisplay.call(this); + if (displayWrapper !== null) { + return displayWrapper._display; + } + return null; + }, + setDisplay: function (value) { + if (value === this._rawDisplay || value === this._meshDisplay) { + return; + } + if (value === null || value instanceof egret.Bitmap) { + this.__parent.setEgretDisplay.call(this, createEgretDisplay(value, 0 /* Image */)); + } + else if (value instanceof egret.Mesh) { + this.__parent.setEgretDisplay.call(this, createEgretDisplay(value, 2 /* Mesh */)); + } + else if (value instanceof Module["EgretArmature"]) { + this.__parent.setChildArmature.call(this, value); + } + } + }); + Object.defineProperty(dragonBones.EgretSlot.prototype, "displayList", { + get: dragonBones.EgretSlot.prototype.getEgretDisplayList, + set: dragonBones.EgretSlot.prototype.setEgretDisplayList, + enumerable: true, + configurable: true + }); + Object.defineProperty(dragonBones.EgretSlot.prototype, "rawDisplay", { + get: dragonBones.EgretSlot.prototype.getRawDisplay, + enumerable: true, + configurable: true + }); + Object.defineProperty(dragonBones.EgretSlot.prototype, "meshDisplay", { + get: dragonBones.EgretSlot.prototype.getMeshDisplay, + enumerable: true, + configurable: true + }); + Object.defineProperty(dragonBones.EgretSlot.prototype, "display", { + get: dragonBones.EgretSlot.prototype.getDisplay, + set: dragonBones.EgretSlot.prototype.setDisplay, + enumerable: true, + configurable: true + }); + dragonBones.EgretTextureAtlasData = Module["EgretTextureAtlasDataWASM"].extend("EgretTextureAtlasData", { + __construct: function (rawTextures) { + this.__parent.__construct.call(this); + this._textureNames = []; + this._texture = null; + if (rawTextures) { + for (var _i = 0, rawTextures_1 = rawTextures; _i < rawTextures_1.length; _i++) { + var texture = rawTextures_1[_i]; + this._textureNames.push(texture.name); + } + } + }, + __destruct: function () { + this.__parent.__destruct.call(this); + this._textureNames.length = 0; + this._texture = null; + } + }); + Object.defineProperty(dragonBones.EgretTextureAtlasData.prototype, "renderTexture", { + get: function () { + return this._texture; + }, + set: function (value) { + if (this._texture === value) { + return; + } + if (value["textureId"] === null || value["textureId"] === undefined) { + egret.WebAssemblyNode.setValuesToBitmapData(value); + } + this._texture = value; + var textures = this.textures; + if (this._texture !== null) { + var bitmapData = this._texture.bitmapData; + var textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; + var textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; + for (var _i = 0, _a = this._textureNames; _i < _a.length; _i++) { + var k = _a[_i]; + for (var i = 0, l = k.length; i < l; ++i) { + if (k.charCodeAt(i) > 255) { + k = encodeURI(k); + break; + } + } + var textureData = textures.get(k); + var subTextureWidth = Math.min(textureData.region.width, textureAtlasWidth - textureData.region.x); // TODO need remove + var subTextureHeight = Math.min(textureData.region.height, textureAtlasHeight - textureData.region.y); // TODO need remove + if (!textureData.renderTexture) { + var currTex = new egret.Texture(); + currTex._bitmapData = bitmapData; + if (textureData.rotated) { + currTex.$initData(textureData.region.x, textureData.region.y, subTextureHeight, subTextureWidth, 0, 0, subTextureHeight, subTextureWidth, textureAtlasWidth, textureAtlasHeight); + } + else { + currTex.$initData(textureData.region.x, textureData.region.y, subTextureWidth, subTextureHeight, 0, 0, subTextureWidth, subTextureHeight, textureAtlasWidth, textureAtlasHeight); + } + // Egret 5.0 + egret.WebAssemblyNode.setValuesToBitmapData(currTex); + textureData.setTextureId(currTex["textureId"]); + textureData.renderTexture = currTex; + } + } + } + else { + for (var _b = 0, _c = this._textureNames; _b < _c.length; _b++) { + var k = _c[_b]; + var textureData = textures.get(k); + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + dragonBones.EgretTextureData = Module["EgretTextureDataWASM"].extend("EgretTextureData", { + __construct: function () { + this.__parent.__construct.call(this); + this._renderTexture = null; + }, + __destruct: function () { + this.__parent.__destruct.call(this); + this._renderTexture = null; + } + }); + Object.defineProperty(dragonBones.EgretTextureData.prototype, "renderTexture", { + get: function () { + return this._renderTexture; + }, + set: function (value) { + if (this._renderTexture === value) { + return; + } + this._renderTexture = value; + }, + enumerable: true, + configurable: true + }); + /* + * @private + * 扩展 c++ WorldClock。(在 c++ 中构造) + */ + dragonBones.WorldClock = Module["WorldClock"]; + dragonBones.WorldClock.prototype._c_contains = dragonBones.WorldClock.prototype.contains; + dragonBones.WorldClock.prototype._c_add = dragonBones.WorldClock.prototype.add; + dragonBones.WorldClock.prototype._c_remove = dragonBones.WorldClock.prototype.remove; + dragonBones.WorldClock.prototype.contains = function (value) { + if (value instanceof dragonBones.Armature) { + return this._c_contains(value.getAnimatable()); + } + return this._c_contains(value); + }; + dragonBones.WorldClock.prototype.add = function (value) { + if (value instanceof dragonBones.Armature) { + return this._c_add(value.getAnimatable()); + } + return this._c_add(value); + }; + dragonBones.WorldClock.prototype.remove = function (value) { + if (value instanceof dragonBones.Armature) { + return this._c_remove(value.getAnimatable()); + } + return this._c_remove(value); + }; + /** + * @private + * 扩展 c++ EgretArmature。(在 js 中构造) + */ + dragonBones.Armature = Module["EgretArmature"]; + dragonBones.Armature.prototype._c_addBone = dragonBones.Armature.prototype.addBone; + dragonBones.Armature.prototype._c_invalidUpdate = dragonBones.Armature.prototype.invalidUpdate; + dragonBones.Armature.prototype.addBone = function (bone, name) { + if (name === null || name === undefined) { + name = ""; + } + return this._c_addBone(bone, name); + }; + dragonBones.Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName === null) { + boneName = ""; + } + return this._c_invalidUpdate(boneName, updateSlotDisplay); + }; + dragonBones.Armature.prototype.getDisplay = function () { + return this.proxy._display; + }; + Object.defineProperty(dragonBones.Armature.prototype, "display", { + get: function () { + return this.proxy._display; + }, + enumerable: true, + configurable: true + }); + /** + * @private + * 扩展 c++ Animation + */ + dragonBones.Animation = Module["Animation"]; + dragonBones.Animation.prototype._c_play = dragonBones.Animation.prototype.play; + dragonBones.Animation.prototype._c_fadeIn = dragonBones.Animation.prototype.fadeIn; + dragonBones.Animation.prototype.play = function (animationName, playTimes) { + if (animationName === void 0) { animationName = null; } + if (playTimes === void 0) { playTimes = -1; } + if (animationName === null) { + animationName = ""; + } + return this._c_play(animationName, playTimes); + }; + dragonBones.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 */; } + if (animationName === null) { + animationName = ""; + } + if (group === null) { + group = ""; + } + return this._c_fadeIn(animationName, fadeInTime, playTimes, layer, group, fadeOutMode); + }; + } + dragonBones.egretWASMInit = egretWASMInit; + var configTables = { + ActionData: { + getter: [], + setter: ["type", "bone", "slot", "data"] + }, + DragonBonesData: { + getter: ["frameIndices"], + setter: [], + array: ["armatureNames"] + }, + ArmatureData: { + getter: ["defaultActions", "actions"], + setter: ["aabb", "defaultAnimation", "defaultSkin", "parent"], + array: ["animationNames"] + }, + BoneData: { + getter: ["transform", "constraints"], + setter: ["parent"] + }, + SlotData: { + getter: [], + setter: ["blendMode", "color", "parent"], + static: ["DEFAULT_COLOR"] + }, + ConstraintData: { + getter: [], + setter: ["target", "root", "bone"] + }, + DisplayData: { + getter: ["transform"], + setter: ["type", "parent"] + }, + ImageDisplayData: { + getter: ["pivot"], + setter: ["texture"] + }, + ArmatureDisplayData: { + getter: ["actions"], + setter: [] // armature + }, + MeshDisplayData: { + getter: [], + setter: ["weight"] + }, + WeightData: { + getter: ["bones"], + setter: [] + }, + AnimationData: { + getter: [], + setter: ["actionTimeline", "zOrderTimeline", "parent"] + }, + TimelineData: { + getter: [], + setter: ["type"] + }, + AnimationConfig: { + getter: [], + setter: ["fadeOutMode", "fadeOutTweenType", "fadeInTweenType"] + }, + TextureData: { + getter: ["region"], + setter: ["frame"] + }, + TransformObject: { + getter: ["globalTransformMatrix", "global", "offset", "origin"], + setter: [] + }, + Armature: { + getter: ["armatureData", "animation", "proxy", "eventDispatcher"], + setter: ["clock"] + }, + Slot: { + getter: ["boundingBoxData"], + setter: ["displayIndex", "childArmature"] + }, + Constraint: { + getter: [], + setter: ["target", "bone", "root"] + }, + Animation: { + getter: ["animationConfig"], + setter: [], + array: ["animationNames"] + }, + WorldClock: { + getter: [], + setter: ["clock"], + static: ["clock"] + }, + EventObject: { + getter: ["armature", "bone", "slot", "animationState", "data"], + setter: [] + }, + EgretArmatureDisplayWASM: { + getter: ["armature", "animation"], + setter: [] + }, + DragonBones: { + getter: ["clock"], + setter: [] + } + }; + function descGetter(funcName, target) { + return { + get: target["_c_get_" + funcName], + enumerable: true, + configurable: true + }; + } + function descSetter(funcName, target) { + return { + get: target["_c_get_" + funcName], + set: target["_c_set_" + funcName], + enumerable: true, + configurable: true + }; + } + function descArrayGetter(funcName, target) { + target; + return { + get: function () { + var array = this["_js_" + funcName]; + if (!array) { + array = []; + var vector = this["_c_get_" + funcName](); + for (var i = 0, l = vector.size(); i < l; ++i) { + array[i] = vector.get(i); + } + } + return array; + }, + enumerable: true, + configurable: true + }; + } + function registerGetterSetter() { + for (var fieldKey in configTables) { + var getterClass = Module[fieldKey]; + var getterClassProto = Module[fieldKey].prototype; + var getterArray = configTables[fieldKey].getter; + var setterArray = configTables[fieldKey].setter; + var staticArray = configTables[fieldKey].static; + var arrayArray = configTables[fieldKey].array; + if (getterArray) { + for (var _i = 0, getterArray_1 = getterArray; _i < getterArray_1.length; _i++) { + var fieldName = getterArray_1[_i]; + Object.defineProperty(getterClassProto, fieldName, descGetter(fieldName, getterClassProto)); + } + } + if (setterArray) { + for (var _a = 0, setterArray_1 = setterArray; _a < setterArray_1.length; _a++) { + var fieldName = setterArray_1[_a]; + Object.defineProperty(getterClassProto, fieldName, descSetter(fieldName, getterClassProto)); + } + } + if (staticArray) { + for (var _b = 0, staticArray_1 = staticArray; _b < staticArray_1.length; _b++) { + var fieldName = staticArray_1[_b]; + Object.defineProperty(getterClass, fieldName, descSetter(fieldName, getterClass)); + } + } + if (arrayArray) { + for (var _c = 0, arrayArray_1 = arrayArray; _c < arrayArray_1.length; _c++) { + var fieldName = arrayArray_1[_c]; + Object.defineProperty(getterClassProto, fieldName, descArrayGetter(fieldName, getterClass)); + } + } + } + } + dragonBones.registerGetterSetter = registerGetterSetter; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var EgretFactory = (function (_super) { + __extends(EgretFactory, _super); + /** + * @inheritDoc + */ + function EgretFactory() { + var _this = _super.call(this) || this; + /** + * @private + */ + _this._rawTextures = null; + if (EgretFactory._dragonBones === null) { + dragonBones.DragonBones.webAssembly = true; + var eventDisplay = new dragonBones.EgretArmatureDisplay(); + EgretFactory._eventManager = eventDisplay; + EgretFactory._dragonBones = new Module["DragonBones"](); + EgretFactory._dragonBones.clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretFactory._clockHandler, EgretFactory); + } + return _this; + } + EgretFactory._clockHandler = function (time) { + var dbcore = EgretFactory._dragonBones; + // + var objects = dbcore.getObjects(); + for (var i = 0, l = objects.size(); i < l; ++i) { + objects.get(i).returnToPool(); + } + objects.resize(0, null); + // + time *= 0.001; + var passedTime = time - EgretFactory._time; + dbcore.clock.advanceTime(passedTime); + EgretFactory._time = time; + // + var events = dbcore.getEvents(); + for (var i = 0, l = events.size(); i < l; ++i) { + var eventObject = events.get(i); + var armature = eventObject.armature; + var type = eventObject.type; + if (armature === null || armature.display === null || armature.display === undefined) { + console.log("armature display error!"); + } + armature.display._dispatchEvent(type, eventObject); + if (type === dragonBones.EventObject.SOUND_EVENT) { + EgretFactory._eventManager._dispatchEvent(eventObject.type, eventObject); + } + eventObject.returnToPool(); + } + events.resize(0, null); + return false; + }; + Object.defineProperty(EgretFactory, "clock", { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return EgretFactory._dragonBones.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretFactory, "factory", { + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + get: function () { + if (EgretFactory._factory === null) { + dragonBones.registerGetterSetter(); + dragonBones.egretWASMInit(); + EgretFactory._factory = new EgretFactory(); + } + return EgretFactory._factory; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + EgretFactory.prototype._isSupportMesh = function () { + if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { + return true; + } + console.warn("Canvas can not support mesh, please change renderMode to webgl."); + return false; + }; + /** + * @private + */ + EgretFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData !== null) { + if (textureAtlas["textureId"] === null) { + egret.WebAssemblyNode.setValuesToBitmapData(textureAtlas); + } + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = new dragonBones.EgretTextureAtlasData(this._rawTextures); + } + return textureAtlasData; + }; + /** + * @private + */ + EgretFactory.prototype._buildArmature = function (dataPackage) { + var armature = new Module['EgretArmature'](); + var armatureDisplay = new dragonBones.EgretArmatureDisplay(); + var armatureProxy = new dragonBones.EgretArmatureProxy(armatureDisplay); + var displayID = armatureDisplay.$waNode.id; + armature.init(dataPackage.armature, armatureProxy, displayID, EgretFactory._dragonBones); + armatureDisplay.init(armature); + return armature; + }; + /** + * @private + */ + EgretFactory.prototype._buildSlots = function (dataPackage, armature) { + var currentSkin = dataPackage.skin; + var defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin === null || defaultSkin === null) { + return; + } + var currentSkinSlotNames = currentSkin.getSkinSlotNames(); + var defaultSkinSlotNames = defaultSkin.getSkinSlotNames(); + var skinSlots = {}; + // for (let k in defaultSkin.displays) { + for (var i = 0, l = defaultSkinSlotNames.size(); i < l; ++i) { + var slotName = defaultSkinSlotNames.get(i); + var displays = defaultSkin.getDisplays(slotName); + if (displays !== null) { + skinSlots[slotName] = displays; + } + } + if (currentSkin !== defaultSkin) { + // for (let k in currentSkin.displays) { + for (var i = 0, l = currentSkinSlotNames.size(); i < l; ++i) { + var slotName = currentSkinSlotNames.get(i); + var displays = currentSkin.getDisplays(slotName); + if (displays !== null) { + skinSlots[slotName] = displays; + } + } + } + // for (const slotData of dataPackage.armature.sortedSlots) { + var slots = dataPackage.armature.sortedSlots; + for (var i = 0, l = slots.size(); i < l; ++i) { + var slotData = slots.get(i); + if (!(slotData.name in skinSlots)) { + continue; + } + var displays = skinSlots[slotData.name]; + var slot = this._buildSlot(dataPackage, slotData, displays, armature); + var displayList = new Module["EgretSlotDisplayVector"](); + for (var i_3 = 0, l_1 = displays.size(); i_3 < l_1; ++i_3) { + var displayData = displays.get(i_3); + if (displayData !== null) { + var display = this._getSlotDisplay(dataPackage, displayData, null, slot); + if (display === null) { + var displayWrapper = dragonBones.createEgretDisplay(display, 0 /* Image */); + displayList.push_back(displayWrapper); + } + else if (display.getDisplayType() === 1 /* Armature */) { + var displayWrapper = dragonBones.createEgretDisplay(display, 1 /* Armature */); + displayList.push_back(displayWrapper); + } + else { + displayList.push_back(display); + } + } + else { + var displayWrapper = dragonBones.createEgretDisplay(null, 0 /* Image */); + displayList.push_back(displayWrapper); + } + } + armature.addSlot(slot, slotData.parent.name); + slot._setEgretDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + /** + * @private + */ + EgretFactory.prototype._buildSlot = function (dataPackage, slotData, displays, armature) { + dataPackage; + armature; + var slot = new dragonBones.EgretSlot(); + slot.init(slotData, displays, new egret.Bitmap(), new egret.Mesh()); + return slot; + }; + /** + * @private + */ + EgretFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 0.0; } + this._rawTextures = rawData ? rawData.SubTexture : null; + return _super.prototype.parseTextureAtlasData.call(this, rawData, textureAtlas, name, scale); + }; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + EgretFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + var armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + EgretFactory.clock.add(armature); + return armature.display; + } + return null; + }; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + EgretFactory.prototype.getTextureDisplay = function (textureName, textureAtlasName) { + if (textureAtlasName === void 0) { textureAtlasName = null; } + var textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName); + if (textureData !== null && textureData.texture === null) { + return new egret.Bitmap(textureData.texture); + } + return null; + }; + /* + * @private + */ + EgretFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.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); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { + display = slot.getMeshWASMDisplay(); + } + else { + display = slot.getRawWASMDisplay(); + } + break; + case 2 /* Mesh */: + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.getMeshWASMDisplay(); + } + else { + display = slot.getRawWASMDisplay(); + } + break; + case 1 /* Armature */: + var armatureDisplayData = displayData; + var childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + 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_3 = actions; _i < actions_3.length; _i++) { + var action = actions_3[_i]; + childArmature.animation.fadeIn(action.name); // TODO action should be do after advanceTime. + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + return display; + }; + /** + * public + */ + EgretFactory.prototype.changeSkin = function (armature, skin, exclude) { + if (exclude === void 0) { exclude = null; } + // for (const slot of armature.getSlots()) { + var slots = armature.getSlots(); + for (var i = 0, l = slots.size(); i < l; ++i) { + var slot = slots.get(i); + if ((exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + var displays = skin.displays.get(slot.name); + if (displays === null || displays === undefined) { + continue; + } + var displayList = slot.getEgretDisplayList(); // Copy. + if (displayList === null || displayList === undefined) { + console.log("Slot does not has displayList" + slot.name); + continue; + } + var datalen = displays.size(); + displayList.resize(datalen, null); // Modify displayList length. + for (var i_4 = 0, l_2 = displays.size(); i_4 < l_2; ++i_4) { + var currData = displays.get(i_4); + var currSlot = this._getSlotDisplay(null, currData, null, slot); + if (currSlot.getDisplayType() == 1 /* Armature */) { + var displayWrapper = dragonBones.createEgretDisplay(currSlot, 1 /* Armature */); + displayList.set(i_4, displayWrapper); + } + else { + displayList.set(i_4, currSlot); + } + } + slot.switchDisplayData(displays); + //TODO + // slot.displayList = displayList; + slot.setEgretDisplayList(displayList); + } + }; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EgretFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + // for (const display of displays) { + for (var i = 0, l = displays.size(); i < l; ++i) { + var display = displays.get(i); + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + }; + /** + * @private + */ + EgretFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + var displayList = slot.getEgretDisplayList(); // Copy. + if (displayList.size() <= displayIndex) { + displayList.resize(displayIndex + 1, null); + } + slot.replaceDisplayData(displayData, displayIndex); + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay(dataPackage, displayData, null, slot); + } + else { + displayList[displayIndex] = null; + } + slot.setEgretDisplayList(displayList); + }; + Object.defineProperty(EgretFactory.prototype, "soundEventManager", { + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return EgretFactory._eventManager; + }, + enumerable: true, + configurable: true + }); + EgretFactory._time = 0; + EgretFactory._dragonBones = null; + EgretFactory._factory = null; + return EgretFactory; + }(dragonBones.BaseFactory)); + dragonBones.EgretFactory = EgretFactory; +})(dragonBones || (dragonBones = {})); diff --git a/reference/Egret/wasm/out/dragonBones-wasm.min.js b/reference/Egret/wasm/out/dragonBones-wasm.min.js new file mode 100644 index 0000000..63b1ff3 --- /dev/null +++ b/reference/Egret/wasm/out/dragonBones-wasm.min.js @@ -0,0 +1 @@ +"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]};return function(e,i){t(e,i);function a(){this.constructor=e}e.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}}();var dragonBones;(function(t){var e=function(){function e(e){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=e}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var i=0,a=this._objects;i0){for(var n=0;ni){r.length=i}t._maxCountMap[a]=i}else{t._defaultMaxCount=i;for(var a in t._poolsMap){if(a in t._maxCountMap){continue}var r=t._poolsMap[a];if(r.length>i){r.length=i}t._maxCountMap[a]=i}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in t._poolsMap){var a=t._poolsMap[r];a.length=0}}};t.borrowObject=function(e){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=1e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=1}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=1}if(r===void 0){r=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=i;this.d=a;this.tx=r;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 i=0;var a=0;var r=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;i+=this.b*t.d;a+=this.c*t.a;r+=this.c*t.b}if(t.b!==0||t.c!==0){i+=this.a*t.b;a+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=i;this.c=a;this.d=r;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var i=this.c;var a=this.d;var r=this.tx;var n=this.ty;if(e===0&&i===0){this.b=this.c=0;if(t===0||a===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;a=this.d=1/a;this.tx=-t*r;this.ty=-a*n}return this}var s=t*a-e*i;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=a*s;e=this.b=-e*s;i=this.c=-i*s;a=this.d=t*s;this.tx=-(o*r+i*n);this.ty=-(e*r+a*n);return this};t.prototype.transformPoint=function(t,e,i,a){if(a===void 0){a=false}i.x=this.a*t+this.c*e;i.y=this.b*t+this.d*e;if(!a){i.x+=this.tx;i.y+=this.ty}};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}if(r===void 0){r=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=i;this.rotation=a;this.scaleX=r;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.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};t.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};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.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};t.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};t.prototype.fromMatrix=function(e){var i=this.scaleX,a=this.scaleY;var r=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-r&&this.rotation-r&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.skew!==0||this.rotation!==0){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}}else{t.a=this.scaleX;t.b=0;t.c=0;t.d=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(i===void 0){i=1}if(a===void 0){a=1}if(r===void 0){r=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=i;this.blueMultiplier=a;this.alphaOffset=r;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,i,a){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}this.x=t;this.y=e;this.width=i;this.height=a}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(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){i=0}if(this.sortedBones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames;var a=i.length;i.length+=10;i[a]=t.a;i[a+1]=t.b;i[a+2]=t.c;i[a+3]=t.d;i[a+4]=t.tx;i[a+5]=t.ty;i[a+6]=e.rotation;i[a+7]=e.skew;i[a+8]=e.scaleX;i[a+9]=e.scaleY;return a};i.prototype.getCacheFrame=function(t,e,i){var a=this.parent.cachedFrames;t.a=a[i];t.b=a[i+1];t.c=a[i+2];t.d=a[i+3];t.tx=a[i+4];t.ty=a[i+5];e.rotation=a[i+6];e.skew=a[i+7];e.scaleX=a[i+8];e.scaleY=a[i+9];e.x=t.tx;e.y=t.ty};i.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Replace bone: "+t.name);this.bones[t.name].returnToPool()}this.bones[t.name]=t;this.sortedBones.push(t)};i.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Replace slot: "+t.name);this.slots[t.name].returnToPool()}this.slots[t.name]=t;this.sortedSlots.push(t)};i.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Replace skin: "+t.name);this.skins[t.name].returnToPool()}this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}};i.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Replace animation: "+t.name);this.animations[t.name].returnToPool()}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return i}(t.BaseObject);t.ArmatureData=i;var a=function(e){__extends(i,e);function i(){var i=e!==null&&e.apply(this,arguments)||this;i.transform=new t.Transform;i.constraints=[];i.userData=null;return i}i.toString=function(){return"[class dragonBones.BoneData]"};i.prototype._onClear=function(){for(var t=0,e=this.constraints;tr){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,i,a,r,n,s,o,l,h,u,f){if(h===void 0){h=null}if(u===void 0){u=null}if(f===void 0){f=null}var _=t>n&&ts&&in&&as&&r=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){return true}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var u=e.rectangleIntersectsSegment(t,i,a,r,-l,-h,l,h,n,s,o);return u};return e}(e);t.RectangleBoundingBoxData=i;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,i,a,r,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;a*=f;var m=i-t;var p=a-e;var c=Math.sqrt(m*m+p*p);var d=m/c;var y=p/c;var g=(r-t)*d+(n-e)*y;var v=g*g;var b=t*t+e*e;var D=s*s;var T=D-b+v;var A=0;if(T>=0){var O=Math.sqrt(T);var S=g-O;var x=g+O;var B=S<0?-1:S<=c?0:1;var E=x<0?-1:x<=c?0:1;var M=B*E;if(M<0){return-1}else if(M===0){if(B===-1){A=2;i=t+x*d;a=(e+x*y)/f;if(l!==null){l.x=i;l.y=a}if(h!==null){h.x=i;h.y=a}if(u!==null){u.x=Math.atan2(a/D*_,i/D);u.y=u.x+Math.PI}}else if(E===1){A=1;t=t+S*d;e=(e+S*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/D*_,t/D);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+S*d;l.y=(e+S*y)/f;if(u!==null){u.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+x*d;h.y=(e+x*y)/f;if(u!==null){u.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var i=this.width*.5;if(t>=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){e*=i/a;return Math.sqrt(t*t+e*e)<=i}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,i,a,r,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.weight=null;return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,i,a,r,n,s,o,l,h){if(o===void 0){o=null}if(l===void 0){l=null}if(h===void 0){h=null}if(t===i){t=i+1e-6}if(e===a){e=a+1e-6}var u=t-i;var f=e-a;var _=t*a-e*i;var m=0;var p=r[n+s-2];var c=r[n+s-1];var d=0;var y=0;var g=0;var v=0;var b=0;var D=0;for(var T=0;T=p&&M<=A||M>=A&&M<=p)&&(u===0||M>=t&&M<=i||M>=i&&M<=t)){var w=(_*x-f*B)/E;if((w>=c&&w<=O||w>=O&&w<=c)&&(f===0||w>=e&&w<=a||w>=a&&w<=e)){if(l!==null){var P=M-t;if(P<0){P=-P}if(m===0){d=P;y=P;g=M;v=w;b=M;D=w;if(h!==null){h.x=Math.atan2(O-c,A-p)-Math.PI*.5;h.y=h.x}}else{if(Py){y=P;b=M;D=w;if(h!==null){h.y=Math.atan2(O-c,A-p)-Math.PI*.5}}}m++}else{g=M;v=w;b=M;D=w;m++;if(h!==null){h.x=Math.atan2(O-c,A-p)-Math.PI*.5;h.y=h.x}break}}}p=A;c=O}if(m===1){if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=g;l.y=v}if(h!==null){h.y=h.x+Math.PI}}else if(m>1){m++;if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=b;l.y=D}}return m};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.weight!==null){this.weight.returnToPool()}this.type=2;this.count=0;this.offset=0;this.x=0;this.y=0;this.vertices=null;this.weight=null};e.prototype.containsPoint=function(t,e){var i=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var a=0,r=this.count,n=r-2;a=e||s=e){var l=this.vertices[this.offset+n];var h=this.vertices[this.offset+a];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 i=0,a=this.cacheFrames.length;i=0};e.prototype.addBoneMask=function(t,e,i){if(i===void 0){i=true}var a=t.getBone(e);if(a===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(i){for(var r=0,n=t.getBones();r=0){this.boneMask.splice(a,1)}if(i){var r=t.getBone(e);if(r!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&r.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,u=t.getBones();he._zOrder?1:-1};i.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=t){i=0}if(this._bones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s=n){continue}var o=i[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(r)}}this._slotsDirty=true;this._zOrderDirty=!a}};i.prototype._addBoneToBoneList=function(t){if(this._bones.indexOf(t)<0){this._bonesDirty=true;this._bones.push(t);this._animation._timelineDirty=true}};i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);if(e>=0){this._bones.splice(e,1);this._animation._timelineDirty=true}};i.prototype._addSlotToSlotList=function(t){if(this._slots.indexOf(t)<0){this._slotsDirty=true;this._slots.push(t);this._animation._timelineDirty=true}};i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);if(e>=0){this._slots.splice(e,1);this._animation._timelineDirty=true}};i.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};i.prototype.dispose=function(){if(this.armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};i.prototype.init=function(e,i,a,r){if(this.armatureData!==null){return}this.armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=i;this._display=a;this._dragonBones=r;this._proxy.init(this);this._animation.init(this);this._animation.animations=this.armatureData.animations};i.prototype.advanceTime=function(e){if(this._lockUpdate){return}if(this.armatureData===null){console.assert(false,"The armature has been disposed.");return}else if(this.armatureData.parent===null){console.assert(false,"The armature data has been disposed.");return}var i=this._cacheFrameIndex;this._animation.advanceTime(e);if(this._bonesDirty){this._bonesDirty=false;this._sortBones()}if(this._slotsDirty){this._slotsDirty=false;this._sortSlots()}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==i){var a=0,r=0;for(a=0,r=this._bones.length;a0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var i=this.getBone(t);if(i!==null){i.invalidUpdate();if(e){for(var a=0,r=this._slots;a0){if(r!==null||n!==null){if(r!==null){var T=o?r.y-e:r.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;m=n.y;y=b;if(s!==null){c=s.y}}}}else{d=b;break}}}if(d!==null&&r!==null){r.x=u;r.y=f;if(s!==null){s.x=p}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=c}}return d};i.prototype.getBone=function(t){for(var e=0,i=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.constraints.length>0){for(var i=0,a=this.constraints;i=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this.constraints.length>0){for(var n=0,s=this.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};i.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};i.prototype.addConstraint=function(t){if(this.constraints.indexOf(t)<0){this.constraints.push(t)}};i.prototype.invalidUpdate=function(){this._transformDirty=true};i.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};i.prototype.getBones=function(){this._bones.length=0;for(var t=0,e=this._armature.getBones();t=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var i=0,a=e.length;i0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=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._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._display===null){return}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._meshData!==null&&this._display===this._meshDisplay){var i=this._meshData.weight!==null;if(this._meshDirty||i&&this._isMeshBonesUpdate()){this._meshDirty=false;this._updateMesh()}if(i){if(this._transformDirty){this._transformDirty=false;this._updateTransform(true)}return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var a=t>=0;this._updateGlobalTransformMatrix(a);if(a&&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(false)}};i.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};i.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);return this._boundingBoxData.containsPoint(i._helpPoint.x,i._helpPoint.y)};i.prototype.intersectsSegment=function(t,e,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);t=i._helpPoint.x;e=i._helpPoint.y;i._helpMatrix.transformPoint(a,r,i._helpPoint);a=i._helpPoint.x;r=i._helpPoint.y;var l=this._boundingBoxData.intersectsSegment(t,e,a,r,n,s,o);if(l>0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,true);o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,true);o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x)}}return l};i.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat();var a=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var r=0,n=i;r0){this._animatebles[e-i]=r;this._animatebles[e]=null}r.advanceTime(t)}else{i++}}if(i>0){a=this._animatebles.length;for(;e=0};t.prototype.add=function(t){if(this._animatebles.indexOf(t)<0){this._animatebles.push(t);t.clock=this}};t.prototype.remove=function(t){var e=this._animatebles.indexOf(t);if(e>=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&i._subFadeState>0){this._armature._dragonBones.bufferObject(i);this._animationStates.length=0;this._lastAnimationState=null}else{var a=i.animationData;var r=a.cacheFrameRate;if(this._animationDirty&&r>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n1){for(var f=0,_=0;f0&&i._subFadeState>0){_++;this._armature._dragonBones.bufferObject(i);this._animationDirty=true;if(this._lastAnimationState===i){this._lastAnimationState=null}}else{if(_>0){this._animationStates[f-_]=i}if(this._timelineDirty){i.updateTimelines()}i.advanceTime(t,0)}if(f===e-1&&_>0){this._animationStates.length-=_;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}this._timelineDirty=false};i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=a.duration;e.position=a.duration-e.position}else if(e.position===a.duration){e.position-=1e-6}else if(e.position>a.duration){e.position%=a.duration}if(e.duration>0&&e.position+e.duration>a.duration){e.duration=a.duration-e.position}if(e.playTimes<0){e.playTimes=a.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,a,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,u=this._animationStates.length;h=this._animationStates[h].layer){}else{l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var f=0,_=this._armature.getSlots();f<_.length;f++){var m=_[f];var p=m.childArmature;if(p!==null&&p.inheritAnimation&&p.animation.hasAnimation(i)&&p.animation.getState(i)===null){p.animation.fadeIn(i)}}if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o;return o};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var i=this._armature.armatureData.defaultAnimation;if(i!==null){this._animationConfig.animation=i.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};i.prototype.fadeIn=function(t,e,i,a,r,n){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=0}if(r===void 0){r=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=i;this._animationConfig.layer=a;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=r!==null?r:"";return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByTime=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByFrame=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*e/a.frameCount}return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByProgress=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByTime(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByFrame(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByProgress(t,e,1);if(i!==null){i.stop()}return i};i.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var i=this._animationStates[e];if(i.name===t){return i}}return null};i.prototype.hasAnimation=function(t){return t in this._animations};i.prototype.getStates=function(){return this._animationStates};Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.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._animations[e]=t[e];this._animationNames.push(e)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});i.prototype.gotoAndPlay=function(t,e,i,a,r,n,s,o,l){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&i>0){this._animationConfig.timeScale=h.duration/i}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}return this.gotoAndStopByTime(t,e)};Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationDataList",{get:function(){var t=[];for(var e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var a=i?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=i?0:1}else if(this._fadeTime>0){this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=i?1:0}if(this._subFadeState>0){if(!i){this._playheadState|=1;this._fadeState=0}var a=i?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}};a.prototype._blendBoneTimline=function(t){var e=t.bone;var i=t.bonePose.result;var a=e.animationPose;var r=this._weightResult>0?this._weightResult:-this._weightResult;if(!e._blendDirty){e._blendDirty=true;e._blendLayer=this.layer;e._blendLayerWeight=r;e._blendLeftWeight=1;a.x=i.x*r;a.y=i.y*r;a.rotation=i.rotation*r;a.skew=i.skew*r;a.scaleX=(i.scaleX-1)*r+1;a.scaleY=(i.scaleY-1)*r+1}else{r*=e._blendLeftWeight;e._blendLayerWeight+=r;a.x+=i.x*r;a.y+=i.y*r;a.rotation+=i.rotation*r;a.skew+=i.skew*r;a.scaleX+=(i.scaleX-1)*r;a.scaleY+=(i.scaleY-1)*r}if(this._fadeState!==0||this._subFadeState!==0){e._transformDirty=true}};a.prototype.init=function(e,i,a){if(this._armature!==null){return}this._armature=e;this.animationData=i;this.resetToPose=a.resetToPose;this.additiveBlending=a.additiveBlending;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.weight=a.weight;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;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,n=this._boneMask.length;r0;var a=true;var r=true;var n=this._time;this._weightResult=this.weight*this._fadeProgress;this._actionTimeline.update(n);if(i){var s=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*s)/s}if(this._zOrderTimeline!==null){this._zOrderTimeline.update(n)}if(i){var o=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===o){a=false;r=false}else{this._armature._cacheFrameIndex=o;if(this.animationData.cachedFrames[o]){r=false}else{this.animationData.cachedFrames[o]=true}}}if(a){if(r){var l=null;var h=null;for(var u=0,f=this._boneTimelines.length;u0){if(l._blendLayer!==this.layer){if(l._blendLayerWeight>=l._blendLeftWeight){l._blendLeftWeight=0;l=null}else{l._blendLayer=this.layer;l._blendLeftWeight-=l._blendLayerWeight;l._blendLayerWeight=0}}}else{l=null}}}l=_.bone}if(l!==null){_.update(n);if(u===f-1){this._blendBoneTimline(_)}else{h=_}}}}for(var u=0,f=this._slotTimelines.length;u0){this._subFadeState=0}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};a.prototype.play=function(){this._playheadState=3};a.prototype.stop=function(){this._playheadState&=1};a.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 i=0,a=this._boneTimelines;i1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};a.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};a.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var i=this._armature.getBone(t);if(i===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var a=0,r=this._armature.getBones();a=0){this._boneMask.splice(i,1)}if(e){var a=this._armature.getBone(t);if(a!==null){var r=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=r;n=0&&a.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=r;h0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(a.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){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 i=0,a=this._boneTimelines;i=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var r=this._animationState.playTimes;var n=r*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(r>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=r;if(t<0){this.currentTime=0}else{this.currentTime=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===i&&this.currentTime===a){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i){this._frameIndex=-1}return true};e.prototype.init=function(t,e,i){this._armature=t;this._animationState=e;this._timelineData=i;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._frameRate=this._armature.armatureData.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._armature.armatureData.parent;this._animationData=this._animationState.animationData;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.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(){};e.prototype.update=function(t){if(this.playState<=0&&this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var i=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==i){this._frameIndex=i;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._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,i){var a=e;switch(t){case 3:a=Math.pow(e,2);break;case 4:a=1-Math.pow(1-e,2);break;case 5:a=.5*(1-Math.cos(e*Math.PI));break}return(a-e)*i+e};e._getEasingCurveValue=function(t,e,i,a){if(t<=0){return 0}else if(t>=1){return 1}var r=i+1;var n=Math.floor(t*r);var s=n===0?0:e[a+n-1];var o=n===r-1?1e4:e[a+n];return(s+(o-s)*(t*r-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){if(n.hasEvent(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.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 p=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+p];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var c=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[c]/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 p=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+p];var c=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[c]/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}(t.TimelineState);t.ZOrderTimelineState=i;var a=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};i.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._dragonBonesData.frameFloatArray;var i=this.bonePose.current;var a=this.bonePose.delta;var r=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;i.x=t[r++];i.y=t[r++];i.rotation=t[r++];i.skew=t[r++];i.scaleX=t[r++];i.scaleY=t[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}a.x=t[r++]-i.x;a.y=t[r++]-i.y;a.rotation=t[r++]-i.rotation;a.skew=t[r++]-i.skew;a.scaleX=t[r++]-i.scaleX;a.scaleY=t[r++]-i.scaleY}}else{var i=this.bonePose.current;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1}};i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var i=this.bonePose.delta;var a=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}var r=this._armature.armatureData.scale;a.x=(t.x+i.x*this._tweenProgress)*r;a.y=(t.y+i.y*this._tweenProgress)*r;a.rotation=t.rotation+i.rotation*this._tweenProgress;a.skew=t.skew+i.skew*this._tweenProgress;a.scaleX=t.scaleX+i.scaleX*this._tweenProgress;a.scaleY=t.scaleY+i.scaleY*this._tweenProgress};i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return i}(t.BoneTimelineState);t.BoneAllTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDislayIndexTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot.slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayIndexTimelineState=r;var n=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var i=this._dragonBonesData.frameIntArray;var a=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var r=i[a];this._current[0]=e[r++];this._current[1]=e[r++];this._current[2]=e[r++];this._current[3]=e[r++];this._current[4]=e[r++];this._current[5]=e[r++];this._current[6]=e[r++];this._current[7]=e[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=i[this._animationData.frameIntOffset+this._frameValueOffset]}else{r=i[a+1*1]}this._delta[0]=e[r++]-this._current[0];this._delta[1]=e[r++]-this._current[1];this._delta[2]=e[r++]-this._current[2];this._delta[3]=e[r++]-this._current[3];this._delta[4]=e[r++]-this._current[4];this._delta[5]=e[r++]-this._current[5];this._delta[6]=e[r++]-this._current[6];this._delta[7]=e[r++]-this._current[7]}}else{var n=this.slot.slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var i=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var a=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*a;i.redMultiplier+=(this._result[1]-i.redMultiplier)*a;i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*a;i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*a;i.alphaOffset+=(this._result[4]-i.alphaOffset)*a;i.redOffset+=(this._result[5]-i.redOffset)*a;i.greenOffset+=(this._result[6]-i.greenOffset)*a;i.blueOffset+=(this._result[7]-i.blueOffset)*a;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){i.alphaMultiplier=this._result[0];i.redMultiplier=this._result[1];i.greenMultiplier=this._result[2];i.blueMultiplier=this._result[3];i.alphaOffset=this._result[4];i.redOffset=this._result[5];i.greenOffset=this._result[6];i.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=n;var s=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SlotFFDTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.meshOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._ffdCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._tweenState===2;var i=this._dragonBonesData.frameFloatArray;var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;if(e){var r=a+this._valueCount;if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n255){return encodeURI(r)}}}return r}return String(r)}return a};a.prototype._getCurvePoint=function(t,e,i,a,r,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var m=u*f;var p=3*l*f;var c=3*u*_;var d=l*_;h.x=m*t+p*i+c*r+d*s;h.y=m*e+p*a+c*n+d*o};a.prototype._samplingEasingCurve=function(t,e){var i=t.length;var a=-2;for(var r=0,n=e.length;r=0&&a+61e-4){var g=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,p,c,g,this._helpPoint);if(s-this._helpPoint.x>0){d=g}else{y=g}}e[r]=this._helpPoint.y}};a.prototype._sortActionFrame=function(t,e){return t.frameStart>e.frameStart?1:-1};a.prototype._parseActionDataInFrame=function(t,e,i,r){if(a.EVENT in t){this._mergeActionFrame(t[a.EVENT],e,10,i,r)}if(a.SOUND in t){this._mergeActionFrame(t[a.SOUND],e,11,i,r)}if(a.ACTION in t){this._mergeActionFrame(t[a.ACTION],e,0,i,r)}if(a.EVENTS in t){this._mergeActionFrame(t[a.EVENTS],e,10,i,r)}if(a.ACTIONS in t){this._mergeActionFrame(t[a.ACTIONS],e,0,i,r)}};a.prototype._mergeActionFrame=function(e,a,r,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,this._armature.actions,r,n,s);var h=null;if(this._actionFrames.length===0){h=new i;h.frameStart=0;this._actionFrames.push(h);h=null}for(var u=0,f=this._actionFrames;u0){var p=r.getBone(_);if(p!==null){m.parent=p}else{(this._cacheBones[_]=this._cacheBones[_]||[]).push(m)}}if(m.name in this._cacheBones){for(var c=0,d=this._cacheBones[m.name];c0){n.root=i.parent}if(t.DragonBones.webAssembly){i.constraints.push_back(n)}else{i.constraints.push(n)}};a.prototype._parseSlot=function(e){var i=t.DragonBones.webAssembly?new Module["SlotData"]:t.BaseObject.borrowObject(t.SlotData);i.displayIndex=a._getNumber(e,a.DISPLAY_INDEX,0);i.zOrder=t.DragonBones.webAssembly?this._armature.sortedSlots.size():this._armature.sortedSlots.length;i.name=a._getString(e,a.NAME,"");i.parent=this._armature.getBone(a._getString(e,a.PARENT,""));if(a.BLEND_MODE in e&&typeof e[a.BLEND_MODE]==="string"){i.blendMode=a._getBlendMode(e[a.BLEND_MODE])}else{i.blendMode=a._getNumber(e,a.BLEND_MODE,0)}if(a.COLOR in e){i.color=t.DragonBones.webAssembly?Module["SlotData"].createColor():t.SlotData.createColor();this._parseColorTransform(e[a.COLOR],i.color)}else{i.color=t.DragonBones.webAssembly?Module["SlotData"].DEFAULT_COLOR:t.SlotData.DEFAULT_COLOR}if(a.ACTIONS in e){var r=this._slotChildActions[i.name]=[];this._parseActionData(e[a.ACTIONS],r,0,null,null)}return i};a.prototype._parseSkin=function(e){var i=t.DragonBones.webAssembly?new Module["SkinData"]:t.BaseObject.borrowObject(t.SkinData);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length===0){i.name=a.DEFAULT_NAME}if(a.SLOT in e){this._skin=i;var r=e[a.SLOT];for(var n=0,s=r;n0?n:r;this._parsePivot(e,o);break;case 1:var l=i=t.DragonBones.webAssembly?new Module["ArmatureDisplayData"]:t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=r;l.path=n.length>0?n:r;l.inheritAnimation=true;if(a.ACTIONS in e){this._parseActionData(e[a.ACTIONS],l.actions,0,null,null)}else if(this._slot.name in this._slotChildActions){var h=this._skin.getDisplays(this._slot.name);if(h===null?this._slot.displayIndex===0:this._slot.displayIndex===h.length){for(var u=0,f=this._slotChildActions[this._slot.name];u0?n:r;m.inheritAnimation=a._getBoolean(e,a.INHERIT_FFD,true);this._parsePivot(e,m);var p=a._getString(e,a.SHARE,"");if(p.length>0){var c=this._meshs[p];m.offset=c.offset;m.weight=c.weight}else{this._parseMesh(e,m);this._meshs[m.name]=m}break;case 3:var d=this._parseBoundingBox(e);if(d!==null){var y=i=t.DragonBones.webAssembly?new Module["BoundingBoxDisplayData"]:t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=r;y.path=n.length>0?n:r;y.boundingBox=d}break}if(i!==null){i.parent=this._armature;if(a.TRANSFORM in e){this._parseTransform(e[a.TRANSFORM],i.transform,this._armature.scale)}}return i};a.prototype._parsePivot=function(t,e){if(a.PIVOT in t){var i=t[a.PIVOT];e.pivot.x=a._getNumber(i,a.X,0);e.pivot.y=a._getNumber(i,a.Y,0)}else{e.pivot.x=.5;e.pivot.y=.5}};a.prototype._parseMesh=function(e,i){var r=e[a.VERTICES];var n=e[a.UVS];var s=e[a.TRIANGLES];var o=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var l=t.DragonBones.webAssembly?this._floatArrayJson:this._data.floatArray;var h=Math.floor(r.length/2);var u=Math.floor(s.length/3);var f=l.length;var _=f+h*2;i.offset=o.length;o.length+=1+1+1+1+u*3;o[i.offset+0]=h;o[i.offset+1]=u;o[i.offset+2]=f;for(var m=0,p=u*3;mn.width){n.width=h}if(un.height){n.height=u}}}return n};a.prototype._parseAnimation=function(e){var i=t.DragonBones.webAssembly?new Module["AnimationData"]:t.BaseObject.borrowObject(t.AnimationData);i.frameCount=Math.max(a._getNumber(e,a.DURATION,1),1);i.playTimes=a._getNumber(e,a.PLAY_TIMES,1);i.duration=i.frameCount/this._armature.frameRate;i.fadeInTime=a._getNumber(e,a.FADE_IN_TIME,0);i.scale=a._getNumber(e,a.SCALE,1);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length<1){i.name=a.DEFAULT_NAME}if(t.DragonBones.webAssembly){i.frameIntOffset=this._frameIntArrayJson.length;i.frameFloatOffset=this._frameFloatArrayJson.length;i.frameOffset=this._frameArrayJson.length}else{i.frameIntOffset=this._data.frameIntArray.length;i.frameFloatOffset=this._data.frameFloatArray.length;i.frameOffset=this._data.frameArray.length}this._animation=i;if(a.FRAME in e){var r=e[a.FRAME];var n=r.length;if(n>0){for(var s=0,o=0;s0){this._actionFrames.sort(this._sortActionFrame);var D=this._animation.actionTimeline=t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);var T=t.DragonBones.webAssembly?this._timelineArrayJson:this._data.timelineArray;var n=this._actionFrames.length;D.type=0;D.offset=T.length;T.length+=1+1+1+1+1+n;T[D.offset+0]=100;T[D.offset+1]=0;T[D.offset+2]=n;T[D.offset+3]=0;T[D.offset+4]=0;this._timeline=D;if(n===1){D.frameIndicesOffset=-1;T[D.offset+5+0]=this._parseCacheActionFrame(this._actionFrames[0])-this._animation.frameOffset}else{var A=this._animation.frameCount+1;var O=this._data.frameIndices;if(t.DragonBones.webAssembly){D.frameIndicesOffset=O.size();for(var S=0;S0){if(a.CURVE in t){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(t[a.CURVE],this._helpArray);r.length+=1+1+this._helpArray.length;r[n+1]=2;r[n+2]=s;for(var o=0;o0){var l=this._armature.sortedSlots.length;var h=new Array(l-o.length/2);var u=new Array(l);for(var f=0;f0?l>=this._prevRotation:l<=this._prevRotation){this._prevTweenRotate=this._prevTweenRotate>0?this._prevTweenRotate-1:this._prevTweenRotate+1}l=this._prevRotation+l-this._prevRotation+t.Transform.PI_D*this._prevTweenRotate}}this._prevTweenRotate=a._getNumber(e,a.TWEEN_ROTATE,0);this._prevRotation=l;var h=n.length;n.length+=6;n[h++]=this._helpTransform.x;n[h++]=this._helpTransform.y;n[h++]=l;n[h++]=this._helpTransform.skew;n[h++]=this._helpTransform.scaleX;n[h++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,i,this._bone,this._slot);return o};a.prototype._parseSlotDisplayIndexFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var s=this._parseFrame(e,i,r,n);n.length+=1;n[s+1]=a._getNumber(e,a.DISPLAY_INDEX,0);this._parseActionDataInFrame(e,i,this._slot.parent,this._slot);return s};a.prototype._parseSlotColorFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameIntArrayJson:this._data.frameIntArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=this._parseTweenFrame(e,i,r,o);var h=-1;if(a.COLOR in e){var u=e[a.COLOR];for(var f in u){f;this._parseColorTransform(u,this._helpColorTransform);h=n.length;n.length+=8;n[h++]=Math.round(this._helpColorTransform.alphaMultiplier*100);n[h++]=Math.round(this._helpColorTransform.redMultiplier*100);n[h++]=Math.round(this._helpColorTransform.greenMultiplier*100);n[h++]=Math.round(this._helpColorTransform.blueMultiplier*100);n[h++]=Math.round(this._helpColorTransform.alphaOffset);n[h++]=Math.round(this._helpColorTransform.redOffset);n[h++]=Math.round(this._helpColorTransform.greenOffset);n[h++]=Math.round(this._helpColorTransform.blueOffset);h-=8;break}}if(h<0){if(this._defalultColorOffset<0){this._defalultColorOffset=h=n.length;n.length+=8;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=0;n[h++]=0;n[h++]=0;n[h++]=0}h=this._defalultColorOffset}var _=s.length;s.length+=1;s[_]=h;return l};a.prototype._parseSlotFFDFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameFloatArrayJson:this._data.frameFloatArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=s.length;var h=this._parseTweenFrame(e,i,r,o);var u=a.VERTICES in e?e[a.VERTICES]:null;var f=a._getNumber(e,a.OFFSET,0);var _=n[this._mesh.offset+0];var m=0;var p=0;var c=0;var d=0;if(this._mesh.weight!==null){var y=this._weightSlotPose[this._mesh.name];this._helpMatrixA.copyFromArray(y,0);s.length+=this._mesh.weight.count*2;c=this._mesh.weight.offset+2+this._mesh.weight.bones.length}else{s.length+=_*2}for(var g=0;g<_*2;g+=2){if(u===null){m=0;p=0}else{if(g=u.length){m=0}else{m=u[g-f]}if(g+1=u.length){p=0}else{p=u[g+1-f]}}if(this._mesh.weight!==null){var v=this._weightBonePoses[this._mesh.name];var b=this._weightBoneIndices[this._mesh.name];var D=n[c++];this._helpMatrixA.transformPoint(m,p,this._helpPoint,true);m=this._helpPoint.x;p=this._helpPoint.y;for(var T=0;T=0||a.DATA_VERSIONS.indexOf(n)>=0){var s=t.DragonBones.webAssembly?new Module["DragonBonesData"]:t.BaseObject.borrowObject(t.DragonBonesData);s.version=r;s.name=a._getString(e,a.NAME,"");s.frameRate=a._getNumber(e,a.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(a.ARMATURE in e){this._defalultColorOffset=-1;this._data=s;this._parseArray(e);var o=e[a.ARMATURE];for(var l=0,h=o;l0){this._parseWASMArray()}this._data=null}this._rawTextureAtlasIndex=0;if(a.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[a.TEXTURE_ATLAS]}else{this._rawTextureAtlases=null}return s}else{console.assert(false,"Nonsupport data version.")}return null};a.prototype.parseTextureAtlasData=function(e,i,r){if(r===void 0){r=0}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,i,r);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}i.width=a._getNumber(e,a.WIDTH,0);i.height=a._getNumber(e,a.HEIGHT,0);i.name=a._getString(e,a.NAME,"");i.imagePath=a._getString(e,a.IMAGE_PATH,"");if(r>0){i.scale=r}else{r=i.scale=a._getNumber(e,a.SCALE,i.scale)}r=1/r;if(a.SUB_TEXTURE in e){var s=e[a.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){u.frame=t.DragonBones.webAssembly?Module["TextureData"].createRectangle():t.TextureData.createRectangle();u.frame.x=a._getNumber(h,a.FRAME_X,0)*r;u.frame.y=a._getNumber(h,a.FRAME_Y,0)*r;u.frame.width=f*r;u.frame.height=_*r}i.addTexture(u)}}return true};a.getInstance=function(){if(a._objectDataParserInstance===null){a._objectDataParserInstance=new a}return a._objectDataParserInstance};a._objectDataParserInstance=null;return a}(t.DataParser);t.ObjectDataParser=e;var i=function(){function t(){this.frameStart=0;this.actions=[]}return t}()})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.prototype._inRange=function(t,e,i){return e<=t&&t<=i};i.prototype._decodeUTF8=function(t){var e=-1;var i=-1;var a=65533;var r=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>r){var f=t[r++];if(f===e){if(l!==0){s=a}else{s=i}}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;r--;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!==i){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};i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255){return encodeURI(t)}}return t};i.prototype._parseBinaryTimeline=function(e,i,a){if(a===void 0){a=null}var r=a!==null?a:t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);r.type=e;r.offset=i;this._timeline=r;var n=this._timelineArray[r.offset+2];if(n===1){r.frameIndicesOffset=-1}else{var s=this._animation.frameCount+1;var o=this._data.frameIndices;if(t.DragonBones.webAssembly){r.frameIndicesOffset=o.size();for(var l=0;l=0){var r=t.DragonBones.webAssembly?new Module["WeightData"]:t.BaseObject.borrowObject(t.WeightData);var n=this._intArray[i.offset+0];var s=this._intArray[a+0];r.offset=a;if(t.DragonBones.webAssembly){r.bones.resize(s,null);for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(i)}}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(i);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=r;t.data=n;t.armature=s;t.skin=null;if(a.length>0){t.skin=s.getSkin(a);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(a);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};i.prototype._buildBones=function(e,i){var a=e.armature.sortedBones;for(var r=0;r<(t.DragonBones.webAssembly?a.size():a.length);++r){var n=t.DragonBones.webAssembly?a.get(r):a[r];var s=t.DragonBones.webAssembly?new Module["Bone"]:t.BaseObject.borrowObject(t.Bone);s.init(n);if(n.parent!==null){i.addBone(s,n.parent.name)}else{i.addBone(s)}var o=n.constraints;for(var l=0;l<(t.DragonBones.webAssembly?o.size():o.length);++l){var h=t.DragonBones.webAssembly?o.get(l):o[l];var u=i.getBone(h.target.name);if(u===null){continue}var f=h;var _=t.DragonBones.webAssembly?new Module["IKConstraint"]:t.BaseObject.borrowObject(t.IKConstraint);var m=f.root!==null?i.getBone(f.root.name):null;_.target=u;_.bone=s;_.root=m;_.bendPositive=f.bendPositive;_.scaleEnabled=f.scaleEnabled;_.weight=f.weight;if(m!==null){m.addConstraint(_)}else{s.addConstraint(_)}}}};i.prototype._buildSlots=function(t,e){var i=t.skin;var a=t.armature.defaultSkin;if(i===null||a===null){return}var r={};for(var n in a.displays){var s=a.displays[n];r[n]=s}if(i!==a){for(var n in i.displays){var s=i.displays[n];r[n]=s}}for(var o=0,l=t.armature.sortedSlots;o0){s.texture=this._getTextureData(t.textureAtlasName,e.path)}if(i!==null&&i.type===2&&this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 2:var o=e;if(o.texture===null){o.texture=this._getTextureData(r,o.path)}else if(t!==null&&t.textureAtlasName.length>0){o.texture=this._getTextureData(t.textureAtlasName,o.path)}if(this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 1:var l=e;var h=this.buildArmature(l.path,r,null,t!==null?t.textureAtlasName:null);if(h!==null){h.inheritAnimation=l.inheritAnimation;if(!h.inheritAnimation){var u=l.actions.length>0?l.actions:h.armatureData.defaultActions;if(u.length>0){for(var f=0,_=u;f<_.length;f++){var m=_[f];h._bufferAction(m,true)}}else{h.animation.play()}}l.armature=h.armatureData}n=h;break}return n};i.prototype._replaceSlotDisplay=function(t,e,i,a){if(a<0){a=i.displayIndex}if(a<0){a=0}var r=i.displayList;if(r.length<=a){r.length=a+1;for(var n=0,s=r.length;n=0){continue}var s=e.displays[n.name];var o=n.displayList;o.length=s.length;for(var l=0,h=s.length;l0?this.width:i.width;var r=this.height>0?this.height:i.height;for(var n=0,s=this._textureNames;n255){o=encodeURI(o);break}}var u=e.get(o);var f=Math.min(u.region.width,a-u.region.x);var _=Math.min(u.region.height,r-u.region.y);if(!u.renderTexture){var m=new egret.Texture;m._bitmapData=i;if(u.rotated){m.$initData(u.region.x,u.region.y,_,f,0,0,_,f,a,r)}else{m.$initData(u.region.x,u.region.y,f,_,0,0,f,_,a,r)}egret.WebAssemblyNode.setValuesToBitmapData(m);u.setTextureId(m["textureId"]);u.renderTexture=m}}}else{for(var p=0,c=this._textureNames;p0){s.texture=this._getTextureData(t.textureAtlasName,e.path)}if(i!==null&&i.type===2&&this._isSupportMesh()){n=a.getMeshWASMDisplay()}else{n=a.getRawWASMDisplay()}break;case 2:var o=e;if(o.texture===null){o.texture=this._getTextureData(r,o.path)}else if(t!==null&&t.textureAtlasName.length>0){o.texture=this._getTextureData(t.textureAtlasName,o.path)}if(this._isSupportMesh()){n=a.getMeshWASMDisplay()}else{n=a.getRawWASMDisplay()}break;case 1:var l=e;var h=this.buildArmature(l.path,r,null,t!==null?t.textureAtlasName:null);if(h!==null){h.inheritAnimation=l.inheritAnimation;if(!h.inheritAnimation){var u=l.actions.length>0?l.actions:h.armatureData.defaultActions;if(u.length>0){for(var f=0,_=u;f<_.length;f++){var m=_[f];h.animation.fadeIn(m.name)}}else{h.animation.play()}}l.armature=h.armatureData}n=h;break}return n};i.prototype.changeSkin=function(e,i,a){if(a===void 0){a=null}var r=e.getSlots();for(var n=0,s=r.size();n=0){continue}var l=i.displays.get(o.name);if(l===null||l===undefined){continue}var h=o.getEgretDisplayList();if(h===null||h===undefined){console.log("Slot does not has displayList"+o.name);continue}var u=l.size();h.resize(u,null);for(var f=0,_=l.size();f<_;++f){var m=l.get(f);var p=this._getSlotDisplay(null,m,null,o);if(p.getDisplayType()==1){var c=t.createEgretDisplay(p,1);h.set(f,c)}else{h.set(f,p)}}o.switchDisplayData(l);o.setEgretDisplayList(h)}};i.prototype.replaceSlotDisplay=function(t,e,i,a,r,n){if(n===void 0){n=-1}var s={};if(!this._fillBuildArmaturePackage(s,t||"",e,"","")||s.skin===null){return}var o=s.skin.getDisplays(i);if(o===null){return}for(var l=0,h=o.size();l void, target: any): void { + this.addEventListener(type, listener, target); + } + /** + * @inheritDoc + */ + public removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void { + this.removeEventListener(type, listener, target); + } + /** + * @inheritDoc + */ + public get armature(): Armature { + return this._armature; + } + /** + * @inheritDoc + */ + public get animation(): Animation { + return this._armature.animation; + } + } + + interface PEgretArmatureProxy extends IArmatureProxy { + __parent: any; + _display: EgretArmatureDisplay; + } + + interface PEgretSlot { + __parent: any; + _rawDisplay: egret.Bitmap; + _meshDisplay: egret.Mesh; + _rawDisplayWASM: any; + _meshDisplayWASM: any; + } + + interface PEgretDisplayWrapper { + _display: egret.DisplayObject | Armature | null; + setDisplayInfo(displayID: number, type: DisplayType): void; + setArmature(value: Armature): void; + } + + export interface PEgretTextureAtlasData extends TextureAtlasData { + renderTexture: egret.Texture | null; + textures: any; + __parent: any; + _textureNames: Array; + _texture: egret.Texture | null; + } + + export interface PEgretTextureData extends TextureData { + renderTexture: egret.Texture | null; + __parent: any; + _renderTexture: egret.Texture | null; + } + + export let EgretArmatureProxy: any; + export let EgretSlot: any; + export let EgretTextureAtlasData: any; + export let EgretTextureData: any; + + export function createEgretDisplay(display: egret.DisplayObject | Armature | null, type: DisplayType): any { + const egretDisplayWrapper = new Module["EgretDisplayWASM"]() as PEgretDisplayWrapper; // TODO 是否可以将 EgretDisplayWASM 改为 EgretDisplayWrapper + let wasmId; + if (display === null) { + wasmId = -1; + egretDisplayWrapper.setDisplayInfo(wasmId, type); + } + else if (type === DisplayType.Armature) { + wasmId = (display as any).getEgretArmatureId(); + egretDisplayWrapper.setDisplayInfo(wasmId, type); + egretDisplayWrapper.setArmature(display as Armature); + } + else { + wasmId = (display as any).$waNode.id; + egretDisplayWrapper.setDisplayInfo(wasmId, type); + } + egretDisplayWrapper._display = display; + + return egretDisplayWrapper; + } + + export function egretWASMInit(): void { + /** + * @private + * 扩展 c++ EgretArmatureProxy。(在 js 中构造) + */ + EgretArmatureProxy = Module["EgretArmatureDisplayWASM"].extend("EgretArmatureProxy", { // TODO 是否可以将 EgretArmatureDisplayWASM 改为 EgretArmatureProxy + __construct: function (this: PEgretArmatureProxy, display: EgretArmatureDisplay) { + this.__parent.__construct.call(this); + this._display = display; + }, + __destruct: function (this: PEgretArmatureProxy) { + this.__parent.__destruct.call(this); + this._display = null as any; + }, + clear: function (this: PEgretArmatureProxy): void { // c++ call. + if (this._display) { + this._display.clear(); + } + + this._display = null as any; + }, + debugUpdate: function (this: PEgretArmatureProxy, isEnabled: boolean): void { // c++ call. + this._display.debugUpdate(isEnabled); + }, + //extend c++ + _dispatchEvent: function (this: PEgretArmatureProxy, type: string, eventObject: EventObject): void { // c++ call. + this._display._dispatchEvent(type, eventObject); + }, + //extend c++ + hasEvent: function (this: PEgretArmatureProxy, type: string): boolean { // c++ call. + return this._display.hasEventListener(type); + }, + dispose: function (this: PEgretArmatureProxy, disposeProxy: boolean): void { + // TODO lsc + disposeProxy; + // return this._display.dispose(disposeProxy); + }, + addEvent: function (this: PEgretArmatureProxy, type: string, listener: (event: EgretEvent) => void, target: any): void { // js call. + this._display.addEvent(type, listener, target); + }, + removeEvent: function (this: PEgretArmatureProxy, type: string, listener: (event: EgretEvent) => void, target: any): void { // js call. + this._display.removeEvent(type, listener, target); + } + }); + + /** + * @private + */ + EgretSlot = Module["EgretSlotWASM"].extend("EgretSlotWrapper", { // TODO 是否可以将 EgretSlotWASM 改为 EgretSlot + __construct: function (this: PEgretSlot) { + this.__parent.__construct.call(this); + this._rawDisplay = null as any; + this._meshDisplay = null as any; + this._rawDisplayWASM = null as any; + this._meshDisplayWASM = null as any; + }, + __destruct: function (this: PEgretSlot) { + this.__parent.__destruct.call(this); + this._rawDisplay = null as any; + this._meshDisplay = null as any; + }, + init: function (this: PEgretSlot, slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void { // js -> c++ + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + + this._rawDisplayWASM = createEgretDisplay(this._rawDisplay, DisplayType.Image); + this._meshDisplayWASM = createEgretDisplay(this._meshDisplay, DisplayType.Mesh); + this.__parent.init.call( + this, + slotData, displayDatas, + this._rawDisplayWASM, + this._meshDisplayWASM + ); + }, + getRawDisplay: function (this: PEgretSlot): egret.Bitmap { + return this._rawDisplay; + }, + getMeshDisplay: function (this: PEgretSlot): egret.Mesh { + return this._meshDisplay; + }, + getRawWASMDisplay: function (this: PEgretSlot): any { + return this._rawDisplayWASM; + }, + getMeshWASMDisplay: function (this: PEgretSlot): any { + return this._meshDisplayWASM; + }, + // extend c++ function + getDisplay: function (this: PEgretSlot): egret.DisplayObject | null { // js -> c++ + const displayWrapper: PEgretDisplayWrapper | null = this.__parent.getEgretDisplay.call(this); + if (displayWrapper !== null) { + return displayWrapper._display as any; + } + + return null; + }, + setDisplay: function (this: PEgretSlot, value: egret.DisplayObject | Armature | null): void { // js -> c++ + if (value === this._rawDisplay || value === this._meshDisplay) { + return; + } + + if (value === null || value instanceof egret.Bitmap) { + this.__parent.setEgretDisplay.call(this, createEgretDisplay(value, DisplayType.Image)); + } + else if (value instanceof egret.Mesh) { + this.__parent.setEgretDisplay.call(this, createEgretDisplay(value, DisplayType.Mesh)); + } + else if (value instanceof Module["EgretArmature"]) { + this.__parent.setChildArmature.call(this, value); + } + } + }); + + Object.defineProperty(EgretSlot.prototype, "displayList", { + get: EgretSlot.prototype.getEgretDisplayList, + set: EgretSlot.prototype.setEgretDisplayList, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretSlot.prototype, "rawDisplay", { + get: EgretSlot.prototype.getRawDisplay, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretSlot.prototype, "meshDisplay", { + get: EgretSlot.prototype.getMeshDisplay, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretSlot.prototype, "display", { + get: EgretSlot.prototype.getDisplay, + set: EgretSlot.prototype.setDisplay, + enumerable: true, + configurable: true + }); + + EgretTextureAtlasData = Module["EgretTextureAtlasDataWASM"].extend("EgretTextureAtlasData", { + __construct: function (this: PEgretTextureAtlasData, rawTextures?: { name: string }[]) { + this.__parent.__construct.call(this); + this._textureNames = []; + this._texture = null; + if (rawTextures) { + for (const texture of rawTextures) { + this._textureNames.push(texture.name); + } + } + }, + __destruct: function (this: PEgretTextureAtlasData) { + this.__parent.__destruct.call(this); + this._textureNames.length = 0; + this._texture = null; + } + }); + + Object.defineProperty((EgretTextureAtlasData as any).prototype, "renderTexture", { + get: function (this: PEgretTextureAtlasData): egret.Texture | null { + return this._texture; + }, + set: function (this: PEgretTextureAtlasData, value: egret.Texture): void { + if (this._texture === value) { + return; + } + if ((value as any)["textureId"] === null || (value as any)["textureId"] === undefined) { + (egret as any).WebAssemblyNode.setValuesToBitmapData(value); + } + this._texture = value; + + const textures = this.textures; + if (this._texture !== null) { + const bitmapData = this._texture.bitmapData; + const textureAtlasWidth = this.width > 0.0 ? this.width : bitmapData.width; + const textureAtlasHeight = this.height > 0.0 ? this.height : bitmapData.height; + for (let k of this._textureNames) { + for (let i = 0, l = k.length; i < l; ++i) { + if (k.charCodeAt(i) > 255) { + k = encodeURI(k); + break; + } + } + + const textureData = textures.get(k) as PEgretTextureData; + const subTextureWidth = Math.min(textureData.region.width, textureAtlasWidth - textureData.region.x); // TODO need remove + const subTextureHeight = Math.min(textureData.region.height, textureAtlasHeight - textureData.region.y); // TODO need remove + + if (!textureData.renderTexture) { + let currTex = new egret.Texture(); + currTex._bitmapData = bitmapData; + if (textureData.rotated) { + currTex.$initData( + textureData.region.x, textureData.region.y, + subTextureHeight, subTextureWidth, + 0, 0, + subTextureHeight, subTextureWidth, + textureAtlasWidth, textureAtlasHeight, + // textureData.rotated + ); + } + else { + currTex.$initData( + textureData.region.x, textureData.region.y, + subTextureWidth, subTextureHeight, + 0, 0, + subTextureWidth, subTextureHeight, + textureAtlasWidth, textureAtlasHeight + ); + } + // Egret 5.0 + (egret as any).WebAssemblyNode.setValuesToBitmapData(currTex); + (textureData as any).setTextureId((currTex as any)["textureId"]); + textureData.renderTexture = currTex; + } + } + } + else { + for (const k of this._textureNames) { + const textureData = textures.get(k) as PEgretTextureData; + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + EgretTextureData = Module["EgretTextureDataWASM"].extend("EgretTextureData", { + __construct: function (this: PEgretTextureData) { + this.__parent.__construct.call(this); + this._renderTexture = null; + }, + __destruct: function (this: PEgretTextureData) { + this.__parent.__destruct.call(this); + this._renderTexture = null; + } + }); + + Object.defineProperty((EgretTextureData as any).prototype, "renderTexture", { + get: function (this: PEgretTextureData): egret.Texture | null { + return this._renderTexture; + }, + set: function (this: PEgretTextureData, value: egret.Texture): void { + if (this._renderTexture === value) { + return; + } + + this._renderTexture = value; + }, + enumerable: true, + configurable: true + }); + + /* + * @private + * 扩展 c++ WorldClock。(在 c++ 中构造) + */ + dragonBones.WorldClock = Module["WorldClock"]; + (dragonBones.WorldClock as any).prototype._c_contains = dragonBones.WorldClock.prototype.contains; + (dragonBones.WorldClock as any).prototype._c_add = dragonBones.WorldClock.prototype.add; + (dragonBones.WorldClock as any).prototype._c_remove = dragonBones.WorldClock.prototype.remove; + (dragonBones.WorldClock as any).prototype.contains = function (this: any, value: IAnimatable): boolean { // js call. + if (value instanceof dragonBones.Armature) { + return this._c_contains((value as any).getAnimatable()); + } + + return this._c_contains(value); + }; + (dragonBones.WorldClock as any).prototype.add = function (this: any, value: IAnimatable): void { // js call. + if (value instanceof dragonBones.Armature) { + return this._c_add((value as any).getAnimatable()); + } + + return this._c_add(value); + }; + (dragonBones.WorldClock as any).prototype.remove = function (this: any, value: IAnimatable): void { // js call. + if (value instanceof dragonBones.Armature) { + return this._c_remove((value as any).getAnimatable()); + } + + return this._c_remove(value); + }; + /** + * @private + * 扩展 c++ EgretArmature。(在 js 中构造) + */ + dragonBones.Armature = Module["EgretArmature"]; + (dragonBones.Armature as any).prototype._c_addBone = dragonBones.Armature.prototype.addBone; + (dragonBones.Armature as any).prototype._c_invalidUpdate = dragonBones.Armature.prototype.invalidUpdate; + dragonBones.Armature.prototype.addBone = function (this: any, bone: Bone, name: string) { + if (name === null || name === undefined) { + name = ""; + } + return this._c_addBone(bone, name); + } + dragonBones.Armature.prototype.invalidUpdate = function (this: any, boneName: string | null = null, updateSlotDisplay: boolean = false): void { + if (boneName === null) { + boneName = ""; + } + return this._c_invalidUpdate(boneName, updateSlotDisplay); + } + dragonBones.Armature.prototype.getDisplay = function (this: any) { + return this.proxy._display; + } + Object.defineProperty(dragonBones.Armature.prototype, "display", { + get: function (this: any) { + return this.proxy._display; + }, + enumerable: true, + configurable: true + }); + /** + * @private + * 扩展 c++ Animation + */ + dragonBones.Animation = Module["Animation"]; + (dragonBones.Animation as any).prototype._c_play = dragonBones.Animation.prototype.play; + (dragonBones.Animation as any).prototype._c_fadeIn = dragonBones.Animation.prototype.fadeIn; + dragonBones.Animation.prototype.play = function (this: any, + animationName: string | null = null, playTimes: number = -1): AnimationState | null { + if (animationName === null) { + animationName = ""; + } + return this._c_play(animationName, playTimes); + } + dragonBones.Animation.prototype.fadeIn = function (this: any, + animationName: string, fadeInTime: number = -1.0, playTimes: number = -1, + layer: number = 0, group: string | null = null, fadeOutMode: AnimationFadeOutMode = AnimationFadeOutMode.SameLayerAndGroup + ): AnimationState | null { + if (animationName === null) { + animationName = ""; + } + if (group === null) { + group = ""; + } + return this._c_fadeIn(animationName, fadeInTime, playTimes, layer, group, fadeOutMode); + } + } + + const configTables: { [key: string]: { getter?: string[], setter?: string[], static?: string[], array?: string[] } } = { + ActionData: { + getter: [], + setter: ["type", "bone", "slot", "data"] + }, + DragonBonesData: { + getter: ["frameIndices"], + setter: [], + array: ["armatureNames"] + }, + ArmatureData: { + getter: ["defaultActions", "actions"], + setter: ["aabb", "defaultAnimation", "defaultSkin", "parent"], + array: ["animationNames"] + }, + BoneData: { + getter: ["transform", "constraints"], + setter: ["parent"] + }, + SlotData: { + getter: [], + setter: ["blendMode", "color", "parent"], + static: ["DEFAULT_COLOR"] + }, + ConstraintData: { + getter: [], + setter: ["target", "root", "bone"] + }, + DisplayData: { + getter: ["transform"], + setter: ["type", "parent"] + }, + ImageDisplayData: { + getter: ["pivot"], + setter: ["texture"] + }, + ArmatureDisplayData: { + getter: ["actions"], + setter: [] // armature + }, + MeshDisplayData: { + getter: [], + setter: ["weight"] + }, + WeightData: { + getter: ["bones"], + setter: [] + }, + AnimationData: { + getter: [], + setter: ["actionTimeline", "zOrderTimeline", "parent"] + }, + TimelineData: { + getter: [], + setter: ["type"] + }, + AnimationConfig: { + getter: [], + setter: ["fadeOutMode", "fadeOutTweenType", "fadeInTweenType"] + }, + TextureData: { + getter: ["region"], + setter: ["frame"] + }, + TransformObject: { + getter: ["globalTransformMatrix", "global", "offset", "origin"], + setter: [] + }, + Armature: { + getter: ["armatureData", "animation", "proxy", "eventDispatcher"], + setter: ["clock"] + }, + Slot: { + getter: ["boundingBoxData"], + setter: ["displayIndex", "childArmature"] + }, + Constraint: { + getter: [], + setter: ["target", "bone", "root"] + }, + Animation: { + getter: ["animationConfig"], + setter: [], + array: ["animationNames"] + }, + WorldClock: { + getter: [], + setter: ["clock"], + static: ["clock"] + }, + EventObject: { + getter: ["armature", "bone", "slot", "animationState", "data"], + setter: [] + }, + EgretArmatureDisplayWASM: { + getter: ["armature", "animation"], + setter: [] + }, + DragonBones: { + getter: ["clock"], + setter: [] + } + } + + function descGetter(funcName: string, target: any) { + return { + get: target["_c_get_" + funcName], + enumerable: true, + configurable: true + }; + } + + function descSetter(funcName: string, target: any) { + return { + get: target["_c_get_" + funcName], + set: target["_c_set_" + funcName], + enumerable: true, + configurable: true + }; + } + + function descArrayGetter(funcName: string, target: any) { + target; + return { + get: function (this: any): Array { + let array = this["_js_" + funcName]; + if (!array) { + array = []; + + const vector = this["_c_get_" + funcName](); + for (let i = 0, l = vector.size(); i < l; ++i) { + array[i] = vector.get(i); + } + } + + return array; + }, + enumerable: true, + configurable: true + }; + } + + export function registerGetterSetter(): void { + for (let fieldKey in configTables) { + const getterClass = Module[fieldKey]; + const getterClassProto = Module[fieldKey].prototype; + const getterArray = configTables[fieldKey].getter; + const setterArray = configTables[fieldKey].setter; + const staticArray = configTables[fieldKey].static; + const arrayArray = configTables[fieldKey].array; + + if (getterArray) { + for (let fieldName of getterArray) { + Object.defineProperty(getterClassProto, fieldName, descGetter(fieldName, getterClassProto)); + } + } + + if (setterArray) { + for (let fieldName of setterArray) { + Object.defineProperty(getterClassProto, fieldName, descSetter(fieldName, getterClassProto)); + } + } + + if (staticArray) { + for (let fieldName of staticArray) { + Object.defineProperty(getterClass, fieldName, descSetter(fieldName, getterClass)); + } + } + + if (arrayArray) { + for (let fieldName of arrayArray) { + Object.defineProperty(getterClassProto, fieldName, descArrayGetter(fieldName, getterClass)); + } + } + } + } +} \ No newline at end of file diff --git a/reference/Egret/wasm/src/dragonBones/egret/EgretFactory.ts b/reference/Egret/wasm/src/dragonBones/egret/EgretFactory.ts new file mode 100644 index 0000000..259732c --- /dev/null +++ b/reference/Egret/wasm/src/dragonBones/egret/EgretFactory.ts @@ -0,0 +1,434 @@ +namespace dragonBones { + /** + * Egret 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class EgretFactory extends BaseFactory { + private static _time: number = 0; + private static _dragonBones: DragonBones = null as any; + private static _factory: EgretFactory | null = null; + private static _eventManager: EgretArmatureDisplay; + private static _clockHandler(time: number): boolean { + const dbcore = EgretFactory._dragonBones as any; + // + const objects = dbcore.getObjects(); + for (let i = 0, l = objects.size(); i < l; ++i) { + objects.get(i).returnToPool(); + } + objects.resize(0, null); + // + time *= 0.001; + const passedTime = time - EgretFactory._time; + dbcore.clock.advanceTime(passedTime); + EgretFactory._time = time; + // + const events = dbcore.getEvents(); + for (let i = 0, l = events.size(); i < l; ++i) { + const eventObject = events.get(i); + const armature = eventObject.armature; + const type = eventObject.type; + if (armature === null || armature.display === null || armature.display === undefined) { + console.log("armature display error!"); + } + armature.display._dispatchEvent(type, eventObject); + if (type === EventObject.SOUND_EVENT) { + EgretFactory._eventManager._dispatchEvent(eventObject.type, eventObject); + } + + eventObject.returnToPool(); + } + events.resize(0, null); + + return false; + } + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 5.0 + * @language zh_CN + */ + public static get clock(): any { + return EgretFactory._dragonBones.clock; + } + /** + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + * @language zh_CN + */ + public static get factory(): EgretFactory { + if (EgretFactory._factory === null) { + registerGetterSetter(); + egretWASMInit(); + EgretFactory._factory = new EgretFactory(); + } + + return EgretFactory._factory; + } + /** + * @private + */ + private _rawTextures: any = null; + /** + * @inheritDoc + */ + public constructor() { + super(); + + if (EgretFactory._dragonBones === null) { + dragonBones.DragonBones.webAssembly = true; + const eventDisplay = new EgretArmatureDisplay(); + EgretFactory._eventManager = eventDisplay; + EgretFactory._dragonBones = new Module["DragonBones"](); + EgretFactory._dragonBones.clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretFactory._clockHandler, EgretFactory); + } + } + /** + * @private + */ + protected _isSupportMesh(): boolean { + if (egret.Capabilities.renderMode === "webgl" || egret.Capabilities.runtimeType === egret.RuntimeType.NATIVE) { + return true; + } + + console.warn("Canvas can not support mesh, please change renderMode to webgl."); + + return false; + } + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: any | null, textureAtlas: egret.Texture): TextureAtlasData { + if (textureAtlasData !== null) { + if ((textureAtlas as any)["textureId"] === null) { + (egret as any).WebAssemblyNode.setValuesToBitmapData(textureAtlas); + } + + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = new EgretTextureAtlasData(this._rawTextures); + } + + return textureAtlasData; + } + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature { + const armature = new Module['EgretArmature'](); + const armatureDisplay = new EgretArmatureDisplay(); + const armatureProxy = new EgretArmatureProxy(armatureDisplay); + const displayID = (armatureDisplay as any).$waNode.id; + armature.init( + dataPackage.armature, + armatureProxy, displayID, EgretFactory._dragonBones + ); + armatureDisplay.init(armature); + return armature; + } + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void { + const currentSkin = dataPackage.skin; + const defaultSkin = dataPackage.armature.defaultSkin; + if (currentSkin === null || defaultSkin === null) { + return; + } + + const currentSkinSlotNames: any = (currentSkin as any).getSkinSlotNames(); + const defaultSkinSlotNames: any = (defaultSkin as any).getSkinSlotNames(); + + const skinSlots: Map> = {}; + // for (let k in defaultSkin.displays) { + for (let i = 0, l = defaultSkinSlotNames.size(); i < l; ++i) { + const slotName = defaultSkinSlotNames.get(i); + const displays = defaultSkin.getDisplays(slotName); + if (displays !== null) { + skinSlots[slotName] = displays; + } + } + + if (currentSkin !== defaultSkin) { + // for (let k in currentSkin.displays) { + for (let i = 0, l = currentSkinSlotNames.size(); i < l; ++i) { + const slotName = currentSkinSlotNames.get(i); + const displays = currentSkin.getDisplays(slotName); + if (displays !== null) { + skinSlots[slotName] = displays; + } + } + } + + // for (const slotData of dataPackage.armature.sortedSlots) { + const slots = dataPackage.armature.sortedSlots as any; + for (let i = 0, l = slots.size(); i < l; ++i) { + const slotData = slots.get(i); + if (!(slotData.name in skinSlots)) { + continue; + } + + const displays = skinSlots[slotData.name]; + const slot = this._buildSlot(dataPackage, slotData, displays, armature); + const displayList = new Module["EgretSlotDisplayVector"](); + for (let i = 0, l = (displays as any).size(); i < l; ++i) { + const displayData = (displays as any).get(i); + if (displayData !== null) { + const display = this._getSlotDisplay(dataPackage, displayData, null, slot); + if (display === null) { + const displayWrapper = createEgretDisplay(display, DisplayType.Image); + displayList.push_back(displayWrapper); + } + else if (display.getDisplayType() === DisplayType.Armature) { + const displayWrapper = createEgretDisplay(display, DisplayType.Armature); + displayList.push_back(displayWrapper); + } + else { + displayList.push_back(display); + } + } + else { + const displayWrapper = createEgretDisplay(null, DisplayType.Image); + displayList.push_back(displayWrapper); + } + } + + armature.addSlot(slot, slotData.parent.name); + (slot as any)._setEgretDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + } + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot { + dataPackage; + armature; + const slot = new EgretSlot() as Slot; + slot.init( + slotData, displays, + new egret.Bitmap(), new egret.Mesh() + ); + + return slot; + } + /** + * @private + */ + public parseTextureAtlasData(rawData: any, textureAtlas: any, name: string | null = null, scale: number = 0.0): TextureAtlasData { + this._rawTextures = rawData ? rawData.SubTexture : null; + + return super.parseTextureAtlasData(rawData, textureAtlas, name, scale); + } + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + public buildArmatureDisplay(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null, textureAtlasName: string | null = null): EgretArmatureDisplay | null { + const armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + EgretFactory.clock.add(armature); + return armature.display as EgretArmatureDisplay; + } + + return null; + } + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public getTextureDisplay(textureName: string, textureAtlasName: string | null = null): egret.Bitmap | null { + const textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName) as any; + if (textureData !== null && textureData.texture === null) { + return new egret.Bitmap(textureData.texture); + } + + return null; + } + /* + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any { + const dataName = dataPackage !== null ? dataPackage.dataName : displayData.parent.parent.name; + let display: any = null; + switch (displayData.type) { + case DisplayType.Image: + const imageDisplayData = displayData as ImageDisplayData; + if (imageDisplayData.texture === null) { + imageDisplayData.texture = this._getTextureData(dataName, displayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + + if (rawDisplayData !== null && rawDisplayData.type === DisplayType.Mesh && this._isSupportMesh()) { + display = (slot as any).getMeshWASMDisplay(); + } + else { + display = (slot as any).getRawWASMDisplay(); + } + break; + + case DisplayType.Mesh: + const meshDisplayData = displayData as MeshDisplayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + + if (this._isSupportMesh()) { + display = (slot as any).getMeshWASMDisplay(); + } + else { + display = (slot as any).getRawWASMDisplay(); + } + break; + + case DisplayType.Armature: + const armatureDisplayData = displayData as ArmatureDisplayData; + const childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + if (childArmature !== null) { + childArmature.inheritAnimation = armatureDisplayData.inheritAnimation; + if (!childArmature.inheritAnimation) { + const actions = armatureDisplayData.actions.length > 0 ? armatureDisplayData.actions : childArmature.armatureData.defaultActions; + if (actions.length > 0) { + for (const action of actions) { + childArmature.animation.fadeIn(action.name); // TODO action should be do after advanceTime. + } + } + else { + childArmature.animation.play(); + } + } + + armatureDisplayData.armature = childArmature.armatureData; // + } + + display = childArmature; + break; + } + + return display; + } + /** + * public + */ + public changeSkin(armature: Armature, skin: SkinData, exclude: Array | null = null): void { + // for (const slot of armature.getSlots()) { + let slots = armature.getSlots(); + for (let i = 0, l = (slots as any).size(); i < l; ++i) { + let slot = (slots as any).get(i); + if ((exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + const displays = (skin.displays as any).get(slot.name); + if (displays === null || displays === undefined) { + continue; + } + const displayList = (slot as any).getEgretDisplayList(); // Copy. + if (displayList === null || displayList === undefined) { + console.log("Slot does not has displayList" + slot.name); + continue; + } + const datalen = displays.size(); + displayList.resize(datalen, null);// Modify displayList length. + + for (let i = 0, l = displays.size(); i < l; ++i) { + let currData = displays.get(i); + let currSlot = this._getSlotDisplay(null, currData, null, slot); + if (currSlot.getDisplayType() == DisplayType.Armature) { + let displayWrapper = createEgretDisplay(currSlot, DisplayType.Armature); + displayList.set(i, displayWrapper); + } + else { + displayList.set(i, currSlot); + } + } + + slot.switchDisplayData(displays); + + //TODO + // slot.displayList = displayList; + (slot as any).setEgretDisplayList(displayList); + } + } + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex: number = -1): void { + const dataPackage: BuildArmaturePackage = {} as any; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + + const displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + + // for (const display of displays) { + for (let i = 0, l = (displays as any).size(); i < l; ++i) { + let display = (displays as any).get(i); + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + } + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + + if (displayIndex < 0) { + displayIndex = 0; + } + + const displayList = (slot as any).getEgretDisplayList(); // Copy. + if ((displayList as any).size() <= displayIndex) { + (displayList as any).resize(displayIndex + 1, null); + } + + (slot as any).replaceDisplayData(displayData, displayIndex); + if (displayData !== null) { + displayList.set(displayIndex, this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.set(displayIndex, null); + } + (slot as any).setEgretDisplayList(displayList); + } + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public get soundEventManager(): egret.EventDispatcher { + return EgretFactory._eventManager; + } + } +} \ No newline at end of file diff --git a/reference/Egret/wasm/tsconfig.json b/reference/Egret/wasm/tsconfig.json new file mode 100644 index 0000000..a672d0f --- /dev/null +++ b/reference/Egret/wasm/tsconfig.json @@ -0,0 +1,74 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": false, + "declaration": true, + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "outFile": "out/dragonBones-wasm.js", + "lib": [ + "es5", + "dom", + "es2015.promise" + ] + }, + "exclude": [ + "node_modules", + "out" + ], + "files": [ + "./libs/egret-wasm.d.ts", + + "../../DragonBones/src/dragonBones/core/DragonBones.ts", + "../../DragonBones/src/dragonBones/core/BaseObject.ts", + + "../../DragonBones/src/dragonBones/geom/Matrix.ts", + "../../DragonBones/src/dragonBones/geom/Transform.ts", + "../../DragonBones/src/dragonBones/geom/ColorTransform.ts", + "../../DragonBones/src/dragonBones/geom/Point.ts", + "../../DragonBones/src/dragonBones/geom/Rectangle.ts", + + "../../DragonBones/src/dragonBones/model/UserData.ts", + "../../DragonBones/src/dragonBones/model/DragonBonesData.ts", + "../../DragonBones/src/dragonBones/model/ArmatureData.ts", + "../../DragonBones/src/dragonBones/model/ConstraintData.ts", + "../../DragonBones/src/dragonBones/model/DisplayData.ts", + "../../DragonBones/src/dragonBones/model/BoundingBoxData.ts", + "../../DragonBones/src/dragonBones/model/AnimationData.ts", + "../../DragonBones/src/dragonBones/model/AnimationConfig.ts", + "../../DragonBones/src/dragonBones/model/TextureAtlasData.ts", + + "../../DragonBones/src/dragonBones/armature/IArmatureProxy.ts", + "../../DragonBones/src/dragonBones/armature/Armature.ts", + "../../DragonBones/src/dragonBones/armature/TransformObject.ts", + "../../DragonBones/src/dragonBones/armature/Bone.ts", + "../../DragonBones/src/dragonBones/armature/Slot.ts", + "../../DragonBones/src/dragonBones/armature/Constraint.ts", + + "../../DragonBones/src/dragonBones/animation/IAnimatable.ts", + "../../DragonBones/src/dragonBones/animation/WorldClock.ts", + "../../DragonBones/src/dragonBones/animation/Animation.ts", + "../../DragonBones/src/dragonBones/animation/AnimationState.ts", + "../../DragonBones/src/dragonBones/animation/BaseTimelineState.ts", + "../../DragonBones/src/dragonBones/animation/TimelineState.ts", + + "../../DragonBones/src/dragonBones/event/EventObject.ts", + "../../DragonBones/src/dragonBones/event/IEventDispatcher.ts", + + "../../DragonBones/src/dragonBones/parser/DataParser.ts", + "../../DragonBones/src/dragonBones/parser/ObjectDataParser.ts", + "../../DragonBones/src/dragonBones/parser/BinaryDataParser.ts", + + "../../DragonBones/src/dragonBones/factory/BaseFactory.ts", + + "./src/dragonBones/egret/EgretArmatureDisplay.ts", + "./src/dragonBones/egret/EgretFactory.ts" + ] +} \ No newline at end of file diff --git a/reference/LICENSE b/reference/LICENSE new file mode 100644 index 0000000..00b61d6 --- /dev/null +++ b/reference/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2012-2016 DragonBones team and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/reference/Pixi/4.x/README.md b/reference/Pixi/4.x/README.md new file mode 100644 index 0000000..c38b11b --- /dev/null +++ b/reference/Pixi/4.x/README.md @@ -0,0 +1,21 @@ +## How to build +``` +$npm install +$npm run build +``` + +## Project structure +``` + |-- libs + |-- pixi.js.d.ts + |-- node_modules + |-- ... + |-- out + |-- ... + |-- src + |-- ... + |-- ... +``` + +## Pixi declaration +[pixi.js.d.ts](https://github.com/pixijs/pixi-typescript/blob/v4.x/pixi.js.d.ts) \ No newline at end of file diff --git a/reference/Pixi/4.x/out/dragonBones.d.ts b/reference/Pixi/4.x/out/dragonBones.d.ts new file mode 100644 index 0000000..881dd51 --- /dev/null +++ b/reference/Pixi/4.x/out/dragonBones.d.ts @@ -0,0 +1,4623 @@ +declare const Module: any; +declare namespace dragonBones { + /** + * @private + */ + const enum BinaryOffset { + WeigthBoneCount = 0, + WeigthFloatOffset = 1, + WeigthBoneIndices = 2, + MeshVertexCount = 0, + MeshTriangleCount = 1, + MeshFloatOffset = 2, + MeshWeightOffset = 3, + MeshVertexIndices = 4, + TimelineScale = 0, + TimelineOffset = 1, + TimelineKeyFrameCount = 2, + TimelineFrameValueCount = 3, + TimelineFrameValueOffset = 4, + TimelineFrameOffset = 5, + FramePosition = 0, + FrameTweenType = 1, + FrameTweenEasingOrCurveSampleCount = 2, + FrameCurveSamples = 3, + FFDTimelineMeshOffset = 0, + FFDTimelineFFDCount = 1, + FFDTimelineValueCount = 2, + FFDTimelineValueOffset = 3, + FFDTimelineFloatOffset = 4, + } + /** + * @private + */ + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, + } + /** + * @private + */ + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, + BoundingBox = 3, + } + /** + * @language zh_CN + * 包围盒类型。 + * @version DragonBones 5.0 + */ + 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, + BoneT = 11, + BoneR = 12, + BoneS = 13, + BoneX = 14, + BoneY = 15, + BoneRotate = 16, + BoneSkew = 17, + BoneScaleX = 18, + BoneScaleY = 19, + SlotVisible = 23, + SlotDisplay = 20, + SlotColor = 21, + SlotFFD = 22, + AnimationTime = 40, + AnimationWeight = 41, + } + /** + * @private + */ + const enum OffsetMode { + None = 0, + Additive = 1, + Override = 2, + } + /** + * @language zh_CN + * 动画混合的淡出方式。 + * @version DragonBones 4.5 + */ + const enum AnimationFadeOutMode { + /** + * 不淡出动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + None = 0, + /** + * 淡出同层的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayer = 1, + /** + * 淡出同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameGroup = 2, + /** + * 淡出同层并且同组的动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + SameLayerAndGroup = 3, + /** + * 淡出所有动画。 + * @version DragonBones 4.5 + * @language zh_CN + */ + All = 4, + /** + * 不替换同名动画。 + * @version DragonBones 5.1 + * @language zh_CN + */ + Single = 5, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * @private + */ + class DragonBones { + static yDown: boolean; + static debug: boolean; + static debugDraw: boolean; + static webAssembly: boolean; + static readonly VERSION: string; + 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 namespace 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); + /** + * @private + */ + static toString(): string; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static setMaxCount(objectConstructor: (typeof BaseObject) | null, maxCount: number): void; + /** + * 清除对象池缓存的对象。 + * @param objectConstructor 对象类。 (不设置则清除所有缓存) + * @version DragonBones 4.5 + * @language zh_CN + */ + static clearPool(objectConstructor?: (typeof BaseObject) | null): void; + /** + * 从对象池中创建指定对象。 + * @param objectConstructor 对象类。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static borrowObject(objectConstructor: { + new (): T; + }): T; + /** + * 对象的唯一标识。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly hashCode: number; + private _isInPool; + /** + * @private + */ + protected abstract _onClear(): void; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + returnToPool(): void; + } +} +declare namespace dragonBones { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Matrix): Matrix; + /** + * @private + */ + copyFromArray(value: Array, offset?: number): Matrix; + /** + * 转换为单位矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + identity(): Matrix; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + concat(value: Matrix): Matrix; + /** + * 转换为逆矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + invert(): Matrix; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class Transform { + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x: number; + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y: number; + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew: number; + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation: number; + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX: number; + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY: 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; + constructor( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x?: number, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y?: number, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew?: number, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation?: number, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX?: number, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleY?: number); + /** + * @private + */ + toString(): string; + /** + * @private + */ + copyFrom(value: Transform): Transform; + /** + * @private + */ + identity(): Transform; + /** + * @private + */ + add(value: Transform): Transform; + /** + * @private + */ + minus(value: Transform): Transform; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fromMatrix(matrix: Matrix): Transform; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + toMatrix(matrix: Matrix): Transform; + } +} +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; + } +} +declare namespace dragonBones { + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * 自定义数据。 + * @version DragonBones 5.0 + * @language zh_CN + */ + class UserData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly ints: Array; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly floats: Array; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly strings: Array; + /** + * @private + */ + protected _onClear(): void; + /** + * 获取自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getInt(index?: number): number; + /** + * 获取自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + getFloat(index?: number): number; + /** + * 获取自定义字符串。 + * @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; + } +} +declare namespace dragonBones { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * 动画帧频。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * 数据版本。 + * @version DragonBones 3.0 + * @language zh_CN + */ + version: string; + /** + * 数据名称。(该名称与龙骨项目名保持一致) + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly frameIndices: Array; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatureNames: Array; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armatures: Map; + /** + * @private + */ + intArray: Array | Int16Array; + /** + * @private + */ + floatArray: Array | Float32Array; + /** + * @private + */ + frameIntArray: Array | Int16Array; + /** + * @private + */ + frameFloatArray: Array | Float32Array; + /** + * @private + */ + frameArray: Array | Int16Array; + /** + * @private + */ + timelineArray: Array | Uint16Array; + /** + * @private + */ + userData: UserData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addArmature(value: ArmatureData): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + getArmature(name: string): ArmatureData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class CanvasData extends BaseObject { + /** + * @private + */ + static toString(): string; + hasBackground: boolean; + color: number; + x: number; + y: number; + width: number; + height: number; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 骨架数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class ArmatureData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + type: ArmatureType; + /** + * 动画帧率。 + * @version DragonBones 3.0 + * @language zh_CN + */ + frameRate: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * @private + */ + scale: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly aabb: Rectangle; + /** + * 所有动画数据名称。 + * @see #armatures + * @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; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly bones: Map; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly slots: Map; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly skins: Map; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animations: Map; + /** + * 获取默认皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultSkin: SkinData | null; + /** + * 获取默认动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + defaultAnimation: AnimationData | null; + /** + * @private + */ + canvas: CanvasData | null; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的龙骨数据。 + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 + * @language zh_CN + */ + parent: DragonBonesData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + sortBones(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + setCacheFrame(globalTransformMatrix: Matrix, transform: Transform): number; + /** + * @private + */ + getCacheFrame(globalTransformMatrix: Matrix, transform: Transform, arrayOffset: number): void; + /** + * @private + */ + addBone(value: BoneData): void; + /** + * @private + */ + addSlot(value: SlotData): void; + /** + * @private + */ + addSkin(value: SkinData): void; + /** + * @private + */ + addAnimation(value: AnimationData): void; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + getBone(name: string): BoneData | null; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + getSlot(name: string): SlotData | null; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + getSkin(name: string): SkinData | null; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + getAnimation(name: string): AnimationData | null; + } + /** + * 骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class BoneData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + inheritTranslation: boolean; + /** + * @private + */ + inheritRotation: boolean; + /** + * @private + */ + inheritScale: boolean; + /** + * @private + */ + inheritReflection: boolean; + /** + * @private + */ + length: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly transform: Transform; + /** + * @private + */ + readonly constraints: Array; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData | null; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class SlotData extends BaseObject { + /** + * @private + */ + static readonly DEFAULT_COLOR: ColorTransform; + /** + * @private + */ + static createColor(): ColorTransform; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + blendMode: BlendMode; + /** + * @private + */ + displayIndex: number; + /** + * @private + */ + zOrder: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + color: ColorTransform; + /** + * @private + */ + userData: UserData | null; + /** + * 所属的父骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + parent: BoneData; + /** + * @private + */ + protected _onClear(): void; + } + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @version DragonBones 3.0 + * @language zh_CN + */ + class SkinData extends BaseObject { + static toString(): string; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly displays: Map>; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + addDisplay(slotName: string, value: DisplayData | null): void; + /** + * @private + */ + getDisplay(slotName: string, displayName: string): DisplayData | null; + /** + * @private + */ + getDisplays(slotName: string): Array | null; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class ConstraintData extends BaseObject { + order: number; + target: BoneData; + bone: BoneData; + root: BoneData | null; + protected _onClear(): void; + } + /** + * @private + */ + class IKConstraintData extends ConstraintData { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + abstract class DisplayData extends BaseObject { + type: DisplayType; + name: string; + path: string; + readonly transform: Transform; + parent: ArmatureData; + 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 + */ + class MeshDisplayData extends ImageDisplayData { + static toString(): string; + inheritAnimation: boolean; + offset: number; + weight: WeightData | null; + protected _onClear(): void; + } + /** + * @private + */ + class BoundingBoxDisplayData extends DisplayData { + static toString(): string; + boundingBox: BoundingBoxData | null; + protected _onClear(): void; + } + /** + * @private + */ + class WeightData extends BaseObject { + static toString(): string; + count: number; + offset: number; + readonly bones: Array; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 边界框数据基类。 + * @see dragonBones.RectangleData + * @see dragonBones.EllipseData + * @see dragonBones.PolygonData + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract class BoundingBoxData extends BaseObject { + /** + * 边界框类型。 + * @version DragonBones 5.0 + * @language zh_CN + */ + type: BoundingBoxType; + /** + * 边界框颜色。 + * @version DragonBones 5.0 + * @language zh_CN + */ + color: number; + /** + * 边界框宽。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + width: number; + /** + * 边界框高。(本地坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + height: number; + /** + * @private + */ + protected _onClear(): void; + /** + * 是否包含点。 + * @version DragonBones 5.0 + * @language zh_CN + */ + abstract containsPoint(pX: number, pY: number): boolean; + /** + * 是否与线段相交。 + * @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; + } + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class RectangleBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class EllipseBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + 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; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } + /** + * 多边形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + class PolygonBoundingBoxData extends BoundingBoxData { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + static polygonIntersectsSegment(xA: number, yA: number, xB: number, yB: number, vertices: Array | Float32Array, offset: number, count: number, intersectionPointA?: { + x: number; + y: number; + } | null, intersectionPointB?: { + x: number; + y: number; + } | null, normalRadians?: { + x: number; + y: number; + } | null): number; + /** + * @private + */ + count: number; + /** + * @private + */ + offset: number; + /** + * @private + */ + x: number; + /** + * @private + */ + y: number; + /** + * 多边形顶点。 + * @version DragonBones 5.1 + * @language zh_CN + */ + vertices: Array | Float32Array; + /** + * @private + */ + weight: WeightData | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @inherDoc + */ + containsPoint(pX: number, pY: number): boolean; + /** + * @inherDoc + */ + 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; + } +} +declare namespace dragonBones { + /** + * 动画数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationData extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * @private + */ + frameIntOffset: number; + /** + * @private + */ + frameFloatOffset: number; + /** + * @private + */ + frameOffset: number; + /** + * 持续的帧数。 ([1~N]) + * @version DragonBones 3.0 + * @language zh_CN + */ + frameCount: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 持续时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + duration: number; + /** + * @private + */ + scale: number; + /** + * 淡入时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * @private + */ + cacheFrameRate: number; + /** + * 数据名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * @private + */ + readonly cachedFrames: Array; + /** + * @private + */ + readonly boneTimelines: Map>; + /** + * @private + */ + readonly slotTimelines: Map>; + /** + * @private + */ + readonly boneCachedFrameIndices: Map>; + /** + * @private + */ + readonly slotCachedFrameIndices: Map>; + /** + * @private + */ + actionTimeline: TimelineData | null; + /** + * @private + */ + zOrderTimeline: TimelineData | null; + /** + * @private + */ + parent: ArmatureData; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + cacheFrames(frameRate: number): void; + /** + * @private + */ + addBoneTimeline(bone: BoneData, timeline: TimelineData): void; + /** + * @private + */ + addSlotTimeline(slot: SlotData, timeline: TimelineData): void; + /** + * @private + */ + getBoneTimelines(name: string): Array | null; + /** + * @private + */ + getSlotTimeline(name: string): Array | null; + /** + * @private + */ + getBoneCachedFrameIndices(name: string): Array | null; + /** + * @private + */ + getSlotCachedFrameIndices(name: string): Array | null; + } + /** + * @private + */ + class TimelineData extends BaseObject { + static toString(): string; + type: TimelineType; + offset: number; + frameIndicesOffset: number; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + class AnimationConfig extends BaseObject { + static toString(): string; + /** + * 是否暂停淡出的动画。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeOut: boolean; + /** + * 淡出模式。 + * @default dragonBones.AnimationFadeOutMode.All + * @see dragonBones.AnimationFadeOutMode + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutMode: AnimationFadeOutMode; + /** + * 淡出缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTweenType: TweenType; + /** + * 淡出时间。 [-1: 与淡入时间同步, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeOutTime: number; + /** + * 否能触发行为。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 是否以增加的方式混合。 + * @default false + * @version DragonBones 5.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否暂停淡入的动画,直到淡入过程结束。 + * @default true + * @version DragonBones 5.0 + * @language zh_CN + */ + pauseFadeIn: boolean; + /** + * 是否将没有动画的对象重置为初始值。 + * @default true + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 淡入缓动方式。 + * @default TweenType.Line + * @see dragonBones.TweenType + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTweenType: TweenType; + /** + * 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + playTimes: number; + /** + * 混合图层,图层高会优先获取混合权重。 + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + layer: number; + /** + * 开始时间。 (以秒为单位) + * @default 0 + * @version DragonBones 5.0 + * @language zh_CN + */ + position: number; + /** + * 持续时间。 [-1: 使用动画数据默认值, 0: 动画停止, (0~N]: 持续时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + duration: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + fadeInTime: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * @default -1 + * @version DragonBones 5.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * 混合权重。 + * @default 1 + * @version DragonBones 5.0 + * @language zh_CN + */ + weight: number; + /** + * 动画状态名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + name: string; + /** + * 动画数据名。 + * @version DragonBones 5.0 + * @language zh_CN + */ + animation: string; + /** + * 混合组,用于动画状态编组,方便控制淡出。 + * @version DragonBones 5.0 + * @language zh_CN + */ + group: string; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly boneMask: Array; + /** + * @private + */ + protected _onClear(): void; + clear(): void; + copyFrom(value: AnimationConfig): void; + containsBoneMask(name: string): boolean; + addBoneMask(armature: Armature, name: string, recursive?: boolean): void; + removeBoneMask(armature: Armature, name: string, recursive?: boolean): void; + } +} +declare namespace dragonBones { + /** + * 贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class TextureAtlasData extends BaseObject { + /** + * 是否开启共享搜索。 + * @default false + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + width: number; + /** + * @private + */ + height: number; + /** + * 贴图集缩放系数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scale: number; + /** + * 贴图集名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 贴图集图片路径。 + * @version DragonBones 3.0 + * @language zh_CN + */ + imagePath: string; + /** + * @private + */ + readonly textures: Map; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + copyFrom(value: TextureAtlasData): void; + /** + * @private + */ + abstract createTexture(): TextureData; + /** + * @private + */ + addTexture(value: TextureData): void; + /** + * @private + */ + getTexture(name: 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; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 骨架代理接口。 + * @version DragonBones 5.0 + */ + interface IArmatureProxy extends IEventDispatcher { + /** + * @private + */ + init(armature: Armature): void; + /** + * @private + */ + clear(): void; + /** + * @language zh_CN + * 释放代理和骨架。 (骨架会回收到对象池) + * @version DragonBones 4.5 + */ + dispose(disposeProxy: boolean): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @language zh_CN + * 获取骨架。 + * @see dragonBones.Armature + * @version DragonBones 4.5 + */ + readonly armature: Armature; + /** + * @language zh_CN + * 获取动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 4.5 + */ + readonly animation: Animation; + } +} +declare namespace dragonBones { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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); + /** + * 是否继承父骨架的动画状态。 + * @default true + * @version DragonBones 4.5 + * @language zh_CN + */ + inheritAnimation: boolean; + /** + * @private + */ + debugDraw: boolean; + /** + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @readonly + * @language zh_CN + */ + armatureData: ArmatureData; + /** + * 用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + private _debugDraw; + private _lockUpdate; + private _bonesDirty; + private _slotsDirty; + private _zOrderDirty; + private _flipX; + private _flipY; + /** + * @internal + * @private + */ + _cacheFrameIndex: number; + private readonly _bones; + private readonly _slots; + private readonly _actions; + private _animation; + private _proxy; + private _display; + /** + * @private + */ + _replaceTextureAtlasData: TextureAtlasData | null; + private _replacedTexture; + /** + * @internal + * @private + */ + _dragonBones: DragonBones; + private _clock; + /** + * @internal + * @private + */ + _parent: Slot | null; + /** + * @private + */ + protected _onClear(): void; + private _sortBones(); + private _sortSlots(); + /** + * @internal + * @private + */ + _sortZOrder(slotIndices: Array | Int16Array | null, offset: number): void; + /** + * @internal + * @private + */ + _addBoneToBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _removeBoneFromBoneList(value: Bone): void; + /** + * @internal + * @private + */ + _addSlotToSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _removeSlotFromSlotList(value: Slot): void; + /** + * @internal + * @private + */ + _bufferAction(action: ActionData, append: boolean): void; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + dispose(): void; + /** + * @private + */ + init(armatureData: ArmatureData, proxy: IArmatureProxy, display: any, dragonBones: DragonBones): void; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(boneName?: string | null, updateSlotDisplay?: boolean): void; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): Slot | null; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBone(name: string): Bone | null; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBoneByDisplay(display: any): Bone | null; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlot(name: string): Slot | null; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlotByDisplay(display: any): Slot | null; + /** + * @deprecated + */ + addBone(value: Bone, parentName?: string | null): void; + /** + * @deprecated + */ + removeBone(value: Bone): void; + /** + * @deprecated + */ + addSlot(value: Slot, parentName: string): void; + /** + * @deprecated + */ + removeSlot(value: Slot): void; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + flipX: boolean; + flipY: boolean; + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + * @language zh_CN + */ + cacheFrameRate: number; + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly name: string; + /** + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly animation: Animation; + /** + * @pivate + */ + readonly proxy: IArmatureProxy; + /** + * @pivate + */ + readonly eventDispatcher: IEventDispatcher; + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly display: any; + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + replacedTexture: any; + /** + * @inheritDoc + */ + clock: WorldClock | null; + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly parent: Slot | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + replaceTexture(texture: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + hasEventListener(type: EventStringType): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + addEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + removeEventListener(type: EventStringType, listener: Function, target: any): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + enableAnimationCache(frameRate: number): void; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + } +} +declare namespace dragonBones { + /** + * 基础变换对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + abstract class TransformObject extends BaseObject { + /** + * @private + */ + protected static readonly _helpMatrix: Matrix; + /** + * @private + */ + protected static readonly _helpTransform: Transform; + /** + * @private + */ + protected static readonly _helpPoint: Point; + /** + * 对象的名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + name: string; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly globalTransformMatrix: Matrix; + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly global: Transform; + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly offset: Transform; + /** + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @readOnly + * @language zh_CN + */ + origin: Transform; + /** + * 可以用于存储临时数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + userData: any; + /** + * @private + */ + protected _globalDirty: boolean; + /** + * @private + */ + _armature: Armature; + /** + * @private + */ + _parent: Bone; + /** + * @private + */ + protected _onClear(): void; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setParent(value: Bone | null): void; + /** + * @private + */ + updateGlobalTransform(): void; + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly armature: Armature; + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly parent: Bone; + } +} +declare namespace dragonBones { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + class Bone extends TransformObject { + static toString(): string; + /** + * @private + */ + offsetMode: OffsetMode; + /** + * @internal + * @private + */ + readonly animationPose: Transform; + /** + * @internal + * @private + */ + readonly constraints: Array; + /** + * @readonly + */ + boneData: BoneData; + /** + * @internal + * @private + */ + _transformDirty: boolean; + /** + * @internal + * @private + */ + _childrenTransformDirty: boolean; + /** + * @internal + * @private + */ + _blendDirty: boolean; + private _localDirty; + private _visible; + private _cachedFrameIndex; + /** + * @internal + * @private + */ + _blendLayer: number; + /** + * @internal + * @private + */ + _blendLeftWeight: number; + /** + * @internal + * @private + */ + _blendLayerWeight: number; + private readonly _bones; + private readonly _slots; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + private _updateGlobalTransformMatrix(isCache); + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + init(boneData: BoneData): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @internal + * @private + */ + updateByConstraint(): void; + /** + * @internal + * @private + */ + addConstraint(constraint: Constraint): void; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(child: TransformObject): boolean; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getBones(): Array; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + getSlots(): Array; + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + visible: boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + readonly length: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + readonly slot: Slot | null; + } +} +declare namespace dragonBones { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class Slot extends TransformObject { + /** + * 显示对象受到控制的动画状态或混合组名称,设置为 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; + /** + * @readonly + */ + slotData: SlotData; + /** + * @private + */ + protected _displayDirty: boolean; + /** + * @private + */ + protected _zOrderDirty: boolean; + /** + * @private + */ + protected _visibleDirty: boolean; + /** + * @private + */ + protected _blendModeDirty: boolean; + /** + * @private + */ + _colorDirty: boolean; + /** + * @private + */ + _meshDirty: boolean; + /** + * @private + */ + protected _transformDirty: boolean; + /** + * @private + */ + protected _visible: boolean; + /** + * @private + */ + protected _blendMode: BlendMode; + /** + * @private + */ + protected _displayIndex: number; + /** + * @private + */ + protected _animationDisplayIndex: number; + /** + * @private + */ + _zOrder: number; + /** + * @private + */ + protected _cachedFrameIndex: number; + /** + * @private + */ + _pivotX: number; + /** + * @private + */ + _pivotY: number; + /** + * @private + */ + protected readonly _localMatrix: Matrix; + /** + * @private + */ + readonly _colorTransform: ColorTransform; + /** + * @private + */ + readonly _ffdVertices: Array; + /** + * @private + */ + readonly _displayDatas: Array; + /** + * @private + */ + protected readonly _displayList: Array; + /** + * @private + */ + protected readonly _meshBones: Array; + /** + * @internal + * @private + */ + _rawDisplayDatas: Array; + /** + * @private + */ + protected _displayData: DisplayData | null; + /** + * @private + */ + protected _textureData: TextureData | null; + /** + * @private + */ + _meshData: MeshDisplayData | null; + /** + * @private + */ + protected _boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + protected _rawDisplay: any; + /** + * @private + */ + protected _meshDisplay: any; + /** + * @private + */ + protected _display: any; + /** + * @private + */ + protected _childArmature: Armature | null; + /** + * @internal + * @private + */ + _cachedFrameIndices: Array | null; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected abstract _initDisplay(value: any): void; + /** + * @private + */ + protected abstract _disposeDisplay(value: any): void; + /** + * @private + */ + protected abstract _onUpdateDisplay(): void; + /** + * @private + */ + protected abstract _addDisplay(): void; + /** + * @private + */ + protected abstract _replaceDisplay(value: any): void; + /** + * @private + */ + protected abstract _removeDisplay(): void; + /** + * @private + */ + protected abstract _updateZOrder(): void; + /** + * @private + */ + abstract _updateVisible(): void; + /** + * @private + */ + protected abstract _updateBlendMode(): void; + /** + * @private + */ + protected abstract _updateColor(): void; + /** + * @private + */ + protected abstract _updateFrame(): void; + /** + * @private + */ + protected abstract _updateMesh(): void; + /** + * @private + */ + protected abstract _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateDisplayData(): void; + /** + * @private + */ + protected _updateDisplay(): void; + /** + * @private + */ + protected _updateGlobalTransformMatrix(isCache: boolean): void; + /** + * @private + */ + protected _isMeshBonesUpdate(): boolean; + /** + * @internal + * @private + */ + _setArmature(value: Armature | null): void; + /** + * @internal + * @private + */ + _setDisplayIndex(value: number, isAnimation?: boolean): boolean; + /** + * @internal + * @private + */ + _setZorder(value: number): boolean; + /** + * @internal + * @private + */ + _setColor(value: ColorTransform): boolean; + /** + * @private + */ + _setDisplayList(value: Array | null): boolean; + /** + * @private + */ + init(slotData: SlotData, displayDatas: Array, rawDisplay: any, meshDisplay: any): void; + /** + * @internal + * @private + */ + update(cacheFrameIndex: number): void; + /** + * @private + */ + updateTransformAndMatrix(): void; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @version DragonBones 5.0 + * @language zh_CN + */ + containsPoint(x: number, y: number): boolean; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + invalidUpdate(): void; + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + displayIndex: number; + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + displayList: Array; + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + readonly boundingBoxData: BoundingBoxData | null; + /** + * @private + */ + readonly rawDisplay: any; + /** + * @private + */ + readonly meshDisplay: any; + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + display: any; + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + childArmature: Armature | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + getDisplay(): any; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + setDisplay(value: any): void; + } +} +declare namespace dragonBones { + /** + * @private + * @internal + */ + abstract class Constraint extends BaseObject { + protected static readonly _helpMatrix: Matrix; + protected static readonly _helpTransform: Transform; + protected static readonly _helpPoint: Point; + target: Bone; + bone: Bone; + root: Bone | null; + protected _onClear(): void; + abstract update(): void; + } + /** + * @private + * @internal + */ + class IKConstraint extends Constraint { + static toString(): string; + bendPositive: boolean; + scaleEnabled: boolean; + weight: number; + protected _onClear(): void; + private _computeA(); + private _computeB(); + update(): void; + } +} +declare namespace dragonBones { + /** + * 播放动画接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 实例中,由 WorldClock 统一更新时间。 + * @see dragonBones.WorldClock + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + interface IAnimatable { + /** + * 更新时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 当前所属的 WordClock 实例。 + * @version DragonBones 5.0 + * @language zh_CN + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + class WorldClock implements IAnimatable { + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + time: number; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private readonly _animatebles; + private _clock; + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(time?: number); + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + advanceTime(passedTime: number): void; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + contains(value: IAnimatable): boolean; + /** + * 添加 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + add(value: IAnimatable): void; + /** + * 移除 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + remove(value: IAnimatable): void; + /** + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + clear(): void; + /** + * @inheritDoc + */ + clock: WorldClock | null; + } +} +declare namespace dragonBones { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + class Animation extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 播放速度。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + private _animationDirty; + /** + * @internal + * @private + */ + _timelineDirty: boolean; + private readonly _animationNames; + private readonly _animationStates; + private readonly _animations; + private _armature; + private _animationConfig; + private _lastAnimationState; + /** + * @private + */ + protected _onClear(): void; + private _fadeOut(animationConfig); + /** + * @internal + * @private + */ + init(armature: Armature): void; + /** + * @internal + * @private + */ + advanceTime(passedTime: number): void; + /** + * 清除所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + reset(): void; + /** + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(animationName?: string | null): void; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + playConfig(animationConfig: AnimationConfig): AnimationState | null; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + play(animationName?: string | null, playTimes?: number): AnimationState | null; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode): AnimationState | null; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState | null; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState | null; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState | null; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByTime(animationName: string, time?: number): AnimationState | null; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState | null; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + * @language zh_CN + */ + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState | null; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + getState(animationName: string): AnimationState | null; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + hasAnimation(animationName: string): boolean; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + getStates(): Array; + /** + * 动画是否处于播放状态。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 上一个正在播放的动画状态名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationName: string; + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly animationNames: Array; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + * @language zh_CN + */ + animations: Map; + /** + * 一个可以快速使用的动画配置实例。 + * @see dragonBones.AnimationConfig + * @version DragonBones 5.0 + * @language zh_CN + */ + readonly animationConfig: AnimationConfig; + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly lastAnimationState: AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string | null, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + gotoAndStop(animationName: string, time?: number): AnimationState | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationList: Array; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + readonly animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class BonePose extends BaseObject { + static toString(): string; + readonly current: Transform; + readonly delta: Transform; + readonly result: Transform; + protected _onClear(): void; + } + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + class AnimationState extends BaseObject { + /** + * @private + */ + static toString(): string; + /** + * 是否将骨架的骨骼和插槽重置为绑定姿势(如果骨骼和插槽在这个动画状态中没有动画)。 + * @version DragonBones 5.1 + * @language zh_CN + */ + resetToPose: boolean; + /** + * 是否以增加的方式混合。 + * @version DragonBones 3.0 + * @language zh_CN + */ + additiveBlending: boolean; + /** + * 是否对插槽的显示对象有控制权。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 + * @language zh_CN + */ + displayControl: boolean; + /** + * 是否能触发行为。 + * @version DragonBones 5.0 + * @language zh_CN + */ + actionEnabled: boolean; + /** + * 混合图层。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + layer: number; + /** + * 播放次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + * @language zh_CN + */ + playTimes: number; + /** + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @version DragonBones 3.0 + * @language zh_CN + */ + timeScale: number; + /** + * 混合权重。 + * @version DragonBones 3.0 + * @language zh_CN + */ + weight: number; + /** + * 自动淡出时间。 [-1: 不自动淡出, [0~N]: 淡出时间] (以秒为单位) + * 当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 + * @version DragonBones 3.0 + * @language zh_CN + */ + autoFadeOutTime: number; + /** + * @private + */ + fadeTotalTime: number; + /** + * 动画名称。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + name: string; + /** + * 混合组。 + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + group: string; + /** + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @readonly + * @language zh_CN + */ + animationData: AnimationData; + private _timelineDirty; + /** + * @internal + * @private + * xx: Play Enabled, Fade Play Enabled + */ + _playheadState: number; + /** + * @internal + * @private + * -1: Fade in, 0: Fade complete, 1: Fade out; + */ + _fadeState: number; + /** + * @internal + * @private + * -1: Fade start, 0: Fading, 1: Fade complete; + */ + _subFadeState: number; + /** + * @internal + * @private + */ + _position: number; + /** + * @internal + * @private + */ + _duration: number; + private _fadeTime; + private _time; + /** + * @internal + * @private + */ + _fadeProgress: number; + private _weightResult; + private readonly _boneMask; + private readonly _boneTimelines; + private readonly _slotTimelines; + private readonly _bonePoses; + private _armature; + /** + * @internal + * @private + */ + _actionTimeline: ActionTimelineState; + private _zOrderTimeline; + /** + * @private + */ + protected _onClear(): void; + private _isDisabled(slot); + private _advanceFadeTime(passedTime); + private _blendBoneTimline(timeline); + /** + * @private + * @internal + */ + init(armature: Armature, animationData: AnimationData, animationConfig: AnimationConfig): void; + /** + * @private + * @internal + */ + updateTimelines(): void; + /** + * @private + * @internal + */ + advanceTime(passedTime: number, cacheFrameRate: number): void; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + play(): void; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + stop(): void; + /** + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 + * @version DragonBones 3.0 + * @language zh_CN + */ + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + containsBoneMask(name: string): boolean; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + addBoneMask(name: string, recursive?: boolean): void; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeBoneMask(name: string, recursive?: boolean): void; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + removeAllBoneMask(): void; + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeIn: boolean; + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeOut: boolean; + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + readonly isFadeComplete: boolean; + /** + * 是否正在播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isPlaying: boolean; + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly isCompleted: boolean; + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly currentPlayTimes: number; + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + readonly totalTime: number; + /** + * 当前播放的时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + currentTime: number; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + readonly clip: AnimationData; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + const enum TweenState { + None = 0, + Once = 1, + Always = 2, + } + /** + * @internal + * @private + */ + abstract class TimelineState extends BaseObject { + playState: number; + currentPlayTimes: number; + currentTime: number; + protected _tweenState: TweenState; + protected _frameRate: number; + protected _frameValueOffset: number; + protected _frameCount: number; + protected _frameOffset: number; + protected _frameIndex: number; + protected _frameRateR: number; + protected _position: number; + protected _duration: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _dragonBonesData: DragonBonesData; + protected _animationData: AnimationData; + protected _timelineData: TimelineData | null; + protected _armature: Armature; + protected _animationState: AnimationState; + protected _actionTimeline: TimelineState; + protected _frameArray: Array | Int16Array; + protected _frameIntArray: Array | Int16Array; + protected _frameFloatArray: Array | Int16Array; + protected _timelineArray: Array | Uint16Array; + protected _frameIndices: Array; + protected _onClear(): void; + protected abstract _onArriveAtFrame(): void; + protected abstract _onUpdateFrame(): void; + protected _setCurrentTime(passedTime: number): boolean; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + abstract class TweenTimelineState extends TimelineState { + private static _getEasingValue(tweenType, progress, easing); + private static _getEasingCurveValue(progress, samples, count, offset); + protected _tweenType: TweenType; + protected _curveCount: number; + protected _framePosition: number; + protected _frameDurationR: number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + abstract class BoneTimelineState extends TweenTimelineState { + bone: Bone; + bonePose: BonePose; + protected _onClear(): void; + } + /** + * @internal + * @private + */ + abstract class SlotTimelineState extends TweenTimelineState { + slot: Slot; + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @internal + * @private + */ + class ActionTimelineState extends TimelineState { + static toString(): string; + private _onCrossFrame(frameIndex); + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + update(passedTime: number): void; + setCurrentTime(value: number): void; + } + /** + * @internal + * @private + */ + class ZOrderTimelineState extends TimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + } + /** + * @internal + * @private + */ + class BoneAllTimelineState extends BoneTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + } + /** + * @internal + * @private + */ + class SlotDislayIndexTimelineState extends SlotTimelineState { + static toString(): string; + protected _onArriveAtFrame(): void; + } + /** + * @internal + * @private + */ + class SlotColorTimelineState extends SlotTimelineState { + static toString(): string; + private _dirty; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + fadeOut(): void; + update(passedTime: number): void; + } + /** + * @internal + * @private + */ + class SlotFFDTimelineState extends SlotTimelineState { + static toString(): string; + meshOffset: number; + private _dirty; + private _frameFloatOffset; + private _valueCount; + private _ffdCount; + private _valueOffset; + private readonly _current; + private readonly _delta; + private readonly _result; + protected _onClear(): void; + protected _onArriveAtFrame(): void; + protected _onUpdateFrame(): void; + init(armature: Armature, animationState: AnimationState, timelineData: TimelineData | null): void; + fadeOut(): void; + update(passedTime: number): void; + } +} +declare namespace dragonBones { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + class EventObject extends BaseObject { + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly START: string; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly LOOP_COMPLETE: string; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly COMPLETE: string; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN: string; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_IN_COMPLETE: string; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT: string; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FADE_OUT_COMPLETE: string; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly FRAME_EVENT: string; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + static readonly SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + time: number; + /** + * 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + type: EventStringType; + /** + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 + * @language zh_CN + */ + name: string; + /** + * 发出事件的骨架。 + * @version DragonBones 4.5 + * @language zh_CN + */ + armature: Armature; + /** + * 发出事件的骨骼。 + * @version DragonBones 4.5 + * @language zh_CN + */ + bone: Bone | null; + /** + * 发出事件的插槽。 + * @version DragonBones 4.5 + * @language zh_CN + */ + slot: Slot | null; + /** + * 发出事件的动画状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + animationState: AnimationState; + /** + * 自定义数据 + * @see dragonBones.CustomData + * @version DragonBones 5.0 + * @language zh_CN + */ + data: UserData | null; + /** + * @private + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | "start" | "loopComplete" | "complete" | "fadeIn" | "fadeInComplete" | "fadeOut" | "fadeOutComplete" | "frameEvent" | "soundEvent"; + /** + * 事件接口。 + * @version DragonBones 4.5 + * @language zh_CN + */ + interface IEventDispatcher { + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @version DragonBones 4.5 + * @language zh_CN + */ + hasEvent(type: EventStringType): boolean; + /** + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + addEvent(type: EventStringType, listener: Function, target: any): void; + /** + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 + * @language zh_CN + */ + removeEvent(type: EventStringType, listener: Function, target: any): void; + } +} +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: 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 BONE: string; + protected static readonly IK: string; + protected static readonly SLOT: string; + protected static readonly SKIN: string; + protected static readonly DISPLAY: string; + protected static readonly ANIMATION: string; + protected static readonly Z_ORDER: string; + protected static readonly FFD: string; + protected static readonly FRAME: string; + protected static readonly TRANSLATE_FRAME: string; + protected static readonly ROTATE_FRAME: string; + protected static readonly SCALE_FRAME: string; + protected static readonly VISIBLE_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 CANVAS: 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 SHARE: string; + protected static readonly PATH: string; + protected static readonly LENGTH: string; + protected static readonly DISPLAY_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_FFD: string; + protected static readonly BEND_POSITIVE: string; + protected static readonly CHAIN: string; + protected static readonly WEIGHT: 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_TYPE: string; + protected static readonly TWEEN_EASING: string; + protected static readonly TWEEN_ROTATE: string; + protected static readonly TWEEN_SCALE: 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_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 GOTO_AND_PLAY: string; + protected static readonly DEFAULT_NAME: string; + protected static _getArmatureType(value: string): ArmatureType; + protected static _getDisplayType(value: string): DisplayType; + protected static _getBoundingBoxType(value: string): BoundingBoxType; + protected static _getActionType(value: string): ActionType; + protected static _getBlendMode(value: string): BlendMode; + /** + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData | null; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): boolean; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData | null; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + private _intArrayJson; + private _floatArrayJson; + private _frameIntArrayJson; + private _frameFloatArrayJson; + private _frameArrayJson; + private _timelineArrayJson; + private _intArrayBuffer; + private _floatArrayBuffer; + private _frameIntArrayBuffer; + private _frameFloatArrayBuffer; + private _frameArrayBuffer; + private _timelineArrayBuffer; + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + 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 _slot: SlotData; + protected _skin: SkinData; + protected _mesh: MeshDisplayData; + protected _animation: AnimationData; + protected _timeline: TimelineData; + protected _rawTextureAtlases: Array | null; + private _defalultColorOffset; + private _prevTweenRotate; + private _prevRotation; + private readonly _helpMatrixA; + private readonly _helpMatrixB; + private readonly _helpTransform; + private readonly _helpColorTransform; + private readonly _helpPoint; + private readonly _helpArray; + private readonly _actionFrames; + private readonly _weightSlotPose; + private readonly _weightBonePoses; + private readonly _weightBoneIndices; + private readonly _cacheBones; + private readonly _meshs; + private readonly _slotChildActions; + /** + * @private + */ + private _getCurvePoint(x1, y1, x2, y2, x3, y3, x4, y4, t, result); + /** + * @private + */ + private _samplingEasingCurve(curve, samples); + private _sortActionFrame(a, b); + private _parseActionDataInFrame(rawData, frameStart, bone, slot); + private _mergeActionFrame(rawData, frameStart, type, bone, slot); + private _parseCacheActionFrame(frame); + /** + * @private + */ + protected _parseArmature(rawData: any, scale: number): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIKConstraint(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData | null; + /** + * @private + */ + protected _parsePivot(rawData: any, display: ImageDisplayData): void; + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parseBoundingBox(rawData: any): BoundingBoxData | null; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseTimeline(rawData: any, type: TimelineType, addIntOffset: boolean, addFloatOffset: boolean, frameValueCount: number, frameParser: (rawData: any, frameStart: number, frameCount: number) => number): TimelineData | null; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): void; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): void; + /** + * @private + */ + protected _parseFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseTweenFrame(rawData: any, frameStart: number, frameCount: number, frameArray: Array): number; + /** + * @private + */ + protected _parseZOrderFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseBoneFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotDisplayIndexFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotColorFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseSlotFFDFrame(rawData: any, frameStart: number, frameCount: number): number; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, type: ActionType, bone: BoneData | null, slot: SlotData | null): number; + /** + * @private + */ + protected _parseTransform(rawData: any, transform: Transform, scale: number): void; + /** + * @private + */ + protected _parseColorTransform(rawData: any, color: ColorTransform): void; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @private + */ + protected _parseWASMArray(): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): boolean; + /** + * @private + */ + private static _objectDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BinaryDataParser extends ObjectDataParser { + private _binary; + private _binaryOffset; + private _intArray; + private _floatArray; + private _frameIntArray; + private _frameFloatArray; + private _frameArray; + private _timelineArray; + private _inRange(a, min, max); + private _decodeUTF8(data); + private _getUTF16Key(value); + private _parseBinaryTimeline(type, offset, timelineData?); + /** + * @private + */ + protected _parseMesh(rawData: any, mesh: MeshDisplayData): void; + /** + * @private + */ + protected _parsePolygonBoundingBox(rawData: any): PolygonBoundingBoxData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseArray(rawData: any): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData | null; + /** + * @private + */ + private static _binaryDataParserInstance; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): BinaryDataParser; + } +} +declare namespace dragonBones { + /** + * @private + */ + class BuildArmaturePackage { + dataName: string; + textureAtlasName: string; + data: DragonBonesData; + armature: ArmatureData; + skin: SkinData | null; + } + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + abstract class BaseFactory { + /** + * @private + */ + protected static _objectParser: ObjectDataParser; + /** + * @private + */ + protected static _binaryParser: BinaryDataParser; + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + autoSearch: boolean; + /** + * @private + */ + protected readonly _dragonBonesDataMap: Map; + /** + * @private + */ + protected readonly _textureAtlasDataMap: Map>; + /** + * @private + */ + protected _dragonBones: DragonBones; + /** + * @private + */ + protected _dataParser: DataParser; + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _isSupportMesh(): boolean; + /** + * @private + */ + protected _getTextureData(textureAtlasName: string, textureName: string): TextureData | null; + /** + * @private + */ + protected _fillBuildArmaturePackage(dataPackage: BuildArmaturePackage, dragonBonesName: string, armatureName: string, skinName: string, textureAtlasName: string): boolean; + /** + * @private + */ + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + /** + * @private + */ + protected _getSlotDisplay(dataPackage: BuildArmaturePackage | null, displayData: DisplayData, rawDisplayData: DisplayData | null, slot: Slot): any; + /** + * @private + */ + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData | null, slot: Slot, displayIndex: number): void; + /** + * @private + */ + protected abstract _buildTextureAtlasData(textureAtlasData: TextureAtlasData | null, textureAtlas: any): TextureAtlasData; + /** + * @private + */ + protected abstract _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected abstract _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + updateTextureAtlasData(name: string, textureAtlases: Array): void; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + getDragonBonesData(name: string): DragonBonesData | null; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeDragonBonesData(name: string, disposeData?: boolean): void; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureAtlasData(name: string): Array | null; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 3.0 + * @language zh_CN + */ + removeTextureAtlasData(name: string, disposeData?: boolean): void; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 5.1 + * @language zh_CN + */ + getArmatureData(name: string, dragonBonesName?: string): ArmatureData | null; + /** + * 清除所有的数据。 + * @param disposeData 是否释放数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + clear(disposeData?: boolean): void; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + buildArmature(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): Armature | null; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplay(dragonBonesName: string | null, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + replaceSlotDisplayList(dragonBonesName: string | null, armatureName: string, slotName: string, slot: Slot): void; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + changeSkin(armature: Armature, skin: SkinData, exclude?: Array | null): void; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string | null, fromDragonBonesDataName?: string | null, replaceOriginalAnimation?: boolean): boolean; + /** + * @private + */ + getAllDragonBonesData(): Map; + /** + * @private + */ + getAllTextureAtlasData(): Map>; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * Pixi 贴图集数据。 + * @version DragonBones 3.0 + */ + class PixiTextureAtlasData extends TextureAtlasData { + static toString(): string; + private _renderTexture; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + createTexture(): TextureData; + /** + * Pixi 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + renderTexture: PIXI.BaseTexture | null; + } + /** + * @private + */ + class PixiTextureData extends TextureData { + static toString(): string; + renderTexture: PIXI.Texture | null; + constructor(); + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @inheritDoc + */ + class PixiArmatureDisplay extends PIXI.Container implements IArmatureProxy { + private _disposeProxy; + private _armature; + private _debugDrawer; + /** + * @inheritDoc + */ + init(armature: Armature): void; + /** + * @inheritDoc + */ + clear(): void; + /** + * @inheritDoc + */ + dispose(disposeProxy?: boolean): void; + /** + * @inheritDoc + */ + destroy(): void; + /** + * @private + */ + debugUpdate(isEnabled: boolean): void; + /** + * @private + */ + _dispatchEvent(type: EventStringType, eventObject: EventObject): void; + /** + * @inheritDoc + */ + hasEvent(type: EventStringType): boolean; + /** + * @inheritDoc + */ + addEvent(type: EventStringType, listener: (event: EventObject) => void, target: any): void; + /** + * @inheritDoc + */ + removeEvent(type: EventStringType, listener: (event: EventObject) => void, target: any): void; + /** + * @inheritDoc + */ + readonly armature: Armature; + /** + * @inheritDoc + */ + readonly animation: Animation; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.PixiFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + advanceTimeBySelf(on: boolean): void; + } +} +declare namespace dragonBones { + /** + * Pixi 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class PixiSlot extends Slot { + static toString(): string; + private _renderDisplay; + /** + * @private + */ + protected _onClear(): void; + /** + * @private + */ + protected _initDisplay(value: any): void; + /** + * @private + */ + protected _disposeDisplay(value: any): void; + /** + * @private + */ + protected _onUpdateDisplay(): void; + /** + * @private + */ + protected _addDisplay(): void; + /** + * @private + */ + protected _replaceDisplay(value: any): void; + /** + * @private + */ + protected _removeDisplay(): void; + /** + * @private + */ + protected _updateZOrder(): void; + /** + * @internal + * @private + */ + _updateVisible(): void; + /** + * @private + */ + protected _updateBlendMode(): void; + /** + * @private + */ + protected _updateColor(): void; + /** + * @private + */ + protected _updateFrame(): void; + /** + * @private + */ + protected _updateMesh(): void; + /** + * @private + */ + protected _updateTransform(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateTransformV3(isSkinnedMesh: boolean): void; + /** + * @private + */ + protected _updateTransformV4(isSkinnedMesh: boolean): void; + } +} +declare namespace dragonBones { + /** + * Pixi 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + class PixiFactory extends BaseFactory { + private static _dragonBonesInstance; + private static _factory; + private static _clockHandler(passedTime); + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + static readonly clock: WorldClock; + /** + * @language zh_CN + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + */ + static readonly factory: PixiFactory; + /** + * @inheritDoc + */ + constructor(dataParser?: DataParser | null); + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: PixiTextureAtlasData | null, textureAtlas: PIXI.BaseTexture | null): PixiTextureAtlasData; + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature; + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + buildArmatureDisplay(armatureName: string, dragonBonesName?: string | null, skinName?: string | null, textureAtlasName?: string | null): PixiArmatureDisplay | null; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + getTextureDisplay(textureName: string, textureAtlasName?: string | null): PIXI.Sprite | null; + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + readonly soundEventManager: PixiArmatureDisplay; + } +} diff --git a/reference/Pixi/4.x/out/dragonBones.js b/reference/Pixi/4.x/out/dragonBones.js new file mode 100644 index 0000000..ab9dd0c --- /dev/null +++ b/reference/Pixi/4.x/out/dragonBones.js @@ -0,0 +1,11273 @@ +"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 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; + } + 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; + armature.eventDispatcher._dispatchEvent(eventObject.type, eventObject); + if (eventObject.type === dragonBones.EventObject.SOUND_EVENT) { + this._eventManager._dispatchEvent(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.yDown = true; + DragonBones.debug = false; + DragonBones.debugDraw = false; + DragonBones.webAssembly = false; + DragonBones.VERSION = "5.1.0"; + return DragonBones; + }()); + dragonBones.DragonBones = DragonBones; + if (!console.warn) { + console.warn = function () { }; + } + if (!console.assert) { + console.assert = function () { }; + } +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var BaseObject = (function () { + function BaseObject() { + /** + * 对象的唯一标识。 + * @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._defaultMaxCount : BaseObject._maxCountMap[classType]; + var pool = BaseObject._poolsMap[classType] = BaseObject._poolsMap[classType] || []; + if (pool.length < maxCount) { + if (!object._isInPool) { + object._isInPool = true; + pool.push(object); + } + else { + console.assert(false, "The object is already in the pool."); + } + } + else { + } + }; + /** + * @private + */ + BaseObject.toString = function () { + throw new Error(); + }; + /** + * 设置每种对象池的最大缓存数量。 + * @param objectConstructor 对象类。 + * @param maxCount 最大缓存数量。 (设置为 0 则不缓存) + * @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) { + if (classType in BaseObject._maxCountMap) { + continue; + } + var pool = BaseObject._poolsMap[classType]; + if (pool.length > maxCount) { + pool.length = maxCount; + } + BaseObject._maxCountMap[classType] = maxCount; + } + } + }; + /** + * 清除对象池缓存的对象。 + * @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; + } + } + }; + /** + * 从对象池中创建指定对象。 + * @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; + }; + /** + * 清除数据并返还对象池。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseObject.prototype.returnToPool = function () { + this._onClear(); + BaseObject._returnObject(this); + }; + BaseObject._hashCode = 0; + BaseObject._defaultMaxCount = 1000; + BaseObject._maxCountMap = {}; + BaseObject._poolsMap = {}; + return BaseObject; + }()); + dragonBones.BaseObject = BaseObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Matrix = (function () { + 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; + } + /** + * @private + */ + 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; + }; + /** + * 转换为单位矩阵。 + * @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; + }; + /** + * 将当前矩阵与另一个矩阵相乘。 + * @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; + }; + /** + * 转换为逆矩阵。 + * @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; + }; + /** + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params 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; + } + }; + return Matrix; + }()); + dragonBones.Matrix = Matrix; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 2D 变换。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var Transform = (function () { + function Transform( + /** + * 水平位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + x, + /** + * 垂直位移。 + * @version DragonBones 3.0 + * @language zh_CN + */ + y, + /** + * 倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + skew, + /** + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + rotation, + /** + * 水平缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + scaleX, + /** + * 垂直缩放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * 矩阵转换为变换。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + 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; + }; + /** + * 转换为矩阵。 + * @param matrix 矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Transform.prototype.toMatrix = function (matrix) { + if (this.skew !== 0.0 || this.rotation !== 0.0) { + 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; + } + } + else { + matrix.a = this.scaleX; + matrix.b = 0.0; + matrix.c = 0.0; + matrix.d = this.scaleY; + } + matrix.tx = this.x; + matrix.ty = this.y; + return this; + }; + /** + * @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 = {})); +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 = {})); +var dragonBones; +(function (dragonBones) { + var Point = (function () { + function Point(x, y) { + if (x === void 0) { x = 0.0; } + if (y === void 0) { y = 0.0; } + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function () { + this.x = this.y = 0.0; + }; + return Point; + }()); + dragonBones.Point = Point; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + var Rectangle = (function () { + 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; + } + Rectangle.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function () { + this.x = this.y = 0.0; + this.width = this.height = 0.0; + }; + return Rectangle; + }()); + dragonBones.Rectangle = Rectangle; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 自定义数据。 + * @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; + /** + * 自定义整数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.ints = []; + /** + * 自定义浮点数。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.floats = []; + /** + * 自定义字符串。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.strings = []; + return _this; + } + /** + * @private + */ + UserData.toString = function () { + return "[class dragonBones.UserData]"; + }; + /** + * @private + */ + UserData.prototype._onClear = function () { + this.ints.length = 0; + this.floats.length = 0; + this.strings.length = 0; + }; + /** + * 获取自定义整数。 + * @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; + }; + /** + * 获取自定义浮点数。 + * @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; + }; + /** + * 获取自定义字符串。 + * @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 = {})); +var dragonBones; +(function (dragonBones) { + /** + * 龙骨数据。 + * 一个龙骨数据包含多个骨架数据。 + * @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; + /** + * @private + */ + _this.frameIndices = []; + /** + * @private + */ + _this.cachedFrames = []; + /** + * 所有骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatureNames = []; + /** + * 所有骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.armatures = {}; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + DragonBonesData.toString = function () { + return "[class dragonBones.DragonBonesData]"; + }; + /** + * @private + */ + 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.frameIndices.length = 0; + this.cachedFrames.length = 0; + this.armatureNames.length = 0; + //this.armatures.clear(); + this.intArray = null; // + this.floatArray = null; // + this.frameIntArray = null; // + this.frameFloatArray = null; // + this.frameArray = null; // + this.timelineArray = null; // + this.userData = null; + }; + /** + * @private + */ + DragonBonesData.prototype.addArmature = function (value) { + if (value.name in this.armatures) { + console.warn("Replace armature: " + value.name); + this.armatures[value.name].returnToPool(); + } + value.parent = this; + this.armatures[value.name] = value; + this.armatureNames.push(value.name); + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + * @language zh_CN + */ + DragonBonesData.prototype.getArmature = function (name) { + return name in this.armatures ? this.armatures[name] : null; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + DragonBonesData.prototype.dispose = function () { + console.warn("已废弃,请参考 @see"); + this.returnToPool(); + }; + return DragonBonesData; + }(dragonBones.BaseObject)); + dragonBones.DragonBonesData = DragonBonesData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var CanvasData = (function (_super) { + __extends(CanvasData, _super); + function CanvasData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + CanvasData.toString = function () { + return "[class dragonBones.CanvasData]"; + }; + /** + * @private + */ + 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; + /** + * 骨架数据。 + * @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(); + /** + * 所有动画数据名称。 + * @see #armatures + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animationNames = []; + /** + * @private + */ + _this.sortedBones = []; + /** + * @private + */ + _this.sortedSlots = []; + /** + * @private + */ + _this.defaultActions = []; + /** + * @private + */ + _this.actions = []; + /** + * 所有骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.bones = {}; + /** + * 所有插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.slots = {}; + /** + * 所有皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.skins = {}; + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.animations = {}; + /** + * @private + */ + _this.canvas = null; // Initial value. + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + /** + * @private + */ + 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.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.skins.clear(); + //this.animations.clear(); + this.defaultSkin = null; + this.defaultAnimation = null; + this.canvas = null; + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + 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; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this.sortedBones.indexOf(constraint.target) < 0) { + flag = true; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this.sortedBones.indexOf(bone.parent) < 0) { + continue; + } + this.sortedBones.push(bone); + count++; + } + }; + /** + * @private + */ + 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); + } + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ArmatureData.prototype.addBone = function (value) { + if (value.name in this.bones) { + console.warn("Replace bone: " + value.name); + this.bones[value.name].returnToPool(); + } + this.bones[value.name] = value; + this.sortedBones.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSlot = function (value) { + if (value.name in this.slots) { + console.warn("Replace slot: " + value.name); + this.slots[value.name].returnToPool(); + } + this.slots[value.name] = value; + this.sortedSlots.push(value); + }; + /** + * @private + */ + ArmatureData.prototype.addSkin = function (value) { + if (value.name in this.skins) { + console.warn("Replace skin: " + value.name); + this.skins[value.name].returnToPool(); + } + this.skins[value.name] = value; + if (this.defaultSkin === null) { + this.defaultSkin = value; + } + }; + /** + * @private + */ + ArmatureData.prototype.addAnimation = function (value) { + if (value.name in this.animations) { + console.warn("Replace animation: " + value.name); + this.animations[value.name].returnToPool(); + } + value.parent = this; + this.animations[value.name] = value; + this.animationNames.push(value.name); + if (this.defaultAnimation === null) { + this.defaultAnimation = value; + } + }; + /** + * 获取骨骼数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.BoneData + * @language zh_CN + */ + ArmatureData.prototype.getBone = function (name) { + return name in this.bones ? this.bones[name] : null; + }; + /** + * 获取插槽数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SlotData + * @language zh_CN + */ + ArmatureData.prototype.getSlot = function (name) { + return name in this.slots ? this.slots[name] : null; + }; + /** + * 获取皮肤数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.SkinData + * @language zh_CN + */ + ArmatureData.prototype.getSkin = function (name) { + return name in this.skins ? this.skins[name] : null; + }; + /** + * 获取动画数据。 + * @param name 数据名称。 + * @version DragonBones 3.0 + * @see dragonBones.AnimationData + * @language zh_CN + */ + ArmatureData.prototype.getAnimation = function (name) { + return name in this.animations ? this.animations[name] : null; + }; + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * 骨骼数据。 + * @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.constraints = []; + /** + * @private + */ + _this.userData = null; // Initial value. + return _this; + } + /** + * @private + */ + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; + }; + /** + * @private + */ + BoneData.prototype._onClear = function () { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.inheritReflection = false; + this.length = 0.0; + this.name = ""; + this.transform.identity(); + this.constraints.length = 0; + this.userData = null; + this.parent = null; + }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * 插槽数据。 + * @see dragonBones.Slot + * @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; + } + /** + * @private + */ + SlotData.createColor = function () { + return new dragonBones.ColorTransform(); + }; + /** + * @private + */ + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; + }; + /** + * @private + */ + SlotData.prototype._onClear = function () { + if (this.userData !== null) { + this.userData.returnToPool(); + } + this.blendMode = 0 /* Normal */; + this.displayIndex = 0; + this.zOrder = 0; + this.name = ""; + this.color = null; // + this.userData = null; + this.parent = null; // + }; + /** + * @private + */ + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; + /** + * 皮肤数据。(通常一个骨架数据至少包含一个皮肤数据) + * @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]"; + }; + /** + * @private + */ + 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(); + }; + /** + * @private + */ + SkinData.prototype.addDisplay = function (slotName, value) { + if (!(slotName in this.displays)) { + this.displays[slotName] = []; + } + 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 = {})); +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.target = null; // + this.bone = null; // + this.root = null; + }; + return ConstraintData; + }(dragonBones.BaseObject)); + dragonBones.ConstraintData = ConstraintData; + /** + * @private + */ + 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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + return IKConstraintData; + }(ConstraintData)); + dragonBones.IKConstraintData = IKConstraintData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @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; + }; + 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.weight = null; // Initial value. + return _this; + } + MeshDisplayData.toString = function () { + return "[class dragonBones.MeshDisplayData]"; + }; + MeshDisplayData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Mesh */; + this.inheritAnimation = false; + this.offset = 0; + this.weight = null; + }; + return MeshDisplayData; + }(ImageDisplayData)); + 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 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; + }; + return WeightData; + }(dragonBones.BaseObject)); + dragonBones.WeightData = WeightData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 边界框数据基类。 + * @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; + } + /** + * @private + */ + BoundingBoxData.prototype._onClear = function () { + this.color = 0x000000; + this.width = 0.0; + this.height = 0.0; + }; + return BoundingBoxData; + }(dragonBones.BaseObject)); + dragonBones.BoundingBoxData = BoundingBoxData; + /** + * 矩形边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var RectangleBoundingBoxData = (function (_super) { + __extends(RectangleBoundingBoxData, _super); + function RectangleBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + RectangleBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* Rectangle */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 椭圆边界框。 + * @version DragonBones 5.1 + * @language zh_CN + */ + var EllipseBoundingBoxData = (function (_super) { + __extends(EllipseBoundingBoxData, _super); + function EllipseBoundingBoxData() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + 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; + }; + /** + * @private + */ + EllipseBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 1 /* Ellipse */; + }; + /** + * @inherDoc + */ + 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; + }; + /** + * @inherDoc + */ + 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; + /** + * 多边形边界框。 + * @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; + /** + * @private + */ + _this.weight = null; // Initial value. + return _this; + } + /** + * @private + */ + PolygonBoundingBoxData.toString = function () { + return "[class dragonBones.PolygonBoundingBoxData]"; + }; + /** + * @private + */ + PolygonBoundingBoxData.polygonIntersectsSegment = function (xA, yA, xB, yB, vertices, offset, count, 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 dXAB = xA - xB; + var dYAB = yA - yB; + var llAB = xA * yB - yA * xB; + var intersectionCount = 0; + var xC = vertices[offset + count - 2]; + var yC = vertices[offset + 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[offset + i]; + var yD = vertices[offset + 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; + }; + /** + * @private + */ + PolygonBoundingBoxData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.weight !== null) { + this.weight.returnToPool(); + } + this.type = 2 /* Polygon */; + this.count = 0; + this.offset = 0; + this.x = 0.0; + this.y = 0.0; + this.vertices = null; // + this.weight = null; + }; + /** + * @inherDoc + */ + 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.count, iP = l - 2; i < l; i += 2) { + var yA = this.vertices[this.offset + iP + 1]; + var yB = this.vertices[this.offset + i + 1]; + if ((yB < pY && yA >= pY) || (yA < pY && yB >= pY)) { + var xA = this.vertices[this.offset + iP]; + var xB = this.vertices[this.offset + i]; + if ((pY - yB) * (xA - xB) / (yA - yB) + xB < pX) { + isInSide = !isInSide; + } + } + iP = i; + } + } + return isInSide; + }; + /** + * @inherDoc + */ + 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.width, this.height, null, null, null) !== 0) { + intersectionCount = PolygonBoundingBoxData.polygonIntersectsSegment(xA, yA, xB, yB, this.vertices, this.offset, this.count, intersectionPointA, intersectionPointB, normalRadians); + } + return intersectionCount; + }; + return PolygonBoundingBoxData; + }(BoundingBoxData)); + dragonBones.PolygonBoundingBoxData = PolygonBoundingBoxData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画数据。 + * @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.boneCachedFrameIndices = {}; + /** + * @private + */ + _this.slotCachedFrameIndices = {}; + /** + * @private + */ + _this.actionTimeline = null; // Initial value. + /** + * @private + */ + _this.zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; + /** + * @private + */ + AnimationData.prototype._onClear = function () { + for (var k in this.boneTimelines) { + for (var kA in this.boneTimelines[k]) { + this.boneTimelines[k][kA].returnToPool(); + } + delete this.boneTimelines[k]; + } + for (var k in this.slotTimelines) { + for (var kA in this.slotTimelines[k]) { + this.slotTimelines[k][kA].returnToPool(); + } + delete this.slotTimelines[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.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.boneCachedFrameIndices.clear(); + //this.slotCachedFrameIndices.clear(); + this.actionTimeline = null; + this.zOrderTimeline = null; + this.parent = null; // + }; + /** + * @private + */ + 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 (bone, timeline) { + var timelines = bone.name in this.boneTimelines ? this.boneTimelines[bone.name] : (this.boneTimelines[bone.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (slot, timeline) { + var timelines = slot.name in this.slotTimelines ? this.slotTimelines[slot.name] : (this.slotTimelines[slot.name] = []); + if (timelines.indexOf(timeline) < 0) { + timelines.push(timeline); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimelines = function (name) { + return name in this.boneTimelines ? this.boneTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimeline = function (name) { + return name in this.slotTimelines ? this.slotTimelines[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getBoneCachedFrameIndices = function (name) { + return name in this.boneCachedFrameIndices ? this.boneCachedFrameIndices[name] : null; + }; + /** + * @private + */ + AnimationData.prototype.getSlotCachedFrameIndices = function (name) { + return name in this.slotCachedFrameIndices ? this.slotCachedFrameIndices[name] : 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; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画配置,描述播放一个动画所需要的全部信息。 + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @language zh_CN + */ + var AnimationConfig = (function (_super) { + __extends(AnimationConfig, _super); + function AnimationConfig() { + var _this = _super !== null && _super.apply(this, arguments) || this; + /** + * 骨骼遮罩。 + * @version DragonBones 5.0 + * @language zh_CN + */ + _this.boneMask = []; + return _this; + } + AnimationConfig.toString = function () { + return "[class dragonBones.AnimationConfig]"; + }; + /** + * @private + */ + AnimationConfig.prototype._onClear = function () { + this.pauseFadeOut = true; + this.fadeOutMode = 4 /* All */; + this.fadeOutTweenType = 1 /* Line */; + this.fadeOutTime = -1.0; + this.actionEnabled = true; + this.additiveBlending = 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.fadeInTime = -1.0; + this.autoFadeOutTime = -1.0; + this.weight = 1.0; + this.name = ""; + this.animation = ""; + this.group = ""; + this.boneMask.length = 0; + }; + AnimationConfig.prototype.clear = function () { + this._onClear(); + }; + 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.additiveBlending = value.additiveBlending; + 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]; + } + }; + AnimationConfig.prototype.containsBoneMask = function (name) { + return this.boneMask.length === 0 || this.boneMask.indexOf(name) >= 0; + }; + AnimationConfig.prototype.addBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = armature.getBone(name); + if (currentBone === null) { + return; + } + if (this.boneMask.indexOf(name) < 0) { + this.boneMask.push(name); + } + if (recursive) { + for (var _i = 0, _a = 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); + } + } + } + }; + AnimationConfig.prototype.removeBoneMask = function (armature, name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this.boneMask.indexOf(name); + if (index >= 0) { + this.boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = armature.getBone(name); + if (currentBone !== null) { + if (this.boneMask.length > 0) { + for (var _i = 0, _a = armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_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 _b = 0, _c = armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + if (bone === currentBone) { + continue; + } + if (!currentBone.contains(bone)) { + this.boneMask.push(bone.name); + } + } + } + } + } + }; + return AnimationConfig; + }(dragonBones.BaseObject)); + dragonBones.AnimationConfig = AnimationConfig; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 贴图集数据。 + * @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; + } + /** + * @private + */ + 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; + } + }; + /** + * @private + */ + TextureAtlasData.prototype.addTexture = function (value) { + if (value.name in this.textures) { + console.warn("Replace texture: " + value.name); + this.textures[value.name].returnToPool(); + } + value.parent = this; + this.textures[value.name] = value; + }; + /** + * @private + */ + TextureAtlasData.prototype.getTexture = function (name) { + return name in this.textures ? this.textures[name] : 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 = {})); +var dragonBones; +(function (dragonBones_1) { + /** + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @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 = []; + _this._actions = []; + _this._animation = null; // Initial value. + _this._proxy = null; // Initial value. + /** + * @private + */ + _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._zOrder > b._zOrder ? 1 : -1; + }; + /** + * @private + */ + 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._actions; _d < _e.length; _d++) { + var action = _e[_d]; + action.returnToPool(); + } + if (this._animation !== null) { + this._animation.returnToPool(); + } + if (this._proxy !== null) { + this._proxy.clear(); + } + if (this._replaceTextureAtlasData !== null) { + this._replaceTextureAtlasData.returnToPool(); + } + this.inheritAnimation = true; + this.debugDraw = false; + this.armatureData = null; // + this.userData = null; + this._debugDraw = false; + this._lockUpdate = false; + this._bonesDirty = false; + this._slotsDirty = false; + this._zOrderDirty = false; + this._flipX = false; + this._flipY = false; + this._cacheFrameIndex = -1; + this._bones.length = 0; + this._slots.length = 0; + this._actions.length = 0; + this._animation = null; // + this._proxy = null; // + this._display = null; + this._replaceTextureAtlasData = null; + this._replacedTexture = null; + this._dragonBones = null; // + this._clock = null; + this._parent = null; + }; + Armature.prototype._sortBones = function () { + var total = this._bones.length; + if (total <= 0) { + return; + } + var sortHelper = this._bones.concat(); + var index = 0; + var count = 0; + this._bones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this._bones.indexOf(bone) >= 0) { + continue; + } + if (bone.constraints.length > 0) { + var flag = false; + for (var _i = 0, _a = bone.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + if (this._bones.indexOf(constraint.target) < 0) { + flag = true; + break; + } + } + if (flag) { + continue; + } + } + if (bone.parent !== null && this._bones.indexOf(bone.parent) < 0) { + continue; + } + this._bones.push(bone); + count++; + } + }; + Armature.prototype._sortSlots = function () { + this._slots.sort(Armature._onSortSlots); + }; + /** + * @internal + * @private + */ + 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 + * @private + */ + Armature.prototype._addBoneToBoneList = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeBoneFromBoneList = function (value) { + var index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._addSlotToSlotList = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots.push(value); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._removeSlotFromSlotList = function (value) { + var index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineDirty = true; + } + }; + /** + * @internal + * @private + */ + Armature.prototype._bufferAction = function (action, append) { + if (this._actions.indexOf(action) < 0) { + if (append) { + this._actions.push(action); + } + else { + this._actions.unshift(action); + } + } + }; + /** + * 释放骨架。 (回收到对象池) + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.dispose = function () { + if (this.armatureData !== null) { + this._lockUpdate = true; + this._dragonBones.bufferObject(this); + } + }; + /** + * @private + */ + 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.init(this); + this._animation.init(this); + this._animation.animations = this.armatureData.animations; + }; + /** + * 更新骨架和动画。 + * @param passedTime 两帧之间的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.advanceTime = function (passedTime) { + if (this._lockUpdate) { + return; + } + if (this.armatureData === null) { + console.assert(false, "The armature has been disposed."); + return; + } + else if (this.armatureData.parent === null) { + console.assert(false, "The armature data has been disposed."); + return; + } + var prevCacheFrameIndex = this._cacheFrameIndex; + // Update nimation. + this._animation.advanceTime(passedTime); + // Sort bones and slots. + if (this._bonesDirty) { + this._bonesDirty = false; + this._sortBones(); + } + if (this._slotsDirty) { + this._slotsDirty = false; + this._sortSlots(); + } + // 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); + } + } + if (this._actions.length > 0) { + this._lockUpdate = true; + for (var _i = 0, _a = this._actions; _i < _a.length; _i++) { + var action = _a[_i]; + if (action.type === 0 /* Play */) { + this._animation.fadeIn(action.name); + } + } + this._actions.length = 0; + this._lockUpdate = false; + } + // + var drawed = this.debugDraw || dragonBones_1.DragonBones.debugDraw; + if (drawed || this._debugDraw) { + this._debugDraw = drawed; + this._proxy.debugUpdate(this._debugDraw); + } + }; + /** + * 更新骨骼和插槽。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName !== null && boneName.length > 0) { + var bone = this.getBone(boneName); + if (bone !== null) { + bone.invalidUpdate(); + if (updateSlotDisplay) { + 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 (updateSlotDisplay) { + for (var _d = 0, _e = this._slots; _d < _e.length; _d++) { + var slot = _e[_d]; + slot.invalidUpdate(); + } + } + } + }; + /** + * 判断点是否在所有插槽的自定义包围盒内。 + * @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; + }; + /** + * 判断线段是否与骨架的所有插槽的自定义包围盒相交。 + * @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; + }; + /** + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @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; + }; + /** + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @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; + }; + /** + * 获取插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @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; + }; + /** + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @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; + }; + /** + * @deprecated + */ + Armature.prototype.addBone = function (value, parentName) { + if (parentName === void 0) { parentName = null; } + console.assert(value !== null); + value._setArmature(this); + value._setParent(parentName !== null ? this.getBone(parentName) : null); + }; + /** + * @deprecated + */ + Armature.prototype.removeBone = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * @deprecated + */ + Armature.prototype.addSlot = function (value, parentName) { + var bone = this.getBone(parentName); + console.assert(value !== null && bone !== null); + value._setArmature(this); + value._setParent(bone); + }; + /** + * @deprecated + */ + Armature.prototype.removeSlot = function (value) { + console.assert(value !== null && value.armature === this); + value._setParent(null); + value._setArmature(null); + }; + /** + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getBones = function () { + return this._bones; + }; + /** + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "flipX", { + 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", { + 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", { + /** + * 动画缓存帧率,当设置的值大于 0 的时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @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", { + /** + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this.armatureData.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * 获得动画控制器。 + * @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", { + /** + * @pivate + */ + get: function () { + return this._proxy; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "replacedTexture", { + /** + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @version DragonBones 4.5 + */ + 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", { + /** + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#replacedTexture + */ + Armature.prototype.replaceTexture = function (texture) { + this.replacedTexture = texture; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.hasEventListener = function (type) { + return this._proxy.hasEvent(type); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.addEventListener = function (type, listener, target) { + this._proxy.addEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#eventDispatcher + */ + Armature.prototype.removeEventListener = function (type, listener, target) { + this._proxy.removeEvent(type, listener, target); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #cacheFrameRate + */ + Armature.prototype.enableAnimationCache = function (frameRate) { + this.cacheFrameRate = frameRate; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Armature.prototype.getDisplay = function () { + return this._display; + }; + return Armature; + }(dragonBones_1.BaseObject)); + dragonBones_1.Armature = Armature; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 基础变换对象。 + * @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; + /** + * 相对于骨架坐标系的矩阵。 + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.globalTransformMatrix = new dragonBones.Matrix(); + /** + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.global = new dragonBones.Transform(); + /** + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + * @language zh_CN + */ + _this.offset = new dragonBones.Transform(); + return _this; + } + /** + * @private + */ + TransformObject.prototype._onClear = function () { + this.name = ""; + this.globalTransformMatrix.identity(); + this.global.identity(); + this.offset.identity(); + this.origin = null; // + this.userData = null; + this._globalDirty = false; + this._armature = null; // + this._parent = null; // + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setArmature = function (value) { + this._armature = value; + }; + /** + * @internal + * @private + */ + TransformObject.prototype._setParent = function (value) { + this._parent = value; + }; + /** + * @private + */ + TransformObject.prototype.updateGlobalTransform = function () { + if (this._globalDirty) { + this._globalDirty = false; + this.global.fromMatrix(this.globalTransformMatrix); + } + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransformObject.prototype, "parent", { + /** + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + TransformObject._helpMatrix = new dragonBones.Matrix(); + /** + * @private + */ + TransformObject._helpTransform = new dragonBones.Transform(); + /** + * @private + */ + TransformObject._helpPoint = new dragonBones.Point(); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @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 + * @private + */ + _this.animationPose = new dragonBones.Transform(); + /** + * @internal + * @private + */ + _this.constraints = []; + _this._bones = []; + _this._slots = []; + return _this; + } + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + /** + * @private + */ + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + constraint.returnToPool(); + } + this.offsetMode = 1 /* Additive */; + this.animationPose.identity(); + this.constraints.length = 0; + this.boneData = null; // + this._transformDirty = false; + this._childrenTransformDirty = false; + this._blendDirty = false; + this._localDirty = true; + this._visible = true; + this._cachedFrameIndex = -1; + this._blendLayer = 0; + this._blendLeftWeight = 1.0; + this._blendLayerWeight = 0.0; + this._bones.length = 0; + this._slots.length = 0; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Bone.prototype._updateGlobalTransformMatrix = function (isCache) { + var flipX = this._armature.flipX; + var flipY = this._armature.flipY === dragonBones.DragonBones.yDown; + var global = this.global; + var globalTransformMatrix = this.globalTransformMatrix; + var inherit = this._parent !== null; + var dR = 0.0; + if (this.offsetMode === 1 /* Additive */) { + // global.copyFrom(this.origin).add(this.offset).add(this.animationPose); + global.x = this.origin.x + this.offset.x + this.animationPose.x; + global.y = this.origin.y + this.offset.y + this.animationPose.y; + global.skew = this.origin.skew + this.offset.skew + this.animationPose.skew; + global.rotation = this.origin.rotation + this.offset.rotation + this.animationPose.rotation; + global.scaleX = this.origin.scaleX * this.offset.scaleX * this.animationPose.scaleX; + global.scaleY = this.origin.scaleY * this.offset.scaleY * this.animationPose.scaleY; + } + else if (this.offsetMode === 0 /* None */) { + global.copyFrom(this.origin).add(this.animationPose); + } + else { + inherit = false; + global.copyFrom(this.offset); + } + if (inherit) { + var parentMatrix = this._parent.globalTransformMatrix; + if (this.boneData.inheritScale) { + if (!this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; // + global.rotation -= dR; + } + global.toMatrix(globalTransformMatrix); + globalTransformMatrix.concat(parentMatrix); + if (this.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 (this.boneData.inheritTranslation) { + var x = global.x; + var y = global.y; + global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + else { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + } + if (this.boneData.inheritRotation) { + this._parent.updateGlobalTransform(); + dR = this._parent.global.rotation; + if (this._parent.global.scaleX < 0.0) { + dR += Math.PI; + } + if (parentMatrix.a * parentMatrix.d - parentMatrix.b * parentMatrix.c < 0.0) { + dR -= global.rotation * 2.0; + if (flipX !== flipY || this.boneData.inheritReflection) { + global.skew += Math.PI; + } + } + global.rotation += dR; + } + else if (flipX || flipY) { + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + } + else { + if (flipX || flipY) { + if (flipX) { + global.x = -global.x; + } + if (flipY) { + global.y = -global.y; + } + if (flipX && flipY) { + dR = Math.PI; + } + else { + dR = -global.rotation * 2.0; + if (flipX) { + dR += Math.PI; + } + global.skew += Math.PI; + } + global.rotation += dR; + } + global.toMatrix(globalTransformMatrix); + } + }; + /** + * @internal + * @private + */ + Bone.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + var oldSlots = null; + var oldBones = null; + if (this._armature !== null) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + this._armature = value; // + if (this._armature !== null) { + this._armature._addBoneToBoneList(this); + } + if (oldSlots !== null) { + for (var _i = 0, oldSlots_1 = oldSlots; _i < oldSlots_1.length; _i++) { + var slot = oldSlots_1[_i]; + if (slot.parent === this) { + slot._setArmature(this._armature); + } + } + } + if (oldBones !== null) { + for (var _a = 0, oldBones_1 = oldBones; _a < oldBones_1.length; _a++) { + var bone = oldBones_1[_a]; + if (bone.parent === this) { + bone._setArmature(this._armature); + } + } + } + }; + /** + * @internal + * @private + */ + Bone.prototype.init = function (boneData) { + if (this.boneData !== null) { + return; + } + this.boneData = boneData; + this.name = this.boneData.name; + this.origin = this.boneData.transform; + }; + /** + * @internal + * @private + */ + Bone.prototype.update = function (cacheFrameIndex) { + this._blendDirty = false; + 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.constraints.length > 0) { + for (var _i = 0, _a = this.constraints; _i < _a.length; _i++) { + var constraint = _a[_i]; + 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.constraints.length > 0) { + for (var _b = 0, _c = this.constraints; _b < _c.length; _b++) { + var constraint = _c[_b]; + 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 + * @private + */ + 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; + } + }; + /** + * @internal + * @private + */ + Bone.prototype.addConstraint = function (constraint) { + if (this.constraints.indexOf(constraint) < 0) { + this.constraints.push(constraint); + } + }; + /** + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.invalidUpdate = function () { + this._transformDirty = true; + }; + /** + * 是否包含骨骼或插槽。 + * @returns + * @see dragonBones.TransformObject + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.contains = function (child) { + if (child === this) { + return false; + } + var ancestor = child; + while (ancestor !== this && ancestor !== null) { + ancestor = ancestor.parent; + } + return ancestor === this; + }; + /** + * 所有的子骨骼。 + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getBones = function () { + this._bones.length = 0; + for (var _i = 0, _a = this._armature.getBones(); _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone.parent === this) { + this._bones.push(bone); + } + } + return this._bones; + }; + /** + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + * @language zh_CN + */ + Bone.prototype.getSlots = function () { + this._slots.length = 0; + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + this._slots.push(slot); + } + } + return this._slots; + }; + Object.defineProperty(Bone.prototype, "visible", { + /** + * 控制此骨骼所有插槽的可见。 + * @default true + * @see dragonBones.Slot + * @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, "length", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #boneData + * @see #dragonBones.BoneData#length + */ + get: function () { + return this.boneData.length; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "slot", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#getSlot() + */ + get: function () { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (slot.parent === this) { + return slot; + } + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @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; + /** + * @private + */ + _this._localMatrix = new dragonBones.Matrix(); + /** + * @private + */ + _this._colorTransform = new dragonBones.ColorTransform(); + /** + * @private + */ + _this._ffdVertices = []; + /** + * @private + */ + _this._displayDatas = []; + /** + * @private + */ + _this._displayList = []; + /** + * @private + */ + _this._meshBones = []; + /** + * @private + */ + _this._rawDisplay = null; // Initial value. + /** + * @private + */ + _this._meshDisplay = null; // Initial value. + return _this; + } + /** + * @private + */ + Slot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + var disposeDisplayList = []; + for (var _i = 0, _a = this._displayList; _i < _a.length; _i++) { + var eachDisplay = _a[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + 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); + } + } + if (this._meshDisplay !== null && this._meshDisplay !== this._rawDisplay) { + this._disposeDisplay(this._meshDisplay); + } + if (this._rawDisplay !== null) { + this._disposeDisplay(this._rawDisplay); + } + this.displayController = null; + this.slotData = null; // + this._displayDirty = false; + this._zOrderDirty = false; + this._blendModeDirty = false; + this._colorDirty = false; + this._meshDirty = false; + this._transformDirty = false; + this._visible = true; + this._blendMode = 0 /* Normal */; + this._displayIndex = -1; + this._animationDisplayIndex = -1; + this._zOrder = 0; + this._cachedFrameIndex = -1; + this._pivotX = 0.0; + this._pivotY = 0.0; + this._localMatrix.identity(); + this._colorTransform.identity(); + this._ffdVertices.length = 0; + this._displayList.length = 0; + this._displayDatas.length = 0; + this._meshBones.length = 0; + this._rawDisplayDatas = null; // + this._displayData = null; + this._textureData = null; + this._meshData = null; + this._boundingBoxData = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._display = null; + this._childArmature = null; + this._cachedFrameIndices = null; + }; + /** + * @private + */ + Slot.prototype._updateDisplayData = function () { + var prevDisplayData = this._displayData; + var prevTextureData = this._textureData; + var prevMeshData = this._meshData; + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.length) { + this._displayData = this._displayDatas[this._displayIndex]; + } + else { + this._displayData = null; + } + // Update texture and mesh data. + if (this._displayData !== null) { + if (this._displayData.type === 0 /* Image */ || this._displayData.type === 2 /* Mesh */) { + this._textureData = this._displayData.texture; + if (this._displayData.type === 2 /* Mesh */) { + this._meshData = this._displayData; + } + else if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */) { + this._meshData = rawDisplayData; + } + else { + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + } + else { + this._textureData = null; + this._meshData = null; + } + // Update bounding box data. + if (this._displayData !== null && this._displayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = this._displayData.boundingBox; + } + else if (rawDisplayData !== null && rawDisplayData.type === 3 /* BoundingBox */) { + this._boundingBoxData = rawDisplayData.boundingBox; + } + else { + this._boundingBoxData = null; + } + if (this._displayData !== prevDisplayData || this._textureData !== prevTextureData || this._meshData !== prevMeshData) { + // Update pivot offset. + if (this._meshData !== null) { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + else if (this._textureData !== null) { + var imageDisplayData = this._displayData; + var 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 * scale; + var height = rect.height * scale; + if (this._textureData.rotated && frame === null) { + width = rect.height; + height = rect.width; + } + this._pivotX *= width; + this._pivotY *= height; + if (frame !== null) { + this._pivotX += frame.x * scale; + this._pivotY += frame.y * scale; + } + } + else { + this._pivotX = 0.0; + this._pivotY = 0.0; + } + // Update mesh bones and ffd vertices. + if (this._meshData !== prevMeshData) { + if (this._meshData !== null) { + if (this._meshData.weight !== null) { + this._ffdVertices.length = this._meshData.weight.count * 2; + this._meshBones.length = this._meshData.weight.bones.length; + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.weight.bones[i].name); + } + } + else { + var vertexCount = this._meshData.parent.parent.intArray[this._meshData.offset + 0 /* MeshVertexCount */]; + this._ffdVertices.length = vertexCount * 2; + this._meshBones.length = 0; + } + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0.0; + } + this._meshDirty = true; + } + else { + this._ffdVertices.length = 0; + this._meshBones.length = 0; + } + } + else if (this._meshData !== null && this._textureData !== prevTextureData) { + this._meshDirty = true; + } + if (this._displayData !== null && rawDisplayData !== null && this._displayData !== rawDisplayData && this._meshData === null) { + 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; + this._displayData.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; + } + // Update original transform. + if (rawDisplayData !== null) { + this.origin = rawDisplayData.transform; + } + else if (this._displayData !== null) { + this.origin = this._displayData.transform; + } + this._displayDirty = true; + this._transformDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display !== null ? this._display : this._rawDisplay; + var prevChildArmature = this._childArmature; + // Update display and child armature. + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + 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._onUpdateDisplay(); + this._replaceDisplay(prevDisplay); + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + } + // Update frame. + if (currentDisplay === this._rawDisplay || currentDisplay === this._meshDisplay) { + this._updateFrame(); + } + // 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. + var actions = null; + if (this._displayData !== null && this._displayData.type === 1 /* Armature */) { + actions = this._displayData.actions; + } + else { + var rawDisplayData = this._displayIndex >= 0 && this._displayIndex < this._rawDisplayDatas.length ? this._rawDisplayDatas[this._displayIndex] : null; + if (rawDisplayData !== null && rawDisplayData.type === 1 /* Armature */) { + actions = rawDisplayData.actions; + } + } + if (actions !== null && actions.length > 0) { + for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) { + var action = actions_1[_i]; + this._childArmature._bufferAction(action, false); // Make sure default action at the beginning. + } + } + else { + this._childArmature.animation.play(); + } + } + } + } + }; + /** + * @private + */ + Slot.prototype._updateGlobalTransformMatrix = function (isCache) { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + if (isCache) { + this.global.fromMatrix(this.globalTransformMatrix); + } + else { + this._globalDirty = true; + } + }; + /** + * @private + */ + Slot.prototype._isMeshBonesUpdate = function () { + for (var _i = 0, _a = this._meshBones; _i < _a.length; _i++) { + var bone = _a[_i]; + if (bone !== null && bone._childrenTransformDirty) { + return true; + } + } + return false; + }; + /** + * @internal + * @private + */ + Slot.prototype._setArmature = function (value) { + if (this._armature === value) { + return; + } + if (this._armature !== null) { + this._armature._removeSlotFromSlotList(this); + } + this._armature = value; // + this._onUpdateDisplay(); + if (this._armature !== null) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); + } + }; + /** + * @internal + * @private + */ + Slot.prototype._setDisplayIndex = function (value, isAnimation) { + if (isAnimation === void 0) { isAnimation = false; } + if (isAnimation) { + if (this._animationDisplayIndex === value) { + return false; + } + this._animationDisplayIndex = value; + } + if (this._displayIndex === value) { + return false; + } + this._displayIndex = value; + this._displayDirty = true; + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setZorder = function (value) { + if (this._zOrder === value) { + //return false; + } + this._zOrder = value; + this._zOrderDirty = true; + return this._zOrderDirty; + }; + /** + * @internal + * @private + */ + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return this._colorDirty; + }; + /** + * @private + */ + Slot.prototype._setDisplayList = function (value) { + if (value !== null && value.length > 0) { + if (this._displayList.length !== value.length) { + this._displayList.length = value.length; + } + for (var i = 0, l = value.length; i < l; ++i) { + var eachDisplay = value[i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + !(eachDisplay instanceof dragonBones.Armature) && this._displayList.indexOf(eachDisplay) < 0) { + this._initDisplay(eachDisplay); + } + this._displayList[i] = eachDisplay; + } + } + else if (this._displayList.length > 0) { + this._displayList.length = 0; + } + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display !== this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display !== null; + } + this._updateDisplayData(); + return this._displayDirty; + }; + /** + * @private + */ + Slot.prototype.init = function (slotData, displayDatas, rawDisplay, meshDisplay) { + if (this.slotData !== null) { + return; + } + this.slotData = slotData; + this.name = this.slotData.name; + this._visibleDirty = true; + this._blendModeDirty = true; + this._colorDirty = true; + this._blendMode = this.slotData.blendMode; + this._zOrder = this.slotData.zOrder; + this._colorTransform.copyFrom(this.slotData.color); + this._rawDisplayDatas = displayDatas; + this._rawDisplay = rawDisplay; + this._meshDisplay = meshDisplay; + this._displayDatas.length = this._rawDisplayDatas.length; + for (var i = 0, l = this._displayDatas.length; i < l; ++i) { + this._displayDatas[i] = this._rawDisplayDatas[i]; + } + }; + /** + * @internal + * @private + */ + Slot.prototype.update = function (cacheFrameIndex) { + if (this._displayDirty) { + this._displayDirty = false; + this._updateDisplay(); + if (this._transformDirty) { + if (this.origin !== null) { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); + } + else { + this.global.copyFrom(this.offset).toMatrix(this._localMatrix); + } + } + } + if (this._zOrderDirty) { + this._zOrderDirty = false; + this._updateZOrder(); + } + 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._display === null) { + return; + } + if (this._blendModeDirty) { + this._blendModeDirty = false; + this._updateBlendMode(); + } + if (this._colorDirty) { + this._colorDirty = false; + this._updateColor(); + } + if (this._meshData !== null && this._display === this._meshDisplay) { + var isSkinned = this._meshData.weight !== null; + if (this._meshDirty || (isSkinned && this._isMeshBonesUpdate())) { + this._meshDirty = false; + this._updateMesh(); + } + if (isSkinned) { + if (this._transformDirty) { + this._transformDirty = false; + this._updateTransform(true); + } + return; + } + } + if (this._transformDirty) { + this._transformDirty = false; + 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(false); + } + }; + /** + * @private + */ + Slot.prototype.updateTransformAndMatrix = function () { + if (this._transformDirty) { + this._transformDirty = false; + this._updateGlobalTransformMatrix(false); + } + }; + /** + * 判断指定的点是否在插槽的自定义包围盒内。 + * @param x 点的水平坐标。(骨架内坐标系) + * @param y 点的垂直坐标。(骨架内坐标系) + * @param color 指定的包围盒颜色。 [0: 与所有包围盒进行判断, N: 仅当包围盒的颜色为 N 时才进行判断] + * @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); + }; + /** + * 判断指定的线段与插槽的自定义包围盒是否相交。 + * @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; + }; + /** + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 + * @language zh_CN + */ + Slot.prototype.invalidUpdate = function () { + this._displayDirty = true; + this._transformDirty = true; + }; + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + if (this._setDisplayIndex(value)) { + this.update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._displayList.concat(); + }, + set: function (value) { + var backupDisplayList = this._displayList.concat(); // Copy. + var disposeDisplayList = new Array(); + if (this._setDisplayList(value)) { + this.update(-1); + } + // Release replaced displays. + for (var _i = 0, backupDisplayList_1 = backupDisplayList; _i < backupDisplayList_1.length; _i++) { + var eachDisplay = backupDisplayList_1[_i]; + if (eachDisplay !== null && eachDisplay !== this._rawDisplay && eachDisplay !== this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var _a = 0, disposeDisplayList_2 = disposeDisplayList; _a < disposeDisplayList_2.length; _a++) { + var eachDisplay = disposeDisplayList_2[_a]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "boundingBoxData", { + /** + * @language zh_CN + * 插槽此时的自定义包围盒数据。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + 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", { + /** + * 此时显示的显示对象。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display === value) { + return; + } + var displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength === 0) { + this._displayIndex = 0; + } + if (this._displayIndex < 0) { + return; + } + else { + var replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @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 + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.getDisplay = function () { + return this._display; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #display + */ + Slot.prototype.setDisplay = function (value) { + this.display = value; + }; + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + * @internal + */ + var Constraint = (function (_super) { + __extends(Constraint, _super); + function Constraint() { + return _super !== null && _super.apply(this, arguments) || this; + } + Constraint.prototype._onClear = function () { + this.target = null; // + this.bone = null; // + this.root = null; // + }; + Constraint._helpMatrix = new dragonBones.Matrix(); + Constraint._helpTransform = new dragonBones.Transform(); + Constraint._helpPoint = new dragonBones.Point(); + return Constraint; + }(dragonBones.BaseObject)); + dragonBones.Constraint = Constraint; + /** + * @private + * @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.bendPositive = false; + this.scaleEnabled = false; + this.weight = 1.0; + }; + IKConstraint.prototype._computeA = function () { + var ikGlobal = this.target.global; + var global = this.bone.global; + var globalTransformMatrix = this.bone.globalTransformMatrix; + // const boneLength = this.bone.boneData.length; + // const x = globalTransformMatrix.a * boneLength; + var ikRadian = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadian += Math.PI; + } + global.rotation += (ikRadian - 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 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 ikRadianA = 0.0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x); + if (lL + lP <= lT) { + } + else if (lP < lL) { + ikRadianA += 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; + if (parent._parent !== null) { + var parentParentMatrix = parent._parent.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; + } + ikRadianA = Math.atan2(global.y - parentGlobal.y, global.x - parentGlobal.x); + } + var dR = (ikRadianA - rawRadianA) * this.weight; + parentGlobal.rotation += dR; + parentGlobal.toMatrix(parent.globalTransformMatrix); + var parentRadian = rawRadianA + dR; + global.x = parentGlobal.x + Math.cos(parentRadian) * lP; + global.y = parentGlobal.y + Math.sin(parentRadian) * lP; + var ikRadianB = Math.atan2(ikGlobal.y - global.y, ikGlobal.x - global.x); + if (global.scaleX < 0.0) { + ikRadianB += Math.PI; + } + dR = (ikRadianB - global.rotation) * this.weight; + global.rotation += dR; + global.toMatrix(globalTransformMatrix); + }; + IKConstraint.prototype.update = function () { + if (this.root === null) { + this.bone.updateByConstraint(); + this._computeA(); + } + else { + this.root.updateByConstraint(); + this.bone.updateByConstraint(); + this._computeB(); + } + }; + return IKConstraint; + }(Constraint)); + dragonBones.IKConstraint = IKConstraint; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * WorldClock 提供时钟支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimateble + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var WorldClock = (function () { + /** + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 实例可以更灵活的为需要更新的 IAnimateble 实例分组,用于控制不同组不同的播放速度) + * @version DragonBones 3.0 + * @language zh_CN + */ + function WorldClock(time) { + if (time === void 0) { time = -1.0; } + /** + * 当前时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + this.time = 0.0; + /** + * 时间流逝速度,用于控制动画变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1.0 + * @version DragonBones 3.0 + * @language zh_CN + */ + this.timeScale = 1.0; + this._animatebles = []; + this._clock = null; + if (time < 0.0) { + this.time = new Date().getTime() * 0.001; + } + else { + this.time = time; + } + } + /** + * 为所有的 IAnimatable 实例更新时间。 + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime !== passedTime) { + passedTime = 0.0; + } + if (passedTime < 0.0) { + passedTime = new Date().getTime() * 0.001 - this.time; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + if (passedTime < 0.0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + if (passedTime === 0.0) { + return; + } + 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; + } + }; + /** + * 是否包含 IAnimatable 实例 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.prototype.contains = function (value) { + return this._animatebles.indexOf(value) >= 0; + }; + /** + * 添加 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; + } + }; + /** + * 移除 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; + } + }; + /** + * 清除所有的 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 + }); + /** + * 一个可以直接使用的全局 WorldClock 实例. + * @version DragonBones 3.0 + * @language zh_CN + */ + WorldClock.clock = new WorldClock(); + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 动画控制器,用来播放动画数据,管理动画状态。 + * @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._animationConfig = null; // Initial value. + return _this; + } + /** + * @private + */ + Animation.toString = function () { + return "[class dragonBones.Animation]"; + }; + /** + * @private + */ + 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]; + } + if (this._animationConfig !== null) { + this._animationConfig.returnToPool(); + } + this.timeScale = 1.0; + this._animationDirty = false; + this._timelineDirty = false; + 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.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.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.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]; + animationState.fadeOut(animationConfig.fadeOutTime, animationConfig.pauseFadeOut); + } + break; + case 0 /* None */: + case 5 /* Single */: + default: + break; + } + }; + /** + * @internal + * @private + */ + Animation.prototype.init = function (armature) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this._animationConfig = dragonBones.BaseObject.borrowObject(dragonBones.AnimationConfig); + }; + /** + * @internal + * @private + */ + Animation.prototype.advanceTime = function (passedTime) { + if (passedTime < 0.0) { + passedTime = -passedTime; + } + if (this._armature.inheritAnimation && this._armature._parent !== null) { + passedTime *= this._armature._parent._armature.animation.timeScale; + } + if (this.timeScale !== 1.0) { + passedTime *= this.timeScale; + } + 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]; + slot._cachedFrameIndices = animationData.getSlotCachedFrameIndices(slot.name); + } + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + if (this._timelineDirty) { + animationState.updateTimelines(); + } + 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; + } + this._timelineDirty = false; + }; + /** + * 清除所有动画状态。 + * @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._timelineDirty = false; + this._animationConfig.clear(); + this._animationStates.length = 0; + this._lastAnimationState = null; + }; + /** + * 暂停播放动画。 + * @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(); + } + } + }; + /** + * 通过动画配置来播放动画。 + * @param animationConfig 动画配置。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationConfig + * @see dragonBones.AnimationState + * @version DragonBones 5.0 + * @beta + * @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.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 > 1) { + 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) { + } + else { + added = true; + this._animationStates.splice(i + 1, 0, animationState); + break; + } + } + if (!added) { + this._animationStates.push(animationState); + } + } + else { + this._animationStates.push(animationState); + } + // Child armature play same name animation. + 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); // + } + } + if (animationConfig.fadeInTime <= 0.0) { + this._armature.advanceTime(0.0); + } + this._lastAnimationState = animationState; + return animationState; + }; + /** + * 播放动画。 + * @param animationName 动画数据名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 淡入播放动画。 + * @param animationName 动画数据名称。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入时间。 [-1: 使用动画数据默认值, [0~N]: 淡入时间] (以秒为单位) + * @param layer 混合图层,图层高会优先获取混合权重。 + * @param group 混合组,用于动画状态编组,方便控制淡出。 + * @param fadeOutMode 淡出模式。 + * @param resetToPose + * @returns 对应的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定时间开始播放动画。 + * @param animationName 动画数据的名称。 + * @param time 开始时间。 (以秒为单位) + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 从指定帧开始播放动画。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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.duration * frame / animationData.frameCount; + } + return this.playConfig(this._animationConfig); + }; + /** + * 从指定进度开始播放动画。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 播放次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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); + }; + /** + * 将动画停止到指定的时间。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的帧。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 将动画停止到指定的进度。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0 ~ 1] + * @returns 对应的动画状态。 + * @see dragonBones.AnimationState + * @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; + }; + /** + * 获取动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.getState = function (animationName) { + var i = this._animationStates.length; + while (i--) { + var animationState = this._animationStates[i]; + if (animationState.name === animationName) { + return animationState; + } + } + return null; + }; + /** + * 是否包含动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + * @language zh_CN + */ + Animation.prototype.hasAnimation = function (animationName) { + return animationName in this._animations; + }; + /** + * 获取所有的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 5.1 + * @language zh_CN + */ + Animation.prototype.getStates = function () { + return this._animationStates; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * 动画是否处于播放状态。 + * @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", { + /** + * 所有动画状态是否均已播放完毕。 + * @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", { + /** + * 上一个正在播放的动画状态名称。 + * @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", { + /** + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * 所有动画数据。 + * @see dragonBones.AnimationData + * @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._animations[k] = value[k]; + this._animationNames.push(k); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationConfig", { + /** + * 一个可以快速使用的动画配置实例。 + * @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", { + /** + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (duration === void 0) { duration = -1; } + 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 */; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + pauseFadeOut; + pauseFadeIn; + this._animationConfig.clear(); + this._animationConfig.resetToPose = true; + 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 : ""; + var animationData = this._animations[animationName]; + if (animationData && duration > 0.0) { + this._animationConfig.timeScale = animationData.duration / duration; + } + return this.playConfig(this._animationConfig); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + Animation.prototype.gotoAndStop = function (animationName, time) { + if (time === void 0) { time = 0; } + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationNames + * @see #animations + */ + get: function () { + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); + } + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var BonePose = (function (_super) { + __extends(BonePose, _super); + function BonePose() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this.current = new dragonBones.Transform(); + _this.delta = new dragonBones.Transform(); + _this.result = new dragonBones.Transform(); + return _this; + } + BonePose.toString = function () { + return "[class dragonBones.BonePose]"; + }; + BonePose.prototype._onClear = function () { + this.current.identity(); + this.delta.identity(); + this.result.identity(); + }; + return BonePose; + }(dragonBones.BaseObject)); + dragonBones.BonePose = BonePose; + /** + * 动画状态,播放动画时产生,可以对每个播放的动画进行更细致的控制和调节。 + * @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._slotTimelines = []; + _this._bonePoses = {}; + /** + * @internal + * @private + */ + _this._actionTimeline = null; // Initial value. + _this._zOrderTimeline = null; // Initial value. + return _this; + } + /** + * @private + */ + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; + /** + * @private + */ + 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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.returnToPool(); + } + for (var k in this._bonePoses) { + this._bonePoses[k].returnToPool(); + delete this._bonePoses[k]; + } + if (this._actionTimeline !== null) { + this._actionTimeline.returnToPool(); + } + if (this._zOrderTimeline !== null) { + this._zOrderTimeline.returnToPool(); + } + this.resetToPose = false; + this.additiveBlending = false; + this.displayControl = false; + this.actionEnabled = false; + this.layer = 0; + this.playTimes = 1; + this.timeScale = 1.0; + this.weight = 1.0; + this.autoFadeOutTime = 0.0; + this.fadeTotalTime = 0.0; + this.name = ""; + this.group = ""; + this.animationData = null; // + this._timelineDirty = true; + 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._slotTimelines.length = 0; + // this._bonePoses.clear(); + this._armature = null; // + this._actionTimeline = null; // + this._zOrderTimeline = null; + }; + AnimationState.prototype._isDisabled = function (slot) { + if (this.displayControl) { + var displayController = slot.displayController; + if (displayController === null || + displayController === this.name || + displayController === this.group) { + return false; + } + } + return true; + }; + AnimationState.prototype._advanceFadeTime = function (passedTime) { + var isFadeOut = this._fadeState > 0; + if (this._subFadeState < 0) { + this._subFadeState = 0; + var eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT : dragonBones.EventObject.FADE_IN; + if (this._armature.eventDispatcher.hasEvent(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 eventType = isFadeOut ? dragonBones.EventObject.FADE_OUT_COMPLETE : dragonBones.EventObject.FADE_IN_COMPLETE; + if (this._armature.eventDispatcher.hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.type = eventType; + eventObject.armature = this._armature; + eventObject.animationState = this; + this._armature._dragonBones.bufferEvent(eventObject); + } + } + }; + AnimationState.prototype._blendBoneTimline = function (timeline) { + var bone = timeline.bone; + var bonePose = timeline.bonePose.result; + var animationPose = bone.animationPose; + var boneWeight = this._weightResult > 0.0 ? this._weightResult : -this._weightResult; + if (!bone._blendDirty) { + bone._blendDirty = true; + bone._blendLayer = this.layer; + bone._blendLayerWeight = boneWeight; + bone._blendLeftWeight = 1.0; + animationPose.x = bonePose.x * boneWeight; + animationPose.y = bonePose.y * boneWeight; + animationPose.rotation = bonePose.rotation * boneWeight; + animationPose.skew = bonePose.skew * boneWeight; + animationPose.scaleX = (bonePose.scaleX - 1.0) * boneWeight + 1.0; + animationPose.scaleY = (bonePose.scaleY - 1.0) * boneWeight + 1.0; + } + else { + boneWeight *= bone._blendLeftWeight; + bone._blendLayerWeight += boneWeight; + animationPose.x += bonePose.x * boneWeight; + animationPose.y += bonePose.y * boneWeight; + animationPose.rotation += bonePose.rotation * boneWeight; + animationPose.skew += bonePose.skew * boneWeight; + animationPose.scaleX += (bonePose.scaleX - 1.0) * boneWeight; + animationPose.scaleY += (bonePose.scaleY - 1.0) * boneWeight; + } + if (this._fadeState !== 0 || this._subFadeState !== 0) { + bone._transformDirty = true; + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.init = function (armature, animationData, animationConfig) { + if (this._armature !== null) { + return; + } + this._armature = armature; + this.animationData = animationData; + this.resetToPose = animationConfig.resetToPose; + this.additiveBlending = animationConfig.additiveBlending; + this.displayControl = animationConfig.displayControl; + this.actionEnabled = animationConfig.actionEnabled; + this.layer = animationConfig.layer; + this.playTimes = animationConfig.playTimes; + this.timeScale = animationConfig.timeScale; + this.fadeTotalTime = animationConfig.fadeInTime; + this.autoFadeOutTime = animationConfig.autoFadeOutTime; + this.weight = animationConfig.weight; + this.name = animationConfig.name.length > 0 ? animationConfig.name : animationConfig.animation; + this.group = animationConfig.group; + 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); + } + }; + /** + * @private + * @internal + */ + AnimationState.prototype.updateTimelines = function () { + var boneTimelines = {}; + for (var _i = 0, _a = this._boneTimelines; _i < _a.length; _i++) { + var timeline = _a[_i]; + var timelineName = timeline.bone.name; + if (!(timelineName in boneTimelines)) { + boneTimelines[timelineName] = []; + } + boneTimelines[timelineName].push(timeline); + } + for (var _b = 0, _c = this._armature.getBones(); _b < _c.length; _b++) { + var bone = _c[_b]; + var timelineName = bone.name; + if (!this.containsBoneMask(timelineName)) { + continue; + } + var timelineDatas = this.animationData.getBoneTimelines(timelineName); + if (timelineName in boneTimelines) { + delete boneTimelines[timelineName]; + } + else { + var bonePose = timelineName in this._bonePoses ? this._bonePoses[timelineName] : (this._bonePoses[timelineName] = dragonBones.BaseObject.borrowObject(BonePose)); + if (timelineDatas !== null) { + for (var _d = 0, timelineDatas_1 = timelineDatas; _d < timelineDatas_1.length; _d++) { + var timelineData = timelineDatas_1[_d]; + switch (timelineData.type) { + case 10 /* BoneAll */: + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, timelineData); + this._boneTimelines.push(timeline); + break; + case 11 /* BoneT */: + case 12 /* BoneR */: + case 13 /* BoneS */: + // TODO + break; + case 14 /* BoneX */: + case 15 /* BoneY */: + case 16 /* BoneRotate */: + case 17 /* BoneSkew */: + case 18 /* BoneScaleX */: + case 19 /* BoneScaleY */: + // TODO + break; + } + } + } + else if (this.resetToPose) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneAllTimelineState); + timeline.bone = bone; + timeline.bonePose = bonePose; + timeline.init(this._armature, this, null); + this._boneTimelines.push(timeline); + } + } + } + for (var k in boneTimelines) { + for (var _e = 0, _f = boneTimelines[k]; _e < _f.length; _e++) { + var timeline = _f[_e]; + this._boneTimelines.splice(this._boneTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + var slotTimelines = {}; + var ffdFlags = []; + for (var _g = 0, _h = this._slotTimelines; _g < _h.length; _g++) { + var timeline = _h[_g]; + var timelineName = timeline.slot.name; + if (!(timelineName in slotTimelines)) { + slotTimelines[timelineName] = []; + } + slotTimelines[timelineName].push(timeline); + } + for (var _j = 0, _k = this._armature.getSlots(); _j < _k.length; _j++) { + var slot = _k[_j]; + var boneName = slot.parent.name; + if (!this.containsBoneMask(boneName)) { + continue; + } + var timelineName = slot.name; + var timelineDatas = this.animationData.getSlotTimeline(timelineName); + if (timelineName in slotTimelines) { + delete slotTimelines[timelineName]; + } + else { + var displayIndexFlag = false; + var colorFlag = false; + ffdFlags.length = 0; + if (timelineDatas !== null) { + for (var _l = 0, timelineDatas_2 = timelineDatas; _l < timelineDatas_2.length; _l++) { + var timelineData = timelineDatas_2[_l]; + switch (timelineData.type) { + case 20 /* SlotDisplay */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + displayIndexFlag = true; + break; + } + case 21 /* SlotColor */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + colorFlag = true; + break; + } + case 22 /* SlotFFD */: + { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, timelineData); + this._slotTimelines.push(timeline); + ffdFlags.push(timeline.meshOffset); + break; + } + } + } + } + if (this.resetToPose) { + if (!displayIndexFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotDislayIndexTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + if (!colorFlag) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotColorTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + for (var _m = 0, _o = slot._rawDisplayDatas; _m < _o.length; _m++) { + var displayData = _o[_m]; + if (displayData !== null && displayData.type === 2 /* Mesh */ && ffdFlags.indexOf(displayData.offset) < 0) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotFFDTimelineState); + timeline.slot = slot; + timeline.init(this._armature, this, null); + this._slotTimelines.push(timeline); + } + } + } + } + } + for (var k in slotTimelines) { + for (var _p = 0, _q = slotTimelines[k]; _p < _q.length; _p++) { + var timeline = _q[_p]; + this._slotTimelines.splice(this._slotTimelines.indexOf(timeline), 1); + timeline.returnToPool(); + } + } + }; + /** + * @private + * @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; + } + if (this._timelineDirty) { + this._timelineDirty = false; + this.updateTimelines(); + } + if (this.weight === 0.0) { + return; + } + var isCacheEnabled = this._fadeState === 0 && cacheFrameRate > 0.0; + var isUpdateTimeline = true; + var isUpdateBoneTimeline = true; + var time = this._time; + this._weightResult = this.weight * this._fadeProgress; + this._actionTimeline.update(time); // Update main timeline. + if (isCacheEnabled) { + var internval = cacheFrameRate * 2.0; + this._actionTimeline.currentTime = Math.floor(this._actionTimeline.currentTime * internval) / internval; + } + if (this._zOrderTimeline !== null) { + 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) { + if (isUpdateBoneTimeline) { + var bone = null; + var prevTimeline = null; // + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var timeline = this._boneTimelines[i]; + if (bone !== timeline.bone) { + if (bone !== null) { + this._blendBoneTimline(prevTimeline); + if (bone._blendDirty) { + if (bone._blendLeftWeight > 0.0) { + if (bone._blendLayer !== this.layer) { + if (bone._blendLayerWeight >= bone._blendLeftWeight) { + bone._blendLeftWeight = 0.0; + bone = null; + } + else { + bone._blendLayer = this.layer; + bone._blendLeftWeight -= bone._blendLayerWeight; + bone._blendLayerWeight = 0.0; + } + } + } + else { + bone = null; + } + } + } + bone = timeline.bone; + } + if (bone !== null) { + timeline.update(time); + if (i === l - 1) { + this._blendBoneTimline(timeline); + } + else { + prevTimeline = timeline; + } + } + } + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var timeline = this._slotTimelines[i]; + if (this._isDisabled(timeline.slot)) { + continue; + } + timeline.update(time); + } + } + if (this._fadeState === 0) { + if (this._subFadeState > 0) { + this._subFadeState = 0; + } + if (this._actionTimeline.playState > 0) { + if (this.autoFadeOutTime >= 0.0) { + this.fadeOut(this.autoFadeOutTime); + } + } + } + }; + /** + * 继续播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.play = function () { + this._playheadState = 3; // 11 + }; + /** + * 暂停播放。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.stop = function () { + this._playheadState &= 1; // 0x + }; + /** + * 淡出动画。 + * @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._slotTimelines; _b < _c.length; _b++) { + var timeline = _c[_b]; + timeline.fadeOut(); + } + } + this.displayControl = false; // + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0.0; + this._fadeTime = this.fadeTotalTime * (1.0 - this._fadeProgress); + }; + /** + * 是否包含骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.containsBoneMask = function (name) { + return this._boneMask.length === 0 || this._boneMask.indexOf(name) >= 0; + }; + /** + * 添加骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.addBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(name); + if (currentBone === null) { + return; + } + if (this._boneMask.indexOf(name) < 0) { + this._boneMask.push(name); + } + 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 = true; + }; + /** + * 删除骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(name); + if (index >= 0) { + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(name); + 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_2 = this._boneMask.indexOf(bone.name); + if (index_2 >= 0 && currentBone.contains(bone)) { + this._boneMask.splice(index_2, 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 = true; + }; + /** + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 + * @language zh_CN + */ + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._timelineDirty = true; + }; + Object.defineProperty(AnimationState.prototype, "isFadeIn", { + /** + * 是否正在淡入。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState < 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeOut", { + /** + * 是否正在淡出。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isFadeComplete", { + /** + * 是否淡入完毕。 + * @version DragonBones 5.1 + * @language zh_CN + */ + get: function () { + return this._fadeState === 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { + /** + * 是否正在播放。 + * @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", { + /** + * 是否播放完毕。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.playState > 0; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * 当前播放次数。 + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._actionTimeline.currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * 总时间。 (以秒为单位) + * @version DragonBones 3.0 + * @language zh_CN + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * 当前播放的时间。 (以秒为单位) + * @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) { + 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, "clip", { + /** + * @deprecated + * 已废弃,请参考 @see + * @see #animationData + */ + get: function () { + return this.animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + var TimelineState = (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + TimelineState.prototype._onClear = function () { + this.playState = -1; + this.currentPlayTimes = -1; + this.currentTime = -1.0; + this._tweenState = 0 /* None */; + this._frameRate = 0; + this._frameValueOffset = 0; + this._frameCount = 0; + this._frameOffset = 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._dragonBonesData = null; // + this._animationData = null; // + this._timelineData = null; // + this._armature = null; // + this._animationState = null; // + this._actionTimeline = null; // + this._frameArray = null; // + this._frameIntArray = null; // + this._frameFloatArray = 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._duration; + } + } + 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._frameRate = this._armature.armatureData.frameRate; + this._frameRateR = 1.0 / this._frameRate; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._dragonBonesData = this._armature.armatureData.parent; + this._animationData = this._animationState.animationData; + if (this._timelineData !== null) { + this._frameIntArray = this._dragonBonesData.frameIntArray; + this._frameFloatArray = this._dragonBonesData.frameFloatArray; + this._frameArray = this._dragonBonesData.frameArray; + this._timelineArray = this._dragonBonesData.timelineArray; + this._frameIndices = this._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 () { }; + TimelineState.prototype.update = function (passedTime) { + if (this.playState <= 0 && 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._tweenState !== 0 /* None */) { + this._onUpdateFrame(); + } + } + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @internal + * @private + */ + 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 segmentCount = count + 1; // + 2 - 1 + var valueIndex = Math.floor(progress * segmentCount); + var fromValue = valueIndex === 0 ? 0.0 : samples[offset + valueIndex - 1]; + var toValue = (valueIndex === segmentCount - 1) ? 10000.0 : 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._tweenProgress = 0.0; + this._tweenEasing = 0.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 */]; // TODO recode ture tween type. + this._tweenState = this._tweenType === 0 /* None */ ? 1 /* Once */ : 2 /* Always */; + 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; + } + 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]; + this._frameDurationR = 1.0 / (this._frameArray[nextFrameOffset] * this._frameRateR - this._framePosition); + } + } + else { + this._tweenState = 1 /* Once */; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function () { + if (this._tweenState === 2 /* Always */) { + 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); + } + } + else { + this._tweenProgress = 0.0; + } + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; + /** + * @internal + * @private + */ + var BoneTimelineState = (function (_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + BoneTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.bone = null; // + this.bonePose = null; // + }; + return BoneTimelineState; + }(TweenTimelineState)); + dragonBones.BoneTimelineState = BoneTimelineState; + /** + * @internal + * @private + */ + var SlotTimelineState = (function (_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.slot = null; // + }; + return SlotTimelineState; + }(TweenTimelineState)); + dragonBones.SlotTimelineState = SlotTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @internal + * @private + */ + 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._armature.armatureData.actions; + for (var i = 0; i < actionCount; ++i) { + var actionIndex = this._frameArray[frameOffset + 2 + i]; + var action = actions[actionIndex]; + if (action.type === 0 /* Play */) { + if (action.slot !== null) { + var slot = this._armature.getSlot(action.slot.name); + if (slot !== null) { + var childArmature = slot.childArmature; + if (childArmature !== null) { + childArmature._bufferAction(action, true); + } + } + } + else if (action.bone !== null) { + for (var _i = 0, _a = this._armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + var childArmature = slot.childArmature; + if (childArmature !== null && slot.parent.boneData === action.bone) { + childArmature._bufferAction(action, true); + } + } + } + else { + this._armature._bufferAction(action, true); + } + } + else { + var eventType = action.type === 10 /* Frame */ ? dragonBones.EventObject.FRAME_EVENT : dragonBones.EventObject.SOUND_EVENT; + if (action.type === 11 /* Sound */ || eventDispatcher.hasEvent(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.type = eventType; + eventObject.name = action.name; + eventObject.data = action.data; + eventObject.armature = this._armature; + eventObject.animationState = this._animationState; + if (action.bone !== null) { + eventObject.bone = this._armature.getBone(action.bone.name); + } + if (action.slot !== null) { + eventObject.slot = this._armature.getSlot(action.slot.name); + } + 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.playState <= 0 && this._setCurrentTime(passedTime)) { + 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 (eventDispatcher.hasEvent(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 (this.currentPlayTimes !== prevPlayTimes) { + if (eventDispatcher.hasEvent(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.hasEvent(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 + * @private + */ + 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 + * @private + */ + 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._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * 6; // ...(timeline value offset)|xxxxxx|xxxxxx|(Value offset)xxxxx|(Next offset)xxxxx|xxxxxx|xxxxxx|... + current.x = frameFloatArray[valueOffset++]; + current.y = frameFloatArray[valueOffset++]; + current.rotation = frameFloatArray[valueOffset++]; + current.skew = frameFloatArray[valueOffset++]; + current.scaleX = frameFloatArray[valueOffset++]; + current.scaleY = frameFloatArray[valueOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + delta.x = frameFloatArray[valueOffset++] - current.x; + delta.y = frameFloatArray[valueOffset++] - current.y; + delta.rotation = frameFloatArray[valueOffset++] - current.rotation; + delta.skew = frameFloatArray[valueOffset++] - current.skew; + delta.scaleX = frameFloatArray[valueOffset++] - current.scaleX; + delta.scaleY = frameFloatArray[valueOffset++] - current.scaleY; + } + // else { + // delta.x = 0.0; + // delta.y = 0.0; + // delta.rotation = 0.0; + // delta.skew = 0.0; + // delta.scaleX = 0.0; + // delta.scaleY = 0.0; + // } + } + else { + var current = this.bonePose.current; + current.x = 0.0; + current.y = 0.0; + current.rotation = 0.0; + current.skew = 0.0; + current.scaleX = 1.0; + current.scaleY = 1.0; + } + }; + BoneAllTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + var current = this.bonePose.current; + var delta = this.bonePose.delta; + var result = this.bonePose.result; + this.bone._transformDirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + var scale = this._armature.armatureData.scale; + result.x = (current.x + delta.x * this._tweenProgress) * scale; + result.y = (current.y + delta.y * this._tweenProgress) * scale; + result.rotation = current.rotation + delta.rotation * this._tweenProgress; + result.skew = current.skew + delta.skew * this._tweenProgress; + result.scaleX = current.scaleX + delta.scaleX * this._tweenProgress; + result.scaleY = current.scaleY + delta.scaleY * this._tweenProgress; + }; + BoneAllTimelineState.prototype.fadeOut = function () { + var result = this.bonePose.result; + result.rotation = dragonBones.Transform.normalizeRadian(result.rotation); + result.skew = dragonBones.Transform.normalizeRadian(result.skew); + }; + return BoneAllTimelineState; + }(dragonBones.BoneTimelineState)); + dragonBones.BoneAllTimelineState = BoneAllTimelineState; + /** + * @internal + * @private + */ + var SlotDislayIndexTimelineState = (function (_super) { + __extends(SlotDislayIndexTimelineState, _super); + function SlotDislayIndexTimelineState() { + return _super !== null && _super.apply(this, arguments) || this; + } + SlotDislayIndexTimelineState.toString = function () { + return "[class dragonBones.SlotDislayIndexTimelineState]"; + }; + SlotDislayIndexTimelineState.prototype._onArriveAtFrame = function () { + if (this.playState >= 0) { + var displayIndex = this._timelineData !== null ? this._frameArray[this._frameOffset + 1] : this.slot.slotData.displayIndex; + if (this.slot.displayIndex !== displayIndex) { + this.slot._setDisplayIndex(displayIndex, true); + } + } + }; + return SlotDislayIndexTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotDislayIndexTimelineState = SlotDislayIndexTimelineState; + /** + * @internal + * @private + */ + 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._delta = [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._onClear = function () { + _super.prototype._onClear.call(this); + this._dirty = false; + }; + SlotColorTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var intArray = this._dragonBonesData.intArray; + var frameIntArray = this._dragonBonesData.frameIntArray; + var valueOffset = this._animationData.frameIntOffset + this._frameValueOffset + this._frameIndex * 1; // ...(timeline value offset)|x|x|(Value offset)|(Next offset)|x|x|... + var colorOffset = frameIntArray[valueOffset]; + this._current[0] = intArray[colorOffset++]; + this._current[1] = intArray[colorOffset++]; + this._current[2] = intArray[colorOffset++]; + this._current[3] = intArray[colorOffset++]; + this._current[4] = intArray[colorOffset++]; + this._current[5] = intArray[colorOffset++]; + this._current[6] = intArray[colorOffset++]; + this._current[7] = intArray[colorOffset++]; + if (this._tweenState === 2 /* Always */) { + if (this._frameIndex === this._frameCount - 1) { + colorOffset = frameIntArray[this._animationData.frameIntOffset + this._frameValueOffset]; + } + else { + colorOffset = frameIntArray[valueOffset + 1 * 1]; + } + this._delta[0] = intArray[colorOffset++] - this._current[0]; + this._delta[1] = intArray[colorOffset++] - this._current[1]; + this._delta[2] = intArray[colorOffset++] - this._current[2]; + this._delta[3] = intArray[colorOffset++] - this._current[3]; + this._delta[4] = intArray[colorOffset++] - this._current[4]; + this._delta[5] = intArray[colorOffset++] - this._current[5]; + this._delta[6] = intArray[colorOffset++] - this._current[6]; + this._delta[7] = intArray[colorOffset++] - this._current[7]; + } + } + else { + var color = this.slot.slotData.color; + this._current[0] = color.alphaMultiplier * 100.0; + this._current[1] = color.redMultiplier * 100.0; + this._current[2] = color.greenMultiplier * 100.0; + this._current[3] = color.blueMultiplier * 100.0; + this._current[4] = color.alphaOffset; + this._current[5] = color.redOffset; + this._current[6] = color.greenOffset; + this._current[7] = color.blueOffset; + } + }; + SlotColorTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + this._result[0] = (this._current[0] + this._delta[0] * this._tweenProgress) * 0.01; + this._result[1] = (this._current[1] + this._delta[1] * this._tweenProgress) * 0.01; + this._result[2] = (this._current[2] + this._delta[2] * this._tweenProgress) * 0.01; + this._result[3] = (this._current[3] + this._delta[3] * this._tweenProgress) * 0.01; + this._result[4] = this._current[4] + this._delta[4] * this._tweenProgress; + this._result[5] = this._current[5] + this._delta[5] * this._tweenProgress; + this._result[6] = this._current[6] + this._delta[6] * this._tweenProgress; + this._result[7] = this._current[7] + this._delta[7] * this._tweenProgress; + }; + SlotColorTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotColorTimelineState.prototype.update = function (passedTime) { + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.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; + this.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]; + this.slot._colorDirty = true; + } + } + } + }; + return SlotColorTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotColorTimelineState = SlotColorTimelineState; + /** + * @internal + * @private + */ + var SlotFFDTimelineState = (function (_super) { + __extends(SlotFFDTimelineState, _super); + function SlotFFDTimelineState() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._current = []; + _this._delta = []; + _this._result = []; + return _this; + } + SlotFFDTimelineState.toString = function () { + return "[class dragonBones.SlotFFDTimelineState]"; + }; + SlotFFDTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.meshOffset = 0; + this._dirty = false; + this._frameFloatOffset = 0; + this._valueCount = 0; + this._ffdCount = 0; + this._valueOffset = 0; + this._current.length = 0; + this._delta.length = 0; + this._result.length = 0; + }; + SlotFFDTimelineState.prototype._onArriveAtFrame = function () { + _super.prototype._onArriveAtFrame.call(this); + if (this._timelineData !== null) { + var isTween = this._tweenState === 2 /* Always */; + var frameFloatArray = this._dragonBonesData.frameFloatArray; + var valueOffset = this._animationData.frameFloatOffset + this._frameValueOffset + this._frameIndex * this._valueCount; + if (isTween) { + var nextValueOffset = valueOffset + this._valueCount; + if (this._frameIndex === this._frameCount - 1) { + nextValueOffset = this._animationData.frameFloatOffset + this._frameValueOffset; + } + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = frameFloatArray[nextValueOffset + i] - (this._current[i] = frameFloatArray[valueOffset + i]); + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = frameFloatArray[valueOffset + i]; + } + } + } + else { + for (var i = 0; i < this._valueCount; ++i) { + this._current[i] = 0.0; + } + } + }; + SlotFFDTimelineState.prototype._onUpdateFrame = function () { + _super.prototype._onUpdateFrame.call(this); + this._dirty = true; + if (this._tweenState !== 2 /* Always */) { + this._tweenState = 0 /* None */; + } + for (var i = 0; i < this._valueCount; ++i) { + this._result[i] = this._current[i] + this._delta[i] * this._tweenProgress; + } + }; + SlotFFDTimelineState.prototype.init = function (armature, animationState, timelineData) { + _super.prototype.init.call(this, armature, animationState, timelineData); + if (this._timelineData !== null) { + var frameIntArray = this._dragonBonesData.frameIntArray; + var frameIntOffset = this._animationData.frameIntOffset + this._timelineArray[this._timelineData.offset + 3 /* TimelineFrameValueCount */]; + this.meshOffset = frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */]; + this._ffdCount = frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */]; + this._valueCount = frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */]; + this._valueOffset = frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */]; + this._frameFloatOffset = frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] + this._animationData.frameFloatOffset; + } + else { + this._valueCount = 0; + } + this._current.length = this._valueCount; + this._delta.length = this._valueCount; + this._result.length = this._valueCount; + for (var i = 0; i < this._valueCount; ++i) { + this._delta[i] = 0.0; + } + }; + SlotFFDTimelineState.prototype.fadeOut = function () { + this._tweenState = 0 /* None */; + this._dirty = false; + }; + SlotFFDTimelineState.prototype.update = function (passedTime) { + if (this.slot._meshData === null || (this._timelineData !== null && this.slot._meshData.offset !== this.meshOffset)) { + return; + } + _super.prototype.update.call(this, passedTime); + // Fade animation. + if (this._tweenState !== 0 /* None */ || this._dirty) { + var result = this.slot._ffdVertices; + if (this._timelineData !== null) { + var frameFloatArray = this._dragonBonesData.frameFloatArray; + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] += (frameFloatArray[this._frameFloatOffset + i] - result[i]) * fadeProgress; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] += (this._result[i - this._valueOffset] - result[i]) * fadeProgress; + } + else { + result[i] += (frameFloatArray[this._frameFloatOffset + i - this._valueCount] - result[i]) * fadeProgress; + } + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + if (i < this._valueOffset) { + result[i] = frameFloatArray[this._frameFloatOffset + i]; + } + else if (i < this._valueOffset + this._valueCount) { + result[i] = this._result[i - this._valueOffset]; + } + else { + result[i] = frameFloatArray[this._frameFloatOffset + i - this._valueCount]; + } + } + this.slot._meshDirty = true; + } + } + else { + this._ffdCount = result.length; // + if (this._animationState._fadeState !== 0 || this._animationState._subFadeState !== 0) { + var fadeProgress = Math.pow(this._animationState._fadeProgress, 2); + for (var i = 0; i < this._ffdCount; ++i) { + result[i] += (0.0 - result[i]) * fadeProgress; + } + this.slot._meshDirty = true; + } + else if (this._dirty) { + this._dirty = false; + for (var i = 0; i < this._ffdCount; ++i) { + result[i] = 0.0; + } + this.slot._meshDirty = true; + } + } + } + }; + return SlotFFDTimelineState; + }(dragonBones.SlotTimelineState)); + dragonBones.SlotFFDTimelineState = SlotFFDTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * 事件数据。 + * @version DragonBones 4.5 + * @language zh_CN + */ + var EventObject = (function (_super) { + __extends(EventObject, _super); + function EventObject() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** + * @private + */ + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; + }; + /** + * @private + */ + 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.data = null; + }; + /** + * 动画开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.START = "start"; + /** + * 动画循环播放一次完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.LOOP_COMPLETE = "loopComplete"; + /** + * 动画播放完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.COMPLETE = "complete"; + /** + * 动画淡入开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN = "fadeIn"; + /** + * 动画淡入完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; + /** + * 动画淡出开始。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT = "fadeOut"; + /** + * 动画淡出完成。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; + /** + * 动画帧事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.FRAME_EVENT = "frameEvent"; + /** + * 动画声音事件。 + * @version DragonBones 4.5 + * @language zh_CN + */ + EventObject.SOUND_EVENT = "soundEvent"; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(dragonBones || (dragonBones = {})); +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._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 */; + 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._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._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 */; + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + DataParser.parseDragonBonesData = function (rawData) { + if (rawData instanceof ArrayBuffer) { + return dragonBones.BinaryDataParser.getInstance().parseDragonBonesData(rawData); + } + else { + return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + } + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + DataParser.parseTextureAtlasData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.warn("已废弃,请参考 @see"); + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; + } + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + } + return textureAtlasData; + }; + 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 = DataParser.DATA_VERSION_5_0; + DataParser.DATA_VERSIONS = [ + DataParser.DATA_VERSION_4_0, + DataParser.DATA_VERSION_4_5, + DataParser.DATA_VERSION_5_0 + ]; + 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.BONE = "bone"; + DataParser.IK = "ik"; + DataParser.SLOT = "slot"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.Z_ORDER = "zOrder"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.TRANSLATE_FRAME = "translateFrame"; + DataParser.ROTATE_FRAME = "rotateFrame"; + DataParser.SCALE_FRAME = "scaleFrame"; + DataParser.VISIBLE_FRAME = "visibleFrame"; + 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.CANVAS = "canvas"; + 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.SHARE = "share"; + DataParser.PATH = "path"; + DataParser.LENGTH = "length"; + DataParser.DISPLAY_INDEX = "displayIndex"; + 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_FFD = "inheritFFD"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_TYPE = "tweenType"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + 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_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.GOTO_AND_PLAY = "gotoAndPlay"; + DataParser.DEFAULT_NAME = "default"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var ObjectDataParser = (function (_super) { + __extends(ObjectDataParser, _super); + function ObjectDataParser() { + /** + * @private + */ + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._intArrayJson = []; + _this._floatArrayJson = []; + _this._frameIntArrayJson = []; + _this._frameFloatArrayJson = []; + _this._frameArrayJson = []; + _this._timelineArrayJson = []; + _this._rawTextureAtlasIndex = 0; + _this._rawBones = []; + _this._data = null; // + _this._armature = null; // + _this._bone = null; // + _this._slot = null; // + _this._skin = null; // + _this._mesh = null; // + _this._animation = null; // + _this._timeline = null; // + _this._rawTextureAtlases = null; + _this._defalultColorOffset = -1; + _this._prevTweenRotate = 0; + _this._prevRotation = 0.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._actionFrames = []; + _this._weightSlotPose = {}; + _this._weightBonePoses = {}; + _this._weightBoneIndices = {}; + _this._cacheBones = {}; + _this._meshs = {}; + _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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var type = typeof value; + if (type === "string") { + if (dragonBones.DragonBones.webAssembly) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + } + return value; + } + return String(value); + } + return defaultValue; + }; + // private readonly _intArray: Array = []; + // private readonly _floatArray: Array = []; + // private readonly _frameIntArray: Array = []; + // private readonly _frameFloatArray: Array = []; + // private readonly _frameArray: Array = []; + // private readonly _timelineArray: Array = []; + /** + * @private + */ + 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; + }; + /** + * @private + */ + ObjectDataParser.prototype._samplingEasingCurve = function (curve, samples) { + var curveCount = curve.length; + var stepIndex = -2; + for (var i = 0, l = samples.length; i < l; ++i) { + var t = (i + 1) / (l + 1); + 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; + } + }; + ObjectDataParser.prototype._sortActionFrame = function (a, b) { + return a.frameStart > b.frameStart ? 1 : -1; + }; + ObjectDataParser.prototype._parseActionDataInFrame = function (rawData, frameStart, bone, slot) { + if (ObjectDataParser.EVENT in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENT], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.SOUND in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.SOUND], frameStart, 11 /* Sound */, bone, slot); + } + if (ObjectDataParser.ACTION in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTION], frameStart, 0 /* Play */, bone, slot); + } + if (ObjectDataParser.EVENTS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.EVENTS], frameStart, 10 /* Frame */, bone, slot); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._mergeActionFrame(rawData[ObjectDataParser.ACTIONS], frameStart, 0 /* Play */, bone, slot); + } + }; + ObjectDataParser.prototype._mergeActionFrame = function (rawData, frameStart, type, bone, slot) { + var actionOffset = dragonBones.DragonBones.webAssembly ? this._armature.actions.size() : this._armature.actions.length; + var actionCount = this._parseActionData(rawData, this._armature.actions, type, bone, slot); + var frame = null; + if (this._actionFrames.length === 0) { + frame = new ActionFrame(); + frame.frameStart = 0; + this._actionFrames.push(frame); + frame = null; + } + for (var _i = 0, _a = this._actionFrames; _i < _a.length; _i++) { + var eachFrame = _a[_i]; + if (eachFrame.frameStart === frameStart) { + frame = eachFrame; + break; + } + } + if (frame === null) { + frame = new ActionFrame(); + frame.frameStart = frameStart; + this._actionFrames.push(frame); + } + for (var i = 0; i < actionCount; ++i) { + frame.actions.push(actionOffset + i); + } + }; + ObjectDataParser.prototype._parseCacheActionFrame = function (frame) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = frameArray.length; + var actionCount = frame.actions.length; + frameArray.length += 1 + 1 + actionCount; + frameArray[frameOffset + 0 /* FramePosition */] = frame.frameStart; + frameArray[frameOffset + 0 /* FramePosition */ + 1] = actionCount; // Action count. + for (var i = 0; i < actionCount; ++i) { + frameArray[frameOffset + 0 /* FramePosition */ + 2 + i] = frame.actions[i]; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArmature = function (rawData, scale) { + // const armature = BaseObject.borrowObject(ArmatureData); + var armature = dragonBones.DragonBones.webAssembly ? new Module["ArmatureData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate); + armature.scale = scale; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); + } + else { + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); + } + if (armature.frameRate === 0) { + armature.frameRate = 24; + } + this._armature = armature; + if (ObjectDataParser.AABB in rawData) { + var rawAABB = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.X, 0.0); + armature.aabb.y = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.Y, 0.0); + armature.aabb.width = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.WIDTH, 0.0); + armature.aabb.height = ObjectDataParser._getNumber(rawAABB, ObjectDataParser.HEIGHT, 0.0); + } + if (ObjectDataParser.CANVAS in rawData) { + var rawCanvas = rawData[ObjectDataParser.CANVAS]; + var canvas = dragonBones.BaseObject.borrowObject(dragonBones.CanvasData); + if (ObjectDataParser.COLOR in rawCanvas) { + ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.hasBackground = true; + } + else { + canvas.hasBackground = false; + } + canvas.color = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.COLOR, 0); + canvas.x = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.X, 0); + canvas.y = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.Y, 0); + canvas.width = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.WIDTH, 0); + canvas.height = ObjectDataParser._getNumber(rawCanvas, ObjectDataParser.HEIGHT, 0); + armature.canvas = canvas; + } + if (ObjectDataParser.BONE in rawData) { + var rawBones = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawBones_1 = rawBones; _i < rawBones_1.length; _i++) { + var rawBone = rawBones_1[_i]; + var parentName = ObjectDataParser._getString(rawBone, ObjectDataParser.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 { + (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); // Raw bone sort. + } + } + if (ObjectDataParser.IK in rawData) { + var rawIKS = rawData[ObjectDataParser.IK]; + for (var _c = 0, rawIKS_1 = rawIKS; _c < rawIKS_1.length; _c++) { + var rawIK = rawIKS_1[_c]; + this._parseIKConstraint(rawIK); + } + } + armature.sortBones(); + if (ObjectDataParser.SLOT in rawData) { + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _d = 0, rawSlots_1 = rawSlots; _d < rawSlots_1.length; _d++) { + var rawSlot = rawSlots_1[_d]; + armature.addSlot(this._parseSlot(rawSlot)); + } + } + if (ObjectDataParser.SKIN in rawData) { + var rawSkins = rawData[ObjectDataParser.SKIN]; + for (var _e = 0, rawSkins_1 = rawSkins; _e < rawSkins_1.length; _e++) { + var rawSkin = rawSkins_1[_e]; + armature.addSkin(this._parseSkin(rawSkin)); + } + } + if (ObjectDataParser.ANIMATION in rawData) { + var rawAnimations = rawData[ObjectDataParser.ANIMATION]; + for (var _f = 0, rawAnimations_1 = rawAnimations; _f < rawAnimations_1.length; _f++) { + var rawAnimation = rawAnimations_1[_f]; + var animation = this._parseAnimation(rawAnimation); + armature.addAnimation(animation); + } + } + if (ObjectDataParser.DEFAULT_ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.DEFAULT_ACTIONS], armature.defaultActions, 0 /* Play */, null, null); + } + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armature.actions, 0 /* Play */, null, null); + } + // for (const action of armature.defaultActions) { // Set default animation from default action. + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? armature.defaultActions.size() : armature.defaultActions.length); ++i) { + var action = dragonBones.DragonBones.webAssembly ? armature.defaultActions.get(i) : armature.defaultActions[i]; + if (action.type === 0 /* Play */) { + var animation = armature.getAnimation(action.name); + if (animation !== null) { + armature.defaultAnimation = animation; + } + break; + } + } + // Clear helper. + this._rawBones.length = 0; + this._armature = null; + for (var k in this._meshs) { + delete this._meshs[k]; + } + for (var k in this._cacheBones) { + delete this._cacheBones[k]; + } + for (var k in this._slotChildActions) { + delete this._slotChildActions[k]; + } + 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._weightBoneIndices) { + delete this._weightBoneIndices[k]; + } + return armature; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBone = function (rawData) { + // const bone = BaseObject.borrowObject(BoneData); + var bone = dragonBones.DragonBones.webAssembly ? new Module["BoneData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.inheritReflection = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_REFLECTION, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armature.scale; + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform, this._armature.scale); + } + return bone; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseIKConstraint = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + var target = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, "")); + if (target === null) { + return; + } + // const constraint = BaseObject.borrowObject(IKConstraintData); + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraintData"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraintData); + constraint.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + constraint.scaleEnabled = ObjectDataParser._getBoolean(rawData, ObjectDataParser.SCALE, false); + constraint.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1.0); + constraint.bone = bone; + constraint.target = target; + var chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + if (chain > 0) { + constraint.root = bone.parent; + } + if (dragonBones.DragonBones.webAssembly) { + bone.constraints.push_back(constraint); + } + else { + bone.constraints.push(constraint); + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlot = function (rawData) { + // const slot = BaseObject.borrowObject(SlotData); + var slot = dragonBones.DragonBones.webAssembly ? new Module["SlotData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = dragonBones.DragonBones.webAssembly ? this._armature.sortedSlots.size() : this._armature.sortedSlots.length; + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, "")); // + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] === "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); + } + if (ObjectDataParser.COLOR in rawData) { + // slot.color = SlotData.createColor(); + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].createColor() : dragonBones.SlotData.createColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + // slot.color = SlotData.DEFAULT_COLOR; + slot.color = dragonBones.DragonBones.webAssembly ? Module["SlotData"].DEFAULT_COLOR : dragonBones.SlotData.DEFAULT_COLOR; + } + if (ObjectDataParser.ACTIONS in rawData) { + var actions = this._slotChildActions[slot.name] = []; + this._parseActionData(rawData[ObjectDataParser.ACTIONS], actions, 0 /* Play */, null, null); + } + return slot; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSkin = function (rawData) { + // const skin = BaseObject.borrowObject(SkinData); + var skin = dragonBones.DragonBones.webAssembly ? new Module["SkinData"]() : dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + if (skin.name.length === 0) { + skin.name = ObjectDataParser.DEFAULT_NAME; + } + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + var rawSlots = rawData[ObjectDataParser.SLOT]; + for (var _i = 0, rawSlots_2 = rawSlots; _i < rawSlots_2.length; _i++) { + var rawSlot = rawSlots_2[_i]; + var slotName = ObjectDataParser._getString(rawSlot, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot !== null) { + this._slot = slot; + if (ObjectDataParser.DISPLAY in rawSlot) { + var rawDisplays = rawSlot[ObjectDataParser.DISPLAY]; + for (var _a = 0, rawDisplays_1 = rawDisplays; _a < rawDisplays_1.length; _a++) { + var rawDisplay = rawDisplays_1[_a]; + skin.addDisplay(slotName, this._parseDisplay(rawDisplay)); + } + } + this._slot = null; // + } + } + this._skin = null; // + } + return skin; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var display = null; + var name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + var path = ObjectDataParser._getString(rawData, ObjectDataParser.PATH, ""); + var type = 0 /* Image */; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] === "string") { + type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, type); + } + switch (type) { + case 0 /* Image */: + // const imageDisplay = display = BaseObject.borrowObject(ImageDisplayData); + var imageDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ImageDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ImageDisplayData); + imageDisplay.name = name; + imageDisplay.path = path.length > 0 ? path : name; + this._parsePivot(rawData, imageDisplay); + break; + case 1 /* Armature */: + // const armatureDisplay = display = BaseObject.borrowObject(ArmatureDisplayData); + var armatureDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["ArmatureDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ArmatureDisplayData); + armatureDisplay.name = name; + armatureDisplay.path = path.length > 0 ? path : name; + armatureDisplay.inheritAnimation = true; + if (ObjectDataParser.ACTIONS in rawData) { + this._parseActionData(rawData[ObjectDataParser.ACTIONS], armatureDisplay.actions, 0 /* Play */, null, null); + } + 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 _i = 0, _a = this._slotChildActions[this._slot.name]; _i < _a.length; _i++) { + var action = _a[_i]; + if (dragonBones.DragonBones.webAssembly) { + armatureDisplay.actions.push_back(action); + } + else { + armatureDisplay.actions.push(action); + } + } + delete this._slotChildActions[this._slot.name]; + } + } + break; + case 2 /* Mesh */: + // const meshDisplay = display = BaseObject.borrowObject(MeshDisplayData); + var meshDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["MeshDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.MeshDisplayData); + meshDisplay.name = name; + meshDisplay.path = path.length > 0 ? path : name; + meshDisplay.inheritAnimation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_FFD, true); + this._parsePivot(rawData, meshDisplay); + var shareName = ObjectDataParser._getString(rawData, ObjectDataParser.SHARE, ""); + if (shareName.length > 0) { + var shareMesh = this._meshs[shareName]; + meshDisplay.offset = shareMesh.offset; + meshDisplay.weight = shareMesh.weight; + } + else { + this._parseMesh(rawData, meshDisplay); + this._meshs[meshDisplay.name] = meshDisplay; + } + break; + case 3 /* BoundingBox */: + var boundingBox = this._parseBoundingBox(rawData); + if (boundingBox !== null) { + // const boundingBoxDisplay = display = BaseObject.borrowObject(BoundingBoxDisplayData); + var boundingBoxDisplay = display = dragonBones.DragonBones.webAssembly ? new Module["BoundingBoxDisplayData"]() : dragonBones.BaseObject.borrowObject(dragonBones.BoundingBoxDisplayData); + boundingBoxDisplay.name = name; + boundingBoxDisplay.path = path.length > 0 ? path : name; + boundingBoxDisplay.boundingBox = boundingBox; + } + break; + } + if (display !== null) { + display.parent = this._armature; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform, this._armature.scale); + } + } + return display; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePivot = function (rawData, display) { + if (ObjectDataParser.PIVOT in rawData) { + var rawPivot = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.X, 0.0); + display.pivot.y = ObjectDataParser._getNumber(rawPivot, ObjectDataParser.Y, 0.0); + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseMesh = function (rawData, mesh) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var rawUVs = rawData[ObjectDataParser.UVS]; + var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + var vertexCount = Math.floor(rawVertices.length / 2); // uint + var triangleCount = Math.floor(rawTriangles.length / 3); // uint + var vertexOffset = floatArray.length; + var uvOffset = vertexOffset + vertexCount * 2; + mesh.offset = intArray.length; + intArray.length += 1 + 1 + 1 + 1 + triangleCount * 3; + intArray[mesh.offset + 0 /* MeshVertexCount */] = vertexCount; + intArray[mesh.offset + 1 /* MeshTriangleCount */] = triangleCount; + intArray[mesh.offset + 2 /* MeshFloatOffset */] = vertexOffset; + for (var i = 0, l = triangleCount * 3; i < l; ++i) { + intArray[mesh.offset + 4 /* MeshVertexIndices */ + i] = rawTriangles[i]; + } + floatArray.length += vertexCount * 2 + vertexCount * 2; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + floatArray[vertexOffset + i] = rawVertices[i]; + floatArray[uvOffset + i] = rawUVs[i]; + } + if (ObjectDataParser.WEIGHTS in rawData) { + var rawWeights = rawData[ObjectDataParser.WEIGHTS]; + var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; + var rawBonePoses = rawData[ObjectDataParser.BONE_POSE]; + var weightBoneIndices = new Array(); + var weightBoneCount = Math.floor(rawBonePoses.length / 7); // uint + var floatOffset = floatArray.length; + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + weight.count = (rawWeights.length - vertexCount) / 2; + weight.offset = intArray.length; + weight.bones.length = weightBoneCount; + weightBoneIndices.length = weightBoneCount; + intArray.length += 1 + 1 + weightBoneCount + vertexCount + weight.count; + intArray[weight.offset + 1 /* WeigthFloatOffset */] = floatOffset; + for (var i = 0; i < weightBoneCount; ++i) { + var rawBoneIndex = rawBonePoses[i * 7]; // uint + var bone = this._rawBones[rawBoneIndex]; + weight.bones[i] = bone; + weightBoneIndices[i] = rawBoneIndex; + if (dragonBones.DragonBones.webAssembly) { + for (var j = 0; j < this._armature.sortedBones.size(); j++) { + if (this._armature.sortedBones.get(j) === bone) { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = j; + } + } + } + else { + intArray[weight.offset + 2 /* WeigthBoneIndices */ + i] = this._armature.sortedBones.indexOf(bone); + } + } + floatArray.length += weight.count * 3; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + for (var i = 0, iW = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weightBoneCount, iV = floatOffset; i < vertexCount; ++i) { + var iD = i * 2; + var vertexBoneCount = intArray[iB++] = rawWeights[iW++]; // uint + var x = floatArray[vertexOffset + iD]; + var y = floatArray[vertexOffset + 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 bone = this._rawBones[rawBoneIndex]; + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint); + intArray[iB++] = weight.bones.indexOf(bone); + floatArray[iV++] = rawWeights[iW++]; + floatArray[iV++] = this._helpPoint.x; + floatArray[iV++] = this._helpPoint.y; + } + } + mesh.weight = weight; + // + this._weightSlotPose[mesh.name] = rawSlotPose; + this._weightBonePoses[mesh.name] = rawBonePoses; + this._weightBoneIndices[mesh.name] = weightBoneIndices; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoundingBox = function (rawData) { + var boundingBox = null; + var type = 0 /* Rectangle */; + if (ObjectDataParser.SUB_TYPE in rawData && typeof rawData[ObjectDataParser.SUB_TYPE] === "string") { + type = ObjectDataParser._getBoundingBoxType(rawData[ObjectDataParser.SUB_TYPE]); + } + else { + type = ObjectDataParser._getNumber(rawData, ObjectDataParser.SUB_TYPE, type); + } + switch (type) { + case 0 /* Rectangle */: + // boundingBox = BaseObject.borrowObject(RectangleBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["RectangleBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.RectangleBoundingBoxData); + break; + case 1 /* Ellipse */: + // boundingBox = BaseObject.borrowObject(EllipseBoundingBoxData); + boundingBox = dragonBones.DragonBones.webAssembly ? new Module["EllipseBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.EllipseBoundingBoxData); + break; + case 2 /* Polygon */: + boundingBox = this._parsePolygonBoundingBox(rawData); + break; + } + if (boundingBox !== null) { + boundingBox.color = ObjectDataParser._getNumber(rawData, ObjectDataParser.COLOR, 0x000000); + if (boundingBox.type === 0 /* Rectangle */ || boundingBox.type === 1 /* Ellipse */) { + boundingBox.width = ObjectDataParser._getNumber(rawData, ObjectDataParser.WIDTH, 0.0); + boundingBox.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0.0); + } + } + return boundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var floatArray = dragonBones.DragonBones.webAssembly ? this._floatArrayJson : this._data.floatArray; + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = floatArray.length; + polygonBoundingBox.count = rawVertices.length; + polygonBoundingBox.vertices = floatArray; + floatArray.length += polygonBoundingBox.count; + for (var i = 0, l = polygonBoundingBox.count; i < l; i += 2) { + var iN = i + 1; + var x = rawVertices[i]; + var y = rawVertices[iN]; + floatArray[polygonBoundingBox.offset + i] = x; + floatArray[polygonBoundingBox.offset + iN] = 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; + } + } + } + return polygonBoundingBox; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ObjectDataParser.DEFAULT_NAME); + // TDOO Check std::string length + if (animation.name.length < 1) { + animation.name = ObjectDataParser.DEFAULT_NAME; + } + if (dragonBones.DragonBones.webAssembly) { + animation.frameIntOffset = this._frameIntArrayJson.length; + animation.frameFloatOffset = this._frameFloatArrayJson.length; + animation.frameOffset = this._frameArrayJson.length; + } + else { + animation.frameIntOffset = this._data.frameIntArray.length; + animation.frameFloatOffset = this._data.frameFloatArray.length; + animation.frameOffset = this._data.frameArray.length; + } + this._animation = animation; + if (ObjectDataParser.FRAME in rawData) { + var rawFrames = rawData[ObjectDataParser.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, ObjectDataParser.DURATION, 1); + } + } + } + if (ObjectDataParser.Z_ORDER in rawData) { + this._animation.zOrderTimeline = this._parseTimeline(rawData[ObjectDataParser.Z_ORDER], 1 /* ZOrder */, false, false, 0, this._parseZOrderFrame); + } + if (ObjectDataParser.BONE in rawData) { + var rawTimelines = rawData[ObjectDataParser.BONE]; + for (var _i = 0, rawTimelines_1 = rawTimelines; _i < rawTimelines_1.length; _i++) { + var rawTimeline = rawTimelines_1[_i]; + this._parseBoneTimeline(rawTimeline); + } + } + if (ObjectDataParser.SLOT in rawData) { + var rawTimelines = rawData[ObjectDataParser.SLOT]; + for (var _a = 0, rawTimelines_2 = rawTimelines; _a < rawTimelines_2.length; _a++) { + var rawTimeline = rawTimelines_2[_a]; + this._parseSlotTimeline(rawTimeline); + } + } + if (ObjectDataParser.FFD in rawData) { + var rawTimelines = rawData[ObjectDataParser.FFD]; + for (var _b = 0, rawTimelines_3 = rawTimelines; _b < rawTimelines_3.length; _b++) { + var rawTimeline = rawTimelines_3[_b]; + var slotName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.SLOT, ""); + var displayName = ObjectDataParser._getString(rawTimeline, ObjectDataParser.NAME, ""); + var slot = this._armature.getSlot(slotName); + if (slot === null) { + continue; + } + this._slot = slot; + this._mesh = this._meshs[displayName]; + var timelineFFD = this._parseTimeline(rawTimeline, 22 /* SlotFFD */, false, true, 0, this._parseSlotFFDFrame); + if (timelineFFD !== null) { + this._animation.addSlotTimeline(slot, timelineFFD); + } + this._slot = null; // + this._mesh = null; // + } + } + if (this._actionFrames.length > 0) { + this._actionFrames.sort(this._sortActionFrame); + // const timeline = this._animation.actionTimeline = BaseObject.borrowObject(TimelineData); + var timeline = this._animation.actionTimeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var keyFrameCount = this._actionFrames.length; + timeline.type = 0 /* Action */; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = 100; + timelineArray[timeline.offset + 1 /* TimelineOffset */] = 0; + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = 0; + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = this._parseCacheActionFrame(this._actionFrames[0]) - this._animation.frameOffset; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + //(frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + var frame = this._actionFrames[iK]; + frameStart = frame.frameStart; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._actionFrames[iK + 1].frameStart - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = this._parseCacheActionFrame(frame) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + this._actionFrames.length = 0; + } + this._animation = null; // + return animation; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTimeline = function (rawData, type, addIntOffset, addFloatOffset, frameValueCount, frameParser) { + if (!(ObjectDataParser.FRAME in rawData)) { + return null; + } + var rawFrames = rawData[ObjectDataParser.FRAME]; + var keyFrameCount = rawFrames.length; + if (keyFrameCount === 0) { + return null; + } + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntArrayLength = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson.length : this._data.frameIntArray.length; + var frameFloatArrayLength = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson.length : this._data.frameFloatArray.length; + // const timeline = BaseObject.borrowObject(TimelineData); + var timeline = dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData); + timeline.type = type; + timeline.offset = timelineArray.length; + timelineArray.length += 1 + 1 + 1 + 1 + 1 + keyFrameCount; + timelineArray[timeline.offset + 0 /* TimelineScale */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1.0) * 100); + timelineArray[timeline.offset + 1 /* TimelineOffset */] = Math.round(ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0.0) * 100); + timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */] = keyFrameCount; + timelineArray[timeline.offset + 3 /* TimelineFrameValueCount */] = frameValueCount; + if (addIntOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameIntArrayLength - this._animation.frameIntOffset; + } + else if (addFloatOffset) { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = frameFloatArrayLength - this._animation.frameFloatOffset; + } + else { + timelineArray[timeline.offset + 4 /* TimelineFrameValueOffset */] = 0; + } + this._timeline = timeline; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + 0] = frameParser.call(this, rawFrames[0], 0, 0) - this._animation.frameOffset; + } + else { + var frameIndices = this._data.frameIndices; + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // frameIndices.resize( frameIndices.size() + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + 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; + frameCount = ObjectDataParser._getNumber(rawFrame, ObjectDataParser.DURATION, 1); + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK] = frameParser.call(this, rawFrame, frameStart, frameCount) - this._animation.frameOffset; + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (bone === null) { + return; + } + this._bone = bone; + this._slot = this._armature.getSlot(this._bone.name); + var timeline = this._parseTimeline(rawData, 10 /* BoneAll */, false, true, 6, this._parseBoneFrame); + if (timeline !== null) { + this._animation.addBoneTimeline(bone, timeline); + } + this._bone = null; // + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "")); + if (slot === null) { + return; + } + this._slot = slot; + var displayIndexTimeline = this._parseTimeline(rawData, 20 /* SlotDisplay */, false, false, 0, this._parseSlotDisplayIndexFrame); + if (displayIndexTimeline !== null) { + this._animation.addSlotTimeline(slot, displayIndexTimeline); + } + var colorTimeline = this._parseTimeline(rawData, 21 /* SlotColor */, true, false, 1, this._parseSlotColorFrame); + if (colorTimeline !== null) { + this._animation.addSlotTimeline(slot, colorTimeline); + } + this._slot = null; // + }; + /** + * @private + */ + ObjectDataParser.prototype._parseFrame = function (rawData, frameStart, frameCount, frameArray) { + rawData; + frameCount; + var frameOffset = frameArray.length; + frameArray.length += 1; + frameArray[frameOffset + 0 /* FramePosition */] = frameStart; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frameStart, frameCount, frameArray) { + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (frameCount > 0) { + if (ObjectDataParser.CURVE in rawData) { + var sampleCount = frameCount + 1; + this._helpArray.length = sampleCount; + this._samplingEasingCurve(rawData[ObjectDataParser.CURVE], this._helpArray); + frameArray.length += 1 + 1 + this._helpArray.length; + frameArray[frameOffset + 1 /* FrameTweenType */] = 2 /* Curve */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = sampleCount; + for (var i = 0; i < sampleCount; ++i) { + frameArray[frameOffset + 3 /* FrameCurveSamples */ + i] = Math.round(this._helpArray[i] * 10000.0); + } + } + else { + var noTween = -2.0; + var tweenEasing = noTween; + if (ObjectDataParser.TWEEN_EASING in rawData) { + tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, noTween); + } + if (tweenEasing === noTween) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + else if (tweenEasing === 0.0) { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 1 /* Line */; + } + else if (tweenEasing < 0.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 3 /* QuadIn */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(-tweenEasing * 100.0); + } + else if (tweenEasing <= 1.0) { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 4 /* QuadOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0); + } + else { + frameArray.length += 1 + 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 5 /* QuadInOut */; + frameArray[frameOffset + 2 /* FrameTweenEasingOrCurveSampleCount */] = Math.round(tweenEasing * 100.0 - 100.0); + } + } + } + else { + frameArray.length += 1; + frameArray[frameOffset + 1 /* FrameTweenType */] = 0 /* None */; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseZOrderFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + if (ObjectDataParser.Z_ORDER in rawData) { + var rawZOrder = rawData[ObjectDataParser.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 < slotCount; ++i_1) { + zOrders[i_1] = -1; + } + var originalIndex = 0; + var unchangedIndex = 0; + for (var i_2 = 0, l = rawZOrder.length; i_2 < l; i_2 += 2) { + var slotIndex = rawZOrder[i_2]; + var zOrderOffset = rawZOrder[i_2 + 1]; + while (originalIndex !== slotIndex) { + unchanged[unchangedIndex++] = originalIndex++; + } + zOrders[originalIndex + zOrderOffset] = originalIndex++; + } + while (originalIndex < slotCount) { + unchanged[unchangedIndex++] = originalIndex++; + } + frameArray.length += 1 + slotCount; + frameArray[frameOffset + 1] = slotCount; + var i = slotCount; + while (i--) { + if (zOrders[i] === -1) { + frameArray[frameOffset + 2 + i] = unchanged[--unchangedIndex]; + } + else { + frameArray[frameOffset + 2 + i] = zOrders[i]; + } + } + return frameOffset; + } + } + frameArray.length += 1; + frameArray[frameOffset + 1] = 0; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneFrame = function (rawData, frameStart, frameCount) { + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + this._helpTransform.identity(); + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], this._helpTransform, 1.0); + } + // Modify rotation. + var rotation = this._helpTransform.rotation; + if (frameStart !== 0) { + if (this._prevTweenRotate === 0) { + rotation = this._prevRotation + dragonBones.Transform.normalizeRadian(rotation - this._prevRotation); + } + else { + if (this._prevTweenRotate > 0 ? rotation >= this._prevRotation : rotation <= this._prevRotation) { + this._prevTweenRotate = this._prevTweenRotate > 0 ? this._prevTweenRotate - 1 : this._prevTweenRotate + 1; + } + rotation = this._prevRotation + rotation - this._prevRotation + dragonBones.Transform.PI_D * this._prevTweenRotate; + } + } + this._prevTweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0.0); + this._prevRotation = rotation; + var frameFloatOffset = frameFloatArray.length; + frameFloatArray.length += 6; + frameFloatArray[frameFloatOffset++] = this._helpTransform.x; + frameFloatArray[frameFloatOffset++] = this._helpTransform.y; + frameFloatArray[frameFloatOffset++] = rotation; + frameFloatArray[frameFloatOffset++] = this._helpTransform.skew; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleX; + frameFloatArray[frameFloatOffset++] = this._helpTransform.scaleY; + this._parseActionDataInFrame(rawData, frameStart, this._bone, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotDisplayIndexFrame = function (rawData, frameStart, frameCount) { + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseFrame(rawData, frameStart, frameCount, frameArray); + frameArray.length += 1; + frameArray[frameOffset + 1] = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + this._parseActionDataInFrame(rawData, frameStart, this._slot.parent, this._slot); + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotColorFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var colorOffset = -1; + if (ObjectDataParser.COLOR in rawData) { + var rawColor = rawData[ObjectDataParser.COLOR]; + for (var k in rawColor) { + k; + this._parseColorTransform(rawColor, this._helpColorTransform); + colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueMultiplier * 100); + intArray[colorOffset++] = Math.round(this._helpColorTransform.alphaOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.redOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.greenOffset); + intArray[colorOffset++] = Math.round(this._helpColorTransform.blueOffset); + colorOffset -= 8; + break; + } + } + if (colorOffset < 0) { + if (this._defalultColorOffset < 0) { + this._defalultColorOffset = colorOffset = intArray.length; + intArray.length += 8; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 100; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + intArray[colorOffset++] = 0; + } + colorOffset = this._defalultColorOffset; + } + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1; + frameIntArray[frameIntOffset] = colorOffset; + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotFFDFrame = function (rawData, frameStart, frameCount) { + var intArray = dragonBones.DragonBones.webAssembly ? this._intArrayJson : this._data.intArray; + var frameFloatArray = dragonBones.DragonBones.webAssembly ? this._frameFloatArrayJson : this._data.frameFloatArray; + var frameArray = dragonBones.DragonBones.webAssembly ? this._frameArrayJson : this._data.frameArray; + var frameFloatOffset = frameFloatArray.length; + var frameOffset = this._parseTweenFrame(rawData, frameStart, frameCount, frameArray); + var rawVertices = ObjectDataParser.VERTICES in rawData ? rawData[ObjectDataParser.VERTICES] : null; + var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); // uint + var vertexCount = intArray[this._mesh.offset + 0 /* MeshVertexCount */]; + var x = 0.0; + var y = 0.0; + var iB = 0; + var iV = 0; + if (this._mesh.weight !== null) { + var rawSlotPose = this._weightSlotPose[this._mesh.name]; + this._helpMatrixA.copyFromArray(rawSlotPose, 0); + frameFloatArray.length += this._mesh.weight.count * 2; + iB = this._mesh.weight.offset + 2 /* WeigthBoneIndices */ + this._mesh.weight.bones.length; + } + else { + 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 (this._mesh.weight !== null) { + var rawBonePoses = this._weightBonePoses[this._mesh.name]; + var weightBoneIndices = this._weightBoneIndices[this._mesh.name]; + var vertexBoneCount = 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 = intArray[iB++]; + var bone = this._mesh.weight.bones[boneIndex]; + var rawBoneIndex = this._rawBones.indexOf(bone); + this._helpMatrixB.copyFromArray(rawBonePoses, weightBoneIndices.indexOf(rawBoneIndex) * 7 + 1); + this._helpMatrixB.invert(); + this._helpMatrixB.transformPoint(x, y, this._helpPoint, true); + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.x; + frameFloatArray[frameFloatOffset + iV++] = this._helpPoint.y; + } + } + else { + frameFloatArray[frameFloatOffset + i] = x; + frameFloatArray[frameFloatOffset + i + 1] = y; + } + } + if (frameStart === 0) { + var frameIntArray = dragonBones.DragonBones.webAssembly ? this._frameIntArrayJson : this._data.frameIntArray; + var timelineArray = dragonBones.DragonBones.webAssembly ? this._timelineArrayJson : this._data.timelineArray; + var frameIntOffset = frameIntArray.length; + frameIntArray.length += 1 + 1 + 1 + 1 + 1; + frameIntArray[frameIntOffset + 0 /* FFDTimelineMeshOffset */] = this._mesh.offset; + frameIntArray[frameIntOffset + 1 /* FFDTimelineFFDCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 2 /* FFDTimelineValueCount */] = frameFloatArray.length - frameFloatOffset; + frameIntArray[frameIntOffset + 3 /* FFDTimelineValueOffset */] = 0; + frameIntArray[frameIntOffset + 4 /* FFDTimelineFloatOffset */] = frameFloatOffset; + timelineArray[this._timeline.offset + 3 /* TimelineFrameValueCount */] = frameIntOffset - this._animation.frameIntOffset; + } + return frameOffset; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseActionData = function (rawData, actions, type, bone, slot) { + var actionCount = 0; + if (typeof rawData === "string") { + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + action.type = type; + action.name = rawData; + action.bone = bone; + action.slot = slot; + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + else if (rawData instanceof Array) { + for (var _i = 0, rawData_1 = rawData; _i < rawData_1.length; _i++) { + var rawAction = rawData_1[_i]; + // const action = BaseObject.borrowObject(ActionData); + var action = dragonBones.DragonBones.webAssembly ? new Module["ActionData"]() : dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + if (ObjectDataParser.GOTO_AND_PLAY in rawAction) { + action.type = 0 /* Play */; + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.GOTO_AND_PLAY, ""); + } + else { + if (ObjectDataParser.TYPE in rawAction && typeof rawAction[ObjectDataParser.TYPE] === "string") { + action.type = ObjectDataParser._getActionType(rawAction[ObjectDataParser.TYPE]); + } + else { + action.type = ObjectDataParser._getNumber(rawAction, ObjectDataParser.TYPE, type); + } + action.name = ObjectDataParser._getString(rawAction, ObjectDataParser.NAME, ""); + } + if (ObjectDataParser.BONE in rawAction) { + var boneName = ObjectDataParser._getString(rawAction, ObjectDataParser.BONE, ""); + action.bone = this._armature.getBone(boneName); + } + else { + action.bone = bone; + } + if (ObjectDataParser.SLOT in rawAction) { + var slotName = ObjectDataParser._getString(rawAction, ObjectDataParser.SLOT, ""); + action.slot = this._armature.getSlot(slotName); + } + else { + action.slot = slot; + } + if (ObjectDataParser.INTS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawInts = rawAction[ObjectDataParser.INTS]; + for (var _a = 0, rawInts_1 = rawInts; _a < rawInts_1.length; _a++) { + var rawValue = rawInts_1[_a]; + dragonBones.DragonBones.webAssembly ? action.data.ints.push_back(rawValue) : action.data.ints.push(rawValue); + } + } + if (ObjectDataParser.FLOATS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawFloats = rawAction[ObjectDataParser.FLOATS]; + for (var _b = 0, rawFloats_1 = rawFloats; _b < rawFloats_1.length; _b++) { + var rawValue = rawFloats_1[_b]; + dragonBones.DragonBones.webAssembly ? action.data.floats.push_back(rawValue) : action.data.floats.push(rawValue); + } + } + if (ObjectDataParser.STRINGS in rawAction) { + if (action.data === null) { + // action.data = BaseObject.borrowObject(UserData); + action.data = dragonBones.DragonBones.webAssembly ? new Module["UserData"]() : dragonBones.BaseObject.borrowObject(dragonBones.UserData); + } + var rawStrings = rawAction[ObjectDataParser.STRINGS]; + for (var _c = 0, rawStrings_1 = rawStrings; _c < rawStrings_1.length; _c++) { + var rawValue = rawStrings_1[_c]; + dragonBones.DragonBones.webAssembly ? action.data.strings.push_back(rawValue) : action.data.strings.push(rawValue); + } + } + dragonBones.DragonBones.webAssembly ? actions.push_back(action) : actions.push(action); + actionCount++; + } + } + return actionCount; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTransform = function (rawData, transform, scale) { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0.0) * scale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0.0) * scale; + if (ObjectDataParser.ROTATE in rawData || ObjectDataParser.SKEW in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.ROTATE, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW, 0.0) * dragonBones.Transform.DEG_RAD); + } + else if (ObjectDataParser.SKEW_X in rawData || ObjectDataParser.SKEW_Y in rawData) { + transform.rotation = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0.0) * dragonBones.Transform.DEG_RAD); + transform.skew = dragonBones.Transform.normalizeRadian(ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0.0) * dragonBones.Transform.DEG_RAD) - transform.rotation; + } + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1.0); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1.0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseArray = function (rawData) { + rawData; + if (dragonBones.DragonBones.webAssembly) { + return; + } + this._data.intArray = []; + this._data.floatArray = []; + this._data.frameIntArray = []; + this._data.frameFloatArray = []; + this._data.frameArray = []; + this._data.timelineArray = []; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseWASMArray = function () { + var intArrayBuf = Module._malloc(this._intArrayJson.length * 2); + this._intArrayBuffer = new Int16Array(Module.HEAP16.buffer, intArrayBuf, this._intArrayJson.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + for (var i1 = 0; i1 < this._intArrayJson.length; ++i1) { + this._intArrayBuffer[i1] = this._intArrayJson[i1]; + } + var floatArrayBuf = Module._malloc(this._floatArrayJson.length * 4); + // Module.HEAPF32.set(this._floatArrayJson, floatArrayBuf); + this._floatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, this._floatArrayJson.length); + for (var i2 = 0; i2 < this._floatArrayJson.length; ++i2) { + this._floatArrayBuffer[i2] = this._floatArrayJson[i2]; + } + var frameIntArrayBuf = Module._malloc(this._frameIntArrayJson.length * 2); + // Module.HEAP16.set(this._frameIntArrayJson, frameIntArrayBuf); + this._frameIntArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, this._frameIntArrayJson.length); + for (var i3 = 0; i3 < this._frameIntArrayJson.length; ++i3) { + this._frameIntArrayBuffer[i3] = this._frameIntArrayJson[i3]; + } + var frameFloatArrayBuf = Module._malloc(this._frameFloatArrayJson.length * 4); + // Module.HEAPF32.set(this._frameFloatArrayJson, frameFloatArrayBuf); + this._frameFloatArrayBuffer = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, this._frameFloatArrayJson.length); + for (var i4 = 0; i4 < this._frameFloatArrayJson.length; ++i4) { + this._frameFloatArrayBuffer[i4] = this._frameFloatArrayJson[i4]; + } + var frameArrayBuf = Module._malloc(this._frameArrayJson.length * 2); + // Module.HEAP16.set(this._frameArrayJson, frameArrayBuf); + this._frameArrayBuffer = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, this._frameArrayJson.length); + for (var i5 = 0; i5 < this._frameArrayJson.length; ++i5) { + this._frameArrayBuffer[i5] = this._frameArrayJson[i5]; + } + var timelineArrayBuf = Module._malloc(this._timelineArrayJson.length * 2); + // Module.HEAPU16.set(this._timelineArrayJson, timelineArrayBuf); + this._timelineArrayBuffer = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, this._timelineArrayJson.length); + for (var i6 = 0; i6 < this._timelineArrayJson.length; ++i6) { + this._timelineArrayBuffer[i6] = this._timelineArrayJson[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined); + var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, ""); + var compatibleVersion = ObjectDataParser._getString(rawData, ObjectDataParser.COMPATIBLE_VERSION, ""); + if (ObjectDataParser.DATA_VERSIONS.indexOf(version) >= 0 || + ObjectDataParser.DATA_VERSIONS.indexOf(compatibleVersion) >= 0) { + // const data = BaseObject.borrowObject(DragonBonesData); + var data = dragonBones.DragonBones.webAssembly ? new Module["DragonBonesData"]() : dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.version = version; + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24); + if (data.frameRate === 0) { + data.frameRate = 24; + } + if (ObjectDataParser.ARMATURE in rawData) { + this._defalultColorOffset = -1; + this._data = data; + this._parseArray(rawData); + var rawArmatures = rawData[ObjectDataParser.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._intArrayJson.length > 0) { + this._parseWASMArray(); + } + this._data = null; + } + this._rawTextureAtlasIndex = 0; + if (ObjectDataParser.TEXTURE_ATLAS in rawData) { + this._rawTextureAtlases = rawData[ObjectDataParser.TEXTURE_ATLAS]; + } + else { + this._rawTextureAtlases = null; + } + return data; + } + else { + console.assert(false, "Nonsupport data version."); + } + return null; + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 0.0; } + console.assert(rawData !== undefined); + if (rawData === null) { + if (this._rawTextureAtlases === null) { + 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, ObjectDataParser.WIDTH, 0); + textureAtlasData.height = ObjectDataParser._getNumber(rawData, ObjectDataParser.HEIGHT, 0); + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, ""); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, ""); + if (scale > 0.0) { + textureAtlasData.scale = scale; + } + else { + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + scale = 1.0 / scale; // + if (ObjectDataParser.SUB_TEXTURE in rawData) { + var rawTextures = rawData[ObjectDataParser.SUB_TEXTURE]; + for (var i = 0, l = rawTextures.length; i < l; ++i) { + var rawTexture = rawTextures[i]; + var textureData = textureAtlasData.createTexture(); + textureData.rotated = ObjectDataParser._getBoolean(rawTexture, ObjectDataParser.ROTATED, false); + textureData.name = ObjectDataParser._getString(rawTexture, ObjectDataParser.NAME, ""); + textureData.region.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.X, 0.0) * scale; + textureData.region.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.Y, 0.0) * scale; + textureData.region.width = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.WIDTH, 0.0) * scale; + textureData.region.height = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.HEIGHT, 0.0) * scale; + var frameWidth = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_WIDTH, -1.0); + var frameHeight = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_HEIGHT, -1.0); + if (frameWidth > 0.0 && frameHeight > 0.0) { + textureData.frame = dragonBones.DragonBones.webAssembly ? Module["TextureData"].createRectangle() : dragonBones.TextureData.createRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_X, 0.0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(rawTexture, ObjectDataParser.FRAME_Y, 0.0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; + } + textureAtlasData.addTexture(textureData); + } + } + return true; + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + ObjectDataParser.getInstance = function () { + if (ObjectDataParser._objectDataParserInstance === null) { + ObjectDataParser._objectDataParserInstance = new ObjectDataParser(); + } + return ObjectDataParser._objectDataParserInstance; + }; + /** + * @private + */ + ObjectDataParser._objectDataParserInstance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; + var ActionFrame = (function () { + function ActionFrame() { + this.frameStart = 0; + this.actions = []; + } + return ActionFrame; + }()); +})(dragonBones || (dragonBones = {})); +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._getUTF16Key = function (value) { + for (var i = 0, l = value.length; i < l; ++i) { + if (value.charCodeAt(i) > 255) { + return encodeURI(value); + } + } + return value; + }; + BinaryDataParser.prototype._parseBinaryTimeline = function (type, offset, timelineData) { + if (timelineData === void 0) { timelineData = null; } + // const timeline = timelineData !== null ? timelineData : BaseObject.borrowObject(TimelineData); + var timeline = timelineData !== null ? timelineData : (dragonBones.DragonBones.webAssembly ? new Module["TimelineData"]() : dragonBones.BaseObject.borrowObject(dragonBones.TimelineData)); + timeline.type = type; + timeline.offset = offset; + this._timeline = timeline; + var keyFrameCount = this._timelineArray[timeline.offset + 2 /* TimelineKeyFrameCount */]; + if (keyFrameCount === 1) { + timeline.frameIndicesOffset = -1; + } + else { + var totalFrameCount = this._animation.frameCount + 1; // One more frame than animation. + var frameIndices = this._data.frameIndices; + if (dragonBones.DragonBones.webAssembly) { + timeline.frameIndicesOffset = frameIndices.size(); + // (frameIndices as any).resize(timeline.frameIndicesOffset + totalFrameCount); + for (var j = 0; j < totalFrameCount; ++j) { + frameIndices.push_back(0); + } + } + else { + timeline.frameIndicesOffset = frameIndices.length; + frameIndices.length += totalFrameCount; + } + for (var i = 0, iK = 0, frameStart = 0, frameCount = 0; i < totalFrameCount; ++i) { + if (frameStart + frameCount <= i && iK < keyFrameCount) { + frameStart = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK]]; + if (iK === keyFrameCount - 1) { + frameCount = this._animation.frameCount - frameStart; + } + else { + frameCount = this._frameArray[this._animation.frameOffset + this._timelineArray[timeline.offset + 5 /* TimelineFrameOffset */ + iK + 1]] - frameStart; + } + iK++; + } + if (dragonBones.DragonBones.webAssembly) { + frameIndices.set(timeline.frameIndicesOffset + i, iK - 1); + } + else { + frameIndices[timeline.frameIndicesOffset + i] = iK - 1; + } + } + } + this._timeline = null; // + return timeline; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseMesh = function (rawData, mesh) { + mesh.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + var weightOffset = this._intArray[mesh.offset + 3 /* MeshWeightOffset */]; + if (weightOffset >= 0) { + // const weight = BaseObject.borrowObject(WeightData); + var weight = dragonBones.DragonBones.webAssembly ? new Module["WeightData"]() : dragonBones.BaseObject.borrowObject(dragonBones.WeightData); + var vertexCount = this._intArray[mesh.offset + 0 /* MeshVertexCount */]; + var boneCount = this._intArray[weightOffset + 0 /* WeigthBoneCount */]; + weight.offset = weightOffset; + if (dragonBones.DragonBones.webAssembly) { + weight.bones.resize(boneCount, null); + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones.set(i, this._rawBones[boneIndex]); + } + } + else { + weight.bones.length = boneCount; + for (var i = 0; i < boneCount; ++i) { + var boneIndex = this._intArray[weightOffset + 2 /* WeigthBoneIndices */ + i]; + weight.bones[i] = this._rawBones[boneIndex]; + } + } + var boneIndicesOffset = weightOffset + 2 /* WeigthBoneIndices */ + boneCount; + for (var i = 0, l = vertexCount; i < l; ++i) { + var vertexBoneCount = this._intArray[boneIndicesOffset++]; + weight.count += vertexBoneCount; + boneIndicesOffset += vertexBoneCount; + } + mesh.weight = weight; + } + }; + /** + * @private + */ + BinaryDataParser.prototype._parsePolygonBoundingBox = function (rawData) { + // const polygonBoundingBox = BaseObject.borrowObject(PolygonBoundingBoxData); + var polygonBoundingBox = dragonBones.DragonBones.webAssembly ? new Module["PolygonBoundingBoxData"]() : dragonBones.BaseObject.borrowObject(dragonBones.PolygonBoundingBoxData); + polygonBoundingBox.offset = rawData[dragonBones.ObjectDataParser.OFFSET]; + polygonBoundingBox.vertices = this._floatArray; + return polygonBoundingBox; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseAnimation = function (rawData) { + // const animation = BaseObject.borrowObject(AnimationData); + var animation = dragonBones.DragonBones.webAssembly ? new Module["AnimationData"]() : dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.frameCount = Math.max(dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.DURATION, 1), 1); + animation.playTimes = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.PLAY_TIMES, 1); + animation.duration = animation.frameCount / this._armature.frameRate; + animation.fadeInTime = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.FADE_IN_TIME, 0.0); + animation.scale = dragonBones.ObjectDataParser._getNumber(rawData, dragonBones.ObjectDataParser.SCALE, 1.0); + animation.name = dragonBones.ObjectDataParser._getString(rawData, dragonBones.ObjectDataParser.NAME, dragonBones.ObjectDataParser.DEFAULT_NAME); + if (animation.name.length === 0) { + animation.name = dragonBones.ObjectDataParser.DEFAULT_NAME; + } + // Offsets. + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + animation.frameIntOffset = offsets[0]; + animation.frameFloatOffset = offsets[1]; + animation.frameOffset = offsets[2]; + this._animation = animation; + if (dragonBones.ObjectDataParser.ACTION in rawData) { + animation.actionTimeline = this._parseBinaryTimeline(0 /* Action */, rawData[dragonBones.ObjectDataParser.ACTION]); + } + if (dragonBones.ObjectDataParser.Z_ORDER in rawData) { + animation.zOrderTimeline = this._parseBinaryTimeline(1 /* ZOrder */, rawData[dragonBones.ObjectDataParser.Z_ORDER]); + } + if (dragonBones.ObjectDataParser.BONE in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.BONE]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + if (dragonBones.ObjectDataParser.SLOT in rawData) { + var rawTimeliness = rawData[dragonBones.ObjectDataParser.SLOT]; + for (var k in rawTimeliness) { + var rawTimelines = rawTimeliness[k]; + if (dragonBones.DragonBones.webAssembly) { + k = this._getUTF16Key(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, timeline); + } + } + } + this._animation = null; + return animation; + }; + /** + * @private + */ + BinaryDataParser.prototype._parseArray = function (rawData) { + var offsets = rawData[dragonBones.ObjectDataParser.OFFSET]; + if (dragonBones.DragonBones.webAssembly) { + var tmpIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + var tmpFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + var tmpFrameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + var tmpFrameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + var tmpTimelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + var intArrayBuf = Module._malloc(tmpIntArray.length * tmpIntArray.BYTES_PER_ELEMENT); + var floatArrayBuf = Module._malloc(tmpFloatArray.length * tmpFloatArray.BYTES_PER_ELEMENT); + var frameIntArrayBuf = Module._malloc(tmpFrameIntArray.length * tmpFrameIntArray.BYTES_PER_ELEMENT); + var frameFloatArrayBuf = Module._malloc(tmpFrameFloatArray.length * tmpFrameFloatArray.BYTES_PER_ELEMENT); + var frameArrayBuf = Module._malloc(tmpFrameArray.length * tmpFrameArray.BYTES_PER_ELEMENT); + var timelineArrayBuf = Module._malloc(tmpTimelineArray.length * tmpTimelineArray.BYTES_PER_ELEMENT); + this._intArray = new Int16Array(Module.HEAP16.buffer, intArrayBuf, tmpIntArray.length); + this._floatArray = new Float32Array(Module.HEAPF32.buffer, floatArrayBuf, tmpFloatArray.length); + this._frameIntArray = new Int16Array(Module.HEAP16.buffer, frameIntArrayBuf, tmpFrameIntArray.length); + this._frameFloatArray = new Float32Array(Module.HEAPF32.buffer, frameFloatArrayBuf, tmpFrameFloatArray.length); + this._frameArray = new Int16Array(Module.HEAP16.buffer, frameArrayBuf, tmpFrameArray.length); + this._timelineArray = new Uint16Array(Module.HEAPU16.buffer, timelineArrayBuf, tmpTimelineArray.length); + // Module.HEAP16.set(tmpIntArray, intArrayBuf); + // Module.HEAPF32.set(tmpFloatArray, floatArrayBuf); + // Module.HEAP16.set(tmpFrameIntArray, frameIntArrayBuf); + // Module.HEAPF32.set(tmpFrameFloatArray, frameFloatArrayBuf); + // Module.HEAP16.set(tmpFrameArray, frameArrayBuf); + // Module.HEAPU16.set(tmpTimelineArray, timelineArrayBuf); + for (var i1 = 0; i1 < tmpIntArray.length; ++i1) { + this._intArray[i1] = tmpIntArray[i1]; + } + for (var i2 = 0; i2 < tmpFloatArray.length; ++i2) { + this._floatArray[i2] = tmpFloatArray[i2]; + } + for (var i3 = 0; i3 < tmpFrameIntArray.length; ++i3) { + this._frameIntArray[i3] = tmpFrameIntArray[i3]; + } + for (var i4 = 0; i4 < tmpFrameFloatArray.length; ++i4) { + this._frameFloatArray[i4] = tmpFrameFloatArray[i4]; + } + for (var i5 = 0; i5 < tmpFrameArray.length; ++i5) { + this._frameArray[i5] = tmpFrameArray[i5]; + } + for (var i6 = 0; i6 < tmpTimelineArray.length; ++i6) { + this._timelineArray[i6] = tmpTimelineArray[i6]; + } + Module['DragonBonesData'].setDragonBoneData(this._data); + Module.ccall('set_dbData_buffer_ptr', 'number', ['number', 'number', 'number', 'number', 'number', 'number'], [intArrayBuf, floatArrayBuf, frameIntArrayBuf, frameFloatArrayBuf, frameArrayBuf, timelineArrayBuf]); + } + else { + this._data.intArray = this._intArray = new Int16Array(this._binary, this._binaryOffset + offsets[0], offsets[1] / Int16Array.BYTES_PER_ELEMENT); + this._data.floatArray = this._floatArray = new Float32Array(this._binary, this._binaryOffset + offsets[2], offsets[3] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameIntArray = this._frameIntArray = new Int16Array(this._binary, this._binaryOffset + offsets[4], offsets[5] / Int16Array.BYTES_PER_ELEMENT); + this._data.frameFloatArray = this._frameFloatArray = new Float32Array(this._binary, this._binaryOffset + offsets[6], offsets[7] / Float32Array.BYTES_PER_ELEMENT); + this._data.frameArray = this._frameArray = new Int16Array(this._binary, this._binaryOffset + offsets[8], offsets[9] / Int16Array.BYTES_PER_ELEMENT); + this._data.timelineArray = this._timelineArray = new Uint16Array(this._binary, this._binaryOffset + offsets[10], offsets[11] / Uint16Array.BYTES_PER_ELEMENT); + } + }; + /** + * @inheritDoc + */ + BinaryDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + console.assert(rawData !== null && rawData !== undefined && rawData instanceof ArrayBuffer); + 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._binary = rawData; + this._binaryOffset = 8 + 4 + headerLength; + return _super.prototype.parseDragonBonesData.call(this, header, scale); + }; + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + BinaryDataParser.getInstance = function () { + if (BinaryDataParser._binaryDataParserInstance === null) { + BinaryDataParser._binaryDataParserInstance = new BinaryDataParser(); + } + return BinaryDataParser._binaryDataParserInstance; + }; + /** + * @private + */ + BinaryDataParser._binaryDataParserInstance = null; + return BinaryDataParser; + }(dragonBones.ObjectDataParser)); + dragonBones.BinaryDataParser = BinaryDataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var BuildArmaturePackage = (function () { + function BuildArmaturePackage() { + this.dataName = ""; + this.textureAtlasName = ""; + this.skin = null; + } + return BuildArmaturePackage; + }()); + dragonBones.BuildArmaturePackage = BuildArmaturePackage; + /** + * 创建骨架的基础工厂。 (通常只需要一个全局工厂实例) + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + var BaseFactory = (function () { + /** + * 创建一个工厂。 (通常只需要一个全局工厂实例) + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + * @language zh_CN + */ + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + /** + * 是否开启共享搜索。 + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 + * @language zh_CN + */ + this.autoSearch = false; + /** + * @private + */ + this._dragonBonesDataMap = {}; + /** + * @private + */ + this._textureAtlasDataMap = {}; + /** + * @private + */ + this._dragonBones = null; + /** + * @private + */ + 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; + } + /** + * @private + */ + BaseFactory.prototype._isSupportMesh = function () { + return true; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + 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; + }; + /** + * @private + */ + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + var bones = dataPackage.armature.sortedBones; + for (var i = 0; i < (dragonBones.DragonBones.webAssembly ? bones.size() : bones.length); ++i) { + var boneData = dragonBones.DragonBones.webAssembly ? bones.get(i) : bones[i]; + var bone = dragonBones.DragonBones.webAssembly ? new Module["Bone"]() : dragonBones.BaseObject.borrowObject(dragonBones.Bone); + bone.init(boneData); + if (boneData.parent !== null) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + var constraints = boneData.constraints; + for (var j = 0; j < (dragonBones.DragonBones.webAssembly ? constraints.size() : constraints.length); ++j) { + var constraintData = dragonBones.DragonBones.webAssembly ? constraints.get(j) : constraints[j]; + var target = armature.getBone(constraintData.target.name); + if (target === null) { + continue; + } + // TODO more constraint type. + var ikConstraintData = constraintData; + var constraint = dragonBones.DragonBones.webAssembly ? new Module["IKConstraint"]() : dragonBones.BaseObject.borrowObject(dragonBones.IKConstraint); + var root = ikConstraintData.root !== null ? armature.getBone(ikConstraintData.root.name) : null; + constraint.target = target; + constraint.bone = bone; + constraint.root = root; + constraint.bendPositive = ikConstraintData.bendPositive; + constraint.scaleEnabled = ikConstraintData.scaleEnabled; + constraint.weight = ikConstraintData.weight; + if (root !== null) { + root.addConstraint(constraint); + } + else { + bone.addConstraint(constraint); + } + } + } + }; + /** + * @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.displays[k]; + skinSlots[k] = displays; + } + if (currentSkin !== defaultSkin) { + for (var k in currentSkin.displays) { + var displays = currentSkin.displays[k]; + skinSlots[k] = displays; + } + } + for (var _i = 0, _a = dataPackage.armature.sortedSlots; _i < _a.length; _i++) { + var slotData = _a[_i]; + if (!(slotData.name in skinSlots)) { + continue; + } + var displays = skinSlots[slotData.name]; + var slot = this._buildSlot(dataPackage, slotData, displays, armature); + var displayList = new Array(); + for (var _b = 0, displays_1 = displays; _b < displays_1.length; _b++) { + var displayData = displays_1[_b]; + if (displayData !== null) { + displayList.push(this._getSlotDisplay(dataPackage, displayData, null, slot)); + } + else { + displayList.push(null); + } + } + armature.addSlot(slot, slotData.parent.name); + slot._setDisplayList(displayList); + slot._setDisplayIndex(slotData.displayIndex, true); + } + }; + /** + * @private + */ + BaseFactory.prototype._getSlotDisplay = function (dataPackage, displayData, rawDisplayData, slot) { + var dataName = dataPackage !== null ? dataPackage.dataName : displayData.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); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + imageDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, displayData.path); + } + if (rawDisplayData !== null && rawDisplayData.type === 2 /* Mesh */ && this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 2 /* Mesh */: + var meshDisplayData = displayData; + if (meshDisplayData.texture === null) { + meshDisplayData.texture = this._getTextureData(dataName, meshDisplayData.path); + } + else if (dataPackage !== null && dataPackage.textureAtlasName.length > 0) { + meshDisplayData.texture = this._getTextureData(dataPackage.textureAtlasName, meshDisplayData.path); + } + if (this._isSupportMesh()) { + display = slot.meshDisplay; + } + else { + display = slot.rawDisplay; + } + break; + case 1 /* Armature */: + var armatureDisplayData = displayData; + var childArmature = this.buildArmature(armatureDisplayData.path, dataName, null, dataPackage !== null ? dataPackage.textureAtlasName : null); + 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_2 = actions; _i < actions_2.length; _i++) { + var action = actions_2[_i]; + childArmature._bufferAction(action, true); + } + } + else { + childArmature.animation.play(); + } + } + armatureDisplayData.armature = childArmature.armatureData; // + } + display = childArmature; + break; + } + return display; + }; + /** + * @private + */ + BaseFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex < 0) { + displayIndex = 0; + } + var displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + for (var i = 0, l = displayList.length; i < l; ++i) { + if (!displayList[i]) { + displayList[i] = null; + } + } + } + if (slot._displayDatas.length <= displayIndex) { + slot._displayDatas.length = displayIndex + 1; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + if (!slot._displayDatas[i]) { + slot._displayDatas[i] = null; + } + } + } + slot._displayDatas[displayIndex] = displayData; + if (displayData !== null) { + displayList[displayIndex] = this._getSlotDisplay(dataPackage, displayData, displayIndex < slot._rawDisplayDatas.length ? slot._rawDisplayDatas[displayIndex] : null, slot); + } + else { + displayList[displayIndex] = null; + } + slot.displayList = displayList; + }; + /** + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 + * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @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 dragonBonesData = null; + if (rawData instanceof ArrayBuffer) { + dragonBonesData = BaseFactory._binaryParser.parseDragonBonesData(rawData, scale); + } + else { + dragonBonesData = this._dataParser.parseDragonBonesData(rawData, scale); + } + while (true) { + var textureAtlasData = this._buildTextureAtlasData(null, null); + if (this._dataParser.parseTextureAtlasData(null, textureAtlasData, scale)) { + this.addTextureAtlasData(textureAtlasData, name); + } + else { + textureAtlasData.returnToPool(); + break; + } + } + if (dragonBonesData !== null) { + this.addDragonBonesData(dragonBonesData, name); + } + return dragonBonesData; + }; + /** + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图。 + * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @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 = 0.0; } + var textureAtlasData = this._buildTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._buildTextureAtlasData(textureAtlasData, textureAtlas || null); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; + }; + /** + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.updateTextureAtlasData = function (name, textureAtlases) { + 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]); + } + } + } + }; + /** + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @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; + }; + /** + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @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("Replace data: " + name); + this._dragonBonesDataMap[name].returnToPool(); + } + this._dragonBonesDataMap[name] = data; + }; + /** + * 移除龙骨数据。 + * @param name 数据名称。 + * @param disposeData 是否释放数据。 + * @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]; + } + }; + /** + * 获取指定名称的贴图集数据列表。 + * @param name 数据名称。 + * @returns 贴图集数据列表。 + * @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; + }; + /** + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @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); + } + }; + /** + * 移除贴图集数据。 + * @param name 数据名称。 + * @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]; + } + }; + /** + * 获取骨架数据。 + * @param name 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称。 + * @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; + }; + /** + * 清除所有的数据。 + * @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]; + } + }; + /** + * 创建一个骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据名称。 + * @returns 骨架 + * @see dragonBones.ArmatureData + * @see dragonBones.Armature + * @version DragonBones 3.0 + * @language zh_CN + */ + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + 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); + // armature.invalidUpdate(null, true); TODO + armature.invalidUpdate("", true); + armature.advanceTime(0.0); // Update armature pose. + return armature; + }; + /** + * 用指定资源替换指定插槽的显示对象。(用 "dragonBonesName/armatureName/slotName/displayName" 的资源替换 "slot" 的显示对象) + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + for (var _i = 0, displays_2 = displays; _i < displays_2.length; _i++) { + var display = displays_2[_i]; + if (display !== null && display.name === displayName) { + this._replaceSlotDisplay(dataPackage, display, slot, displayIndex); + break; + } + } + }; + /** + * 用指定资源列表替换插槽的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var dataPackage = {}; + if (!this._fillBuildArmaturePackage(dataPackage, dragonBonesName || "", armatureName, "", "") || dataPackage.skin === null) { + return; + } + var displays = dataPackage.skin.getDisplays(slotName); + if (displays === null) { + return; + } + var displayIndex = 0; + for (var _i = 0, displays_3 = displays; _i < displays_3.length; _i++) { + var displayData = displays_3[_i]; + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + }; + /** + * 更换骨架皮肤。 + * @param armature 骨架。 + * @param skin 皮肤数据。 + * @param exclude 不需要更新的插槽。 + * @see dragonBones.Armature + * @see dragonBones.SkinData + * @version DragonBones 5.1 + * @language zh_CN + */ + BaseFactory.prototype.changeSkin = function (armature, skin, exclude) { + if (exclude === void 0) { exclude = null; } + for (var _i = 0, _a = armature.getSlots(); _i < _a.length; _i++) { + var slot = _a[_i]; + if (!(slot.name in skin.displays) || (exclude !== null && exclude.indexOf(slot.name) >= 0)) { + continue; + } + var displays = skin.displays[slot.name]; + var displayList = slot.displayList; // Copy. + displayList.length = displays.length; // Modify displayList length. + for (var i = 0, l = displays.length; i < l; ++i) { + var displayData = displays[i]; + if (displayData !== null) { + displayList[i] = this._getSlotDisplay(null, displayData, null, slot); + } + else { + displayList[i] = null; + } + } + slot._rawDisplayDatas = displays; + slot._displayDatas.length = displays.length; + for (var i = 0, l = slot._displayDatas.length; i < l; ++i) { + slot._displayDatas[i] = displays[i]; + } + slot.displayList = displayList; + } + }; + /** + * 将骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param replaceOriginalAnimation 是否替换原有的同名动画。 + * @returns 是否替换成功。 + * @see dragonBones.Armature + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + * @language zh_CN + */ + BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation) { + if (fromSkinName === void 0) { fromSkinName = null; } + if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } + if (replaceOriginalAnimation === void 0) { replaceOriginalAnimation = true; } + var dataPackage = new BuildArmaturePackage(); + if (this._fillBuildArmaturePackage(dataPackage, fromDragonBonesDataName || "", fromArmatreName, fromSkinName || "", "")) { + var fromArmatureData = dataPackage.armature; + if (replaceOriginalAnimation) { + toArmature.animation.animations = fromArmatureData.animations; + } + else { + var animations = {}; + for (var animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + for (var animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + toArmature.animation.animations = animations; + } + if (dataPackage.skin) { + var slots = toArmature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var toSlot = slots[i]; + var toSlotDisplayList = toSlot.displayList; + for (var j = 0, lJ = toSlotDisplayList.length; j < lJ; ++j) { + var toDisplayObject = toSlotDisplayList[j]; + if (toDisplayObject instanceof dragonBones.Armature) { + var displays = dataPackage.skin.getDisplays(toSlot.name); + if (displays !== null && j < displays.length) { + var fromDisplayData = displays[j]; + if (fromDisplayData !== null && fromDisplayData.type === 1 /* Armature */) { + this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.path, fromSkinName, fromDragonBonesDataName, replaceOriginalAnimation); + } + } + } + } + } + return true; + } + } + return false; + }; + /** + * @private + */ + BaseFactory.prototype.getAllDragonBonesData = function () { + return this._dragonBonesDataMap; + }; + /** + * @private + */ + BaseFactory.prototype.getAllTextureAtlasData = function () { + return this._textureAtlasDataMap; + }; + /** + * @private + */ + BaseFactory._objectParser = null; + /** + * @private + */ + BaseFactory._binaryParser = null; + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * Pixi 贴图集数据。 + * @version DragonBones 3.0 + */ + var PixiTextureAtlasData = (function (_super) { + __extends(PixiTextureAtlasData, _super); + function PixiTextureAtlasData() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._renderTexture = null; // Initial value. + return _this; + } + PixiTextureAtlasData.toString = function () { + return "[class dragonBones.PixiTextureAtlasData]"; + }; + /** + * @private + */ + PixiTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + //this.texture.dispose(); + } + this.renderTexture = null; + }; + /** + * @private + */ + PixiTextureAtlasData.prototype.createTexture = function () { + return dragonBones.BaseObject.borrowObject(PixiTextureData); + }; + Object.defineProperty(PixiTextureAtlasData.prototype, "renderTexture", { + /** + * Pixi 贴图。 + * @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]; + textureData.renderTexture = new PIXI.Texture(this._renderTexture, textureData.region, // No need to set frame. + textureData.region, new PIXI.Rectangle(0, 0, textureData.region.width, textureData.region.height), textureData.rotated // .d.ts bug + ); + } + } + else { + for (var k in this.textures) { + var textureData = this.textures[k]; + textureData.renderTexture = null; + } + } + }, + enumerable: true, + configurable: true + }); + return PixiTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.PixiTextureAtlasData = PixiTextureAtlasData; + /** + * @private + */ + var PixiTextureData = (function (_super) { + __extends(PixiTextureData, _super); + function PixiTextureData() { + var _this = _super.call(this) || this; + _this.renderTexture = null; // Initial value. + return _this; + } + PixiTextureData.toString = function () { + return "[class dragonBones.PixiTextureData]"; + }; + PixiTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.renderTexture !== null) { + this.renderTexture.destroy(); + } + this.renderTexture = null; + }; + return PixiTextureData; + }(dragonBones.TextureData)); + dragonBones.PixiTextureData = PixiTextureData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @inheritDoc + */ + var PixiArmatureDisplay = (function (_super) { + __extends(PixiArmatureDisplay, _super); + function PixiArmatureDisplay() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._disposeProxy = false; + _this._armature = null; + _this._debugDrawer = null; + return _this; + } + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.init = function (armature) { + this._armature = armature; + }; + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.clear = function () { + if (this._debugDrawer !== null) { + this._debugDrawer.destroy(true); + } + this._disposeProxy = false; + this._armature = null; + this._debugDrawer = null; + _super.prototype.destroy.call(this); + }; + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.dispose = function (disposeProxy) { + if (disposeProxy === void 0) { disposeProxy = true; } + this._disposeProxy = disposeProxy; + if (this._armature !== null) { + this._armature.dispose(); + this._armature = null; + } + }; + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.destroy = function () { + this.dispose(); + }; + /** + * @private + */ + PixiArmatureDisplay.prototype.debugUpdate = function (isEnabled) { + if (isEnabled) { + if (this._debugDrawer === null) { + this._debugDrawer = new PIXI.Sprite(); + var boneDrawer_1 = new PIXI.Graphics(); + this._debugDrawer.addChild(boneDrawer_1); + } + this.addChild(this._debugDrawer); + var boneDrawer = this._debugDrawer.getChildAt(0); + boneDrawer.clear(); + var bones = this._armature.getBones(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + var boneLength = bone.boneData.length; + var startX = bone.globalTransformMatrix.tx; + var startY = bone.globalTransformMatrix.ty; + var endX = startX + bone.globalTransformMatrix.a * boneLength; + var endY = startY + bone.globalTransformMatrix.b * boneLength; + boneDrawer.lineStyle(2.0, 0x00FFFF, 0.7); + boneDrawer.moveTo(startX, startY); + boneDrawer.lineTo(endX, endY); + boneDrawer.lineStyle(0.0, 0, 0.0); + boneDrawer.beginFill(0x00FFFF, 0.7); + boneDrawer.drawCircle(startX, startY, 3.0); + boneDrawer.endFill(); + } + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + var boundingBoxData = slot.boundingBoxData; + if (boundingBoxData) { + var child = this._debugDrawer.getChildByName(slot.name); + if (!child) { + child = new PIXI.Graphics(); + child.name = slot.name; + this._debugDrawer.addChild(child); + } + child.clear(); + child.beginFill(0xFF00FF, 0.3); + switch (boundingBoxData.type) { + case 0 /* Rectangle */: + child.drawRect(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); + break; + case 1 /* Ellipse */: + child.drawEllipse(-boundingBoxData.width * 0.5, -boundingBoxData.height * 0.5, boundingBoxData.width, boundingBoxData.height); + break; + case 2 /* Polygon */: + var polygon = boundingBoxData; + var vertices = polygon.vertices; + for (var i_3 = 0, l_1 = polygon.count; i_3 < l_1; i_3 += 2) { + if (i_3 === 0) { + child.moveTo(vertices[i_3], vertices[i_3 + 1]); + } + else { + child.lineTo(vertices[i_3], vertices[i_3 + 1]); + } + } + break; + default: + break; + } + child.endFill(); + slot.updateTransformAndMatrix(); + slot.updateGlobalTransform(); + var transform = slot.global; + child.setTransform(transform.x, transform.y, transform.scaleX, transform.scaleY, transform.rotation, transform.skew, 0.0, slot._pivotX, slot._pivotY); + } + else { + var child = this._debugDrawer.getChildByName(slot.name); + if (child) { + this._debugDrawer.removeChild(child); + } + } + } + } + else if (this._debugDrawer && this._debugDrawer.parent === this) { + this.removeChild(this._debugDrawer); + } + }; + /** + * @private + */ + PixiArmatureDisplay.prototype._dispatchEvent = function (type, eventObject) { + this.emit(type, eventObject); + }; + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.hasEvent = function (type) { + return this.listeners(type, true); // .d.ts bug + }; + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.addEvent = function (type, listener, target) { + this.addListener(type, listener, target); + }; + /** + * @inheritDoc + */ + PixiArmatureDisplay.prototype.removeEvent = function (type, listener, target) { + this.removeListener(type, listener, target); + }; + Object.defineProperty(PixiArmatureDisplay.prototype, "armature", { + /** + * @inheritDoc + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PixiArmatureDisplay.prototype, "animation", { + /** + * @inheritDoc + */ + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.PixiFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + PixiArmatureDisplay.prototype.advanceTimeBySelf = function (on) { + if (on) { + this._armature.clock = dragonBones.PixiFactory.clock; + } + else { + this._armature.clock = null; + } + }; + return PixiArmatureDisplay; + }(PIXI.Container)); + dragonBones.PixiArmatureDisplay = PixiArmatureDisplay; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Pixi 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var PixiSlot = (function (_super) { + __extends(PixiSlot, _super); + function PixiSlot() { + return _super !== null && _super.apply(this, arguments) || this; + } + PixiSlot.toString = function () { + return "[class dragonBones.PixiSlot]"; + }; + /** + * @private + */ + PixiSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._updateTransform = PIXI.VERSION[0] === "3" ? this._updateTransformV3 : this._updateTransformV4; + this._renderDisplay = null; + }; + /** + * @private + */ + PixiSlot.prototype._initDisplay = function (value) { + value; + }; + /** + * @private + */ + PixiSlot.prototype._disposeDisplay = function (value) { + value.destroy(); + }; + /** + * @private + */ + PixiSlot.prototype._onUpdateDisplay = function () { + this._renderDisplay = (this._display ? this._display : this._rawDisplay); + }; + /** + * @private + */ + PixiSlot.prototype._addDisplay = function () { + var container = this._armature.display; + container.addChild(this._renderDisplay); + }; + /** + * @private + */ + PixiSlot.prototype._replaceDisplay = function (value) { + var container = this._armature.display; + var prevDisplay = value; + container.addChild(this._renderDisplay); + container.swapChildren(this._renderDisplay, prevDisplay); + container.removeChild(prevDisplay); + }; + /** + * @private + */ + PixiSlot.prototype._removeDisplay = function () { + this._renderDisplay.parent.removeChild(this._renderDisplay); + }; + /** + * @private + */ + PixiSlot.prototype._updateZOrder = function () { + var container = this._armature.display; + var index = container.getChildIndex(this._renderDisplay); + if (index === this._zOrder) { + return; + } + container.addChildAt(this._renderDisplay, this._zOrder); + }; + /** + * @internal + * @private + */ + PixiSlot.prototype._updateVisible = function () { + this._renderDisplay.visible = this._parent.visible; + }; + /** + * @private + */ + PixiSlot.prototype._updateBlendMode = function () { + switch (this._blendMode) { + case 0 /* Normal */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.NORMAL; + break; + case 1 /* Add */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.ADD; + break; + case 3 /* Darken */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.DARKEN; + break; + case 4 /* Difference */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.DIFFERENCE; + break; + case 6 /* HardLight */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.HARD_LIGHT; + break; + case 9 /* Lighten */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.LIGHTEN; + break; + case 10 /* Multiply */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.MULTIPLY; + break; + case 11 /* Overlay */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.OVERLAY; + break; + case 12 /* Screen */: + this._renderDisplay.blendMode = PIXI.BLEND_MODES.SCREEN; + break; + default: + break; + } + }; + /** + * @private + */ + PixiSlot.prototype._updateColor = function () { + this._renderDisplay.alpha = this._colorTransform.alphaMultiplier; + // TODO + }; + /** + * @private + */ + PixiSlot.prototype._updateFrame = function () { + var meshData = this._display === this._meshDisplay ? this._meshData : null; + var currentTextureData = this._textureData; + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + var currentTextureAtlasData = currentTextureData.parent; + if (this._armature.replacedTexture !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.PixiTextureAtlasData); + 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) { + var currentTextureAtlas = currentTextureData.renderTexture; + if (meshData !== null) { + var data = meshData.parent.parent; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var triangleCount = intArray[meshData.offset + 1 /* MeshTriangleCount */]; + var verticesOffset = intArray[meshData.offset + 2 /* MeshFloatOffset */]; + var uvOffset = verticesOffset + vertexCount * 2; + var meshDisplay = this._renderDisplay; + var textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : currentTextureAtlas.width; + var textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : currentTextureAtlas.height; + meshDisplay.vertices = new Float32Array(vertexCount * 2); + meshDisplay.uvs = new Float32Array(vertexCount * 2); + meshDisplay.indices = new Uint16Array(triangleCount * 3); + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + meshDisplay.vertices[i] = floatArray[verticesOffset + i]; + meshDisplay.uvs[i] = floatArray[uvOffset + i]; + } + for (var i = 0; i < triangleCount * 3; ++i) { + meshDisplay.indices[i] = intArray[meshData.offset + 4 /* MeshVertexIndices */ + i]; + } + for (var i = 0, l = meshDisplay.uvs.length; i < l; i += 2) { + var u = meshDisplay.uvs[i]; + var v = meshDisplay.uvs[i + 1]; + meshDisplay.uvs[i] = (currentTextureData.region.x + u * currentTextureData.region.width) / textureAtlasWidth; + meshDisplay.uvs[i + 1] = (currentTextureData.region.y + v * currentTextureData.region.height) / textureAtlasHeight; + } + meshDisplay.texture = renderTexture; + //meshDisplay.dirty = true; // Pixi 3.x + meshDisplay.dirty++; // Pixi 4.x Can not support change mesh vertice count. + } + else { + var normalDisplay = this._renderDisplay; + normalDisplay.texture = renderTexture; + } + this._updateVisible(); + return; + } + } + if (meshData !== null) { + var meshDisplay = this._renderDisplay; + meshDisplay.texture = null; + meshDisplay.x = 0.0; + meshDisplay.y = 0.0; + meshDisplay.visible = false; + } + else { + var normalDisplay = this._renderDisplay; + normalDisplay.texture = null; + normalDisplay.x = 0.0; + normalDisplay.y = 0.0; + normalDisplay.visible = false; + } + }; + /** + * @private + */ + PixiSlot.prototype._updateMesh = function () { + var hasFFD = this._ffdVertices.length > 0; + var meshData = this._meshData; + var weight = meshData.weight; + var meshDisplay = this._renderDisplay; + if (weight !== null) { + var data = meshData.parent.parent; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var weightFloatOffset = intArray[weight.offset + 1 /* WeigthFloatOffset */]; + for (var i = 0, iD = 0, iB = weight.offset + 2 /* WeigthBoneIndices */ + weight.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 = this._meshBones[boneIndex]; + if (bone !== null) { + var matrix = bone.globalTransformMatrix; + var weight_1 = floatArray[iV++]; + var xL = floatArray[iV++]; + var yL = floatArray[iV++]; + if (hasFFD) { + xL += this._ffdVertices[iF++]; + yL += this._ffdVertices[iF++]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight_1; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight_1; + } + } + meshDisplay.vertices[iD++] = xG; + meshDisplay.vertices[iD++] = yG; + } + } + else if (hasFFD) { + var data = meshData.parent.parent; + var intArray = data.intArray; + var floatArray = data.floatArray; + var vertexCount = intArray[meshData.offset + 0 /* MeshVertexCount */]; + var vertexOffset = intArray[meshData.offset + 2 /* MeshFloatOffset */]; + for (var i = 0, l = vertexCount * 2; i < l; ++i) { + meshDisplay.vertices[i] = floatArray[vertexOffset + i] + this._ffdVertices[i]; + } + } + }; + /** + * @private + */ + PixiSlot.prototype._updateTransform = function (isSkinnedMesh) { + isSkinnedMesh; + throw new Error(); + }; + /** + * @private + */ + PixiSlot.prototype._updateTransformV3 = function (isSkinnedMesh) { + if (isSkinnedMesh) { + this._renderDisplay.setTransform(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); + } + else { + this.updateGlobalTransform(); // Update transform. + var transform = this.global; + var x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); + var y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.setTransform(x, y, transform.scaleX, transform.scaleY, transform.rotation, transform.skew, 0.0); + } + else { + this._renderDisplay.position.set(x, y); + this._renderDisplay.rotation = transform.rotation; + this._renderDisplay.skew.set(-transform.skew, 0.0); + this._renderDisplay.scale.set(transform.scaleX, transform.scaleY); + } + } + }; + /** + * @private + */ + PixiSlot.prototype._updateTransformV4 = function (isSkinnedMesh) { + if (isSkinnedMesh) { + this._renderDisplay.setTransform(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); + } + else { + this.updateGlobalTransform(); // Update transform. + var transform = this.global; + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.setTransform(transform.x, transform.y, transform.scaleX, transform.scaleY, transform.rotation, -transform.skew, 0.0, this._pivotX, this._pivotY); + } + else { + var x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); + var y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); + this._renderDisplay.position.set(x, y); + this._renderDisplay.rotation = transform.rotation; + this._renderDisplay.skew.set(-transform.skew, 0.0); + this._renderDisplay.scale.set(transform.scaleX, transform.scaleY); + } + } + }; + return PixiSlot; + }(dragonBones.Slot)); + dragonBones.PixiSlot = PixiSlot; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * Pixi 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + var PixiFactory = (function (_super) { + __extends(PixiFactory, _super); + /** + * @inheritDoc + */ + function PixiFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + var _this = _super.call(this, dataParser) || this; + if (PixiFactory._dragonBonesInstance === null) { + var eventManager = new dragonBones.PixiArmatureDisplay(); + PixiFactory._dragonBonesInstance = new dragonBones.DragonBones(eventManager); + PIXI.ticker.shared.add(PixiFactory._clockHandler, PixiFactory); + } + _this._dragonBones = PixiFactory._dragonBonesInstance; + return _this; + } + PixiFactory._clockHandler = function (passedTime) { + // PixiFactory._dragonBonesInstance.advanceTime(PIXI.ticker.shared.elapsedMS * passedTime * 0.001); + passedTime; + PixiFactory._dragonBonesInstance.advanceTime(-1); + }; + Object.defineProperty(PixiFactory, "clock", { + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + get: function () { + return PixiFactory._dragonBonesInstance.clock; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(PixiFactory, "factory", { + /** + * @language zh_CN + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + */ + get: function () { + if (PixiFactory._factory === null) { + PixiFactory._factory = new PixiFactory(); + } + return PixiFactory._factory; + }, + enumerable: true, + configurable: true + }); + /** + * @private + */ + PixiFactory.prototype._buildTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.PixiTextureAtlasData); + } + return textureAtlasData; + }; + /** + * @private + */ + PixiFactory.prototype._buildArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplay = new dragonBones.PixiArmatureDisplay(); + armature.init(dataPackage.armature, armatureDisplay, armatureDisplay, this._dragonBones); + return armature; + }; + /** + * @private + */ + PixiFactory.prototype._buildSlot = function (dataPackage, slotData, displays, armature) { + dataPackage; + armature; + var slot = dragonBones.BaseObject.borrowObject(dragonBones.PixiSlot); + slot.init(slotData, displays, new PIXI.Sprite(), new PIXI.mesh.Mesh(null, null, null, null, PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES)); + return slot; + }; + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + PixiFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName, textureAtlasName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + if (textureAtlasName === void 0) { textureAtlasName = null; } + var armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + this._dragonBones.clock.add(armature); + return armature.display; + } + return null; + }; + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + PixiFactory.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) { + return new PIXI.Sprite(textureData.renderTexture); + } + return null; + }; + Object.defineProperty(PixiFactory.prototype, "soundEventManager", { + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + get: function () { + return this._dragonBones.eventManager; + }, + enumerable: true, + configurable: true + }); + PixiFactory._dragonBonesInstance = null; + PixiFactory._factory = null; + return PixiFactory; + }(dragonBones.BaseFactory)); + dragonBones.PixiFactory = PixiFactory; +})(dragonBones || (dragonBones = {})); +//# sourceMappingURL=dragonBones.js.map \ No newline at end of file diff --git a/reference/Pixi/4.x/out/dragonBones.min.js b/reference/Pixi/4.x/out/dragonBones.min.js new file mode 100644 index 0000000..738078e --- /dev/null +++ b/reference/Pixi/4.x/out/dragonBones.min.js @@ -0,0 +1 @@ +"use strict";var __extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)if(e.hasOwnProperty(i))t[i]=e[i]};return function(e,i){t(e,i);function a(){this.constructor=e}e.prototype=i===null?Object.create(i):(a.prototype=i.prototype,new a)}}();var dragonBones;(function(t){var e=function(){function e(e){this._clock=new t.WorldClock;this._events=[];this._objects=[];this._eventManager=null;this._eventManager=e}e.prototype.advanceTime=function(e){if(this._objects.length>0){for(var i=0,a=this._objects;i0){for(var n=0;ni){r.length=i}t._maxCountMap[a]=i}else{t._defaultMaxCount=i;for(var a in t._poolsMap){if(a in t._maxCountMap){continue}var r=t._poolsMap[a];if(r.length>i){r.length=i}t._maxCountMap[a]=i}}};t.clearPool=function(e){if(e===void 0){e=null}if(e!==null){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){a.length=0}}else{for(var r in t._poolsMap){var a=t._poolsMap[r];a.length=0}}};t.borrowObject=function(e){var i=String(e);var a=i in t._poolsMap?t._poolsMap[i]:null;if(a!==null&&a.length>0){var r=a.pop();r._isInPool=false;return r}var n=new e;n._onClear();return n};t.prototype.returnToPool=function(){this._onClear();t._returnObject(this)};t._hashCode=0;t._defaultMaxCount=1e3;t._maxCountMap={};t._poolsMap={};return t}();t.BaseObject=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=1}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=1}if(r===void 0){r=0}if(n===void 0){n=0}this.a=t;this.b=e;this.c=i;this.d=a;this.tx=r;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 i=0;var a=0;var r=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;i+=this.b*t.d;a+=this.c*t.a;r+=this.c*t.b}if(t.b!==0||t.c!==0){i+=this.a*t.b;a+=this.d*t.c;n+=this.ty*t.c;s+=this.tx*t.b}this.a=e;this.b=i;this.c=a;this.d=r;this.tx=n;this.ty=s;return this};t.prototype.invert=function(){var t=this.a;var e=this.b;var i=this.c;var a=this.d;var r=this.tx;var n=this.ty;if(e===0&&i===0){this.b=this.c=0;if(t===0||a===0){this.a=this.b=this.tx=this.ty=0}else{t=this.a=1/t;a=this.d=1/a;this.tx=-t*r;this.ty=-a*n}return this}var s=t*a-e*i;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=a*s;e=this.b=-e*s;i=this.c=-i*s;a=this.d=t*s;this.tx=-(o*r+i*n);this.ty=-(e*r+a*n);return this};t.prototype.transformPoint=function(t,e,i,a){if(a===void 0){a=false}i.x=this.a*t+this.c*e;i.y=this.b*t+this.d*e;if(!a){i.x+=this.tx;i.y+=this.ty}};return t}();t.Matrix=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}if(r===void 0){r=1}if(n===void 0){n=1}this.x=t;this.y=e;this.skew=i;this.rotation=a;this.scaleX=r;this.scaleY=n}t.normalizeRadian=function(t){t=(t+Math.PI)%(Math.PI*2);t+=t>0?-Math.PI:Math.PI;return t};t.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};t.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};t.prototype.identity=function(){this.x=this.y=0;this.skew=this.rotation=0;this.scaleX=this.scaleY=1;return this};t.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};t.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};t.prototype.fromMatrix=function(e){var i=this.scaleX,a=this.scaleY;var r=t.PI_Q;this.x=e.tx;this.y=e.ty;this.rotation=Math.atan(e.b/e.a);var n=Math.atan(-e.c/e.d);this.scaleX=this.rotation>-r&&this.rotation-r&&n=0&&this.scaleX<0){this.scaleX=-this.scaleX;this.rotation=this.rotation-Math.PI}if(a>=0&&this.scaleY<0){this.scaleY=-this.scaleY;n=n-Math.PI}this.skew=n-this.rotation;return this};t.prototype.toMatrix=function(t){if(this.skew!==0||this.rotation!==0){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}}else{t.a=this.scaleX;t.b=0;t.c=0;t.d=this.scaleY}t.tx=this.x;t.ty=this.y;return this};t.PI_D=Math.PI*2;t.PI_H=Math.PI/2;t.PI_Q=Math.PI/4;t.RAD_DEG=180/Math.PI;t.DEG_RAD=Math.PI/180;return t}();t.Transform=e})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(){function t(t,e,i,a,r,n,s,o){if(t===void 0){t=1}if(e===void 0){e=1}if(i===void 0){i=1}if(a===void 0){a=1}if(r===void 0){r=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=i;this.blueMultiplier=a;this.alphaOffset=r;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,i,a){if(t===void 0){t=0}if(e===void 0){e=0}if(i===void 0){i=0}if(a===void 0){a=0}this.x=t;this.y=e;this.width=i;this.height=a}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(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.ints=[];e.floats=[];e.strings=[];return e}e.toString=function(){return"[class dragonBones.UserData]"};e.prototype._onClear=function(){this.ints.length=0;this.floats.length=0;this.strings.length=0};e.prototype.getInt=function(t){if(t===void 0){t=0}return t>=0&&t=0&&t=0&&t=t){i=0}if(this.sortedBones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s0){return}this.cacheFrameRate=t;for(var e in this.animations){this.animations[e].cacheFrames(this.cacheFrameRate)}};i.prototype.setCacheFrame=function(t,e){var i=this.parent.cachedFrames;var a=i.length;i.length+=10;i[a]=t.a;i[a+1]=t.b;i[a+2]=t.c;i[a+3]=t.d;i[a+4]=t.tx;i[a+5]=t.ty;i[a+6]=e.rotation;i[a+7]=e.skew;i[a+8]=e.scaleX;i[a+9]=e.scaleY;return a};i.prototype.getCacheFrame=function(t,e,i){var a=this.parent.cachedFrames;t.a=a[i];t.b=a[i+1];t.c=a[i+2];t.d=a[i+3];t.tx=a[i+4];t.ty=a[i+5];e.rotation=a[i+6];e.skew=a[i+7];e.scaleX=a[i+8];e.scaleY=a[i+9];e.x=t.tx;e.y=t.ty};i.prototype.addBone=function(t){if(t.name in this.bones){console.warn("Replace bone: "+t.name);this.bones[t.name].returnToPool()}this.bones[t.name]=t;this.sortedBones.push(t)};i.prototype.addSlot=function(t){if(t.name in this.slots){console.warn("Replace slot: "+t.name);this.slots[t.name].returnToPool()}this.slots[t.name]=t;this.sortedSlots.push(t)};i.prototype.addSkin=function(t){if(t.name in this.skins){console.warn("Replace skin: "+t.name);this.skins[t.name].returnToPool()}this.skins[t.name]=t;if(this.defaultSkin===null){this.defaultSkin=t}};i.prototype.addAnimation=function(t){if(t.name in this.animations){console.warn("Replace animation: "+t.name);this.animations[t.name].returnToPool()}t.parent=this;this.animations[t.name]=t;this.animationNames.push(t.name);if(this.defaultAnimation===null){this.defaultAnimation=t}};i.prototype.getBone=function(t){return t in this.bones?this.bones[t]:null};i.prototype.getSlot=function(t){return t in this.slots?this.slots[t]:null};i.prototype.getSkin=function(t){return t in this.skins?this.skins[t]:null};i.prototype.getAnimation=function(t){return t in this.animations?this.animations[t]:null};return i}(t.BaseObject);t.ArmatureData=i;var a=function(e){__extends(i,e);function i(){var i=e!==null&&e.apply(this,arguments)||this;i.transform=new t.Transform;i.constraints=[];i.userData=null;return i}i.toString=function(){return"[class dragonBones.BoneData]"};i.prototype._onClear=function(){for(var t=0,e=this.constraints;tr){s|=2}if(en){s|=8}return s};e.rectangleIntersectsSegment=function(t,i,a,r,n,s,o,l,h,u,f){if(h===void 0){h=null}if(u===void 0){u=null}if(f===void 0){f=null}var _=t>n&&ts&&in&&as&&r=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){return true}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=this.width*.5;var h=this.height*.5;var u=e.rectangleIntersectsSegment(t,i,a,r,-l,-h,l,h,n,s,o);return u};return e}(e);t.RectangleBoundingBoxData=i;var a=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.EllipseData]"};e.ellipseIntersectsSegment=function(t,e,i,a,r,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;a*=f;var m=i-t;var p=a-e;var c=Math.sqrt(m*m+p*p);var d=m/c;var y=p/c;var g=(r-t)*d+(n-e)*y;var v=g*g;var b=t*t+e*e;var D=s*s;var T=D-b+v;var A=0;if(T>=0){var O=Math.sqrt(T);var B=g-O;var x=g+O;var S=B<0?-1:B<=c?0:1;var M=x<0?-1:x<=c?0:1;var w=S*M;if(w<0){return-1}else if(w===0){if(S===-1){A=2;i=t+x*d;a=(e+x*y)/f;if(l!==null){l.x=i;l.y=a}if(h!==null){h.x=i;h.y=a}if(u!==null){u.x=Math.atan2(a/D*_,i/D);u.y=u.x+Math.PI}}else if(M===1){A=1;t=t+B*d;e=(e+B*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/D*_,t/D);u.y=u.x+Math.PI}}else{A=3;if(l!==null){l.x=t+B*d;l.y=(e+B*y)/f;if(u!==null){u.x=Math.atan2(l.y/D*_,l.x/D)}}if(h!==null){h.x=t+x*d;h.y=(e+x*y)/f;if(u!==null){u.y=Math.atan2(h.y/D*_,h.x/D)}}}}}return A};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.type=1};e.prototype.containsPoint=function(t,e){var i=this.width*.5;if(t>=-i&&t<=i){var a=this.height*.5;if(e>=-a&&e<=a){e*=i/a;return Math.sqrt(t*t+e*e)<=i}}return false};e.prototype.intersectsSegment=function(t,i,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}var l=e.ellipseIntersectsSegment(t,i,a,r,0,0,this.width*.5,this.height*.5,n,s,o);return l};return e}(e);t.EllipseBoundingBoxData=a;var r=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e.weight=null;return e}e.toString=function(){return"[class dragonBones.PolygonBoundingBoxData]"};e.polygonIntersectsSegment=function(t,e,i,a,r,n,s,o,l,h){if(o===void 0){o=null}if(l===void 0){l=null}if(h===void 0){h=null}if(t===i){t=i+1e-6}if(e===a){e=a+1e-6}var u=t-i;var f=e-a;var _=t*a-e*i;var m=0;var p=r[n+s-2];var c=r[n+s-1];var d=0;var y=0;var g=0;var v=0;var b=0;var D=0;for(var T=0;T=p&&w<=A||w>=A&&w<=p)&&(u===0||w>=t&&w<=i||w>=i&&w<=t)){var E=(_*x-f*S)/M;if((E>=c&&E<=O||E>=O&&E<=c)&&(f===0||E>=e&&E<=a||E>=a&&E<=e)){if(l!==null){var P=w-t;if(P<0){P=-P}if(m===0){d=P;y=P;g=w;v=E;b=w;D=E;if(h!==null){h.x=Math.atan2(O-c,A-p)-Math.PI*.5;h.y=h.x}}else{if(Py){y=P;b=w;D=E;if(h!==null){h.y=Math.atan2(O-c,A-p)-Math.PI*.5}}}m++}else{g=w;v=E;b=w;D=E;m++;if(h!==null){h.x=Math.atan2(O-c,A-p)-Math.PI*.5;h.y=h.x}break}}}p=A;c=O}if(m===1){if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=g;l.y=v}if(h!==null){h.y=h.x+Math.PI}}else if(m>1){m++;if(o!==null){o.x=g;o.y=v}if(l!==null){l.x=b;l.y=D}}return m};e.prototype._onClear=function(){t.prototype._onClear.call(this);if(this.weight!==null){this.weight.returnToPool()}this.type=2;this.count=0;this.offset=0;this.x=0;this.y=0;this.vertices=null;this.weight=null};e.prototype.containsPoint=function(t,e){var i=false;if(t>=this.x&&t<=this.width&&e>=this.y&&e<=this.height){for(var a=0,r=this.count,n=r-2;a=e||s=e){var l=this.vertices[this.offset+n];var h=this.vertices[this.offset+a];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 i=0,a=this.cacheFrames.length;i=0};e.prototype.addBoneMask=function(t,e,i){if(i===void 0){i=true}var a=t.getBone(e);if(a===null){return}if(this.boneMask.indexOf(e)<0){this.boneMask.push(e)}if(i){for(var r=0,n=t.getBones();r=0){this.boneMask.splice(a,1)}if(i){var r=t.getBone(e);if(r!==null){if(this.boneMask.length>0){for(var n=0,s=t.getBones();n=0&&r.contains(o)){this.boneMask.splice(l,1)}}}else{for(var h=0,u=t.getBones();he._zOrder?1:-1};i.prototype._onClear=function(){if(this._clock!==null){this._clock.remove(this)}for(var t=0,e=this._bones;t=t){i=0}if(this._bones.indexOf(r)>=0){continue}if(r.constraints.length>0){var n=false;for(var s=0,o=r.constraints;s=n){continue}var o=i[s];var l=this.getSlot(o.name);if(l!==null){l._setZorder(r)}}this._slotsDirty=true;this._zOrderDirty=!a}};i.prototype._addBoneToBoneList=function(t){if(this._bones.indexOf(t)<0){this._bonesDirty=true;this._bones.push(t);this._animation._timelineDirty=true}};i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);if(e>=0){this._bones.splice(e,1);this._animation._timelineDirty=true}};i.prototype._addSlotToSlotList=function(t){if(this._slots.indexOf(t)<0){this._slotsDirty=true;this._slots.push(t);this._animation._timelineDirty=true}};i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);if(e>=0){this._slots.splice(e,1);this._animation._timelineDirty=true}};i.prototype._bufferAction=function(t,e){if(this._actions.indexOf(t)<0){if(e){this._actions.push(t)}else{this._actions.unshift(t)}}};i.prototype.dispose=function(){if(this.armatureData!==null){this._lockUpdate=true;this._dragonBones.bufferObject(this)}};i.prototype.init=function(e,i,a,r){if(this.armatureData!==null){return}this.armatureData=e;this._animation=t.BaseObject.borrowObject(t.Animation);this._proxy=i;this._display=a;this._dragonBones=r;this._proxy.init(this);this._animation.init(this);this._animation.animations=this.armatureData.animations};i.prototype.advanceTime=function(e){if(this._lockUpdate){return}if(this.armatureData===null){console.assert(false,"The armature has been disposed.");return}else if(this.armatureData.parent===null){console.assert(false,"The armature data has been disposed.");return}var i=this._cacheFrameIndex;this._animation.advanceTime(e);if(this._bonesDirty){this._bonesDirty=false;this._sortBones()}if(this._slotsDirty){this._slotsDirty=false;this._sortSlots()}if(this._cacheFrameIndex<0||this._cacheFrameIndex!==i){var a=0,r=0;for(a=0,r=this._bones.length;a0){this._lockUpdate=true;for(var n=0,s=this._actions;n0){var i=this.getBone(t);if(i!==null){i.invalidUpdate();if(e){for(var a=0,r=this._slots;a0){if(r!==null||n!==null){if(r!==null){var T=o?r.y-e:r.x-t;if(T<0){T=-T}if(d===null||Th){h=T;_=n.x;m=n.y;y=b;if(s!==null){c=s.y}}}}else{d=b;break}}}if(d!==null&&r!==null){r.x=u;r.y=f;if(s!==null){s.x=p}}if(y!==null&&n!==null){n.x=_;n.y=m;if(s!==null){s.y=c}}return d};i.prototype.getBone=function(t){for(var e=0,i=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.constraints.length>0){for(var i=0,a=this.constraints;i=0){this._transformDirty=false;this._cachedFrameIndices[t]=this._cachedFrameIndex}else{this._transformDirty=true;this._cachedFrameIndex=-1}}}else{if(this.constraints.length>0){for(var n=0,s=this.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};i.prototype.updateByConstraint=function(){if(this._localDirty){this._localDirty=false;if(this._transformDirty||this._parent!==null&&this._parent._childrenTransformDirty){this._updateGlobalTransformMatrix(true)}this._transformDirty=true}};i.prototype.addConstraint=function(t){if(this.constraints.indexOf(t)<0){this.constraints.push(t)}};i.prototype.invalidUpdate=function(){this._transformDirty=true};i.prototype.contains=function(t){if(t===this){return false}var e=t;while(e!==this&&e!==null){e=e.parent}return e===this};i.prototype.getBones=function(){this._bones.length=0;for(var t=0,e=this._armature.getBones();t=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex=0&&this._displayIndex0){for(var o=0,l=n;o0){if(this._displayList.length!==e.length){this._displayList.length=e.length}for(var i=0,a=e.length;i0){this._displayList.length=0}if(this._displayIndex>=0&&this._displayIndex=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._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._display===null){return}if(this._blendModeDirty){this._blendModeDirty=false;this._updateBlendMode()}if(this._colorDirty){this._colorDirty=false;this._updateColor()}if(this._meshData!==null&&this._display===this._meshDisplay){var i=this._meshData.weight!==null;if(this._meshDirty||i&&this._isMeshBonesUpdate()){this._meshDirty=false;this._updateMesh()}if(i){if(this._transformDirty){this._transformDirty=false;this._updateTransform(true)}return}}if(this._transformDirty){this._transformDirty=false;if(this._cachedFrameIndex<0){var a=t>=0;this._updateGlobalTransformMatrix(a);if(a&&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(false)}};i.prototype.updateTransformAndMatrix=function(){if(this._transformDirty){this._transformDirty=false;this._updateGlobalTransformMatrix(false)}};i.prototype.containsPoint=function(t,e){if(this._boundingBoxData===null){return false}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);return this._boundingBoxData.containsPoint(i._helpPoint.x,i._helpPoint.y)};i.prototype.intersectsSegment=function(t,e,a,r,n,s,o){if(n===void 0){n=null}if(s===void 0){s=null}if(o===void 0){o=null}if(this._boundingBoxData===null){return 0}this.updateTransformAndMatrix();i._helpMatrix.copyFrom(this.globalTransformMatrix);i._helpMatrix.invert();i._helpMatrix.transformPoint(t,e,i._helpPoint);t=i._helpPoint.x;e=i._helpPoint.y;i._helpMatrix.transformPoint(a,r,i._helpPoint);a=i._helpPoint.x;r=i._helpPoint.y;var l=this._boundingBoxData.intersectsSegment(t,e,a,r,n,s,o);if(l>0){if(l===1||l===2){if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n);if(s!==null){s.x=n.x;s.y=n.y}}else if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}else{if(n!==null){this.globalTransformMatrix.transformPoint(n.x,n.y,n)}if(s!==null){this.globalTransformMatrix.transformPoint(s.x,s.y,s)}}if(o!==null){this.globalTransformMatrix.transformPoint(Math.cos(o.x),Math.sin(o.x),i._helpPoint,true);o.x=Math.atan2(i._helpPoint.y,i._helpPoint.x);this.globalTransformMatrix.transformPoint(Math.cos(o.y),Math.sin(o.y),i._helpPoint,true);o.y=Math.atan2(i._helpPoint.y,i._helpPoint.x)}}return l};i.prototype.invalidUpdate=function(){this._displayDirty=true;this._transformDirty=true};Object.defineProperty(i.prototype,"displayIndex",{get:function(){return this._displayIndex},set:function(t){if(this._setDisplayIndex(t)){this.update(-1)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"displayList",{get:function(){return this._displayList.concat()},set:function(e){var i=this._displayList.concat();var a=new Array;if(this._setDisplayList(e)){this.update(-1)}for(var r=0,n=i;r0){this._animatebles[e-i]=r;this._animatebles[e]=null}r.advanceTime(t)}else{i++}}if(i>0){a=this._animatebles.length;for(;e=0};t.prototype.add=function(t){if(this._animatebles.indexOf(t)<0){this._animatebles.push(t);t.clock=this}};t.prototype.remove=function(t){var e=this._animatebles.indexOf(t);if(e>=0){this._animatebles[e]=null;t.clock=null}};t.prototype.clear=function(){for(var t=0,e=this._animatebles;t0&&i._subFadeState>0){this._armature._dragonBones.bufferObject(i);this._animationStates.length=0;this._lastAnimationState=null}else{var a=i.animationData;var r=a.cacheFrameRate;if(this._animationDirty&&r>0){this._animationDirty=false;for(var n=0,s=this._armature.getBones();n1){for(var f=0,_=0;f0&&i._subFadeState>0){_++;this._armature._dragonBones.bufferObject(i);this._animationDirty=true;if(this._lastAnimationState===i){this._lastAnimationState=null}}else{if(_>0){this._animationStates[f-_]=i}if(this._timelineDirty){i.updateTimelines()}i.advanceTime(t,0)}if(f===e-1&&_>0){this._animationStates.length-=_;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}this._timelineDirty=false};i.prototype.reset=function(){for(var t=0,e=this._animationStates;t1){if(e.position<0){e.position%=a.duration;e.position=a.duration-e.position}else if(e.position===a.duration){e.position-=1e-6}else if(e.position>a.duration){e.position%=a.duration}if(e.duration>0&&e.position+e.duration>a.duration){e.duration=a.duration-e.position}if(e.playTimes<0){e.playTimes=a.playTimes}}else{e.playTimes=1;e.position=0;if(e.duration>0){e.duration=0}}if(e.duration===0){e.duration=-1}this._fadeOut(e);var o=t.BaseObject.borrowObject(t.AnimationState);o.init(this._armature,a,e);this._animationDirty=true;this._armature._cacheFrameIndex=-1;if(this._animationStates.length>0){var l=false;for(var h=0,u=this._animationStates.length;h=this._animationStates[h].layer){}else{l=true;this._animationStates.splice(h+1,0,o);break}}if(!l){this._animationStates.push(o)}}else{this._animationStates.push(o)}for(var f=0,_=this._armature.getSlots();f<_.length;f++){var m=_[f];var p=m.childArmature;if(p!==null&&p.inheritAnimation&&p.animation.hasAnimation(i)&&p.animation.getState(i)===null){p.animation.fadeIn(i)}}if(e.fadeInTime<=0){this._armature.advanceTime(0)}this._lastAnimationState=o;return o};i.prototype.play=function(t,e){if(t===void 0){t=null}if(e===void 0){e=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t!==null?t:"";if(t!==null&&t.length>0){this.playConfig(this._animationConfig)}else if(this._lastAnimationState===null){var i=this._armature.armatureData.defaultAnimation;if(i!==null){this._animationConfig.animation=i.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};i.prototype.fadeIn=function(t,e,i,a,r,n){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=0}if(r===void 0){r=null}if(n===void 0){n=3}this._animationConfig.clear();this._animationConfig.fadeOutMode=n;this._animationConfig.playTimes=i;this._animationConfig.layer=a;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=r!==null?r:"";return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByTime=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.position=e;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByFrame=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*e/a.frameCount}return this.playConfig(this._animationConfig)};i.prototype.gotoAndPlayByProgress=function(t,e,i){if(e===void 0){e=0}if(i===void 0){i=-1}this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.playTimes=i;this._animationConfig.fadeInTime=0;this._animationConfig.animation=t;var a=t in this._animations?this._animations[t]:null;if(a!==null){this._animationConfig.position=a.duration*(e>0?e:0)}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStopByTime=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByTime(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByFrame=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByFrame(t,e,1);if(i!==null){i.stop()}return i};i.prototype.gotoAndStopByProgress=function(t,e){if(e===void 0){e=0}var i=this.gotoAndPlayByProgress(t,e,1);if(i!==null){i.stop()}return i};i.prototype.getState=function(t){var e=this._animationStates.length;while(e--){var i=this._animationStates[e];if(i.name===t){return i}}return null};i.prototype.hasAnimation=function(t){return t in this._animations};i.prototype.getStates=function(){return this._animationStates};Object.defineProperty(i.prototype,"isPlaying",{get:function(){for(var t=0,e=this._animationStates;t0},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationName",{get:function(){return this._lastAnimationState!==null?this._lastAnimationState.name:""},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationNames",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.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._animations[e]=t[e];this._animationNames.push(e)}},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationConfig",{get:function(){this._animationConfig.clear();return this._animationConfig},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"lastAnimationState",{get:function(){return this._lastAnimationState},enumerable:true,configurable:true});i.prototype.gotoAndPlay=function(t,e,i,a,r,n,s,o,l){if(e===void 0){e=-1}if(i===void 0){i=-1}if(a===void 0){a=-1}if(r===void 0){r=0}if(n===void 0){n=null}if(s===void 0){s=3}if(o===void 0){o=true}if(l===void 0){l=true}o;l;this._animationConfig.clear();this._animationConfig.resetToPose=true;this._animationConfig.fadeOutMode=s;this._animationConfig.playTimes=a;this._animationConfig.layer=r;this._animationConfig.fadeInTime=e;this._animationConfig.animation=t;this._animationConfig.group=n!==null?n:"";var h=this._animations[t];if(h&&i>0){this._animationConfig.timeScale=h.duration/i}return this.playConfig(this._animationConfig)};i.prototype.gotoAndStop=function(t,e){if(e===void 0){e=0}return this.gotoAndStopByTime(t,e)};Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:true,configurable:true});Object.defineProperty(i.prototype,"animationDataList",{get:function(){var t=[];for(var e=0,i=this._animationNames.length;e0;if(this._subFadeState<0){this._subFadeState=0;var a=i?t.EventObject.FADE_OUT:t.EventObject.FADE_IN;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}if(e<0){e=-e}this._fadeTime+=e;if(this._fadeTime>=this.fadeTotalTime){this._subFadeState=1;this._fadeProgress=i?0:1}else if(this._fadeTime>0){this._fadeProgress=i?1-this._fadeTime/this.fadeTotalTime:this._fadeTime/this.fadeTotalTime}else{this._fadeProgress=i?1:0}if(this._subFadeState>0){if(!i){this._playheadState|=1;this._fadeState=0}var a=i?t.EventObject.FADE_OUT_COMPLETE:t.EventObject.FADE_IN_COMPLETE;if(this._armature.eventDispatcher.hasEvent(a)){var r=t.BaseObject.borrowObject(t.EventObject);r.type=a;r.armature=this._armature;r.animationState=this;this._armature._dragonBones.bufferEvent(r)}}};a.prototype._blendBoneTimline=function(t){var e=t.bone;var i=t.bonePose.result;var a=e.animationPose;var r=this._weightResult>0?this._weightResult:-this._weightResult;if(!e._blendDirty){e._blendDirty=true;e._blendLayer=this.layer;e._blendLayerWeight=r;e._blendLeftWeight=1;a.x=i.x*r;a.y=i.y*r;a.rotation=i.rotation*r;a.skew=i.skew*r;a.scaleX=(i.scaleX-1)*r+1;a.scaleY=(i.scaleY-1)*r+1}else{r*=e._blendLeftWeight;e._blendLayerWeight+=r;a.x+=i.x*r;a.y+=i.y*r;a.rotation+=i.rotation*r;a.skew+=i.skew*r;a.scaleX+=(i.scaleX-1)*r;a.scaleY+=(i.scaleY-1)*r}if(this._fadeState!==0||this._subFadeState!==0){e._transformDirty=true}};a.prototype.init=function(e,i,a){if(this._armature!==null){return}this._armature=e;this.animationData=i;this.resetToPose=a.resetToPose;this.additiveBlending=a.additiveBlending;this.displayControl=a.displayControl;this.actionEnabled=a.actionEnabled;this.layer=a.layer;this.playTimes=a.playTimes;this.timeScale=a.timeScale;this.fadeTotalTime=a.fadeInTime;this.autoFadeOutTime=a.autoFadeOutTime;this.weight=a.weight;this.name=a.name.length>0?a.name:a.animation;this.group=a.group;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,n=this._boneMask.length;r0;var a=true;var r=true;var n=this._time;this._weightResult=this.weight*this._fadeProgress;this._actionTimeline.update(n);if(i){var s=e*2;this._actionTimeline.currentTime=Math.floor(this._actionTimeline.currentTime*s)/s}if(this._zOrderTimeline!==null){this._zOrderTimeline.update(n)}if(i){var o=Math.floor(this._actionTimeline.currentTime*e);if(this._armature._cacheFrameIndex===o){a=false;r=false}else{this._armature._cacheFrameIndex=o;if(this.animationData.cachedFrames[o]){r=false}else{this.animationData.cachedFrames[o]=true}}}if(a){if(r){var l=null;var h=null;for(var u=0,f=this._boneTimelines.length;u0){if(l._blendLayer!==this.layer){if(l._blendLayerWeight>=l._blendLeftWeight){l._blendLeftWeight=0;l=null}else{l._blendLayer=this.layer;l._blendLeftWeight-=l._blendLayerWeight;l._blendLayerWeight=0}}}else{l=null}}}l=_.bone}if(l!==null){_.update(n);if(u===f-1){this._blendBoneTimline(_)}else{h=_}}}}for(var u=0,f=this._slotTimelines.length;u0){this._subFadeState=0}if(this._actionTimeline.playState>0){if(this.autoFadeOutTime>=0){this.fadeOut(this.autoFadeOutTime)}}}};a.prototype.play=function(){this._playheadState=3};a.prototype.stop=function(){this._playheadState&=1};a.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 i=0,a=this._boneTimelines;i1e-6?t/this._fadeProgress:0;this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)};a.prototype.containsBoneMask=function(t){return this._boneMask.length===0||this._boneMask.indexOf(t)>=0};a.prototype.addBoneMask=function(t,e){if(e===void 0){e=true}var i=this._armature.getBone(t);if(i===null){return}if(this._boneMask.indexOf(t)<0){this._boneMask.push(t)}if(e){for(var a=0,r=this._armature.getBones();a=0){this._boneMask.splice(i,1)}if(e){var a=this._armature.getBone(t);if(a!==null){var r=this._armature.getBones();if(this._boneMask.length>0){for(var n=0,s=r;n=0&&a.contains(o)){this._boneMask.splice(l,1)}}}else{for(var h=0,u=r;h0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isFadeComplete",{get:function(){return this._fadeState===0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isPlaying",{get:function(){return(this._playheadState&2)!==0&&this._actionTimeline.playState<=0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"isCompleted",{get:function(){return this._actionTimeline.playState>0},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"currentPlayTimes",{get:function(){return this._actionTimeline.currentPlayTimes},enumerable:true,configurable:true});Object.defineProperty(a.prototype,"totalTime",{get:function(){return this._duration},enumerable:true,configurable:true});Object.defineProperty(a.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){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 i=0,a=this._boneTimelines;i=0?1:-1;this.currentPlayTimes=1;this.currentTime=this._actionTimeline.currentTime}else if(this._actionTimeline===null||this._timeScale!==1||this._timeOffset!==0){var r=this._animationState.playTimes;var n=r*this._duration;t*=this._timeScale;if(this._timeOffset!==0){t+=this._timeOffset*this._animationData.duration}if(r>0&&(t>=n||t<=-n)){if(this.playState<=0&&this._animationState._playheadState===3){this.playState=1}this.currentPlayTimes=r;if(t<0){this.currentTime=0}else{this.currentTime=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===i&&this.currentTime===a){return false}if(e<0&&this.playState!==e||this.playState<=0&&this.currentPlayTimes!==i){this._frameIndex=-1}return true};e.prototype.init=function(t,e,i){this._armature=t;this._animationState=e;this._timelineData=i;this._actionTimeline=this._animationState._actionTimeline;if(this===this._actionTimeline){this._actionTimeline=null}this._frameRate=this._armature.armatureData.frameRate;this._frameRateR=1/this._frameRate;this._position=this._animationState._position;this._duration=this._animationState._duration;this._dragonBonesData=this._armature.armatureData.parent;this._animationData=this._animationState.animationData;if(this._timelineData!==null){this._frameIntArray=this._dragonBonesData.frameIntArray;this._frameFloatArray=this._dragonBonesData.frameFloatArray;this._frameArray=this._dragonBonesData.frameArray;this._timelineArray=this._dragonBonesData.timelineArray;this._frameIndices=this._dragonBonesData.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(){};e.prototype.update=function(t){if(this.playState<=0&&this._setCurrentTime(t)){if(this._frameCount>1){var e=Math.floor(this.currentTime*this._frameRate);var i=this._frameIndices[this._timelineData.frameIndicesOffset+e];if(this._frameIndex!==i){this._frameIndex=i;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._tweenState!==0){this._onUpdateFrame()}}};return e}(t.BaseObject);t.TimelineState=e;var i=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e._getEasingValue=function(t,e,i){var a=e;switch(t){case 3:a=Math.pow(e,2);break;case 4:a=1-Math.pow(1-e,2);break;case 5:a=.5*(1-Math.cos(e*Math.PI));break}return(a-e)*i+e};e._getEasingCurveValue=function(t,e,i,a){if(t<=0){return 0}else if(t>=1){return 1}var r=i+1;var n=Math.floor(t*r);var s=n===0?0:e[a+n-1];var o=n===r-1?1e4:e[a+n];return(s+(o-s)*(t*r-n))*1e-4};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._tweenType=0;this._curveCount=0;this._framePosition=0;this._frameDurationR=0;this._tweenProgress=0;this._tweenEasing=0};e.prototype._onArriveAtFrame=function(){if(this._frameCount>1&&(this._frameIndex!==this._frameCount-1||this._animationState.playTimes===0||this._animationState.currentPlayTimes0){if(n.hasEvent(t.EventObject.COMPLETE)){h=t.BaseObject.borrowObject(t.EventObject);h.type=t.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 p=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+p];if(this.currentPlayTimes===a){if(m===_){m=-1}}}while(m>=0){var c=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[c]/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 p=Math.floor(r*this._frameRate);m=this._frameIndices[u.frameIndicesOffset+p];var c=this._animationData.frameOffset+this._timelineArray[u.offset+5+m];var d=this._frameArray[c]/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}(t.TimelineState);t.ZOrderTimelineState=i;var a=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.toString=function(){return"[class dragonBones.BoneAllTimelineState]"};i.prototype._onArriveAtFrame=function(){e.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var t=this._dragonBonesData.frameFloatArray;var i=this.bonePose.current;var a=this.bonePose.delta;var r=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*6;i.x=t[r++];i.y=t[r++];i.rotation=t[r++];i.skew=t[r++];i.scaleX=t[r++];i.scaleY=t[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}a.x=t[r++]-i.x;a.y=t[r++]-i.y;a.rotation=t[r++]-i.rotation;a.skew=t[r++]-i.skew;a.scaleX=t[r++]-i.scaleX;a.scaleY=t[r++]-i.scaleY}}else{var i=this.bonePose.current;i.x=0;i.y=0;i.rotation=0;i.skew=0;i.scaleX=1;i.scaleY=1}};i.prototype._onUpdateFrame=function(){e.prototype._onUpdateFrame.call(this);var t=this.bonePose.current;var i=this.bonePose.delta;var a=this.bonePose.result;this.bone._transformDirty=true;if(this._tweenState!==2){this._tweenState=0}var r=this._armature.armatureData.scale;a.x=(t.x+i.x*this._tweenProgress)*r;a.y=(t.y+i.y*this._tweenProgress)*r;a.rotation=t.rotation+i.rotation*this._tweenProgress;a.skew=t.skew+i.skew*this._tweenProgress;a.scaleX=t.scaleX+i.scaleX*this._tweenProgress;a.scaleY=t.scaleY+i.scaleY*this._tweenProgress};i.prototype.fadeOut=function(){var e=this.bonePose.result;e.rotation=t.Transform.normalizeRadian(e.rotation);e.skew=t.Transform.normalizeRadian(e.skew)};return i}(t.BoneTimelineState);t.BoneAllTimelineState=a;var r=function(t){__extends(e,t);function e(){return t!==null&&t.apply(this,arguments)||this}e.toString=function(){return"[class dragonBones.SlotDislayIndexTimelineState]"};e.prototype._onArriveAtFrame=function(){if(this.playState>=0){var t=this._timelineData!==null?this._frameArray[this._frameOffset+1]:this.slot.slotData.displayIndex;if(this.slot.displayIndex!==t){this.slot._setDisplayIndex(t,true)}}};return e}(t.SlotTimelineState);t.SlotDislayIndexTimelineState=r;var n=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[0,0,0,0,0,0,0,0];e._delta=[0,0,0,0,0,0,0,0];e._result=[0,0,0,0,0,0,0,0];return e}e.toString=function(){return"[class dragonBones.SlotColorTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this._dirty=false};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._dragonBonesData.intArray;var i=this._dragonBonesData.frameIntArray;var a=this._animationData.frameIntOffset+this._frameValueOffset+this._frameIndex*1;var r=i[a];this._current[0]=e[r++];this._current[1]=e[r++];this._current[2]=e[r++];this._current[3]=e[r++];this._current[4]=e[r++];this._current[5]=e[r++];this._current[6]=e[r++];this._current[7]=e[r++];if(this._tweenState===2){if(this._frameIndex===this._frameCount-1){r=i[this._animationData.frameIntOffset+this._frameValueOffset]}else{r=i[a+1*1]}this._delta[0]=e[r++]-this._current[0];this._delta[1]=e[r++]-this._current[1];this._delta[2]=e[r++]-this._current[2];this._delta[3]=e[r++]-this._current[3];this._delta[4]=e[r++]-this._current[4];this._delta[5]=e[r++]-this._current[5];this._delta[6]=e[r++]-this._current[6];this._delta[7]=e[r++]-this._current[7]}}else{var n=this.slot.slotData.color;this._current[0]=n.alphaMultiplier*100;this._current[1]=n.redMultiplier*100;this._current[2]=n.greenMultiplier*100;this._current[3]=n.blueMultiplier*100;this._current[4]=n.alphaOffset;this._current[5]=n.redOffset;this._current[6]=n.greenOffset;this._current[7]=n.blueOffset}};e.prototype._onUpdateFrame=function(){t.prototype._onUpdateFrame.call(this);this._dirty=true;if(this._tweenState!==2){this._tweenState=0}this._result[0]=(this._current[0]+this._delta[0]*this._tweenProgress)*.01;this._result[1]=(this._current[1]+this._delta[1]*this._tweenProgress)*.01;this._result[2]=(this._current[2]+this._delta[2]*this._tweenProgress)*.01;this._result[3]=(this._current[3]+this._delta[3]*this._tweenProgress)*.01;this._result[4]=this._current[4]+this._delta[4]*this._tweenProgress;this._result[5]=this._current[5]+this._delta[5]*this._tweenProgress;this._result[6]=this._current[6]+this._delta[6]*this._tweenProgress;this._result[7]=this._current[7]+this._delta[7]*this._tweenProgress};e.prototype.fadeOut=function(){this._tweenState=0;this._dirty=false};e.prototype.update=function(e){t.prototype.update.call(this,e);if(this._tweenState!==0||this._dirty){var i=this.slot._colorTransform;if(this._animationState._fadeState!==0||this._animationState._subFadeState!==0){if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){var a=Math.pow(this._animationState._fadeProgress,4);i.alphaMultiplier+=(this._result[0]-i.alphaMultiplier)*a;i.redMultiplier+=(this._result[1]-i.redMultiplier)*a;i.greenMultiplier+=(this._result[2]-i.greenMultiplier)*a;i.blueMultiplier+=(this._result[3]-i.blueMultiplier)*a;i.alphaOffset+=(this._result[4]-i.alphaOffset)*a;i.redOffset+=(this._result[5]-i.redOffset)*a;i.greenOffset+=(this._result[6]-i.greenOffset)*a;i.blueOffset+=(this._result[7]-i.blueOffset)*a;this.slot._colorDirty=true}}else if(this._dirty){this._dirty=false;if(i.alphaMultiplier!==this._result[0]||i.redMultiplier!==this._result[1]||i.greenMultiplier!==this._result[2]||i.blueMultiplier!==this._result[3]||i.alphaOffset!==this._result[4]||i.redOffset!==this._result[5]||i.greenOffset!==this._result[6]||i.blueOffset!==this._result[7]){i.alphaMultiplier=this._result[0];i.redMultiplier=this._result[1];i.greenMultiplier=this._result[2];i.blueMultiplier=this._result[3];i.alphaOffset=this._result[4];i.redOffset=this._result[5];i.greenOffset=this._result[6];i.blueOffset=this._result[7];this.slot._colorDirty=true}}}};return e}(t.SlotTimelineState);t.SlotColorTimelineState=n;var s=function(t){__extends(e,t);function e(){var e=t!==null&&t.apply(this,arguments)||this;e._current=[];e._delta=[];e._result=[];return e}e.toString=function(){return"[class dragonBones.SlotFFDTimelineState]"};e.prototype._onClear=function(){t.prototype._onClear.call(this);this.meshOffset=0;this._dirty=false;this._frameFloatOffset=0;this._valueCount=0;this._ffdCount=0;this._valueOffset=0;this._current.length=0;this._delta.length=0;this._result.length=0};e.prototype._onArriveAtFrame=function(){t.prototype._onArriveAtFrame.call(this);if(this._timelineData!==null){var e=this._tweenState===2;var i=this._dragonBonesData.frameFloatArray;var a=this._animationData.frameFloatOffset+this._frameValueOffset+this._frameIndex*this._valueCount;if(e){var r=a+this._valueCount;if(this._frameIndex===this._frameCount-1){r=this._animationData.frameFloatOffset+this._frameValueOffset}for(var n=0;n255){return encodeURI(r)}}}return r}return String(r)}return a};a.prototype._getCurvePoint=function(t,e,i,a,r,n,s,o,l,h){var u=1-l;var f=u*u;var _=l*l;var m=u*f;var p=3*l*f;var c=3*u*_;var d=l*_;h.x=m*t+p*i+c*r+d*s;h.y=m*e+p*a+c*n+d*o};a.prototype._samplingEasingCurve=function(t,e){var i=t.length;var a=-2;for(var r=0,n=e.length;r=0&&a+61e-4){var g=(y+d)*.5;this._getCurvePoint(l,h,u,f,_,m,p,c,g,this._helpPoint);if(s-this._helpPoint.x>0){d=g}else{y=g}}e[r]=this._helpPoint.y}};a.prototype._sortActionFrame=function(t,e){return t.frameStart>e.frameStart?1:-1};a.prototype._parseActionDataInFrame=function(t,e,i,r){if(a.EVENT in t){this._mergeActionFrame(t[a.EVENT],e,10,i,r)}if(a.SOUND in t){this._mergeActionFrame(t[a.SOUND],e,11,i,r)}if(a.ACTION in t){this._mergeActionFrame(t[a.ACTION],e,0,i,r)}if(a.EVENTS in t){this._mergeActionFrame(t[a.EVENTS],e,10,i,r)}if(a.ACTIONS in t){this._mergeActionFrame(t[a.ACTIONS],e,0,i,r)}};a.prototype._mergeActionFrame=function(e,a,r,n,s){var o=t.DragonBones.webAssembly?this._armature.actions.size():this._armature.actions.length;var l=this._parseActionData(e,this._armature.actions,r,n,s);var h=null;if(this._actionFrames.length===0){h=new i;h.frameStart=0;this._actionFrames.push(h);h=null}for(var u=0,f=this._actionFrames;u0){var p=r.getBone(_);if(p!==null){m.parent=p}else{(this._cacheBones[_]=this._cacheBones[_]||[]).push(m)}}if(m.name in this._cacheBones){for(var c=0,d=this._cacheBones[m.name];c0){n.root=i.parent}if(t.DragonBones.webAssembly){i.constraints.push_back(n)}else{i.constraints.push(n)}};a.prototype._parseSlot=function(e){var i=t.DragonBones.webAssembly?new Module["SlotData"]:t.BaseObject.borrowObject(t.SlotData);i.displayIndex=a._getNumber(e,a.DISPLAY_INDEX,0);i.zOrder=t.DragonBones.webAssembly?this._armature.sortedSlots.size():this._armature.sortedSlots.length;i.name=a._getString(e,a.NAME,"");i.parent=this._armature.getBone(a._getString(e,a.PARENT,""));if(a.BLEND_MODE in e&&typeof e[a.BLEND_MODE]==="string"){i.blendMode=a._getBlendMode(e[a.BLEND_MODE])}else{i.blendMode=a._getNumber(e,a.BLEND_MODE,0)}if(a.COLOR in e){i.color=t.DragonBones.webAssembly?Module["SlotData"].createColor():t.SlotData.createColor();this._parseColorTransform(e[a.COLOR],i.color)}else{i.color=t.DragonBones.webAssembly?Module["SlotData"].DEFAULT_COLOR:t.SlotData.DEFAULT_COLOR}if(a.ACTIONS in e){var r=this._slotChildActions[i.name]=[];this._parseActionData(e[a.ACTIONS],r,0,null,null)}return i};a.prototype._parseSkin=function(e){var i=t.DragonBones.webAssembly?new Module["SkinData"]:t.BaseObject.borrowObject(t.SkinData);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length===0){i.name=a.DEFAULT_NAME}if(a.SLOT in e){this._skin=i;var r=e[a.SLOT];for(var n=0,s=r;n0?n:r;this._parsePivot(e,o);break;case 1:var l=i=t.DragonBones.webAssembly?new Module["ArmatureDisplayData"]:t.BaseObject.borrowObject(t.ArmatureDisplayData);l.name=r;l.path=n.length>0?n:r;l.inheritAnimation=true;if(a.ACTIONS in e){this._parseActionData(e[a.ACTIONS],l.actions,0,null,null)}else if(this._slot.name in this._slotChildActions){var h=this._skin.getDisplays(this._slot.name);if(h===null?this._slot.displayIndex===0:this._slot.displayIndex===h.length){for(var u=0,f=this._slotChildActions[this._slot.name];u0?n:r;m.inheritAnimation=a._getBoolean(e,a.INHERIT_FFD,true);this._parsePivot(e,m);var p=a._getString(e,a.SHARE,"");if(p.length>0){var c=this._meshs[p];m.offset=c.offset;m.weight=c.weight}else{this._parseMesh(e,m);this._meshs[m.name]=m}break;case 3:var d=this._parseBoundingBox(e);if(d!==null){var y=i=t.DragonBones.webAssembly?new Module["BoundingBoxDisplayData"]:t.BaseObject.borrowObject(t.BoundingBoxDisplayData);y.name=r;y.path=n.length>0?n:r;y.boundingBox=d}break}if(i!==null){i.parent=this._armature;if(a.TRANSFORM in e){this._parseTransform(e[a.TRANSFORM],i.transform,this._armature.scale)}}return i};a.prototype._parsePivot=function(t,e){if(a.PIVOT in t){var i=t[a.PIVOT];e.pivot.x=a._getNumber(i,a.X,0);e.pivot.y=a._getNumber(i,a.Y,0)}else{e.pivot.x=.5;e.pivot.y=.5}};a.prototype._parseMesh=function(e,i){var r=e[a.VERTICES];var n=e[a.UVS];var s=e[a.TRIANGLES];var o=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var l=t.DragonBones.webAssembly?this._floatArrayJson:this._data.floatArray;var h=Math.floor(r.length/2);var u=Math.floor(s.length/3);var f=l.length;var _=f+h*2;i.offset=o.length;o.length+=1+1+1+1+u*3;o[i.offset+0]=h;o[i.offset+1]=u;o[i.offset+2]=f;for(var m=0,p=u*3;mn.width){n.width=h}if(un.height){n.height=u}}}return n};a.prototype._parseAnimation=function(e){var i=t.DragonBones.webAssembly?new Module["AnimationData"]:t.BaseObject.borrowObject(t.AnimationData);i.frameCount=Math.max(a._getNumber(e,a.DURATION,1),1);i.playTimes=a._getNumber(e,a.PLAY_TIMES,1);i.duration=i.frameCount/this._armature.frameRate;i.fadeInTime=a._getNumber(e,a.FADE_IN_TIME,0);i.scale=a._getNumber(e,a.SCALE,1);i.name=a._getString(e,a.NAME,a.DEFAULT_NAME);if(i.name.length<1){i.name=a.DEFAULT_NAME}if(t.DragonBones.webAssembly){i.frameIntOffset=this._frameIntArrayJson.length;i.frameFloatOffset=this._frameFloatArrayJson.length;i.frameOffset=this._frameArrayJson.length}else{i.frameIntOffset=this._data.frameIntArray.length;i.frameFloatOffset=this._data.frameFloatArray.length;i.frameOffset=this._data.frameArray.length}this._animation=i;if(a.FRAME in e){var r=e[a.FRAME];var n=r.length;if(n>0){for(var s=0,o=0;s0){this._actionFrames.sort(this._sortActionFrame);var D=this._animation.actionTimeline=t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);var T=t.DragonBones.webAssembly?this._timelineArrayJson:this._data.timelineArray;var n=this._actionFrames.length;D.type=0;D.offset=T.length;T.length+=1+1+1+1+1+n;T[D.offset+0]=100;T[D.offset+1]=0;T[D.offset+2]=n;T[D.offset+3]=0;T[D.offset+4]=0;this._timeline=D;if(n===1){D.frameIndicesOffset=-1;T[D.offset+5+0]=this._parseCacheActionFrame(this._actionFrames[0])-this._animation.frameOffset}else{var A=this._animation.frameCount+1;var O=this._data.frameIndices;if(t.DragonBones.webAssembly){D.frameIndicesOffset=O.size();for(var B=0;B0){if(a.CURVE in t){var s=i+1;this._helpArray.length=s;this._samplingEasingCurve(t[a.CURVE],this._helpArray);r.length+=1+1+this._helpArray.length;r[n+1]=2;r[n+2]=s;for(var o=0;o0){var l=this._armature.sortedSlots.length;var h=new Array(l-o.length/2);var u=new Array(l);for(var f=0;f0?l>=this._prevRotation:l<=this._prevRotation){this._prevTweenRotate=this._prevTweenRotate>0?this._prevTweenRotate-1:this._prevTweenRotate+1}l=this._prevRotation+l-this._prevRotation+t.Transform.PI_D*this._prevTweenRotate}}this._prevTweenRotate=a._getNumber(e,a.TWEEN_ROTATE,0);this._prevRotation=l;var h=n.length;n.length+=6;n[h++]=this._helpTransform.x;n[h++]=this._helpTransform.y;n[h++]=l;n[h++]=this._helpTransform.skew;n[h++]=this._helpTransform.scaleX;n[h++]=this._helpTransform.scaleY;this._parseActionDataInFrame(e,i,this._bone,this._slot);return o};a.prototype._parseSlotDisplayIndexFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var s=this._parseFrame(e,i,r,n);n.length+=1;n[s+1]=a._getNumber(e,a.DISPLAY_INDEX,0);this._parseActionDataInFrame(e,i,this._slot.parent,this._slot);return s};a.prototype._parseSlotColorFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameIntArrayJson:this._data.frameIntArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=this._parseTweenFrame(e,i,r,o);var h=-1;if(a.COLOR in e){var u=e[a.COLOR];for(var f in u){f;this._parseColorTransform(u,this._helpColorTransform);h=n.length;n.length+=8;n[h++]=Math.round(this._helpColorTransform.alphaMultiplier*100);n[h++]=Math.round(this._helpColorTransform.redMultiplier*100);n[h++]=Math.round(this._helpColorTransform.greenMultiplier*100);n[h++]=Math.round(this._helpColorTransform.blueMultiplier*100);n[h++]=Math.round(this._helpColorTransform.alphaOffset);n[h++]=Math.round(this._helpColorTransform.redOffset);n[h++]=Math.round(this._helpColorTransform.greenOffset);n[h++]=Math.round(this._helpColorTransform.blueOffset);h-=8;break}}if(h<0){if(this._defalultColorOffset<0){this._defalultColorOffset=h=n.length;n.length+=8;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=100;n[h++]=0;n[h++]=0;n[h++]=0;n[h++]=0}h=this._defalultColorOffset}var _=s.length;s.length+=1;s[_]=h;return l};a.prototype._parseSlotFFDFrame=function(e,i,r){var n=t.DragonBones.webAssembly?this._intArrayJson:this._data.intArray;var s=t.DragonBones.webAssembly?this._frameFloatArrayJson:this._data.frameFloatArray;var o=t.DragonBones.webAssembly?this._frameArrayJson:this._data.frameArray;var l=s.length;var h=this._parseTweenFrame(e,i,r,o);var u=a.VERTICES in e?e[a.VERTICES]:null;var f=a._getNumber(e,a.OFFSET,0);var _=n[this._mesh.offset+0];var m=0;var p=0;var c=0;var d=0;if(this._mesh.weight!==null){var y=this._weightSlotPose[this._mesh.name];this._helpMatrixA.copyFromArray(y,0);s.length+=this._mesh.weight.count*2;c=this._mesh.weight.offset+2+this._mesh.weight.bones.length}else{s.length+=_*2}for(var g=0;g<_*2;g+=2){if(u===null){m=0;p=0}else{if(g=u.length){m=0}else{m=u[g-f]}if(g+1=u.length){p=0}else{p=u[g+1-f]}}if(this._mesh.weight!==null){var v=this._weightBonePoses[this._mesh.name];var b=this._weightBoneIndices[this._mesh.name];var D=n[c++];this._helpMatrixA.transformPoint(m,p,this._helpPoint,true);m=this._helpPoint.x;p=this._helpPoint.y;for(var T=0;T=0||a.DATA_VERSIONS.indexOf(n)>=0){var s=t.DragonBones.webAssembly?new Module["DragonBonesData"]:t.BaseObject.borrowObject(t.DragonBonesData);s.version=r;s.name=a._getString(e,a.NAME,"");s.frameRate=a._getNumber(e,a.FRAME_RATE,24);if(s.frameRate===0){s.frameRate=24}if(a.ARMATURE in e){this._defalultColorOffset=-1;this._data=s;this._parseArray(e);var o=e[a.ARMATURE];for(var l=0,h=o;l0){this._parseWASMArray()}this._data=null}this._rawTextureAtlasIndex=0;if(a.TEXTURE_ATLAS in e){this._rawTextureAtlases=e[a.TEXTURE_ATLAS]}else{this._rawTextureAtlases=null}return s}else{console.assert(false,"Nonsupport data version.")}return null};a.prototype.parseTextureAtlasData=function(e,i,r){if(r===void 0){r=0}console.assert(e!==undefined);if(e===null){if(this._rawTextureAtlases===null){return false}var n=this._rawTextureAtlases[this._rawTextureAtlasIndex++];this.parseTextureAtlasData(n,i,r);if(this._rawTextureAtlasIndex>=this._rawTextureAtlases.length){this._rawTextureAtlasIndex=0;this._rawTextureAtlases=null}return true}i.width=a._getNumber(e,a.WIDTH,0);i.height=a._getNumber(e,a.HEIGHT,0);i.name=a._getString(e,a.NAME,"");i.imagePath=a._getString(e,a.IMAGE_PATH,"");if(r>0){i.scale=r}else{r=i.scale=a._getNumber(e,a.SCALE,i.scale)}r=1/r;if(a.SUB_TEXTURE in e){var s=e[a.SUB_TEXTURE];for(var o=0,l=s.length;o0&&_>0){u.frame=t.DragonBones.webAssembly?Module["TextureData"].createRectangle():t.TextureData.createRectangle();u.frame.x=a._getNumber(h,a.FRAME_X,0)*r;u.frame.y=a._getNumber(h,a.FRAME_Y,0)*r;u.frame.width=f*r;u.frame.height=_*r}i.addTexture(u)}}return true};a.getInstance=function(){if(a._objectDataParserInstance===null){a._objectDataParserInstance=new a}return a._objectDataParserInstance};a._objectDataParserInstance=null;return a}(t.DataParser);t.ObjectDataParser=e;var i=function(){function t(){this.frameStart=0;this.actions=[]}return t}()})(dragonBones||(dragonBones={}));var dragonBones;(function(t){var e=function(e){__extends(i,e);function i(){return e!==null&&e.apply(this,arguments)||this}i.prototype._inRange=function(t,e,i){return e<=t&&t<=i};i.prototype._decodeUTF8=function(t){var e=-1;var i=-1;var a=65533;var r=0;var n="";var s;var o=0;var l=0;var h=0;var u=0;while(t.length>r){var f=t[r++];if(f===e){if(l!==0){s=a}else{s=i}}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;r--;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!==i){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};i.prototype._getUTF16Key=function(t){for(var e=0,i=t.length;e255){return encodeURI(t)}}return t};i.prototype._parseBinaryTimeline=function(e,i,a){if(a===void 0){a=null}var r=a!==null?a:t.DragonBones.webAssembly?new Module["TimelineData"]:t.BaseObject.borrowObject(t.TimelineData);r.type=e;r.offset=i;this._timeline=r;var n=this._timelineArray[r.offset+2];if(n===1){r.frameIndicesOffset=-1}else{var s=this._animation.frameCount+1;var o=this._data.frameIndices;if(t.DragonBones.webAssembly){r.frameIndicesOffset=o.size();for(var l=0;l=0){var r=t.DragonBones.webAssembly?new Module["WeightData"]:t.BaseObject.borrowObject(t.WeightData);var n=this._intArray[i.offset+0];var s=this._intArray[a+0];r.offset=a;if(t.DragonBones.webAssembly){r.bones.resize(s,null);for(var o=0;o0){if(e in this._dragonBonesDataMap){n=this._dragonBonesDataMap[e];s=n.getArmature(i)}}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(i);if(s!==null){e=o;break}}}}if(s!==null){t.dataName=e;t.textureAtlasName=r;t.data=n;t.armature=s;t.skin=null;if(a.length>0){t.skin=s.getSkin(a);if(t.skin===null&&this.autoSearch){for(var o in this._dragonBonesDataMap){var l=this._dragonBonesDataMap[o];var h=l.getArmature(a);if(h!==null){t.skin=h.defaultSkin;break}}}}if(t.skin===null){t.skin=s.defaultSkin}return true}return false};i.prototype._buildBones=function(e,i){var a=e.armature.sortedBones;for(var r=0;r<(t.DragonBones.webAssembly?a.size():a.length);++r){var n=t.DragonBones.webAssembly?a.get(r):a[r];var s=t.DragonBones.webAssembly?new Module["Bone"]:t.BaseObject.borrowObject(t.Bone);s.init(n);if(n.parent!==null){i.addBone(s,n.parent.name)}else{i.addBone(s)}var o=n.constraints;for(var l=0;l<(t.DragonBones.webAssembly?o.size():o.length);++l){var h=t.DragonBones.webAssembly?o.get(l):o[l];var u=i.getBone(h.target.name);if(u===null){continue}var f=h;var _=t.DragonBones.webAssembly?new Module["IKConstraint"]:t.BaseObject.borrowObject(t.IKConstraint);var m=f.root!==null?i.getBone(f.root.name):null;_.target=u;_.bone=s;_.root=m;_.bendPositive=f.bendPositive;_.scaleEnabled=f.scaleEnabled;_.weight=f.weight;if(m!==null){m.addConstraint(_)}else{s.addConstraint(_)}}}};i.prototype._buildSlots=function(t,e){var i=t.skin;var a=t.armature.defaultSkin;if(i===null||a===null){return}var r={};for(var n in a.displays){var s=a.displays[n];r[n]=s}if(i!==a){for(var n in i.displays){var s=i.displays[n];r[n]=s}}for(var o=0,l=t.armature.sortedSlots;o0){s.texture=this._getTextureData(t.textureAtlasName,e.path)}if(i!==null&&i.type===2&&this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 2:var o=e;if(o.texture===null){o.texture=this._getTextureData(r,o.path)}else if(t!==null&&t.textureAtlasName.length>0){o.texture=this._getTextureData(t.textureAtlasName,o.path)}if(this._isSupportMesh()){n=a.meshDisplay}else{n=a.rawDisplay}break;case 1:var l=e;var h=this.buildArmature(l.path,r,null,t!==null?t.textureAtlasName:null);if(h!==null){h.inheritAnimation=l.inheritAnimation;if(!h.inheritAnimation){var u=l.actions.length>0?l.actions:h.armatureData.defaultActions;if(u.length>0){for(var f=0,_=u;f<_.length;f++){var m=_[f];h._bufferAction(m,true)}}else{h.animation.play()}}l.armature=h.armatureData}n=h;break}return n};i.prototype._replaceSlotDisplay=function(t,e,i,a){if(a<0){a=i.displayIndex}if(a<0){a=0}var r=i.displayList;if(r.length<=a){r.length=a+1;for(var n=0,s=r.length;n=0){continue}var s=e.displays[n.name];var o=n.displayList;o.length=s.length;for(var l=0,h=s.length;l=0&&this._display!==null&&i!==null){var a=i.parent;if(this._armature.replacedTexture!==null&&this._rawDisplayDatas.indexOf(this._displayData)>=0){if(this._armature._replaceTextureAtlasData===null){a=t.BaseObject.borrowObject(t.PixiTextureAtlasData);a.copyFrom(i.parent);a.renderTexture=this._armature.replacedTexture;this._armature._replaceTextureAtlasData=a}else{a=this._armature._replaceTextureAtlasData}i=a.getTexture(i.name)}var r=i.renderTexture;if(r!==null){var n=i.renderTexture;if(e!==null){var s=e.parent.parent;var o=s.intArray;var l=s.floatArray;var h=o[e.offset+0];var u=o[e.offset+1];var f=o[e.offset+2];var _=f+h*2;var m=this._renderDisplay;var p=a.width>0?a.width:n.width;var c=a.height>0?a.height:n.height;m.vertices=new Float32Array(h*2);m.uvs=new Float32Array(h*2);m.indices=new Uint16Array(u*3);for(var d=0,y=h*2;d0;var e=this._meshData;var i=e.weight;var a=this._renderDisplay;if(i!==null){var r=e.parent.parent;var n=r.intArray;var s=r.floatArray;var o=n[e.offset+0];var l=n[i.offset+1];for(var h=0,u=0,f=i.offset+2+i.bones.length,_=l,m=0;h void, target: any): void { + this.addListener(type, listener, target); + } + /** + * @inheritDoc + */ + public removeEvent(type: EventStringType, listener: (event: EventObject) => void, target: any): void { + this.removeListener(type, listener, target); + } + /** + * @inheritDoc + */ + public get armature(): Armature { + return this._armature; + } + /** + * @inheritDoc + */ + public get animation(): Animation { + return this._armature.animation; + } + + /** + * @deprecated + * 已废弃,请参考 @see + * @see dragonBones.Armature#clock + * @see dragonBones.PixiFactory#clock + * @see dragonBones.Animation#timescale + * @see dragonBones.Animation#stop() + */ + public advanceTimeBySelf(on: boolean): void { + if (on) { + this._armature.clock = PixiFactory.clock; + } + else { + this._armature.clock = null; + } + } + } +} \ No newline at end of file diff --git a/reference/Pixi/4.x/src/dragonBones/pixi/PixiFactory.ts b/reference/Pixi/4.x/src/dragonBones/pixi/PixiFactory.ts new file mode 100644 index 0000000..7c6f559 --- /dev/null +++ b/reference/Pixi/4.x/src/dragonBones/pixi/PixiFactory.ts @@ -0,0 +1,136 @@ +namespace dragonBones { + /** + * Pixi 工厂。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class PixiFactory extends BaseFactory { + private static _dragonBonesInstance: DragonBones = null as any; + private static _factory: PixiFactory = null as any; + private static _clockHandler(passedTime: number): void { + // PixiFactory._dragonBonesInstance.advanceTime(PIXI.ticker.shared.elapsedMS * passedTime * 0.001); + passedTime; + PixiFactory._dragonBonesInstance.advanceTime(-1); + } + /** + * 一个可以直接使用的全局 WorldClock 实例。(由引擎驱动) + * @version DragonBones 5.0 + * @language zh_CN + */ + public static get clock(): WorldClock { + return PixiFactory._dragonBonesInstance.clock; + } + /** + * @language zh_CN + * 一个可以直接使用的全局工厂实例。 + * @version DragonBones 4.7 + */ + public static get factory(): PixiFactory { + if (PixiFactory._factory === null) { + PixiFactory._factory = new PixiFactory(); + } + + return PixiFactory._factory; + } + /** + * @inheritDoc + */ + public constructor(dataParser: DataParser | null = null) { + super(dataParser); + + if (PixiFactory._dragonBonesInstance === null) { + const eventManager = new PixiArmatureDisplay(); + PixiFactory._dragonBonesInstance = new DragonBones(eventManager); + PIXI.ticker.shared.add(PixiFactory._clockHandler, PixiFactory); + } + + this._dragonBones = PixiFactory._dragonBonesInstance; + } + /** + * @private + */ + protected _buildTextureAtlasData(textureAtlasData: PixiTextureAtlasData | null, textureAtlas: PIXI.BaseTexture | null): PixiTextureAtlasData { + if (textureAtlasData) { + textureAtlasData.renderTexture = textureAtlas; + } + else { + textureAtlasData = BaseObject.borrowObject(PixiTextureAtlasData); + } + + return textureAtlasData; + } + /** + * @private + */ + protected _buildArmature(dataPackage: BuildArmaturePackage): Armature { + const armature = BaseObject.borrowObject(Armature); + const armatureDisplay = new PixiArmatureDisplay(); + + armature.init( + dataPackage.armature, + armatureDisplay, armatureDisplay, this._dragonBones + ); + + return armature; + } + /** + * @private + */ + protected _buildSlot(dataPackage: BuildArmaturePackage, slotData: SlotData, displays: Array, armature: Armature): Slot { + dataPackage; + armature; + const slot = BaseObject.borrowObject(PixiSlot); + + slot.init( + slotData, displays, + new PIXI.Sprite(), new PIXI.mesh.Mesh(null as any, null as any, null as any, null as any, PIXI.mesh.Mesh.DRAW_MODES.TRIANGLES) + ); + + return slot; + } + /** + * 创建一个指定名称的骨架。 + * @param armatureName 骨架名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @param textureAtlasName 贴图集数据名称,如果未设置,则使用龙骨数据。 + * @returns 骨架的显示容器。 + * @see dragonBones.EgretArmatureDisplay + * @version DragonBones 4.5 + * @language zh_CN + */ + public buildArmatureDisplay(armatureName: string, dragonBonesName: string | null = null, skinName: string | null = null, textureAtlasName: string | null = null): PixiArmatureDisplay | null { + const armature = this.buildArmature(armatureName, dragonBonesName, skinName, textureAtlasName); + if (armature !== null) { + this._dragonBones.clock.add(armature); + + return armature.display as PixiArmatureDisplay; + } + + return null; + } + /** + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param textureAtlasName 指定的贴图集数据名称,如果未设置,将检索所有的贴图集数据。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public getTextureDisplay(textureName: string, textureAtlasName: string | null = null): PIXI.Sprite | null { + const textureData = this._getTextureData(textureAtlasName !== null ? textureAtlasName : "", textureName) as PixiTextureData; + if (textureData !== null && textureData.renderTexture !== null) { + return new PIXI.Sprite(textureData.renderTexture); + } + + return null; + } + /** + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + * @language zh_CN + */ + public get soundEventManager(): PixiArmatureDisplay { + return this._dragonBones.eventManager as PixiArmatureDisplay; + } + } +} \ No newline at end of file diff --git a/reference/Pixi/4.x/src/dragonBones/pixi/PixiSlot.ts b/reference/Pixi/4.x/src/dragonBones/pixi/PixiSlot.ts new file mode 100644 index 0000000..2090d7c --- /dev/null +++ b/reference/Pixi/4.x/src/dragonBones/pixi/PixiSlot.ts @@ -0,0 +1,348 @@ +namespace dragonBones { + /** + * Pixi 插槽。 + * @version DragonBones 3.0 + * @language zh_CN + */ + export class PixiSlot extends Slot { + public static toString(): string { + return "[class dragonBones.PixiSlot]"; + } + + private _renderDisplay: PIXI.DisplayObject; + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + this._updateTransform = PIXI.VERSION[0] === "3" ? this._updateTransformV3 : this._updateTransformV4; + this._renderDisplay = null as any; + } + /** + * @private + */ + protected _initDisplay(value: any): void { + value; + } + /** + * @private + */ + protected _disposeDisplay(value: any): void { + (value as PIXI.DisplayObject).destroy(); + } + /** + * @private + */ + protected _onUpdateDisplay(): void { + this._renderDisplay = (this._display ? this._display : this._rawDisplay) as PIXI.DisplayObject; + } + /** + * @private + */ + protected _addDisplay(): void { + const container = this._armature.display as PixiArmatureDisplay; + container.addChild(this._renderDisplay); + } + /** + * @private + */ + protected _replaceDisplay(value: any): void { + const container = this._armature.display as PixiArmatureDisplay; + const prevDisplay = value as PIXI.DisplayObject; + container.addChild(this._renderDisplay); + container.swapChildren(this._renderDisplay, prevDisplay); + container.removeChild(prevDisplay); + } + /** + * @private + */ + protected _removeDisplay(): void { + this._renderDisplay.parent.removeChild(this._renderDisplay); + } + /** + * @private + */ + protected _updateZOrder(): void { + const container = this._armature.display as PixiArmatureDisplay; + const index = container.getChildIndex(this._renderDisplay); + if (index === this._zOrder) { + return; + } + + container.addChildAt(this._renderDisplay, this._zOrder); + } + /** + * @internal + * @private + */ + public _updateVisible(): void { + this._renderDisplay.visible = this._parent.visible; + } + /** + * @private + */ + protected _updateBlendMode(): void { + switch (this._blendMode) { + case BlendMode.Normal: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.NORMAL; + break; + + case BlendMode.Add: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.ADD; + break; + + case BlendMode.Darken: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.DARKEN; + break; + + case BlendMode.Difference: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.DIFFERENCE; + break; + + case BlendMode.HardLight: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.HARD_LIGHT; + break; + + case BlendMode.Lighten: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.LIGHTEN; + break; + + case BlendMode.Multiply: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.MULTIPLY; + break; + + case BlendMode.Overlay: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.OVERLAY; + break; + + case BlendMode.Screen: + (this._renderDisplay as PIXI.Sprite).blendMode = PIXI.BLEND_MODES.SCREEN; + break; + + default: + break; + } + } + /** + * @private + */ + protected _updateColor(): void { + this._renderDisplay.alpha = this._colorTransform.alphaMultiplier; + // TODO + } + /** + * @private + */ + protected _updateFrame(): void { + const meshData = this._display === this._meshDisplay ? this._meshData : null; + let currentTextureData = this._textureData as (PixiTextureData | null); + + if (this._displayIndex >= 0 && this._display !== null && currentTextureData !== null) { + let currentTextureAtlasData = currentTextureData.parent as PixiTextureAtlasData; + if (this._armature.replacedTexture !== null && this._rawDisplayDatas.indexOf(this._displayData) >= 0) { // Update replaced texture atlas. + if (this._armature._replaceTextureAtlasData === null) { + currentTextureAtlasData = BaseObject.borrowObject(PixiTextureAtlasData); + currentTextureAtlasData.copyFrom(currentTextureData.parent); + currentTextureAtlasData.renderTexture = this._armature.replacedTexture; + this._armature._replaceTextureAtlasData = currentTextureAtlasData; + } + else { + currentTextureAtlasData = this._armature._replaceTextureAtlasData as PixiTextureAtlasData; + } + + currentTextureData = currentTextureAtlasData.getTexture(currentTextureData.name) as PixiTextureData; + } + + const renderTexture = currentTextureData.renderTexture; + if (renderTexture !== null) { + const currentTextureAtlas = currentTextureData.renderTexture as PIXI.Texture; + if (meshData !== null) { // Mesh. + const data = meshData.parent.parent; + const intArray = data.intArray; + const floatArray = data.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const triangleCount = intArray[meshData.offset + BinaryOffset.MeshTriangleCount]; + const verticesOffset = intArray[meshData.offset + BinaryOffset.MeshFloatOffset]; + const uvOffset = verticesOffset + vertexCount * 2; + + const meshDisplay = this._renderDisplay as PIXI.mesh.Mesh; + const textureAtlasWidth = currentTextureAtlasData.width > 0.0 ? currentTextureAtlasData.width : currentTextureAtlas.width; + const textureAtlasHeight = currentTextureAtlasData.height > 0.0 ? currentTextureAtlasData.height : currentTextureAtlas.height; + + meshDisplay.vertices = new Float32Array(vertexCount * 2) as any; + meshDisplay.uvs = new Float32Array(vertexCount * 2) as any; + meshDisplay.indices = new Uint16Array(triangleCount * 3) as any; + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + meshDisplay.vertices[i] = floatArray[verticesOffset + i]; + meshDisplay.uvs[i] = floatArray[uvOffset + i]; + } + + for (let i = 0; i < triangleCount * 3; ++i) { + meshDisplay.indices[i] = intArray[meshData.offset + BinaryOffset.MeshVertexIndices + i]; + } + + for (let i = 0, l = meshDisplay.uvs.length; i < l; i += 2) { + const u = meshDisplay.uvs[i]; + const v = meshDisplay.uvs[i + 1]; + meshDisplay.uvs[i] = (currentTextureData.region.x + u * currentTextureData.region.width) / textureAtlasWidth; + meshDisplay.uvs[i + 1] = (currentTextureData.region.y + v * currentTextureData.region.height) / textureAtlasHeight; + } + + meshDisplay.texture = renderTexture as any; + //meshDisplay.dirty = true; // Pixi 3.x + meshDisplay.dirty++; // Pixi 4.x Can not support change mesh vertice count. + } + else { // Normal texture. + const normalDisplay = this._renderDisplay as PIXI.Sprite; + normalDisplay.texture = renderTexture; + } + + this._updateVisible(); + return; + } + } + + if (meshData !== null) { + const meshDisplay = this._renderDisplay as PIXI.mesh.Mesh; + meshDisplay.texture = null as any; + meshDisplay.x = 0.0; + meshDisplay.y = 0.0; + meshDisplay.visible = false; + } + else { + const normalDisplay = this._renderDisplay as PIXI.Sprite; + normalDisplay.texture = null as any; + normalDisplay.x = 0.0; + normalDisplay.y = 0.0; + normalDisplay.visible = false; + } + } + /** + * @private + */ + protected _updateMesh(): void { + const hasFFD = this._ffdVertices.length > 0; + const meshData = this._meshData as MeshDisplayData; + const weight = meshData.weight; + const meshDisplay = this._renderDisplay as PIXI.mesh.Mesh; + + if (weight !== null) { + const data = meshData.parent.parent; + const intArray = data.intArray; + const floatArray = data.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const weightFloatOffset = intArray[weight.offset + BinaryOffset.WeigthFloatOffset]; + + for ( + let i = 0, iD = 0, iB = weight.offset + BinaryOffset.WeigthBoneIndices + weight.bones.length, iV = weightFloatOffset, iF = 0; + i < vertexCount; + ++i + ) { + const boneCount = intArray[iB++]; + let xG = 0.0, yG = 0.0; + for (let j = 0; j < boneCount; ++j) { + const boneIndex = intArray[iB++]; + const bone = this._meshBones[boneIndex]; + if (bone !== null) { + const matrix = bone.globalTransformMatrix; + const weight = floatArray[iV++]; + let xL = floatArray[iV++]; + let yL = floatArray[iV++]; + + if (hasFFD) { + xL += this._ffdVertices[iF++]; + yL += this._ffdVertices[iF++]; + } + + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + } + } + + meshDisplay.vertices[iD++] = xG; + meshDisplay.vertices[iD++] = yG; + } + } + else if (hasFFD) { + const data = meshData.parent.parent; + const intArray = data.intArray; + const floatArray = data.floatArray; + const vertexCount = intArray[meshData.offset + BinaryOffset.MeshVertexCount]; + const vertexOffset = intArray[meshData.offset + BinaryOffset.MeshFloatOffset]; + + for (let i = 0, l = vertexCount * 2; i < l; ++i) { + meshDisplay.vertices[i] = floatArray[vertexOffset + i] + this._ffdVertices[i]; + } + } + } + /** + * @private + */ + protected _updateTransform(isSkinnedMesh: boolean): void { + isSkinnedMesh; + throw new Error(); + } + /** + * @private + */ + protected _updateTransformV3(isSkinnedMesh: boolean): void { + if (isSkinnedMesh) { // Identity transform. + this._renderDisplay.setTransform(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); + } + else { + this.updateGlobalTransform(); // Update transform. + + const transform = this.global; + const x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); + const y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); + + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.setTransform( + x, y, + transform.scaleX, transform.scaleY, + transform.rotation, + transform.skew, 0.0, + ); + } + else { + this._renderDisplay.position.set(x, y); + this._renderDisplay.rotation = transform.rotation; + this._renderDisplay.skew.set(-transform.skew, 0.0); + this._renderDisplay.scale.set(transform.scaleX, transform.scaleY); + } + } + } + /** + * @private + */ + protected _updateTransformV4(isSkinnedMesh: boolean): void { + if (isSkinnedMesh) { // Identity transform. + this._renderDisplay.setTransform(0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0); + } + else { + this.updateGlobalTransform(); // Update transform. + + const transform = this.global; + + if (this._renderDisplay === this._rawDisplay || this._renderDisplay === this._meshDisplay) { + this._renderDisplay.setTransform( + transform.x, transform.y, + transform.scaleX, transform.scaleY, + transform.rotation, + -transform.skew, 0.0, + this._pivotX, this._pivotY + ); + } + else { + const x = transform.x - (this.globalTransformMatrix.a * this._pivotX + this.globalTransformMatrix.c * this._pivotY); + const y = transform.y - (this.globalTransformMatrix.b * this._pivotX + this.globalTransformMatrix.d * this._pivotY); + this._renderDisplay.position.set(x, y); + this._renderDisplay.rotation = transform.rotation; + this._renderDisplay.skew.set(-transform.skew, 0.0); + this._renderDisplay.scale.set(transform.scaleX, transform.scaleY); + } + } + } + } +} \ No newline at end of file diff --git a/reference/Pixi/4.x/src/dragonBones/pixi/PixiTextureAtlasData.ts b/reference/Pixi/4.x/src/dragonBones/pixi/PixiTextureAtlasData.ts new file mode 100644 index 0000000..109283f --- /dev/null +++ b/reference/Pixi/4.x/src/dragonBones/pixi/PixiTextureAtlasData.ts @@ -0,0 +1,91 @@ +namespace dragonBones { + /** + * @language zh_CN + * Pixi 贴图集数据。 + * @version DragonBones 3.0 + */ + export class PixiTextureAtlasData extends TextureAtlasData { + public static toString(): string { + return "[class dragonBones.PixiTextureAtlasData]"; + } + + private _renderTexture: PIXI.BaseTexture | null = null; // Initial value. + /** + * @private + */ + protected _onClear(): void { + super._onClear(); + + if (this.renderTexture !== null) { + //this.texture.dispose(); + } + + this.renderTexture = null; + } + /** + * @private + */ + public createTexture(): TextureData { + return BaseObject.borrowObject(PixiTextureData); + } + /** + * Pixi 贴图。 + * @version DragonBones 3.0 + * @language zh_CN + */ + public get renderTexture(): PIXI.BaseTexture | null { + return this._renderTexture; + } + public set renderTexture(value: PIXI.BaseTexture | null) { + if (this._renderTexture === value) { + return; + } + + this._renderTexture = value; + + if (this._renderTexture !== null) { + for (let k in this.textures) { + const textureData = this.textures[k] as PixiTextureData; + + textureData.renderTexture = new PIXI.Texture( + this._renderTexture, + textureData.region as PIXI.Rectangle, // No need to set frame. + textureData.region as PIXI.Rectangle, + new PIXI.Rectangle(0, 0, textureData.region.width, textureData.region.height), + textureData.rotated as any // .d.ts bug + ); + } + } + else { + for (let k in this.textures) { + const textureData = this.textures[k] as PixiTextureData; + textureData.renderTexture = null; + } + } + } + } + /** + * @private + */ + export class PixiTextureData extends TextureData { + public static toString(): string { + return "[class dragonBones.PixiTextureData]"; + } + + public renderTexture: PIXI.Texture | null = null; // Initial value. + + public constructor() { + super(); + } + + protected _onClear(): void { + super._onClear(); + + if (this.renderTexture !== null) { + this.renderTexture.destroy(); + } + + this.renderTexture = null; + } + } +} \ No newline at end of file diff --git a/reference/Pixi/4.x/tsconfig.json b/reference/Pixi/4.x/tsconfig.json new file mode 100644 index 0000000..6c84e14 --- /dev/null +++ b/reference/Pixi/4.x/tsconfig.json @@ -0,0 +1,77 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": true, + "declaration": true, + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "outFile": "out/dragonBones.js", + "lib": [ + "es5", + "dom", + "es2015.promise" + ] + }, + "exclude": [ + "node_modules", + "out" + ], + "files": [ + "./libs/pixi.js.d.ts", + "../../DragonBones/src/dragonBones/modules.ts", + + "../../DragonBones/src/dragonBones/core/DragonBones.ts", + "../../DragonBones/src/dragonBones/core/BaseObject.ts", + + "../../DragonBones/src/dragonBones/geom/Matrix.ts", + "../../DragonBones/src/dragonBones/geom/Transform.ts", + "../../DragonBones/src/dragonBones/geom/ColorTransform.ts", + "../../DragonBones/src/dragonBones/geom/Point.ts", + "../../DragonBones/src/dragonBones/geom/Rectangle.ts", + + "../../DragonBones/src/dragonBones/model/UserData.ts", + "../../DragonBones/src/dragonBones/model/DragonBonesData.ts", + "../../DragonBones/src/dragonBones/model/ArmatureData.ts", + "../../DragonBones/src/dragonBones/model/ConstraintData.ts", + "../../DragonBones/src/dragonBones/model/DisplayData.ts", + "../../DragonBones/src/dragonBones/model/BoundingBoxData.ts", + "../../DragonBones/src/dragonBones/model/AnimationData.ts", + "../../DragonBones/src/dragonBones/model/AnimationConfig.ts", + "../../DragonBones/src/dragonBones/model/TextureAtlasData.ts", + + "../../DragonBones/src/dragonBones/armature/IArmatureProxy.ts", + "../../DragonBones/src/dragonBones/armature/Armature.ts", + "../../DragonBones/src/dragonBones/armature/TransformObject.ts", + "../../DragonBones/src/dragonBones/armature/Bone.ts", + "../../DragonBones/src/dragonBones/armature/Slot.ts", + "../../DragonBones/src/dragonBones/armature/Constraint.ts", + + "../../DragonBones/src/dragonBones/animation/IAnimatable.ts", + "../../DragonBones/src/dragonBones/animation/WorldClock.ts", + "../../DragonBones/src/dragonBones/animation/Animation.ts", + "../../DragonBones/src/dragonBones/animation/AnimationState.ts", + "../../DragonBones/src/dragonBones/animation/BaseTimelineState.ts", + "../../DragonBones/src/dragonBones/animation/TimelineState.ts", + + "../../DragonBones/src/dragonBones/event/EventObject.ts", + "../../DragonBones/src/dragonBones/event/IEventDispatcher.ts", + + "../../DragonBones/src/dragonBones/parser/DataParser.ts", + "../../DragonBones/src/dragonBones/parser/ObjectDataParser.ts", + "../../DragonBones/src/dragonBones/parser/BinaryDataParser.ts", + + "../../DragonBones/src/dragonBones/factory/BaseFactory.ts", + + "./src/dragonBones/pixi/PixiTextureAtlasData.ts", + "./src/dragonBones/pixi/PixiArmatureDisplay.ts", + "./src/dragonBones/pixi/PixiSlot.ts", + "./src/dragonBones/pixi/PixiFactory.ts" + ] +} \ No newline at end of file diff --git a/reference/Pixi/4.x/tslint.json b/reference/Pixi/4.x/tslint.json new file mode 100644 index 0000000..eeb58d1 --- /dev/null +++ b/reference/Pixi/4.x/tslint.json @@ -0,0 +1,15 @@ +{ + "rules": { + "no-unused-expression": true, + "no-unreachable": true, + "no-duplicate-variable": true, + "no-duplicate-key": true, + "no-unused-variable": true, + "curly": false, + "class-name": true, + "triple-equals": true, + "semicolon": [ + true + ] + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/README.md b/reference/Pixi/Demos/README.md new file mode 100644 index 0000000..87314a4 --- /dev/null +++ b/reference/Pixi/Demos/README.md @@ -0,0 +1,28 @@ +## How to run +``` +$npm install +$npm run start +``` + +## Project structure +``` + |-- libs + |-- dragonBones + |-- dragonBones.js + |-- ... + |-- pixi + |-- pixi.js + |-- ... + |-- node_modules + |-- ... + |-- out + |-- ... + |-- resource + |-- ... + |-- src + |-- ... + |-- ... +``` + +## Pixijs +[pixi.js](https://github.com/pixijs/pixi.js/releases/) \ No newline at end of file diff --git a/reference/Pixi/Demos/index.html b/reference/Pixi/Demos/index.html new file mode 100644 index 0000000..40e3eb3 --- /dev/null +++ b/reference/Pixi/Demos/index.html @@ -0,0 +1,29 @@ + + + + + + DragonBones + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reference/Pixi/Demos/out/AnimationBaseTest.js b/reference/Pixi/Demos/out/AnimationBaseTest.js new file mode 100644 index 0000000..edd68bc --- /dev/null +++ b/reference/Pixi/Demos/out/AnimationBaseTest.js @@ -0,0 +1,107 @@ +"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 AnimationBaseTest = (function (_super) { + __extends(AnimationBaseTest, _super); + function AnimationBaseTest() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._isTouched = false; + return _this; + } + AnimationBaseTest.prototype._onStart = function () { + var _this = this; + PIXI.loader + .add("dragonBonesData", "./resource/assets/animation_base_test_ske.json") + .add("textureData", "./resource/assets/animation_base_test_tex.json") + .add("texture", "./resource/assets/animation_base_test_tex.png"); + PIXI.loader.once("complete", function (loader, resources) { + var factory = dragonBones.PixiFactory.factory; + factory.parseDragonBonesData(resources["dragonBonesData"].data); + factory.parseTextureAtlasData(resources["textureData"].data, resources["texture"].texture); + _this._armatureDisplay = factory.buildArmatureDisplay("progressBar"); + _this._armatureDisplay.x = _this.stage.width * 0.5; + _this._armatureDisplay.y = _this.stage.height * 0.5; + _this.stage.addChild(_this._armatureDisplay); + // Test animation event + _this._armatureDisplay.addListener(dragonBones.EventObject.START, _this._animationEventHandler, _this); + _this._armatureDisplay.addListener(dragonBones.EventObject.LOOP_COMPLETE, _this._animationEventHandler, _this); + _this._armatureDisplay.addListener(dragonBones.EventObject.COMPLETE, _this._animationEventHandler, _this); + _this._armatureDisplay.addListener(dragonBones.EventObject.FADE_IN, _this._animationEventHandler, _this); + _this._armatureDisplay.addListener(dragonBones.EventObject.FADE_IN_COMPLETE, _this._animationEventHandler, _this); + _this._armatureDisplay.addListener(dragonBones.EventObject.FADE_OUT, _this._animationEventHandler, _this); + _this._armatureDisplay.addListener(dragonBones.EventObject.FADE_OUT_COMPLETE, _this._animationEventHandler, _this); + // Test frame event + _this._armatureDisplay.addListener(dragonBones.EventObject.FRAME_EVENT, _this._animationEventHandler, _this); + // Test animation config. + // const animaitonConfig = this._armatureDisplay.animation.animationConfig; + // animaitonConfig.name = "test"; // Animation state name. + // animaitonConfig.animation = "idle"; // Animation name. + // animaitonConfig.playTimes = 1; // Play one time. + // animaitonConfig.playTimes = 3; // Play several times. + // animaitonConfig.playTimes = 0; // Loop play. + // animaitonConfig.timeScale = 1.0; // Play speed. + // animaitonConfig.timeScale = -1.0; // Reverse play. + // animaitonConfig.position = 1.0; // Goto and play. + // animaitonConfig.duration = 3.0; // Interval play. + // this._armatureDisplay.animation.playConfig(animaitonConfig); + _this._armatureDisplay.animation.play("idle", 1); + // + _this.stage.interactive = true; + _this.stage.addListener("touchstart", _this._touchHandler, _this); + _this.stage.addListener("touchend", _this._touchHandler, _this); + _this.stage.addListener("touchmove", _this._touchHandler, _this); + _this.stage.addListener("mousedown", _this._touchHandler, _this); + _this.stage.addListener("mouseup", _this._touchHandler, _this); + _this.stage.addListener("mousemove", _this._touchHandler, _this); + var text = new PIXI.Text("", { align: "center" }); + text.text = "Click to control animation play progress."; + text.scale.x = 0.7; + text.scale.y = 0.7; + text.x = (_this.renderer.width - text.width) * 0.5; + text.y = _this.renderer.height - 60; + _this._stage.addChild(text); + // + _this._startRenderTick(); + }); + PIXI.loader.load(); + }; + AnimationBaseTest.prototype._touchHandler = function (event) { + var progress = Math.min(Math.max((event.data.global.x - this._armatureDisplay.x + 300) / 600, 0.0), 1.0); + switch (event.type) { + case "touchstart": + case "mousedown": + this._isTouched = true; + // this._armatureDisplay.animation.gotoAndPlayByTime("idle", 0.5, 1); + // this._armatureDisplay.animation.gotoAndStopByTime("idle", 1); + // this._armatureDisplay.animation.gotoAndPlayByFrame("idle", 25, 2); + // this._armatureDisplay.animation.gotoAndStopByFrame("idle", 50); + // this._armatureDisplay.animation.gotoAndPlayByProgress("idle", progress, 3); + this._armatureDisplay.animation.gotoAndStopByProgress("idle", progress); + break; + case "touchend": + case "mouseup": + this._isTouched = false; + this._armatureDisplay.animation.play(); + break; + case "touchmove": + case "mousemove": + if (this._isTouched) { + var animationState = this._armatureDisplay.animation.getState("idle"); + animationState.currentTime = animationState.totalTime * progress; + } + break; + } + }; + AnimationBaseTest.prototype._animationEventHandler = function (event) { + console.log(event.animationState.name, event.type, event.name ? event.name : ""); + }; + return AnimationBaseTest; +}(BaseTest)); diff --git a/reference/Pixi/Demos/out/BaseTest.js b/reference/Pixi/Demos/out/BaseTest.js new file mode 100644 index 0000000..ede5b97 --- /dev/null +++ b/reference/Pixi/Demos/out/BaseTest.js @@ -0,0 +1,36 @@ +"use strict"; +var BaseTest = (function () { + function BaseTest() { + this._renderer = new PIXI.WebGLRenderer(1136, 640); + this._stage = new PIXI.Container(); + this._backgroud = new PIXI.Sprite(PIXI.Texture.EMPTY); + this._renderer.backgroundColor = 0x666666; + this._backgroud.width = this._renderer.width; + this._backgroud.height = this._renderer.height; + this._stage.addChild(this._backgroud); + document.body.appendChild(this._renderer.view); + this._onStart(); + } + BaseTest.prototype._renderHandler = function (deltaTime) { + this._renderer.render(this._stage); + }; + BaseTest.prototype._startRenderTick = function () { + // Make sure render after dragonBones update. + PIXI.ticker.shared.add(this._renderHandler, this); + }; + Object.defineProperty(BaseTest.prototype, "renderer", { + get: function () { + return this._renderer; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(BaseTest.prototype, "stage", { + get: function () { + return this._stage; + }, + enumerable: true, + configurable: true + }); + return BaseTest; +}()); diff --git a/reference/Pixi/Demos/out/CoreElement.js b/reference/Pixi/Demos/out/CoreElement.js new file mode 100644 index 0000000..da04538 --- /dev/null +++ b/reference/Pixi/Demos/out/CoreElement.js @@ -0,0 +1,458 @@ +"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 coreElement; +(function (coreElement) { + var Game = (function (_super) { + __extends(Game, _super); + function Game() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._left = false; + _this._right = false; + _this._bullets = []; + return _this; + } + Game.prototype._onStart = function () { + var _this = this; + PIXI.loader + .add("dataA", "./resource/assets/core_element/mecha_1502b_ske.json") + .add("textureDataA", "./resource/assets/core_element/mecha_1502b_tex.json") + .add("textureA", "./resource/assets/core_element/mecha_1502b_tex.png") + .add("dataB", "./resource/assets/core_element/skin_1502b_ske.json") + .add("textureDataB", "./resource/assets/core_element/skin_1502b_tex.json") + .add("textureB", "./resource/assets/core_element/skin_1502b_tex.png") + .add("dataC", "./resource/assets/core_element/weapon_1000_ske.json") + .add("textureDataC", "./resource/assets/core_element/weapon_1000_tex.json") + .add("textureC", "./resource/assets/core_element/weapon_1000_tex.png"); + PIXI.loader.once("complete", function (loader, resources) { + Game.STAGE_WIDTH = _this._stage.width; + Game.STAGE_HEIGHT = _this._stage.height; + Game.GROUND = Game.STAGE_HEIGHT - 150; + Game.instance = _this; + PIXI.ticker.shared.add(_this._enterFrameHandler, _this); + var factory = dragonBones.PixiFactory.factory; + factory.parseDragonBonesData(resources["dataA"].data); + factory.parseTextureAtlasData(resources["textureDataA"].data, resources["textureA"].texture); + factory.parseDragonBonesData(resources["dataB"].data); + factory.parseTextureAtlasData(resources["textureDataB"].data, resources["textureB"].texture); + factory.parseDragonBonesData(resources["dataC"].data); + factory.parseTextureAtlasData(resources["textureDataC"].data, resources["textureC"].texture); + _this._player = new Mecha(); + // Listener. + _this._stage.interactive = true; + _this._stage.addListener('touchstart', _this._touchHandler, _this); + _this._stage.addListener('touchend', _this._touchHandler, _this); + _this._stage.addListener('touchmove', _this._touchHandler, _this); + _this._stage.addListener('mousedown', _this._touchHandler, _this); + _this._stage.addListener('mouseup', _this._touchHandler, _this); + _this._stage.addListener('mousemove', _this._touchHandler, _this); + _this._stage.addChild(_this._backgroud); + document.addEventListener("keydown", _this._keyHandler); + document.addEventListener("keyup", _this._keyHandler); + // Info. + var text = new PIXI.Text("", { align: "center" }); + text.text = "Press W/A/S/D to move. Press Q/E to switch weapons. Press SPACE to switch skin.\nMouse Move to aim. Click to fire."; + text.scale.x = 0.7; + text.scale.y = 0.7; + text.x = (Game.STAGE_WIDTH - text.width) * 0.5; + text.y = Game.STAGE_HEIGHT - 60; + _this._stage.addChild(text); + // + _this._startRenderTick(); + }); + PIXI.loader.load(); + }; + Game.prototype._touchHandler = function (event) { + this._player.aim(event.data.global.x, event.data.global.y); + if (event.type === 'touchstart' || event.type === 'mousedown') { + this._player.attack(true); + } + else if (event.type === 'touchend' || event.type === 'mouseup') { + this._player.attack(false); + } + }; + Game.prototype._keyHandler = function (event) { + var isDown = event.type === "keydown"; + switch (event.keyCode) { + case 37: + case 65: + Game.instance._left = isDown; + Game.instance._updateMove(-1); + break; + case 39: + case 68: + Game.instance._right = isDown; + Game.instance._updateMove(1); + break; + case 38: + case 87: + if (isDown) { + Game.instance._player.jump(); + } + break; + case 83: + case 40: + Game.instance._player.squat(isDown); + break; + case 81: + if (isDown) { + Game.instance._player.switchWeaponR(); + } + break; + case 69: + if (isDown) { + Game.instance._player.switchWeaponL(); + } + break; + case 32: + if (isDown) { + Game.instance._player.switchSkin(); + } + break; + } + }; + Game.prototype._enterFrameHandler = function (deltaTime) { + if (this._player) { + this._player.update(); + } + var i = this._bullets.length; + while (i--) { + var bullet = this._bullets[i]; + if (bullet.update()) { + this._bullets.splice(i, 1); + } + } + }; + Game.prototype._updateMove = function (dir) { + if (this._left && this._right) { + this._player.move(dir); + } + else if (this._left) { + this._player.move(-1); + } + else if (this._right) { + this._player.move(1); + } + else { + this._player.move(0); + } + }; + Game.prototype.addBullet = function (bullet) { + this._bullets.push(bullet); + }; + Game.G = 0.6; + return Game; + }(BaseTest)); + coreElement.Game = Game; + var Mecha = (function () { + function Mecha() { + this._isJumpingA = false; + this._isJumpingB = false; + this._isSquating = false; + this._isAttackingA = false; + this._isAttackingB = false; + this._weaponRIndex = 0; + this._weaponLIndex = 0; + this._skinIndex = 0; + this._faceDir = 1; + this._aimDir = 0; + this._moveDir = 0; + this._aimRadian = 0.0; + this._speedX = 0.0; + this._speedY = 0.0; + this._aimState = null; + this._walkState = null; + this._attackState = null; + this._target = new PIXI.Point(); + this._helpPoint = new PIXI.Point(); + this._armatureDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay("mecha_1502b"); + this._armatureDisplay.x = Game.STAGE_WIDTH * 0.5; + this._armatureDisplay.y = Game.GROUND; + this._armature = this._armatureDisplay.armature; + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.FADE_IN_COMPLETE, this._animationEventHandler, this); + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.FADE_OUT_COMPLETE, this._animationEventHandler, this); + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this); + // Get weapon childArmature. + this._weaponL = this._armature.getSlot("weapon_l").childArmature; + this._weaponR = this._armature.getSlot("weapon_r").childArmature; + this._weaponL.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + this._weaponR.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + Game.instance.stage.addChild(this._armatureDisplay); + this._updateAnimation(); + } + Mecha.prototype.move = function (dir) { + if (this._moveDir === dir) { + return; + } + this._moveDir = dir; + this._updateAnimation(); + }; + Mecha.prototype.jump = function () { + if (this._isJumpingA) { + return; + } + this._isJumpingA = true; + this._armature.animation.fadeIn("jump_1", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP).resetToPose = false; + this._walkState = null; + }; + Mecha.prototype.squat = function (isSquating) { + if (this._isSquating === isSquating) { + return; + } + this._isSquating = isSquating; + this._updateAnimation(); + }; + Mecha.prototype.attack = function (isAttacking) { + if (this._isAttackingA === isAttacking) { + return; + } + this._isAttackingA = isAttacking; + }; + Mecha.prototype.switchWeaponL = function () { + this._weaponL.eventDispatcher.removeEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + this._weaponLIndex++; + this._weaponLIndex %= Mecha.WEAPON_L_LIST.length; + var weaponName = Mecha.WEAPON_L_LIST[this._weaponLIndex]; + this._weaponL = dragonBones.PixiFactory.factory.buildArmature(weaponName); + this._armature.getSlot("weapon_l").childArmature = this._weaponL; + this._weaponL.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + }; + Mecha.prototype.switchWeaponR = function () { + this._weaponR.eventDispatcher.removeEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + this._weaponRIndex++; + this._weaponRIndex %= Mecha.WEAPON_R_LIST.length; + var weaponName = Mecha.WEAPON_R_LIST[this._weaponRIndex]; + this._weaponR = dragonBones.PixiFactory.factory.buildArmature(weaponName); + this._armature.getSlot("weapon_r").childArmature = this._weaponR; + this._weaponR.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + }; + Mecha.prototype.switchSkin = function () { + this._skinIndex++; + this._skinIndex %= Mecha.SKINS.length; + var skinName = Mecha.SKINS[this._skinIndex]; + var skinData = dragonBones.PixiFactory.factory.getArmatureData(skinName).defaultSkin; + dragonBones.PixiFactory.factory.changeSkin(this._armature, skinData, ["weapon_l", "weapon_r"]); + }; + Mecha.prototype.aim = function (x, y) { + this._target.x = x; + this._target.y = y; + }; + Mecha.prototype.update = function () { + this._updatePosition(); + this._updateAim(); + this._updateAttack(); + }; + Mecha.prototype._animationEventHandler = function (event) { + switch (event.type) { + case dragonBones.EventObject.FADE_IN_COMPLETE: + if (event.animationState.name === "jump_1") { + this._isJumpingB = true; + this._speedY = -Mecha.JUMP_SPEED; + if (this._moveDir !== 0) { + if (this._moveDir * this._faceDir > 0) { + this._speedX = Mecha.MAX_MOVE_SPEED_FRONT * this._faceDir; + } + else { + this._speedX = -Mecha.MAX_MOVE_SPEED_BACK * this._faceDir; + } + } + this._armature.animation.fadeIn("jump_2", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP).resetToPose = false; + } + break; + case dragonBones.EventObject.FADE_OUT_COMPLETE: + if (event.animationState.name === "attack_01") { + this._isAttackingB = false; + this._attackState = null; + } + break; + case dragonBones.EventObject.COMPLETE: + if (event.animationState.name === "jump_4") { + this._isJumpingA = false; + this._isJumpingB = false; + this._updateAnimation(); + } + break; + } + }; + Mecha.prototype._frameEventHandler = function (event) { + if (event.name === "fire") { + this._helpPoint.x = event.bone.global.x; + this._helpPoint.y = event.bone.global.y; + this._helpPoint.copy(event.armature.display.toGlobal(this._helpPoint)); + this._fire(this._helpPoint); + } + }; + Mecha.prototype._fire = function (firePoint) { + var radian = this._faceDir < 0 ? Math.PI - this._aimRadian : this._aimRadian; + var bullet = new Bullet("bullet_01", "fire_effect_01", radian + Math.random() * 0.02 - 0.01, 40, firePoint); + Game.instance.addBullet(bullet); + }; + Mecha.prototype._updateAnimation = function () { + if (this._isJumpingA) { + return; + } + if (this._isSquating) { + this._speedX = 0; + this._armature.animation.fadeIn("squat", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP).resetToPose = false; + this._walkState = null; + return; + } + if (this._moveDir === 0) { + this._speedX = 0; + this._armature.animation.fadeIn("idle", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP).resetToPose = false; + this._walkState = null; + } + else { + if (this._walkState === null) { + this._walkState = this._armature.animation.fadeIn("walk", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP); + this._walkState.resetToPose = false; + } + if (this._moveDir * this._faceDir > 0) { + this._walkState.timeScale = Mecha.MAX_MOVE_SPEED_FRONT / Mecha.NORMALIZE_MOVE_SPEED; + } + else { + this._walkState.timeScale = -Mecha.MAX_MOVE_SPEED_BACK / Mecha.NORMALIZE_MOVE_SPEED; + } + if (this._moveDir * this._faceDir > 0) { + this._speedX = Mecha.MAX_MOVE_SPEED_FRONT * this._faceDir; + } + else { + this._speedX = -Mecha.MAX_MOVE_SPEED_BACK * this._faceDir; + } + } + }; + Mecha.prototype._updatePosition = function () { + if (this._speedX !== 0.0) { + this._armatureDisplay.x += this._speedX; + if (this._armatureDisplay.x < 0) { + this._armatureDisplay.x = 0; + } + else if (this._armatureDisplay.x > Game.STAGE_WIDTH) { + this._armatureDisplay.x = Game.STAGE_WIDTH; + } + } + if (this._speedY !== 0.0) { + if (this._speedY < 5.0 && this._speedY + Game.G >= 5.0) { + this._armature.animation.fadeIn("jump_3", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP).resetToPose = false; + } + this._speedY += Game.G; + this._armatureDisplay.y += this._speedY; + if (this._armatureDisplay.y > Game.GROUND) { + this._armatureDisplay.y = Game.GROUND; + this._speedY = 0.0; + this._armature.animation.fadeIn("jump_4", -1.0, -1, 0, Mecha.NORMAL_ANIMATION_GROUP).resetToPose = false; + } + } + }; + Mecha.prototype._updateAim = function () { + this._faceDir = this._target.x > this._armatureDisplay.x ? 1 : -1; + if (this._armatureDisplay.armature.flipX !== this._faceDir < 0) { + this._armatureDisplay.armature.flipX = !this._armatureDisplay.armature.flipX; + if (this._moveDir !== 0) { + this._updateAnimation(); + } + } + var aimOffsetY = this._armature.getBone("chest").global.y * this._armatureDisplay.scale.y; + if (this._faceDir > 0) { + this._aimRadian = Math.atan2(this._target.y - this._armatureDisplay.y - aimOffsetY, this._target.x - this._armatureDisplay.x); + } + else { + this._aimRadian = Math.PI - Math.atan2(this._target.y - this._armatureDisplay.y - aimOffsetY, this._target.x - this._armatureDisplay.x); + if (this._aimRadian > Math.PI) { + this._aimRadian -= Math.PI * 2.0; + } + } + var aimDir = 0; + if (this._aimRadian > 0.0) { + aimDir = -1; + } + else { + aimDir = 1; + } + if (this._aimState === null || this._aimDir !== aimDir) { + this._aimDir = aimDir; + // Animation mixing. + if (this._aimDir >= 0) { + this._aimState = this._armature.animation.fadeIn("aim_up", -1.0, -1, 0, Mecha.AIM_ANIMATION_GROUP); + } + else { + this._aimState = this._armature.animation.fadeIn("aim_down", -1.0, -1, 0, Mecha.AIM_ANIMATION_GROUP); + } + this._aimState.resetToPose = false; + } + this._aimState.weight = Math.abs(this._aimRadian / Math.PI * 2); + this._armature.invalidUpdate(); + }; + Mecha.prototype._updateAttack = function () { + if (!this._isAttackingA || this._isAttackingB) { + return; + } + this._isAttackingB = true; + this._attackState = this._armature.animation.fadeIn("attack_01", -1.0, -1, 0, Mecha.ATTACK_ANIMATION_GROUP); + this._attackState.resetToPose = false; + this._attackState.autoFadeOutTime = this._attackState.fadeTotalTime; + }; + Mecha.JUMP_SPEED = 20; + Mecha.NORMALIZE_MOVE_SPEED = 3.6; + Mecha.MAX_MOVE_SPEED_FRONT = Mecha.NORMALIZE_MOVE_SPEED * 1.4; + Mecha.MAX_MOVE_SPEED_BACK = Mecha.NORMALIZE_MOVE_SPEED * 1.0; + Mecha.NORMAL_ANIMATION_GROUP = "normal"; + Mecha.AIM_ANIMATION_GROUP = "aim"; + Mecha.ATTACK_ANIMATION_GROUP = "attack"; + Mecha.WEAPON_L_LIST = ["weapon_1502b_l", "weapon_1005", "weapon_1005b", "weapon_1005c", "weapon_1005d", "weapon_1005e"]; + Mecha.WEAPON_R_LIST = ["weapon_1502b_r", "weapon_1005", "weapon_1005b", "weapon_1005c", "weapon_1005d"]; + Mecha.SKINS = ["mecha_1502b", "skin_a", "skin_b", "skin_c"]; + return Mecha; + }()); + var Bullet = (function () { + function Bullet(armatureName, effectArmatureName, radian, speed, position) { + this._speedX = 0.0; + this._speedY = 0.0; + this._effecDisplay = null; + this._speedX = Math.cos(radian) * speed; + this._speedY = Math.sin(radian) * speed; + this._armatureDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay(armatureName); + this._armatureDisplay.x = position.x + Math.random() * 2 - 1; + this._armatureDisplay.y = position.y + Math.random() * 2 - 1; + this._armatureDisplay.rotation = radian; + if (effectArmatureName !== null) { + this._effecDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay(effectArmatureName); + this._effecDisplay.rotation = radian; + this._effecDisplay.x = this._armatureDisplay.x; + this._effecDisplay.y = this._armatureDisplay.y; + this._effecDisplay.scale.set(1 + Math.random() * 1, 1 + Math.random() * 0.5); + if (Math.random() < 0.5) { + this._effecDisplay.scale.y *= -1; + } + Game.instance.stage.addChild(this._effecDisplay); + this._effecDisplay.animation.play("idle"); + } + Game.instance.stage.addChild(this._armatureDisplay); + this._armatureDisplay.animation.play("idle"); + } + Bullet.prototype.update = function () { + this._armatureDisplay.x += this._speedX; + this._armatureDisplay.y += this._speedY; + if (this._armatureDisplay.x < -100.0 || this._armatureDisplay.x >= Game.STAGE_WIDTH + 100.0 || + this._armatureDisplay.y < -100.0 || this._armatureDisplay.y >= Game.STAGE_HEIGHT + 100.0) { + Game.instance.stage.removeChild(this._armatureDisplay); + this._armatureDisplay.dispose(); + if (this._effecDisplay !== null) { + Game.instance.stage.removeChild(this._effecDisplay); + this._effecDisplay.dispose(); + } + return true; + } + return false; + }; + return Bullet; + }()); +})(coreElement || (coreElement = {})); diff --git a/reference/Pixi/Demos/out/HelloDragonBones.js b/reference/Pixi/Demos/out/HelloDragonBones.js new file mode 100644 index 0000000..580e902 --- /dev/null +++ b/reference/Pixi/Demos/out/HelloDragonBones.js @@ -0,0 +1,55 @@ +"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 __()); + }; +})(); +/** + * How to use + * 1. Load data. + * + * 2. Parse data. + * factory.parseDragonBonesData(); + * factory.parseTextureAtlasData(); + * + * 3. Build armature. + * armatureDisplay = factory.buildArmatureDisplay("armatureName"); + * + * 4. Play animation. + * armatureDisplay.animation.play("animationName"); + * + * 5. Add armature to stage. + * addChild(armatureDisplay); + */ +var HelloDragonBones = (function (_super) { + __extends(HelloDragonBones, _super); + function HelloDragonBones() { + return _super !== null && _super.apply(this, arguments) || this; + } + HelloDragonBones.prototype._onStart = function () { + var _this = this; + PIXI.loader + .add("dragonBonesData", "./resource/assets/dragon_boy_ske.dbbin", { loadType: PIXI.loaders.Resource.LOAD_TYPE.XHR, xhrType: PIXI.loaders.Resource.XHR_RESPONSE_TYPE.BUFFER }) + .add("textureData", "./resource/assets/dragon_boy_tex.json") + .add("texture", "./resource/assets/dragon_boy_tex.png"); + PIXI.loader.once("complete", function (loader, resources) { + var factory = dragonBones.PixiFactory.factory; + factory.parseDragonBonesData(resources["dragonBonesData"].data); + factory.parseTextureAtlasData(resources["textureData"].data, resources["texture"].texture); + var armatureDisplay = factory.buildArmatureDisplay("DragonBoy"); + armatureDisplay.animation.play("walk"); + _this.stage.addChild(armatureDisplay); + armatureDisplay.x = _this._renderer.width * 0.5; + armatureDisplay.y = _this._renderer.height * 0.5 + 100; + // + _this._startRenderTick(); + }); + PIXI.loader.load(); + }; + return HelloDragonBones; +}(BaseTest)); diff --git a/reference/Pixi/Demos/out/PerformanceTest.js b/reference/Pixi/Demos/out/PerformanceTest.js new file mode 100644 index 0000000..010a753 --- /dev/null +++ b/reference/Pixi/Demos/out/PerformanceTest.js @@ -0,0 +1,133 @@ +"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 PerformanceTest = (function (_super) { + __extends(PerformanceTest, _super); + function PerformanceTest() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._addingArmature = false; + _this._removingArmature = false; + _this._text = new PIXI.Text("", { align: "center" }); + _this._armatures = []; + return _this; + } + PerformanceTest.prototype._onStart = function () { + var _this = this; + PIXI.loader + .add("dragonBonesData", "./resource/assets/dragon_boy_ske.json") + .add("textureData", "./resource/assets/dragon_boy_tex.json") + .add("texture", "./resource/assets/dragon_boy_tex.png"); + PIXI.loader.once("complete", function (loader, resources) { + _this._resources = resources; + // + _this._text.scale.x = 0.7; + _this._text.scale.y = 0.7; + _this.stage.addChild(_this._text); + // + _this._stage.interactive = true; + _this._stage.addListener("touchstart", _this._touchHandler, _this); + _this._stage.addListener("touchend", _this._touchHandler, _this); + _this._stage.addListener("mousedown", _this._touchHandler, _this); + _this._stage.addListener("mouseup", _this._touchHandler, _this); + PIXI.ticker.shared.add(_this._enterFrameHandler, _this); + for (var i = 0; i < 100; ++i) { + _this._addArmature(); + } + _this._resetPosition(); + _this._updateText(); + // + _this._startRenderTick(); + }); + PIXI.loader.load(); + }; + PerformanceTest.prototype._enterFrameHandler = function (deltaTime) { + if (this._addingArmature) { + for (var i = 0; i < 10; ++i) { + this._addArmature(); + } + this._resetPosition(); + this._updateText(); + } + if (this._removingArmature) { + for (var i = 0; i < 10; ++i) { + this._removeArmature(); + } + this._resetPosition(); + this._updateText(); + } + }; + PerformanceTest.prototype._touchHandler = function (event) { + switch (event.type) { + case "touchstart": + case "mousedown": + var touchRight = event.data.global.x > this._renderer.width * 0.5; + this._addingArmature = touchRight; + this._removingArmature = !touchRight; + break; + case "touchend": + case "mouseup": + this._addingArmature = false; + this._removingArmature = false; + break; + } + }; + PerformanceTest.prototype._addArmature = function () { + if (this._armatures.length === 0) { + dragonBones.PixiFactory.factory.parseDragonBonesData(this._resources["dragonBonesData"].data); + dragonBones.PixiFactory.factory.parseTextureAtlasData(this._resources["textureData"].data, this._resources["texture"].texture); + } + var armatureDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay("DragonBoy"); + armatureDisplay.armature.cacheFrameRate = 24; + armatureDisplay.animation.play("walk", 0); + armatureDisplay.scale.set(0.7, 0.7); + this.stage.addChild(armatureDisplay); + this._armatures.push(armatureDisplay); + }; + PerformanceTest.prototype._removeArmature = function () { + if (this._armatures.length === 0) { + return; + } + var armatureDisplay = this._armatures.pop(); + this.stage.removeChild(armatureDisplay); + armatureDisplay.dispose(); + if (this._armatures.length === 0) { + dragonBones.PixiFactory.factory.clear(true); + dragonBones.BaseObject.clearPool(); + } + }; + PerformanceTest.prototype._resetPosition = function () { + var armatureCount = this._armatures.length; + if (armatureCount === 0) { + return; + } + var paddingH = 50; + var paddingV = 150; + var gapping = 100; + var stageWidth = this.renderer.width - paddingH * 2; + var columnCount = Math.floor(stageWidth / gapping); + var paddingHModify = (this.renderer.width - columnCount * gapping) * 0.5; + var dX = stageWidth / columnCount; + var dY = (this.renderer.height - paddingV * 2) / Math.ceil(armatureCount / columnCount); + for (var i = 0, l = armatureCount; i < l; ++i) { + var armatureDisplay = this._armatures[i]; + var lineY = Math.floor(i / columnCount); + armatureDisplay.x = (i % columnCount) * dX + paddingHModify; + armatureDisplay.y = lineY * dY + paddingV; + } + }; + PerformanceTest.prototype._updateText = function () { + this._text.text = "Count: " + this._armatures.length + " \nTouch screen left to decrease count / right to increase count."; + this._text.x = (this.renderer.width - this._text.width) * 0.5; + this._text.y = this.renderer.height - 60; + this.stage.addChild(this._text); + }; + return PerformanceTest; +}(BaseTest)); diff --git a/reference/Pixi/Demos/out/ReplaceSlotDisplay.js b/reference/Pixi/Demos/out/ReplaceSlotDisplay.js new file mode 100644 index 0000000..99d02f2 --- /dev/null +++ b/reference/Pixi/Demos/out/ReplaceSlotDisplay.js @@ -0,0 +1,87 @@ +"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 ReplaceSlotDisplay = (function (_super) { + __extends(ReplaceSlotDisplay, _super); + function ReplaceSlotDisplay() { + var _this = _super !== null && _super.apply(this, arguments) || this; + _this._displayIndex = 0; + _this._replaceDisplays = [ + // Replace normal display. + "display0002", "display0003", "display0004", "display0005", "display0006", "display0007", "display0008", "display0009", "display0010", + // Replace mesh display. + "meshA", "meshB", "meshC", + ]; + _this._factory = dragonBones.PixiFactory.factory; + return _this; + } + ReplaceSlotDisplay.prototype._onStart = function () { + var _this = this; + PIXI.loader + .add("dragonBonesDataA", "./resource/assets/replace_slot_display/main_ske.json") + .add("textureDataA", "./resource/assets/replace_slot_display/main_tex.json") + .add("textureA", "./resource/assets/replace_slot_display/main_tex.png") + .add("dragonBonesDataB", "./resource/assets/replace_slot_display/replace_ske.json") + .add("textureDataB", "./resource/assets/replace_slot_display/replace_tex.json") + .add("textureB", "./resource/assets/replace_slot_display/replace_tex.png"); + PIXI.loader.once("complete", function (loader, resources) { + _this._factory.parseDragonBonesData(resources["dragonBonesDataA"].data); + _this._factory.parseTextureAtlasData(resources["textureDataA"].data, resources["textureA"].texture); + _this._factory.parseDragonBonesData(resources["dragonBonesDataB"].data); + _this._factory.parseTextureAtlasData(resources["textureDataB"].data, resources["textureB"].texture); + _this._armatureDisplay = _this._factory.buildArmatureDisplay("MyArmature"); + _this._armatureDisplay.animation.timeScale = 0.1; + _this._armatureDisplay.animation.play(); + _this._armatureDisplay.x = _this.stage.width * 0.5; + _this._armatureDisplay.y = _this.stage.height * 0.5; + _this.stage.addChild(_this._armatureDisplay); + var touchHandler = function (event) { + _this._replaceDisplay(); + }; + _this.stage.interactive = true; + _this.stage.addListener("touchstart", touchHandler, _this); + _this.stage.addListener("mousedown", touchHandler, _this); + // + _this._startRenderTick(); + }); + PIXI.loader.load(); + }; + ReplaceSlotDisplay.prototype._replaceDisplay = function () { + this._displayIndex = (this._displayIndex + 1) % this._replaceDisplays.length; + var replaceDisplayName = this._replaceDisplays[this._displayIndex]; + if (replaceDisplayName.indexOf("mesh") >= 0) { + switch (replaceDisplayName) { + case "meshA": + // Normal to mesh. + this._factory.replaceSlotDisplay("replace", "MyMesh", "meshA", "weapon_1004_1", this._armatureDisplay.armature.getSlot("weapon")); + // Replace mesh texture. + this._factory.replaceSlotDisplay("replace", "MyDisplay", "ball", "display0002", this._armatureDisplay.armature.getSlot("mesh")); + break; + case "meshB": + // Normal to mesh. + this._factory.replaceSlotDisplay("replace", "MyMesh", "meshB", "weapon_1004_1", this._armatureDisplay.armature.getSlot("weapon")); + // Replace mesh texture. + this._factory.replaceSlotDisplay("replace", "MyDisplay", "ball", "display0003", this._armatureDisplay.armature.getSlot("mesh")); + break; + case "meshC": + // Back to normal. + this._factory.replaceSlotDisplay("replace", "MyMesh", "mesh", "weapon_1004_1", this._armatureDisplay.armature.getSlot("weapon")); + // Replace mesh texture. + this._factory.replaceSlotDisplay("replace", "MyDisplay", "ball", "display0005", this._armatureDisplay.armature.getSlot("mesh")); + break; + } + } + else { + this._factory.replaceSlotDisplay("replace", "MyDisplay", "ball", replaceDisplayName, this._armatureDisplay.armature.getSlot("ball")); + } + }; + return ReplaceSlotDisplay; +}(BaseTest)); diff --git a/reference/Pixi/Demos/package.json b/reference/Pixi/Demos/package.json new file mode 100644 index 0000000..c086727 --- /dev/null +++ b/reference/Pixi/Demos/package.json @@ -0,0 +1,16 @@ +{ + "name": "dragonbones-pixi-demos", + "version": "5.1.0", + "main": "", + "scripts": { + "start": "tsc & copyfiles -u 3 -s ../4.x/out/* libs/dragonBones/ & anywhere", + "upgradeA": "cd .. & cd 4.x & npm run build & cd .. & cd Demos", + "upgradeB": "copyfiles -u 3 ../4.x/out/* libs/dragonBones/", + "upgrade": "npm run upgradeA & npm run upgradeB" + }, + "devDependencies": { + "anywhere": "^1.4.0", + "copyfiles": "^1.2.0", + "typescript": "^2.4.2" + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/animation_base_test_ske.json b/reference/Pixi/Demos/resource/assets/animation_base_test_ske.json new file mode 100644 index 0000000..067c964 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/animation_base_test_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"armature":[{"aabb":{"width":611,"y":-82.37399983406067,"height":97.37399983406067,"x":-300},"type":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"idle"}],"skin":[{"name":"","slot":[{"display":[{"path":"_texture/track","type":"image","name":"_texture/track","transform":{}}],"name":"track"},{"display":[{"path":"_texture/thrmb","type":"image","name":"_texture/thrmb","transform":{"x":-33}}],"name":"thrmb"},{"display":[{"transform":{"skX":-0.8115,"skY":-0.8115},"path":"loading","type":"armature","name":"loading","filterType":"armature"}],"name":"loading"},{"display":[{"path":"_texture/bar","type":"image","name":"_texture/bar","transform":{"x":300}}],"name":"bar"}]}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{},"name":"track","parent":"root"},{"inheritScale":0,"transform":{"x":-300},"name":"bar","parent":"root"},{"inheritScale":0,"transform":{"x":300},"name":"thrmb","parent":"root"},{"transform":{"skX":0.8115,"y":-50,"skY":0.8115},"name":"loading","parent":"root"}],"slot":[{"name":"track","parent":"track","color":{}},{"z":1,"name":"bar","parent":"bar","color":{}},{"z":2,"name":"thrmb","parent":"thrmb","color":{}},{"z":3,"name":"loading","parent":"loading","color":{}}],"animation":[{"frame":[{"duration":50,"tweenEasing":null,"events":[{"name":"startEvent"}]},{"duration":50,"tweenEasing":null,"events":[{"name":"middleEvent"}]},{"duration":0,"tweenEasing":null,"events":[{"name":"completeEvent"}]}],"duration":100,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":100}],"name":"track"},{"frame":[{"transform":{"scX":0.01},"tweenEasing":0,"duration":100},{"transform":{},"tweenEasing":null,"duration":0}],"name":"bar"},{"frame":[{"transform":{"scX":0.5,"scY":0.5,"x":-600},"tweenEasing":0,"duration":5},{"transform":{"x":-565},"tweenEasing":0,"duration":90},{"transform":{"x":-30},"tweenEasing":0,"duration":5},{"transform":{"scX":0.5,"scY":0.5},"tweenEasing":null,"duration":0}],"name":"thrmb"},{"frame":[{"transform":{},"tweenEasing":null,"duration":100}],"name":"root"},{"frame":[{"transform":{},"tweenEasing":null,"duration":100}],"name":"loading"}],"slot":[{"frame":[{"tweenEasing":null,"duration":100}],"name":"track"},{"frame":[{"tweenEasing":null,"duration":100}],"name":"bar"},{"frame":[{"color":{"aM":0},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":90},{"tweenEasing":0,"duration":5},{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"thrmb"},{"frame":[{"duration":100,"actions":[{"gotoAndPlay":"idle"}],"tweenEasing":0},{"duration":0,"actions":[{"gotoAndPlay":"hide"}],"tweenEasing":null}],"name":"loading"}],"ffd":[],"name":"idle"}],"frameRate":24,"name":"progressBar"},{"aabb":{"width":108,"y":-51.950005000000004,"height":104,"x":-54},"type":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"idle"}],"skin":[{"name":"","slot":[{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"1"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"3"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"4"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"6"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"5"},{"display":[{"path":"_texture/_diamond","type":"image","name":"_texture/_diamond","transform":{"y":0.15}}],"name":"2"}]}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-11,"scX":0.3329,"scY":0.3333,"x":-19},"name":"6","parent":"root"},{"inheritScale":0,"transform":{"y":11,"scX":0.3329,"scY":0.3333,"x":-19},"name":"5","parent":"root"},{"inheritScale":0,"transform":{"y":22,"scX":0.3329,"scY":0.3333},"name":"4","parent":"root"},{"inheritScale":0,"transform":{"y":11,"scX":0.3329,"scY":0.3333,"x":19},"name":"3","parent":"root"},{"inheritScale":0,"transform":{"y":-11,"scX":0.3329,"scY":0.3333,"x":19},"name":"2","parent":"root"},{"inheritScale":0,"transform":{"y":-22,"scX":0.3329,"scY":0.3333},"name":"1","parent":"root"}],"slot":[{"name":"6","parent":"6","color":{}},{"z":1,"name":"5","parent":"5","color":{}},{"z":2,"name":"4","parent":"4","color":{}},{"z":3,"name":"3","parent":"3","color":{}},{"z":4,"name":"2","parent":"2","color":{}},{"z":5,"name":"1","parent":"1","color":{}}],"animation":[{"playTimes":0,"frame":[],"duration":30,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":30}],"name":"root"},{"frame":[{"transform":{"y":-2,"x":-4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":20},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-2,"x":-4},"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"transform":{},"tweenEasing":0,"duration":20},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":3,"x":-4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"transform":{},"tweenEasing":0,"duration":15},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":null,"duration":0}],"name":"4"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":2,"x":4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"3"},{"frame":[{"transform":{},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-2,"x":4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":15},{"transform":{},"tweenEasing":null,"duration":0}],"name":"2"},{"frame":[{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-4},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":20},{"transform":{},"tweenEasing":null,"duration":0}],"name":"1"}],"slot":[{"frame":[{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":0,"duration":20},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":20},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":15},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":5}],"name":"4"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":10},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":10}],"name":"3"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":15}],"name":"2"},{"frame":[{"color":{"aM":50},"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"color":{"aM":50},"tweenEasing":null,"duration":20}],"name":"1"}],"ffd":[],"name":"idle","fadeInTime":0.2},{"playTimes":0,"frame":[],"duration":0,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":0}],"name":"root"},{"frame":[{"transform":{"y":11,"x":19},"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"transform":{"y":-11,"x":19},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"transform":{"y":-22},"tweenEasing":null,"duration":0}],"name":"4"},{"frame":[{"transform":{"y":-11,"x":-19},"tweenEasing":null,"duration":0}],"name":"3"},{"frame":[{"transform":{"y":11,"x":-19},"tweenEasing":null,"duration":0}],"name":"2"},{"frame":[{"transform":{"y":22},"tweenEasing":null,"duration":0}],"name":"1"}],"slot":[{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"6"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"5"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"4"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"3"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"2"},{"frame":[{"color":{"aM":0},"tweenEasing":null,"duration":0}],"name":"1"}],"ffd":[],"name":"hide","fadeInTime":0.2}],"frameRate":24,"name":"loading"}],"name":"AnimationBaseTest","version":"5.0"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/animation_base_test_tex.json b/reference/Pixi/Demos/resource/assets/animation_base_test_tex.json new file mode 100644 index 0000000..e53778e --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/animation_base_test_tex.json @@ -0,0 +1 @@ +{"imagePath":"animation_base_test_tex.png","width":1024,"SubTexture":[{"width":600,"y":1,"height":4,"name":"_texture/track","x":73},{"width":600,"y":7,"height":4,"name":"_texture/bar","x":73},{"width":88,"y":1,"height":30,"name":"_texture/thrmb","x":675},{"width":70,"y":1,"height":60,"name":"_texture/_diamond","x":1}],"height":64,"name":"AnimationBaseTest"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/animation_base_test_tex.png b/reference/Pixi/Demos/resource/assets/animation_base_test_tex.png new file mode 100644 index 0000000..f24f5ee Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/animation_base_test_tex.png differ diff --git a/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_ske.json b/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_ske.json new file mode 100644 index 0000000..8d98c7e --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_ske.json @@ -0,0 +1,7232 @@ +{ + "frameRate": 24, + "isGlobal": 0, + "armature": [ + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "bullet_01_f/bullet_01", + "transform": { + "x": -27 + } + } + ], + "name": "b" + } + ] + } + ], + "bone": [ + { + "inheritScale": 0, + "length": 20, + "name": "b", + "transform": {} + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 74, + "y": -10, + "height": 20, + "x": -64 + }, + "slot": [ + { + "name": "b", + "parent": "b", + "color": { + "aM": 50 + } + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "bullet_01", + "ik": [], + "animation": [ + { + "duration": 4, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 4, + "transform": { + "scX": 0.1, + "scY": 0.3 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "scX": 1.8 + }, + "tweenEasing": null + } + ], + "name": "b" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 4, + "tweenEasing": 0, + "color": { + "aM": 50 + } + }, + { + "duration": 0, + "tweenEasing": null + } + ], + "name": "b" + } + ], + "name": "idle" + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "fire_effect_01_f/fireEffect", + "transform": { + "scX": 1.5, + "x": 21 + } + } + ], + "name": "root" + } + ] + } + ], + "bone": [ + { + "inheritScale": 0, + "length": 30, + "name": "root", + "transform": {} + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 48, + "y": -19, + "height": 38, + "x": -3 + }, + "slot": [ + { + "name": "root", + "parent": "root", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "fire_effect_01", + "ik": [], + "animation": [ + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + }, + { + "duration": 0, + "displayIndex": -1, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "name": "idle" + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "flame_01_f/bbb", + "transform": { + "skX": -90, + "skY": -90, + "x": 95 + } + } + ], + "blendMode": "add", + "name": "b2" + }, + { + "display": [ + { + "type": "image", + "name": "flame_01_f/ba_bu_flame1", + "transform": { + "y": 85, + "skX": -90, + "skY": -90 + } + } + ], + "name": "b1" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "length": 30, + "transform": { + "skX": 90, + "skY": 90 + }, + "parent": "root", + "inheritScale": 0, + "name": "b2" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 180, + "y": -22, + "height": 234, + "x": -90 + }, + "slot": [ + { + "name": "b1", + "parent": "root", + "color": {} + }, + { + "blendMode": "add", + "z": 1, + "parent": "b2", + "name": "b2", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "flame_01", + "ik": [], + "animation": [ + { + "duration": 2, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "b2" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": 0 + }, + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 30 + } + } + ], + "name": "b2" + } + ], + "name": "idle", + "playTimes": 0 + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/calf_r", + "transform": { + "y": 2.05, + "skX": 0.1784, + "skY": 0.1784, + "x": 16.95 + } + } + ], + "name": "calf_r" + }, + { + "display": [ + { + "transform": { + "skX": -90, + "skY": -90, + "scX": 0.8, + "scY": 0.8 + }, + "type": "armature", + "name": "flame_01", + "filterType": null + } + ], + "name": "effects_f" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/foot_l_0", + "transform": { + "y": 6.4707, + "skX": 89.9982, + "skY": 89.9982, + "scX": 0.9955, + "scY": 1.0045, + "x": 0.0002 + } + } + ], + "name": "foot_l" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/shouder_r_1", + "transform": { + "y": -3.0591, + "skX": -50.3304, + "skY": -50.3127, + "scX": 0.9998, + "scY": 1.0002, + "x": 1.8548 + } + } + ], + "name": "shouder_r" + }, + { + "display": [ + { + "transform": { + "skX": -90, + "skY": -90 + }, + "type": "armature", + "name": "flame_01", + "filterType": null + } + ], + "name": "effects_b" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/calf_l", + "transform": { + "y": 0.95, + "skX": -0.1967, + "skY": -0.1976, + "x": 15 + } + } + ], + "name": "calf_l" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_1_r_1", + "transform": { + "y": -1.9, + "skX": 0.438, + "skY": 0.438, + "x": 21.55 + } + } + ], + "name": "thigh_1_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/pelvis", + "transform": { + "y": 7.5, + "x": 3.5 + } + } + ], + "name": "pelvis" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/shouder_l_0", + "transform": { + "y": -3.2345, + "skX": 129.6702, + "skY": 129.6875, + "scX": 0.9998, + "scY": 1.0002, + "x": 0.7822 + } + } + ], + "name": "shouder_l" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_r", + "transform": { + "y": -11.55, + "skX": -0.1635, + "skY": -0.1626, + "x": 12.45 + } + } + ], + "name": "thigh_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/chest", + "transform": { + "y": 29.4658, + "skX": 89.9994, + "skY": 90.0004, + "x": -17.0277 + } + } + ], + "name": "chest" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_1_l_0", + "transform": { + "y": -2.95, + "skX": 0.1119, + "skY": 0.1128, + "x": 23 + } + } + ], + "name": "thigh_1_l" + }, + { + "display": [ + { + "transform": {}, + "type": "armature", + "name": "weapon_1502b_r", + "filterType": null + } + ], + "name": "weapon_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/foot_r", + "transform": { + "y": 7.4165, + "skX": 89.9982, + "skY": 89.9982, + "scX": 0.9955, + "scY": 1.0045, + "x": -0.502 + } + } + ], + "name": "foot_r" + }, + { + "display": [ + { + "type": "image", + "name": "mecha_1502b_folder/thigh_l", + "transform": { + "y": -5.55, + "skX": 0.0463, + "skY": 0.0455, + "x": 13.45 + } + } + ], + "name": "thigh_l" + }, + { + "display": [ + { + "transform": {}, + "type": "armature", + "name": "weapon_1502b_l", + "filterType": null + } + ], + "name": "weapon_l" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "length": 20, + "transform": { + "y": -25, + "scX": 0.9955, + "x": 62.85 + }, + "parent": "root", + "inheritScale": 0, + "name": "foot_l" + }, + { + "length": 40, + "transform": { + "y": -133.55, + "skX": 21.9887, + "skY": 21.9887, + "scX": 0.9995, + "scY": 0.9977, + "x": 8.3 + }, + "parent": "root", + "inheritScale": 0, + "name": "thigh_l" + }, + { + "length": 42, + "transform": { + "y": -112.45, + "skX": 69.8809, + "skY": 69.8854, + "scX": 0.9876, + "scY": 0.9979, + "x": -8.55 + }, + "parent": "root", + "inheritScale": 0, + "name": "thigh_r" + }, + { + "length": 20, + "transform": { + "y": -123.15, + "skX": -89.9991, + "skY": -89.9991 + }, + "parent": "root", + "inheritScale": 0, + "name": "pelvis" + }, + { + "length": 20, + "transform": { + "y": -4, + "scX": 0.9955, + "x": -43.8 + }, + "parent": "root", + "inheritScale": 0, + "name": "foot_r" + }, + { + "length": 50, + "transform": { + "y": -0.04, + "skX": 97.9614, + "skY": 97.9621, + "scX": 0.9894, + "scY": 0.9971, + "x": 40.11 + }, + "parent": "thigh_l", + "inheritScale": 0, + "name": "thigh_1_l" + }, + { + "length": 20, + "transform": { + "skX": -90, + "skY": -90, + "x": 13.75 + }, + "parent": "pelvis", + "inheritScale": 0, + "name": "chest" + }, + { + "length": 53, + "transform": { + "y": -0.01, + "skX": 105.4235, + "skY": 105.423, + "scX": 0.9984, + "scY": 0.9995, + "x": 41.52 + }, + "parent": "thigh_r", + "inheritScale": 0, + "name": "thigh_1_r" + }, + { + "length": 20, + "transform": { + "y": 31.28, + "scX": 0.9965, + "scY": 0.9969, + "x": 13.74 + }, + "parent": "chest", + "inheritScale": 0, + "name": "shouder_r" + }, + { + "length": 20, + "transform": { + "y": 46.59, + "scX": 0.9965, + "scY": 0.9969, + "x": -2.41 + }, + "parent": "chest", + "inheritScale": 0, + "name": "shouder_l" + }, + { + "inheritRotation": 0, + "length": 100, + "transform": { + "y": 3.13, + "skX": 130, + "skY": 130, + "x": 11.65 + }, + "parent": "chest", + "inheritScale": 0, + "name": "effects_b" + }, + { + "length": 64, + "transform": { + "y": 0.01, + "skX": -70.8583, + "skY": -70.864, + "scX": 1.0149, + "scY": 0.9967, + "x": 50.91 + }, + "parent": "thigh_1_l", + "inheritScale": 0, + "name": "calf_l" + }, + { + "inheritRotation": 0, + "length": 100, + "transform": { + "y": -13.37, + "skX": 90, + "skY": 90, + "x": -20.82 + }, + "parent": "chest", + "inheritScale": 0, + "name": "effects_f" + }, + { + "length": 66, + "transform": { + "y": -0.02, + "skX": -88.4874, + "skY": -88.4933, + "scX": 0.9852, + "scY": 0.9996, + "x": 53.26 + }, + "parent": "thigh_1_r", + "inheritScale": 0, + "name": "calf_r" + }, + { + "length": 100, + "transform": { + "skX": 180, + "skY": 180, + "scX": 0.9982, + "scY": 0.9994, + "x": 5.98 + }, + "parent": "shouder_r", + "inheritScale": 0, + "name": "weapon_r" + }, + { + "length": 100, + "transform": { + "y": 0.04, + "skX": 180, + "skY": 180, + "scX": 0.998, + "scY": 0.9993, + "x": 5.6 + }, + "parent": "shouder_l", + "inheritScale": 0, + "name": "weapon_l" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 202.6571337556091, + "y": -262.3655325241823, + "height": 320.2820325241823, + "x": -111.39678584090109 + }, + "slot": [ + { + "name": "weapon_l", + "parent": "weapon_l", + "color": {} + }, + { + "z": 1, + "name": "shouder_l", + "parent": "shouder_l", + "color": {} + }, + { + "z": 2, + "name": "foot_l", + "parent": "foot_l", + "color": {} + }, + { + "z": 3, + "name": "thigh_1_l", + "parent": "thigh_1_l", + "color": {} + }, + { + "z": 4, + "name": "calf_l", + "parent": "calf_l", + "color": {} + }, + { + "z": 5, + "name": "thigh_l", + "parent": "thigh_l", + "color": {} + }, + { + "z": 6, + "name": "pelvis", + "parent": "pelvis", + "color": {} + }, + { + "z": 7, + "name": "effects_f", + "parent": "effects_f", + "color": { + "aM": 0 + } + }, + { + "z": 8, + "name": "chest", + "parent": "chest", + "color": {} + }, + { + "z": 9, + "name": "effects_b", + "parent": "effects_b", + "color": { + "aM": 0 + } + }, + { + "z": 10, + "name": "foot_r", + "parent": "foot_r", + "color": {} + }, + { + "z": 11, + "name": "thigh_1_r", + "parent": "thigh_1_r", + "color": {} + }, + { + "z": 12, + "name": "calf_r", + "parent": "calf_r", + "color": {} + }, + { + "z": 13, + "name": "thigh_r", + "parent": "thigh_r", + "color": {} + }, + { + "z": 14, + "name": "shouder_r", + "parent": "shouder_r", + "color": {} + }, + { + "z": 15, + "name": "weapon_r", + "parent": "weapon_r", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "mecha_1502b", + "ik": [ + { + "bone": "calf_l", + "chain": 1, + "bendPositive": "false", + "name": "calf_l", + "target": "foot_l" + }, + { + "bone": "calf_r", + "chain": 1, + "bendPositive": "false", + "name": "calf_r", + "target": "foot_r" + } + ], + "animation": [ + { + "duration": 60, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -0.04, + "skY": 0.0009, + "scX": 1.0004, + "x": -0.01 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -0.61, + "skX": 3.5176, + "skY": 3.5176, + "x": -0.46 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -3.95, + "skX": 3.2612, + "skY": 3.2619, + "scX": 1.0008, + "scY": 0.9998 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -4 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "skX": -3.4867, + "skY": -3.5176, + "scX": 0.9996, + "scY": 1.0027 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": -4.05, + "skX": 2.2559, + "skY": 2.2558, + "scX": 0.9985, + "scY": 1.0002 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": 0.55, + "skX": 3.5176, + "skY": 3.5176, + "x": 0.49 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 30, + "transform": { + "y": 0.06, + "skY": -0.0009, + "scX": 1.0002, + "x": 0.01 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 60, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.2, + "name": "idle", + "playTimes": 0 + }, + { + "duration": 30, + "frame": [ + { + "duration": 14, + "tweenEasing": null + }, + { + "duration": 16, + "tweenEasing": null, + "events": [ + { + "name": "step", + "bone": "foot_r" + } + ] + }, + { + "duration": 0, + "tweenEasing": null, + "events": [ + { + "name": "step" + } + ] + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 4, + "transform": { + "y": 0.21, + "skX": -13.2798, + "skY": -13.279, + "x": 0.32 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.2, + "skX": -12.4984, + "skY": -12.4984, + "scX": 0.9998, + "x": 0.25 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.28, + "skX": -12.29, + "skY": -12.2892, + "scX": 0.9997, + "x": 0.14 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.21, + "skX": -16.0776, + "skY": -16.0767, + "scX": 0.9996, + "scY": 0.9998, + "x": 0.33 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.14, + "skX": -15.1996, + "skY": -15.1996, + "scX": 0.9997, + "x": 0.52 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.15, + "skX": -13.4429, + "skY": -13.442, + "x": 0.87 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.21, + "skX": -13.2798, + "skY": -13.279, + "x": 0.32 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": -0.49, + "skX": 11.6982, + "skY": 10.0384, + "scX": 1.1315, + "scY": 1.0017, + "x": -1.93 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -1.58, + "skX": 9.3988, + "skY": 9.2902, + "scX": 1.0079, + "x": -0.43 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -2.37, + "skX": 8.1528, + "skY": 9.1018, + "scX": 0.9313, + "scY": 0.9988, + "x": 0.46 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -1.99, + "skX": 13.6189, + "skY": 13.1293, + "scX": 1.037, + "scY": 1.0004, + "x": -1.3 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.1, + "skX": 14.9031, + "skY": 12.4457, + "scX": 1.2006, + "scY": 1.0028, + "x": -3.33 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 1.08, + "skX": 13.1082, + "skY": 10.6515, + "scX": 1.2005, + "scY": 1.0028, + "x": -3.69 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.49, + "skX": 11.6982, + "skY": 10.0384, + "scX": 1.1315, + "scY": 1.0017, + "x": -1.93 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.3, + "scX": 0.999, + "x": 16.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.3, + "scX": 0.9981, + "x": 12.15 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -1.15, + "scX": 0.9994, + "x": -7.15 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -2.5, + "scX": 1.0021, + "x": -39.35 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -5.1, + "skX": 1.0018, + "skY": 1.0018, + "scX": 1.0028, + "x": -81.1 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -10.25, + "skX": 8.0065, + "skY": 8.0073, + "scX": 0.9898, + "scY": 0.9991, + "x": -102.2 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -13.45, + "skX": 14.0174, + "skY": 14.0174, + "scX": 1.0146, + "scY": 0.9985, + "x": -108.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -20.4, + "skX": 28.3082, + "skY": 28.3075, + "scX": 0.9856, + "scY": 0.9973, + "x": -111.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -29.65, + "skX": 37.8443, + "skY": 37.847, + "scX": 0.9987, + "scY": 0.9968, + "x": -86.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -33.25, + "skX": 38.3489, + "skY": 38.3494, + "scX": 1.0058, + "scY": 0.9968, + "x": -71.8 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -35.1, + "skX": 26.0511, + "skY": 26.0511, + "scX": 1.004, + "scY": 0.9974, + "x": -49.45 + }, + "tweenEasing": 0 + }, + { + "duration": 6, + "transform": { + "y": -33.55, + "skX": 18.2766, + "skY": 18.2774, + "scX": 1.0066, + "scY": 0.998, + "x": -39.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -12.45, + "skX": -15.7668, + "skY": -15.7676, + "scX": 1.0049, + "scY": 0.9982, + "x": 14.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.3, + "scX": 0.999, + "x": 16.75 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -10.85, + "skX": 1.7556, + "skY": 1.7583, + "scX": 1.0008, + "x": -4.15 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2.8, + "skX": 8.7821, + "skY": 8.7805, + "scX": 0.9991, + "scY": 0.9994, + "x": -5.75 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -8.05, + "skX": 15.0552, + "skY": 15.0559, + "scX": 0.9974, + "scY": 0.9992, + "x": -7.55 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -17.85, + "skX": 28.8664, + "skY": 28.8666, + "scX": 0.9897, + "scY": 0.9991, + "x": -10.55 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -24.1, + "skX": 47.6881, + "skY": 47.6814, + "scX": 0.9656, + "scY": 1.0002, + "x": -15.45 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -14.5, + "skX": 56.4569, + "skY": 56.4521, + "scX": 0.9566, + "scY": 1.001, + "x": -15.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -10.05, + "skX": 54.9538, + "skY": 54.9501, + "scX": 0.9602, + "scY": 1.0009, + "x": -15.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 1.6, + "skX": 48.189, + "skY": 48.1838, + "scX": 0.9672, + "scY": 1.0002, + "x": -14.9 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.85, + "skX": 39.9103, + "skY": 39.9075, + "scX": 0.9635, + "scY": 0.9996, + "x": -14.4 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.75, + "skX": 32.1298, + "skY": 32.1271, + "scX": 0.971, + "scY": 0.9992, + "x": -13.8 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -6.1, + "skX": 12.5454, + "skY": 12.5447, + "scX": 0.993, + "scY": 0.9993, + "x": -11.95 + }, + "tweenEasing": 0 + }, + { + "duration": 6, + "transform": { + "y": -9.45, + "skX": 5.0166, + "skY": 5.0169, + "scX": 0.9989, + "scY": 0.9996, + "x": -10.85 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -15.3, + "skX": -4.2618, + "skY": -4.2608, + "scX": 1.0018, + "scY": 1.0004, + "x": -4.9 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -10.85, + "skX": 1.7556, + "skY": 1.7583, + "scX": 1.0008, + "x": -4.15 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": -11.35, + "skX": 8.7547, + "skY": 8.7549, + "scX": 0.9864, + "scY": 0.999, + "x": -10.5 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -6.75, + "skX": 8.5031, + "skY": 8.5048, + "scX": 0.9816, + "scY": 0.999, + "x": -9.3 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -16.4, + "skX": 8.7549, + "skY": 8.7555, + "scX": 0.984, + "scY": 0.999, + "x": -8.75 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -11.35, + "skX": 9.0056, + "skY": 9.0057, + "scX": 1.0044, + "scY": 0.999, + "x": -10.5 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -2.3, + "skX": 9.2556, + "skY": 9.2542, + "scX": 1.0118, + "scY": 0.999, + "x": -12.45 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -9.95, + "skX": 9.5045, + "skY": 9.5052, + "scX": 1.0123, + "scY": 0.9989, + "x": -12.45 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -11.35, + "skX": 8.7547, + "skY": 8.7549, + "scX": 0.9864, + "scY": 0.999, + "x": -10.5 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": -0.18, + "skX": -5.5, + "skY": -5.5135, + "scX": 0.9997, + "scY": 1.001, + "x": -0.09 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.05, + "skX": -5.2163, + "skY": -5.2966, + "scX": 0.9997, + "scY": 1.0072, + "x": 0.14 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.03, + "skX": -5.4472, + "skY": -5.5673, + "scX": 0.9998, + "scY": 1.0109, + "x": 0.3 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.01, + "skX": -5.9558, + "skY": -6.0573, + "scX": 0.9997, + "scY": 1.0092, + "x": 0.12 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.12, + "skX": -6.5087, + "skY": -6.5003, + "scX": 0.9997, + "scY": 0.9991, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -0.25, + "skX": -6.7986, + "skY": -6.7138, + "scX": 0.9996, + "scY": 0.992, + "x": -0.27 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.18, + "skX": -5.5, + "skY": -5.5135, + "scX": 0.9997, + "scY": 1.001, + "x": -0.09 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.4, + "skX": 7.0054, + "skY": 7.0071, + "scX": 0.9748, + "scY": 0.9992, + "x": -16.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -17.5, + "skX": 28.5597, + "skY": 28.5583, + "scX": 1.0043, + "scY": 0.9972, + "x": -20.95 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -24.25, + "skX": 21.5371, + "skY": 21.5363, + "scX": 1.0169, + "scY": 0.9977, + "x": 2.05 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -26.2, + "skX": 16.5221, + "skY": 16.5229, + "scX": 1.0189, + "scY": 0.9982, + "x": 15.95 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -30.85, + "skX": 11.2628, + "skY": 11.2628, + "scX": 1.0148, + "scY": 0.9987, + "x": 43.9 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -30.5, + "skX": 8.2592, + "skY": 8.2575, + "scX": 1.0131, + "scY": 0.9991, + "x": 56 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -6.25, + "skX": -15.0159, + "skY": -15.0143, + "scX": 1.017, + "scY": 0.9984, + "x": 101.45 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 7.85, + "skX": -1.25, + "skY": -1.2509, + "scX": 1.0029, + "scY": 0.9998, + "x": 102.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 7.8, + "skX": -0.625, + "skY": -0.6254, + "scX": 1.0016, + "x": 101.125 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 7.75, + "scX": 1.0003, + "x": 99.65 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 7.05, + "skX": 0.0035, + "skY": 0.0035, + "scX": 0.9988, + "x": 76.2 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 6.35, + "scX": 0.9979, + "x": 50.75 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 4.35, + "skX": 0.7527, + "skY": 0.7518, + "scX": 0.9933, + "x": 7.9 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.4, + "skX": 7.0054, + "skY": 7.0071, + "scX": 0.9748, + "scY": 0.9992, + "x": -16.75 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -11.8, + "skX": 23.2823, + "skY": 23.2807, + "scX": 1.0012, + "scY": 1.0018, + "x": -17.1 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.75, + "skX": 12.2765, + "skY": 12.2735, + "scX": 1.0078, + "scY": 1.0012, + "x": -14.2 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -5.4, + "skX": 5.5145, + "skY": 5.5127, + "scX": 1.0083, + "scY": 1.0005, + "x": -11.15 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -8.25, + "skX": -1.0013, + "skY": -1.0056, + "scX": 1.0099, + "scY": 0.9998, + "x": -9.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -14.85, + "skX": -15.3018, + "skY": -15.3079, + "scX": 1.0115, + "scY": 0.999, + "x": -6.85 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -18.05, + "skX": -21.8297, + "skY": -21.8354, + "scX": 1.0114, + "scY": 0.9988, + "x": -5.75 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -21.25, + "skX": -32.626, + "skY": -32.632, + "scX": 1.0082, + "scY": 0.999, + "x": -3.6 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -17, + "skX": -20.5755, + "skY": -20.5791, + "scX": 1.0115, + "scY": 0.9988, + "x": -4.5 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -12.7, + "skX": -15.0502, + "skY": -15.0562, + "scX": 1.0109, + "scY": 0.999, + "x": -5.55 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -6.3, + "skX": -20.0717, + "skY": -20.0779, + "scX": 1.0114, + "scY": 0.9989, + "x": -6.7 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -5.55, + "skX": -19.0685, + "skY": -19.0725, + "scX": 1.0093, + "scY": 0.9989, + "x": -10.45 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -13.95, + "skX": -5.767, + "skY": -5.77, + "scX": 1.0024, + "scY": 0.9995, + "x": -13 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -22.55, + "skX": 15.5262, + "skY": 15.5271, + "scX": 0.9958, + "scY": 1.0016, + "x": -16.3 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -11.8, + "skX": 23.2823, + "skY": 23.2807, + "scX": 1.0012, + "scY": 1.0018, + "x": -17.1 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": 0.66, + "skX": 9.4644, + "skY": 9.6617, + "scX": 0.9857, + "scY": 0.9996, + "x": 1.86 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 1.24, + "skX": 6.8557, + "skY": 8.4041, + "scX": 0.8951, + "scY": 0.9983, + "x": 0.3 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 1.82, + "skX": 5.8718, + "skY": 7.4208, + "scX": 0.8951, + "scY": 0.9983, + "x": -0.57 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 1.85, + "skX": 11.6349, + "skY": 13.1834, + "scX": 0.8952, + "scY": 0.9984, + "x": 1.19 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.6, + "skX": 13.0119, + "skY": 12.1388, + "scX": 1.0644, + "scY": 1.0008, + "x": 3.01 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": -0.16, + "skX": 11.7217, + "skY": 9.922, + "scX": 1.1373, + "scY": 1.0019, + "x": 3.6 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.66, + "skX": 9.4644, + "skY": 9.6617, + "scX": 0.9857, + "scY": 0.9996, + "x": 1.86 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 4, + "transform": { + "y": 0.27, + "skX": -12.9031, + "skY": -12.9031, + "scX": 0.9997, + "x": 0.2 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.3, + "skX": -11.6123, + "skY": -11.6123, + "scX": 0.9996, + "scY": 0.9998, + "x": -0.16 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.42, + "skX": -10.609, + "skY": -10.6081, + "scX": 0.9995, + "scY": 0.9998, + "x": -0.9 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.35, + "skX": -16.1317, + "skY": -16.1317, + "scX": 0.9993, + "scY": 0.9998, + "x": 0.14 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.17, + "skX": -14.8927, + "skY": -14.8927, + "scX": 0.9995, + "scY": 0.9998, + "x": 0.41 + }, + "tweenEasing": 0 + }, + { + "duration": 8, + "transform": { + "y": 0.19, + "skX": -12.7133, + "skY": -12.7133, + "scX": 0.9996, + "x": 0.41 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.27, + "skX": -12.9031, + "skY": -12.9031, + "scX": 0.9997, + "x": 0.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 30, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.2, + "name": "walk", + "playTimes": 0 + }, + { + "duration": 3, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.08, + "skX": -0.0054, + "skY": -0.0046, + "scX": 1.002, + "scY": 1.0006, + "x": 0.19 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.1, + "skX": -0.0054, + "skY": -0.0046, + "scX": 1.002, + "scY": 1.0006, + "x": 0.18 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.48, + "skX": 4.4951, + "skY": 4.5075, + "scX": 1.0004, + "scY": 1.0015, + "x": -0.78 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.86, + "skX": 7.4976, + "skY": 7.5101, + "scX": 1.0004, + "scY": 1.0015, + "x": -1.1 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 13.534, + "skX": -7.269, + "skY": -7.269, + "scX": 0.9988, + "scY": 1.0015, + "x": -17.524 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 15.434, + "skX": -7.269, + "skY": -7.269, + "scX": 0.9988, + "scY": 1.0015, + "x": -17.524 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 13.834, + "skX": -1.7543, + "skY": -1.7543, + "scX": 0.9998, + "x": -17.574 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 15.734, + "skX": -1.7543, + "skY": -1.7543, + "scX": 0.9998, + "x": -17.574 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.1, + "skX": -4.5063, + "skY": -4.5021, + "scX": 0.9997, + "scY": 0.9995, + "x": -0.05 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.33, + "skX": -5.7548, + "skY": -5.7494, + "scX": 0.9996, + "scY": 0.9992, + "x": -0.03 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 14.134, + "skX": 8.2707, + "skY": 8.2663, + "scX": 1.0112, + "scY": 1.0015, + "x": -17.674 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 16.034, + "skX": 8.2707, + "skY": 8.2663, + "scX": 1.0112, + "scY": 1.0015, + "x": -17.674 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.37, + "skX": 4.4953, + "skY": 4.5082, + "scX": 1.0005, + "scY": 1.0015, + "x": 0.66 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.89, + "skX": 7.4979, + "skY": 7.5107, + "scX": 1.0005, + "scY": 1.0015, + "x": 1.13 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.05, + "skX": -0.0061, + "skY": -0.0061, + "scX": 1.0017, + "scY": 1.0005, + "x": 0.15 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.06, + "skX": -0.0061, + "skY": -0.0061, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.21 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_r" + } + ], + "fadeInTime": 0.2, + "name": "attack_01", + "playTimes": 5 + }, + { + "duration": 9, + "frame": [ + { + "duration": 4, + "tweenEasing": null + }, + { + "duration": 5, + "tweenEasing": null, + "events": [ + { + "name": "step", + "bone": "foot_l" + } + ] + }, + { + "duration": 0, + "action": "attack_02_1", + "tweenEasing": null + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.19, + "skY": 0.0009, + "scX": 0.9998 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.19, + "skY": 0.0009, + "scX": 1.0011, + "scY": 1.0003, + "x": 0.37 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.34 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -1.27, + "skX": 6.0331, + "skY": 6.0331, + "x": -0.86 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.89, + "skX": 4.524, + "skY": 4.524, + "x": -1.17 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.16, + "skX": 0.0044, + "skY": 0.0044, + "x": -0.45 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -15.75, + "x": -60.15 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -4.85, + "x": -110.7 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -4.85, + "x": -110.7 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -28.65, + "skX": 47.9363, + "skY": 47.934, + "scX": 0.9793, + "scY": 1.0002, + "x": -19.85 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -17.3, + "skX": 92.2581, + "skY": 92.2557, + "scX": 0.9465, + "x": -39.65 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 18.95, + "skX": 48.1876, + "skY": 48.1844, + "scX": 0.9767, + "scY": 1.0002, + "x": -55.2 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 19.15, + "x": -56 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -1.55, + "skX": -5.9764, + "skY": -6.0331, + "scX": 0.9994, + "scY": 1.0047, + "x": 35.55 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": -0.1, + "skX": -4.4827, + "skY": -4.524, + "scX": 0.9995, + "scY": 1.0035, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.1, + "skX": -0.0026, + "skY": -0.0044, + "scY": 1.0002, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -29.5, + "skX": 9.5199, + "skY": 9.5204, + "scX": 0.9925, + "scY": 1.0009, + "x": -20.5 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 19.4, + "skX": -35.3872, + "skY": -35.392, + "scX": 1.0113, + "scY": 0.999, + "x": -56.8 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 1.38, + "skX": 6.0331, + "skY": 6.0331, + "x": 1.16 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.32, + "skX": 4.524, + "skY": 4.524, + "x": 1.44 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.43, + "skX": 0.0044, + "skY": 0.0044, + "x": 0.93 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": 0.23, + "skY": -0.0009, + "scX": 0.9996, + "scY": 0.9998 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 0.22, + "scX": 1.0008, + "scY": 1.0003, + "x": 0.38 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.24, + "scX": 1.0016, + "scY": 1.0005, + "x": 0.37 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 9, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 9, + "actions": [ + { + "gotoAndPlay": "prepare_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 9, + "actions": [ + { + "gotoAndPlay": "prepare_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_r" + } + ], + "fadeInTime": 0.2, + "name": "attack_02" + }, + { + "duration": 3, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.34 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "action": "fire_01", + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.33 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.16, + "skX": 0.0044, + "skY": 0.0044, + "x": -0.45 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.72, + "skX": 3.5184, + "skY": 3.5184, + "x": -0.9 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": { + "y": -4.85, + "x": -110.7 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 18.95, + "skX": 48.1876, + "skY": 48.1844, + "scX": 0.9767, + "scY": 1.0002, + "x": -55.2 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 22, + "skX": 46.6831, + "skY": 46.6806, + "scX": 0.9778, + "x": -56.4 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 19.15, + "x": -56 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 22.25, + "x": -57.2 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.1, + "skX": -0.0026, + "skY": -0.0044, + "scY": 1.0002, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.1, + "skX": -3.4856, + "skY": -3.5184, + "scX": 0.9996, + "scY": 1.0029, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 19.4, + "skX": -35.3872, + "skY": -35.392, + "scX": 1.0113, + "scY": 0.999, + "x": -56.8 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 22.55, + "skX": -39.4031, + "skY": -39.4078, + "scX": 1.0107, + "scY": 0.9992, + "x": -58 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.43, + "skX": 0.0044, + "skY": 0.0044, + "x": 0.93 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 0.12, + "skX": 3.5184, + "skY": 3.5184, + "x": 1.51 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.24, + "scX": 1.0016, + "scY": 1.0005, + "x": 0.37 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "action": "fire_01", + "transform": { + "y": 0.18, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.39 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + }, + { + "duration": 0, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 3, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 3, + "actions": [ + { + "gotoAndPlay": "fire_01" + } + ], + "tweenEasing": null + } + ], + "name": "weapon_r" + } + ], + "fadeInTime": 0.1, + "name": "attack_02_1", + "playTimes": 10 + }, + { + "duration": 10, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.04, + "scX": 1.0015, + "scY": 1.0005, + "x": -0.02 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.36, + "skX": -20.7464, + "skY": -20.7456, + "scX": 0.9988, + "scY": 0.9996, + "x": 0.2 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.14, + "skX": 8.9426, + "skY": 8.9434, + "scX": 0.9982, + "scY": 0.9994, + "x": 0.44 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.19, + "skX": 5.5746, + "skY": 5.5754, + "scX": 0.9974, + "scY": 0.9991, + "x": 0.49 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.13, + "skX": 47.427, + "skY": 47.4278, + "scX": 0.9977, + "scY": 0.9992, + "x": 0.56 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.09, + "skX": 52.6335, + "skY": 52.6343, + "scX": 0.9973, + "scY": 0.9991, + "x": 0.51 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -2.07, + "skX": 12.0717, + "skY": 12.0717, + "x": -1.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2.5, + "skX": -1.9074, + "skY": -1.9139, + "x": -1.87 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 2.88, + "skX": -8.0387, + "skY": -8.0452, + "x": 3.68 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 1.72, + "skX": -1.6311, + "skY": -1.6376, + "x": 1.42 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 3.09, + "skX": -28.3747, + "skY": -28.3747, + "x": 4.47 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 3.2, + "skX": -16.7919, + "skY": -16.7984, + "x": 5.39 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 6, + "transform": { + "y": -5, + "x": -114.2 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -5, + "x": -114.2 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -14.05, + "skX": 10.0352, + "skY": 10.0352, + "scX": 1.0014, + "scY": 0.9993, + "x": 15.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -24.4, + "skX": 54.7039, + "skY": 54.6998, + "scX": 0.9738, + "scY": 1.0008, + "x": -51.9 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 45, + "skX": 31.1254, + "skY": 31.1262, + "scX": 0.9895, + "scY": 0.9991, + "x": -81.7 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 35.8, + "skX": 28.1119, + "skY": 28.1111, + "scX": 0.993, + "scY": 0.9991, + "x": -81.75 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 44.8, + "skX": 17.8174, + "skY": 17.8178, + "scX": 0.9986, + "scY": 0.9991, + "x": -87.3 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 45.8, + "skX": 16.3115, + "skY": 16.3114, + "scX": 0.9993, + "scY": 0.9991, + "x": -87.9 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 44.8, + "skX": 16.8133, + "skY": 16.8129, + "scX": 0.9992, + "scY": 0.9991, + "x": -87.3 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -14.25, + "skX": -1.7519, + "skY": -1.7533, + "scX": 1.0015, + "scY": 0.9997, + "x": 15.55 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -24.75, + "skX": 12.2581, + "skY": 12.2593, + "scX": 0.9907, + "scY": 0.9986, + "x": -52.7 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 45.6, + "skX": -6.5047, + "skY": -6.5058, + "scX": 1.0051, + "scY": 0.9993, + "x": -82.85 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 36.25, + "skX": -6.5047, + "skY": -6.5058, + "scX": 1.0051, + "scY": 0.9993, + "x": -82.9 + }, + "tweenEasing": 0 + }, + { + "duration": 3, + "transform": { + "y": 45.35, + "skX": -6.5047, + "skY": -6.5058, + "scX": 1.0051, + "scY": 0.9993, + "x": -88.5 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -0.08, + "skX": -10.2014, + "skY": -10.3185, + "scX": 0.9988, + "scY": 1.0096 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.12, + "skX": -24.2129, + "skY": -24.3318, + "scX": 0.9988, + "scY": 1.0097, + "x": 0.06 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.13, + "skX": 30.9807, + "skY": 31.1144, + "scX": 0.9974, + "scY": 0.985, + "x": -0.12 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.17, + "skX": 19.224, + "skY": 19.3108, + "scX": 0.9985, + "scY": 0.9906, + "x": -0.12 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": -0.07, + "skX": 25.9728, + "skY": 26.0924, + "scX": 0.9978, + "scY": 0.9869, + "x": -0.09 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.84, + "skX": 34.7399, + "skY": 34.8805, + "scX": 0.9972, + "scY": 0.9841, + "x": -1.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.07, + "skX": 38.5028, + "skY": 38.6462, + "scX": 0.9969, + "scY": 0.9836, + "x": -0.09 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.2, + "x": -26.7 + }, + "tweenEasing": 0 + }, + { + "duration": 4, + "transform": { + "y": -2, + "x": -43.6 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2, + "x": -43.6 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 10, + "transform": { + "y": -0.21, + "skX": -23.7864, + "skY": -23.7989, + "scX": 0.9872, + "scY": 0.9984, + "x": 0.12 + }, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 10, + "transform": { + "y": -0.04, + "skX": 28.5439, + "skY": 28.5391, + "scX": 0.9903, + "scY": 0.9993, + "x": 0.32 + }, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": -14.4, + "skX": 7.7667, + "skY": 7.7665, + "scX": 0.9946, + "scY": 1.0007, + "x": 15.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -25.15, + "skX": -4.7653, + "skY": -4.7658, + "scX": 1.0019, + "scY": 0.9996, + "x": -53.5 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 46.15, + "skX": 8.5209, + "skY": 8.5185, + "scX": 0.9989, + "scY": 1.0008, + "x": -84 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 36.7, + "skX": -12.0389, + "skY": -12.0428, + "scX": 1.008, + "scY": 0.9992, + "x": -84.1 + }, + "tweenEasing": 0 + }, + { + "duration": 1, + "transform": { + "y": 45.95, + "skX": -5.2656, + "skY": -5.2681, + "scX": 1.0059, + "scY": 0.9996, + "x": -89.75 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 46.95, + "skX": 0.7538, + "skY": 0.7506, + "scX": 1.0032, + "x": -90.35 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 45.95, + "skX": 0.5035, + "skY": 0.5004, + "scX": 1.0031, + "x": -89.75 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 1.98, + "skX": 12.0717, + "skY": 12.0717, + "x": 1.21 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 2.32, + "skX": -26.7681, + "skY": -26.7747, + "scX": 0.7204, + "scY": 0.9983, + "x": 2.18 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -4.33, + "skX": 1.9651, + "skY": 1.9585, + "scX": 0.8952, + "scY": 0.9985, + "x": -2.87 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -2.65, + "skX": -10.8838, + "skY": -10.8904, + "scX": 0.9907, + "scY": 1.0009, + "x": -0.64 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -4.74, + "skX": -32.6458, + "skY": -32.6387, + "scX": 0.9997, + "scY": 1.0002, + "x": -3.51 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -5.12, + "skX": -24.7198, + "skY": -24.7264, + "scX": 1.0003, + "x": -4.15 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 2, + "transform": { + "y": 0.02, + "skY": -0.0009, + "scX": 1.0013, + "scY": 1.0004, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.22, + "skX": 11.8408, + "skY": 11.8408, + "scX": 0.9986, + "scY": 0.9996, + "x": 9.24 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.14, + "skX": 7.9952, + "skY": 7.9952, + "scX": 0.9993, + "scY": 0.9998, + "x": 0.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.56, + "skX": 19.4318, + "skY": 19.4318, + "scX": 0.9968, + "scY": 0.999, + "x": 11.53 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.54, + "skX": 48.2468, + "skY": 48.2468, + "scX": 0.9976, + "scY": 0.9992, + "x": 11.64 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -1.55, + "skX": 57.4615, + "skY": 57.4615, + "scX": 0.9969, + "scY": 0.999, + "x": 11.65 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 10, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "death" + }, + { + "duration": 8, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.04, + "scX": 0.9989, + "scY": 0.9996, + "x": -0.02 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 0.17, + "skY": 0.0009, + "scX": 1.0013, + "scY": 1.0004, + "x": 0.26 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.23, + "skY": 0.0017, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.28 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.15, + "skY": 0.0009, + "scX": 1.0019, + "scY": 1.0006, + "x": 0.21 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.07, + "skX": 12.0717, + "skY": 12.0717, + "x": -1.35 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 0.18, + "skX": -3.0111, + "skY": -3.0111, + "x": 0.04 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -0.36, + "skX": -9.4689, + "skY": -9.4689, + "x": 9.94 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 1.45, + "skX": -12.052, + "skY": -12.052, + "x": 1.5 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -8.45, + "x": -53 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -1.25, + "x": -78.8 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -14.05, + "skX": 10.0352, + "skY": 10.0352, + "scX": 1.0014, + "scY": 0.9993, + "x": 15.35 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -1.35, + "skX": -8.0191, + "skY": -8.0191, + "scX": 0.9964, + "scY": 1.0008, + "x": -51.85 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 2, + "skX": 1.003, + "skY": 1.0023, + "scX": 1.0002, + "x": -61.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 7.1, + "skX": 6.0193, + "skY": 6.02, + "scX": 1.0013, + "scY": 0.9996, + "x": -54.65 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -14.25, + "skX": -1.7519, + "skY": -1.7533, + "scX": 1.0015, + "scY": 0.9997, + "x": 15.55 + }, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -1.4, + "skX": 12.2581, + "skY": 12.2593, + "scX": 0.9907, + "scY": 0.9986, + "x": -52.6 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 7.15, + "skX": 10.5078, + "skY": 10.507, + "scX": 0.9919, + "scY": 0.9989, + "x": -55.45 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.08, + "skX": -10.2014, + "skY": -10.3185, + "scX": 0.9988, + "scY": 1.0096 + }, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -0.09, + "skX": -9.2713, + "skY": -9.2481, + "scX": 0.9996, + "scY": 0.9976, + "x": -0.05 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -0.09, + "skX": 1.4611, + "skY": 1.5451, + "scX": 0.9986, + "scY": 0.991, + "x": -0.05 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -1.2, + "x": -26.7 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -14.4, + "skX": 7.7667, + "skY": 7.7665, + "scX": 0.9946, + "scY": 1.0007, + "x": 15.75 + }, + "tweenEasing": 0 + }, + { + "duration": 7, + "transform": { + "y": -1.45, + "skX": -7.5225, + "skY": -7.525, + "scX": 1.0041, + "scY": 0.9994, + "x": -53.35 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 7.25, + "skX": -1.0033, + "skY": -1.0035, + "scX": 1.0007, + "scY": 0.9998, + "x": -56.25 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 1.98, + "skX": 12.0717, + "skY": 12.0717, + "x": 1.21 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": -0.54, + "skX": -3.0111, + "skY": -3.0111, + "x": 0.42 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": -3.08, + "skX": -9.4689, + "skY": -9.4689, + "x": 8.58 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": -1.98, + "skX": -12.052, + "skY": -12.052, + "x": -0.92 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.02, + "skY": -0.0009, + "scX": 0.9986, + "scY": 0.9995, + "x": -0.1 + }, + "tweenEasing": 0 + }, + { + "duration": 5, + "transform": { + "y": 0.24, + "scX": 1.001, + "scY": 1.0004, + "x": 0.17 + }, + "tweenEasing": 0 + }, + { + "duration": 2, + "transform": { + "y": 0.29, + "scX": 1.0014, + "scY": 1.0005, + "x": 0.27 + }, + "tweenEasing": 0 + }, + { + "duration": 0, + "transform": { + "y": 0.18, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.26 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 8, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "hit" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.24, + "skY": 0.0009, + "scX": 0.9983, + "scY": 0.9994, + "x": 0.18 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 2.18, + "skX": -17.0743, + "skY": -17.0743, + "x": 3.04 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.25, + "x": -51.4 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 32.95, + "skX": 28.6151, + "skY": 28.6146, + "scX": 0.9929, + "scY": 0.9991, + "x": -5.9 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 33.35, + "x": -5.95 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": 16.9669, + "skY": 17.0743, + "scX": 0.9981, + "scY": 0.9882, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -23.137, + "skY": -23.137, + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.95, + "x": 20.4 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 33.85, + "skX": -1.0021, + "skY": -1.0039, + "scX": 1.002, + "scY": 0.9998, + "x": -6 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.82, + "skX": -17.0743, + "skY": -17.0743, + "x": -2.45 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.18, + "skY": 0.0009, + "scX": 0.9985, + "scY": 0.9995, + "x": 0.18 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_1" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.01, + "skY": 0.0009, + "scX": 1.0016, + "scY": 1.0005, + "x": 0.05 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.03, + "skX": 12.0717, + "skY": 12.0717, + "x": -1.6 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 10.8, + "skX": 57.6806, + "skY": 57.68, + "scX": 0.9907, + "scY": 0.997, + "x": -83.05 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.2, + "skX": 46.6827, + "skY": 46.6812, + "scX": 0.9819, + "x": -5.9 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": 25.2948, + "skY": 25.2935, + "scX": 0.9847, + "scY": 0.9974, + "x": -5.95 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.71, + "skX": -37.2482, + "skY": -37.3652, + "scX": 0.9988, + "scY": 1.0096, + "x": -0.2 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": 1.2365, + "skY": 1.2365 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -8.75, + "skX": 57.68, + "skY": 57.6793, + "scX": 0.9908, + "scY": 0.997, + "x": -44.3 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": 31.0364, + "skY": 31.0434, + "scX": 0.9759, + "scY": 1.0009, + "x": -6.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 1.82, + "skX": 12.0717, + "skY": 12.0717, + "x": 1.49 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.08, + "scX": 0.9997, + "x": 0.11 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_2" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 3.11, + "skX": -29.9982, + "skY": -29.9974, + "scX": 1.002, + "scY": 1.0007, + "x": -2.66 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.01, + "skX": 12.0701, + "skY": 12.0703, + "x": -1.62 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 29.9, + "skX": -16.3344, + "skY": -16.3344, + "scX": 0.9907, + "scY": 0.997, + "x": -20.7 + }, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.2, + "skX": 27.2191, + "skY": 27.2173, + "scX": 0.9818, + "x": -5.9 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": 25.2948, + "skY": 25.2935, + "scX": 0.9847, + "scY": 0.9974, + "x": -5.95 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -16.22, + "skY": -16.22 + }, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.71, + "skX": -7.25, + "skY": -7.3656, + "scX": 0.9988, + "scY": 1.0096, + "x": -0.2 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -11.7614, + "skY": -11.7614 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 34.35, + "skX": -17.8725, + "skY": -17.8709, + "scX": 0.9908, + "scY": 0.997, + "x": 29.95 + }, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.25, + "skX": -6.4479, + "skY": -6.4395, + "scX": 0.9759, + "scY": 1.0009, + "x": -6.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 1.84, + "skX": 12.0708, + "skY": 12.071, + "x": 1.48 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.28, + "skX": -29.9989, + "skY": -29.9989, + "scX": 1.0018, + "scY": 1.0006, + "x": 2.58 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_3" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 2.26, + "skX": -24.1896, + "skY": -24.1887, + "scX": 1.002, + "scY": 1.0007, + "x": -2.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.91, + "skX": -5.0202, + "skY": -5.0216, + "x": 0.77 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 37.6, + "skX": 7.7638, + "skY": 7.7638, + "scX": 0.9429, + "scY": 0.9992, + "x": 0.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 38.1, + "x": 0.1 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.05, + "skX": 29.1728, + "skY": 29.2112, + "scX": 0.9994, + "scY": 0.9959, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "skX": -22.362, + "skY": -22.362, + "scX": 0.5, + "scY": 0.5 + }, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 38.65, + "skX": 11.7477, + "skY": 11.7432, + "scX": 0.9828, + "scY": 1.0009, + "x": 0.15 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -1.46, + "skX": -5.0204, + "skY": -5.0211, + "x": -0.78 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.18, + "skX": -24.1901, + "skY": -24.1901, + "scX": 1.0018, + "scY": 1.0006, + "x": 0.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + }, + { + "duration": 0, + "displayIndex": -1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_f" + }, + { + "frame": [ + { + "duration": 1, + "tweenEasing": null, + "color": { + "aM": 0 + } + }, + { + "duration": 0, + "displayIndex": -1, + "tweenEasing": null, + "color": { + "aM": 0 + } + } + ], + "name": "effects_b" + } + ], + "fadeInTime": 0.1, + "name": "jump_4" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.16, + "skY": 0.0009, + "scX": 1.0015, + "scY": 1.0004, + "x": 0.19 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.9, + "skX": -5.0198, + "skY": -5.0198, + "x": 0.83 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 37.6, + "skX": -6.3646, + "skY": -6.3646, + "scX": 0.9429, + "scY": 0.9992, + "x": 0.05 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 38.1, + "x": 0.1 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.05, + "skX": 5.0015, + "skY": 5.0013, + "scX": 0.9994, + "scY": 0.9959, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 22.4, + "skX": 19.7978, + "skY": 19.7933, + "scX": 1.0112, + "scY": 1.0015, + "x": -6.7 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -1.38, + "skX": -5.0198, + "skY": -5.0198, + "x": -0.75 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.22, + "scX": 1.001, + "scY": 1.0002, + "x": 0.21 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "squat" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.09, + "skX": -20.5765, + "skY": -20.5756, + "scX": 1.002, + "scY": 1.0007, + "x": 0.13 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.41, + "skX": -16.7092, + "skY": -16.695, + "scX": 1.0004, + "scY": 1.0015, + "x": -0.79 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 20.85, + "skX": -5.0134, + "skY": -5.0141, + "scX": 0.9986, + "scY": 1.0014, + "x": -6.55 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 21.15, + "skX": -23.2231, + "skY": -23.2231, + "x": -6.6 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.11, + "skX": -29.5028, + "skY": -29.5002, + "scX": 0.9997, + "scY": 0.9995, + "x": -0.06 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 21.45, + "skX": 7.2697, + "skY": 7.2648, + "scX": 1.011, + "scY": 1.0014, + "x": -6.7 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 0.44, + "skX": -16.7003, + "skY": -16.6872, + "scX": 1.0004, + "scY": 1.0015, + "x": 0.69 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.07, + "skX": -20.5843, + "skY": -20.5843, + "scX": 1.0017, + "scY": 1.0005, + "x": 0.2 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "aim_up" + }, + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 7.3, + "skX": 13.8338, + "skY": 13.8346, + "scX": 1.002, + "scY": 1.0007, + "x": -14.03 + }, + "tweenEasing": null + } + ], + "name": "weapon_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 2.72, + "skX": 19.4945, + "skY": 19.5066, + "scX": 1.0004, + "scY": 1.0015, + "x": 9.53 + }, + "tweenEasing": null + } + ], + "name": "shouder_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 29.0164, + "skX": -5.0138, + "skY": -5.0138, + "scX": 0.9986, + "scY": 1.0014, + "x": -3.8279 + }, + "tweenEasing": null + } + ], + "name": "thigh_l" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 21.15, + "skX": 35.6959, + "skY": 35.6959, + "x": -6.6 + }, + "tweenEasing": null + } + ], + "name": "pelvis" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.12, + "skX": 20.9537, + "skY": 20.9586, + "scX": 0.9997, + "scY": 0.9995, + "x": -0.1 + }, + "tweenEasing": null + } + ], + "name": "chest" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "foot_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "thigh_1_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "calf_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": 11.9358, + "skX": 0.0022, + "skY": -0.0022, + "x": -9.3081 + }, + "tweenEasing": null + } + ], + "name": "thigh_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -2.7, + "skX": 19.494, + "skY": 19.5068, + "scX": 1.0004, + "scY": 1.0015, + "x": -9.69 + }, + "tweenEasing": null + } + ], + "name": "shouder_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": { + "y": -0.07, + "skX": 13.8335, + "skY": 13.8335, + "scX": 1.0017, + "scY": 1.0005, + "x": 0.14 + }, + "tweenEasing": null + } + ], + "name": "weapon_r" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_b" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "effects_f" + } + ], + "slot": [], + "fadeInTime": 0.1, + "name": "aim_down" + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/back_l", + "transform": { + "y": 0.9655, + "skX": -1.9759, + "skY": -1.9759, + "x": -10.0006 + } + } + ], + "name": "back" + }, + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0001", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0002", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0003", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + } + ], + "name": "front" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "inheritScale": 0, + "transform": { + "y": -8, + "x": 81 + }, + "name": "fire", + "parent": "root" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 151.9727, + "y": -21.0345, + "height": 44, + "x": -68.0006 + }, + "slot": [ + { + "name": "back", + "parent": "root", + "color": {} + }, + { + "z": 1, + "name": "front", + "parent": "root", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "weapon_1502b_l", + "ik": [], + "animation": [ + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [], + "name": "idle" + }, + { + "duration": 2, + "frame": [ + { + "duration": 0, + "tweenEasing": null, + "events": [ + { + "name": "fire", + "bone": "fire" + } + ] + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + }, + { + "duration": 1, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 0, + "displayIndex": 2, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "fire_01" + }, + { + "duration": 6, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 2, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 2, + "tweenEasing": null + }, + { + "duration": 0, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "prepare_01", + "playTimes": 0 + } + ] + }, + { + "skin": [ + { + "name": "", + "slot": [ + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/back_r", + "transform": { + "y": 1.5324, + "skX": -1.9759, + "skY": -1.9759, + "x": -10.4813 + } + } + ], + "name": "back" + }, + { + "display": [ + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0001", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0002", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + }, + { + "type": "image", + "name": "weapon_1502b_folder/image/paoguan_0003", + "transform": { + "y": -2.6705, + "skX": -1.9759, + "skY": -1.9759, + "x": 36.9721 + } + } + ], + "name": "front" + } + ] + } + ], + "bone": [ + { + "transform": {}, + "name": "root" + }, + { + "inheritScale": 0, + "transform": { + "y": -7, + "x": 81 + }, + "name": "fire", + "parent": "root" + } + ], + "type": "Armature", + "frameRate": 24, + "aabb": { + "width": 154.9534, + "y": -20.9676, + "height": 45, + "x": -70.9813 + }, + "slot": [ + { + "name": "back", + "parent": "root", + "color": {} + }, + { + "z": 1, + "name": "front", + "parent": "root", + "color": {} + } + ], + "defaultActions": [ + { + "gotoAndPlay": "idle" + } + ], + "name": "weapon_1502b_r", + "ik": [], + "animation": [ + { + "duration": 1, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 1, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [], + "name": "idle" + }, + { + "duration": 2, + "frame": [ + { + "duration": 0, + "tweenEasing": null, + "events": [ + { + "name": "fire", + "bone": "fire" + } + ] + } + ], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 2, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 1, + "tweenEasing": null + }, + { + "duration": 1, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 0, + "displayIndex": 2, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "fire_01" + }, + { + "duration": 6, + "frame": [], + "ffd": [], + "bone": [ + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "fire" + }, + { + "frame": [ + { + "duration": 6, + "transform": {}, + "tweenEasing": null + } + ], + "name": "root" + } + ], + "slot": [ + { + "frame": [ + { + "duration": 2, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 1, + "tweenEasing": null + }, + { + "duration": 2, + "displayIndex": 2, + "tweenEasing": null + }, + { + "duration": 0, + "tweenEasing": null + } + ], + "name": "front" + } + ], + "name": "prepare_01", + "playTimes": 0 + } + ] + } + ], + "name": "mecha_1502b", + "version": "5.0" +} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_tex.json b/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_tex.json new file mode 100644 index 0000000..9452b23 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_tex.json @@ -0,0 +1 @@ +{"width":512,"SubTexture":[{"width":74,"y":93,"height":20,"name":"bullet_01_f/bullet_01","x":307},{"width":48,"y":1,"height":38,"name":"fire_effect_01_f/fireEffect","x":212},{"width":180,"y":430,"height":52,"name":"flame_01_f/ba_bu_flame1","x":1},{"frameY":0,"y":1,"frameWidth":86,"frameX":-2,"frameHeight":234,"width":81,"height":233,"name":"flame_01_f/bbb","x":1},{"width":44,"y":1,"height":39,"name":"mecha_1502b_folder/shouder_l_0","x":319},{"width":29,"y":77,"height":106,"name":"mecha_1502b_folder/foot_l_0","x":434},{"width":50,"y":185,"height":32,"name":"mecha_1502b_folder/thigh_1_l_0","x":434},{"width":122,"y":177,"height":46,"name":"mecha_1502b_folder/calf_l","x":84},{"width":101,"y":118,"height":57,"name":"mecha_1502b_folder/thigh_l","x":84},{"width":41,"y":77,"height":65,"name":"mecha_1502b_folder/pelvis","x":465},{"width":89,"y":236,"height":192,"name":"mecha_1502b_folder/chest","x":1},{"width":29,"y":77,"height":109,"name":"mecha_1502b_folder/foot_r","x":403},{"width":55,"y":1,"height":32,"name":"mecha_1502b_folder/thigh_1_r_1","x":262},{"width":126,"y":1,"height":52,"name":"mecha_1502b_folder/calf_r","x":84},{"width":103,"y":55,"height":61,"name":"mecha_1502b_folder/thigh_r","x":84},{"width":43,"y":144,"height":39,"name":"mecha_1502b_folder/shouder_r_1","x":465},{"width":116,"y":55,"height":44,"name":"weapon_1502b_folder/back_l","x":189},{"frameY":0,"y":39,"frameWidth":94,"frameX":0,"frameHeight":36,"width":93,"height":36,"name":"weapon_1502b_folder/image/paoguan_0002","x":403},{"width":94,"y":1,"height":36,"name":"weapon_1502b_folder/image/paoguan_0003","x":403},{"width":94,"y":55,"height":36,"name":"weapon_1502b_folder/image/paoguan_0001","x":307},{"width":121,"y":118,"height":45,"name":"weapon_1502b_folder/back_r","x":187}],"height":512,"name":"mecha_1502b","imagePath":"mecha_1502b_tex.png"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_tex.png b/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_tex.png new file mode 100644 index 0000000..368d0f3 Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/core_element/mecha_1502b_tex.png differ diff --git a/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_ske.json b/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_ske.json new file mode 100644 index 0000000..532c09f --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"armature":[{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"mecha_1003_folder/calf_r_0","transform":{"y":1.8721,"x":27.7907}}],"name":"calf_r"},{"display":[{"type":"image","name":"mecha_1003d_folder/thigh_l_0","transform":{"y":2.8796,"x":19.1837}}],"name":"thigh_l"},{"display":[{"type":"image","name":"mecha_1002_folder/upperarm_r_2","transform":{"y":2.5661,"skX":-99.6918,"skY":-99.6918}}],"name":"shouder_r"},{"display":[{"type":"image","name":"mecha_1004_folder/chest_1","transform":{"y":46.4064,"skX":89.5694,"skY":89.5694,"x":-8.7784}}],"name":"chest"},{"display":[{"type":"image","name":"mecha_1004d_folder/foot_l_0","transform":{"y":7.7385,"skX":90,"skY":90,"x":2.3128}}],"name":"foot_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_r_1","transform":{"y":-1.9,"skX":0.438,"skY":0.438,"x":21.55}}],"name":"thigh_1_r"},{"display":[{"type":"image","name":"mecha_1003_folder/calf_l_0","transform":{"y":4.1499,"x":26.8604}}],"name":"calf_l"},{"display":[{"type":"image","name":"mecha_1003d_folder/thigh_r_0","transform":{"y":-7.6009,"x":15.0357}}],"name":"thigh_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/pelvis","transform":{"y":7.5,"x":3.5}}],"name":"pelvis"},{"display":[{"type":"image","name":"mecha_1002_folder/upperarm_l_2","transform":{"y":-3.8492,"skX":-105.7978,"skY":-105.7978,"x":-0.8558}}],"name":"shouder_l"},{"display":[{"type":"image","name":"mecha_1004d_folder/foot_r_1","transform":{"y":9.2478,"skX":90,"skY":90,"x":2.5697}}],"name":"foot_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_l_0","transform":{"y":-2.95,"skX":0.1119,"skY":0.1128,"x":23}}],"name":"thigh_1_l"}]}],"bone":[{"transform":{},"name":"root"},{"length":20,"transform":{"y":-25,"scX":0.9955,"x":62.85},"parent":"root","inheritScale":0,"name":"foot_l"},{"length":40,"transform":{"y":-133.55,"skX":21.9887,"skY":21.9887,"scX":0.9995,"scY":0.9977,"x":8.3},"parent":"root","inheritScale":0,"name":"thigh_l"},{"length":42,"transform":{"y":-112.45,"skX":69.8809,"skY":69.8854,"scX":0.9876,"scY":0.9979,"x":-8.55},"parent":"root","inheritScale":0,"name":"thigh_r"},{"length":20,"transform":{"y":-123.15,"skX":-89.9991,"skY":-89.9991},"parent":"root","inheritScale":0,"name":"pelvis"},{"length":20,"transform":{"y":-4,"scX":0.9955,"x":-43.8},"parent":"root","inheritScale":0,"name":"foot_r"},{"length":50,"transform":{"y":-0.04,"skX":97.9614,"skY":97.9621,"scX":0.9894,"scY":0.9971,"x":40.11},"parent":"thigh_l","inheritScale":0,"name":"thigh_1_l"},{"length":20,"transform":{"skX":-90,"skY":-90,"x":13.75},"parent":"pelvis","inheritScale":0,"name":"chest"},{"length":53,"transform":{"y":-0.01,"skX":105.4235,"skY":105.423,"scX":0.9984,"scY":0.9995,"x":41.52},"parent":"thigh_r","inheritScale":0,"name":"thigh_1_r"},{"length":20,"transform":{"y":31.28,"scX":0.9965,"scY":0.9969,"x":13.74},"parent":"chest","inheritScale":0,"name":"shouder_r"},{"length":20,"transform":{"y":46.59,"scX":0.9965,"scY":0.9969,"x":-2.41},"parent":"chest","inheritScale":0,"name":"shouder_l"},{"inheritRotation":0,"length":100,"transform":{"y":3.13,"skX":130,"skY":130,"x":11.65},"parent":"chest","inheritScale":0,"name":"effects_b"},{"length":64,"transform":{"y":0.01,"skX":-70.8583,"skY":-70.864,"scX":1.0149,"scY":0.9967,"x":50.91},"parent":"thigh_1_l","inheritScale":0,"name":"calf_l"},{"inheritRotation":0,"length":100,"transform":{"y":-13.37,"skX":90,"skY":90,"x":-20.82},"parent":"chest","inheritScale":0,"name":"effects_f"},{"length":66,"transform":{"y":-0.02,"skX":-88.4874,"skY":-88.4933,"scX":0.9852,"scY":0.9996,"x":53.26},"parent":"thigh_1_r","inheritScale":0,"name":"calf_r"},{"length":100,"transform":{"skX":180,"skY":180,"scX":0.9982,"scY":0.9994,"x":5.98},"parent":"shouder_r","inheritScale":0,"name":"weapon_r"},{"length":100,"transform":{"y":0.04,"skX":180,"skY":180,"scX":0.998,"scY":0.9993,"x":5.6},"parent":"shouder_l","inheritScale":0,"name":"weapon_l"}],"type":"Armature","frameRate":24,"aabb":{"width":176.64362862645802,"y":-233.80623389915854,"height":281.5540549156089,"x":-95.10679917154837},"slot":[{"name":"shouder_l","parent":"shouder_l","color":{}},{"z":1,"name":"foot_l","parent":"foot_l","color":{}},{"z":2,"name":"thigh_1_l","parent":"thigh_1_l","color":{}},{"z":3,"name":"calf_l","parent":"calf_l","color":{}},{"z":4,"name":"thigh_l","parent":"thigh_l","color":{}},{"z":5,"name":"pelvis","parent":"pelvis","color":{}},{"z":6,"name":"chest","parent":"chest","color":{}},{"z":7,"name":"foot_r","parent":"foot_r","color":{}},{"z":8,"name":"thigh_1_r","parent":"thigh_1_r","color":{}},{"z":9,"name":"calf_r","parent":"calf_r","color":{}},{"z":10,"name":"thigh_r","parent":"thigh_r","color":{}},{"z":11,"name":"shouder_r","parent":"shouder_r","color":{}}],"defaultActions":[{"gotoAndPlay":"empty"}],"name":"skin_a","ik":[{"bone":"calf_l","chain":1,"bendPositive":"false","name":"calf_l","target":"foot_l"},{"bone":"calf_r","chain":1,"bendPositive":"false","name":"calf_r","target":"foot_r"}],"animation":[{"duration":0,"frame":[],"ffd":[],"bone":[{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"root"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"pelvis"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"chest"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_b"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_f"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_l"}],"slot":[],"name":"empty","playTimes":0}]},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"mecha_1003_folder/calf_r_0","transform":{"y":2.1179,"x":27.5723}}],"name":"calf_r"},{"display":[{"type":"image","name":"mecha_1008d_folder/thigh_r_0","transform":{"y":0.8121,"x":21.8806}}],"name":"thigh_r"},{"display":[{"type":"image","name":"mecha_1003_folder/foot_r_0","transform":{"y":10.5628,"skX":90,"skY":90}}],"name":"foot_r"},{"display":[{"type":"image","name":"mecha_1008d_folder/thigh_l_0","transform":{"y":-0.794,"x":21.2746}}],"name":"thigh_l"},{"display":[{"type":"image","name":"mecha_1003_folder/calf_l_0","transform":{"y":3.7974,"x":25.8031}}],"name":"calf_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_r_1","transform":{"y":-1.9,"skX":0.438,"skY":0.438,"x":21.55}}],"name":"thigh_1_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_l_0","transform":{"y":-2.95,"skX":0.1119,"skY":0.1128,"x":23}}],"name":"thigh_1_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/pelvis","transform":{"y":7.5,"x":3.5}}],"name":"pelvis"},{"display":[{"type":"image","name":"mecha_1003_folder/foot_l_0","transform":{"y":10.132,"skX":90,"skY":90,"x":-0.2792}}],"name":"foot_l"}]}],"bone":[{"transform":{},"name":"root"},{"length":20,"transform":{"y":-25,"scX":0.9955,"x":62.85},"parent":"root","inheritScale":0,"name":"foot_l"},{"length":40,"transform":{"y":-133.55,"skX":21.9887,"skY":21.9887,"scX":0.9995,"scY":0.9977,"x":8.3},"parent":"root","inheritScale":0,"name":"thigh_l"},{"length":42,"transform":{"y":-112.45,"skX":69.8809,"skY":69.8854,"scX":0.9876,"scY":0.9979,"x":-8.55},"parent":"root","inheritScale":0,"name":"thigh_r"},{"length":20,"transform":{"y":-123.15,"skX":-89.9991,"skY":-89.9991},"parent":"root","inheritScale":0,"name":"pelvis"},{"length":20,"transform":{"y":-4,"scX":0.9955,"x":-43.8},"parent":"root","inheritScale":0,"name":"foot_r"},{"length":50,"transform":{"y":-0.04,"skX":97.9614,"skY":97.9621,"scX":0.9894,"scY":0.9971,"x":40.11},"parent":"thigh_l","inheritScale":0,"name":"thigh_1_l"},{"length":20,"transform":{"skX":-90,"skY":-90,"x":13.75},"parent":"pelvis","inheritScale":0,"name":"chest"},{"length":53,"transform":{"y":-0.01,"skX":105.4235,"skY":105.423,"scX":0.9984,"scY":0.9995,"x":41.52},"parent":"thigh_r","inheritScale":0,"name":"thigh_1_r"},{"length":20,"transform":{"y":31.28,"scX":0.9965,"scY":0.9969,"x":13.74},"parent":"chest","inheritScale":0,"name":"shouder_r"},{"length":20,"transform":{"y":46.59,"scX":0.9965,"scY":0.9969,"x":-2.41},"parent":"chest","inheritScale":0,"name":"shouder_l"},{"inheritRotation":0,"length":100,"transform":{"y":3.13,"skX":130,"skY":130,"x":11.65},"parent":"chest","inheritScale":0,"name":"effects_b"},{"length":64,"transform":{"y":0.01,"skX":-70.8583,"skY":-70.864,"scX":1.0149,"scY":0.9967,"x":50.91},"parent":"thigh_1_l","inheritScale":0,"name":"calf_l"},{"inheritRotation":0,"length":100,"transform":{"y":-13.37,"skX":90,"skY":90,"x":-20.82},"parent":"chest","inheritScale":0,"name":"effects_f"},{"length":66,"transform":{"y":-0.02,"skX":-88.4874,"skY":-88.4933,"scX":0.9852,"scY":0.9996,"x":53.26},"parent":"thigh_1_r","inheritScale":0,"name":"calf_r"},{"length":100,"transform":{"skX":180,"skY":180,"scX":0.9982,"scY":0.9994,"x":5.98},"parent":"shouder_r","inheritScale":0,"name":"weapon_r"},{"length":100,"transform":{"y":0.04,"skX":180,"skY":180,"scX":0.998,"scY":0.9993,"x":5.6},"parent":"shouder_l","inheritScale":0,"name":"weapon_l"}],"type":"Armature","frameRate":24,"aabb":{"width":181.67820326799887,"y":-159.1498821898437,"height":216.2126923697017,"x":-95.3644576640574},"slot":[{"name":"foot_l","parent":"foot_l","color":{}},{"z":1,"name":"thigh_1_l","parent":"thigh_1_l","color":{}},{"z":2,"name":"calf_l","parent":"calf_l","color":{}},{"z":3,"name":"thigh_l","parent":"thigh_l","color":{}},{"z":4,"name":"pelvis","parent":"pelvis","color":{}},{"z":5,"name":"foot_r","parent":"foot_r","color":{}},{"z":6,"name":"thigh_1_r","parent":"thigh_1_r","color":{}},{"z":7,"name":"calf_r","parent":"calf_r","color":{}},{"z":8,"name":"thigh_r","parent":"thigh_r","color":{}}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"name":"skin_b","ik":[{"bone":"calf_l","chain":1,"bendPositive":"false","name":"calf_l","target":"foot_l"},{"bone":"calf_r","chain":1,"bendPositive":"false","name":"calf_r","target":"foot_r"}],"animation":[{"duration":0,"frame":[],"ffd":[],"bone":[{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"root"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"pelvis"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"chest"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_b"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_f"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_l"}],"slot":[],"name":"newAnimation","playTimes":0}]},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"mecha_1003d_folder/calf_l_0","transform":{"y":1.8851,"x":27.6888}}],"name":"calf_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_r_1","transform":{"y":-1.9,"skX":0.438,"skY":0.438,"x":21.55}}],"name":"thigh_1_r"},{"display":[{"type":"image","name":"mecha_1007d_folder/foot_l_1","transform":{"y":9.6443,"skX":90,"skY":90,"x":6.2003}}],"name":"foot_l"},{"display":[{"type":"image","name":"mecha_1004d_folder/chest_1","transform":{"y":52.0796,"skX":90,"skY":90,"x":-10.0293}}],"name":"chest"},{"display":[{"type":"image","name":"mecha_1004d_folder/shouder_r_2","transform":{"y":-3.0957,"skX":-90,"skY":-90,"x":-5.4198}}],"name":"shouder_r"},{"display":[{"type":"image","name":"mecha_1007d_folder/thigh_l_0","transform":{"y":-0.447,"x":26.8758}}],"name":"thigh_l"},{"display":[{"type":"image","name":"mecha_1003d_folder/calf_r_0","transform":{"y":1.2965,"x":29.7327}}],"name":"calf_r"},{"display":[{"type":"image","name":"mecha_1502b_folder/thigh_1_l_0","transform":{"y":-2.95,"skX":0.1119,"skY":0.1128,"x":23}}],"name":"thigh_1_l"},{"display":[{"type":"image","name":"mecha_1007d_folder/foot_r_0","transform":{"y":11.1489,"skX":90,"skY":90,"x":7.3628}}],"name":"foot_r"},{"display":[{"type":"image","name":"mecha_1004d_folder/shouder_l_2","transform":{"y":-1.1608,"skX":-90,"skY":-90,"x":-7.7426}}],"name":"shouder_l"},{"display":[{"type":"image","name":"mecha_1502b_folder/pelvis","transform":{"y":7.5,"x":3.5}}],"name":"pelvis"},{"display":[{"type":"image","name":"mecha_1007d_folder/thigh_r_0","transform":{"y":1.6378,"x":22.6896}}],"name":"thigh_r"}]}],"bone":[{"transform":{},"name":"root"},{"length":20,"transform":{"y":-25,"scX":0.9955,"x":62.85},"parent":"root","inheritScale":0,"name":"foot_l"},{"length":40,"transform":{"y":-133.55,"skX":21.9887,"skY":21.9887,"scX":0.9995,"scY":0.9977,"x":8.3},"parent":"root","inheritScale":0,"name":"thigh_l"},{"length":42,"transform":{"y":-112.45,"skX":69.8809,"skY":69.8854,"scX":0.9876,"scY":0.9979,"x":-8.55},"parent":"root","inheritScale":0,"name":"thigh_r"},{"length":20,"transform":{"y":-123.15,"skX":-89.9991,"skY":-89.9991},"parent":"root","inheritScale":0,"name":"pelvis"},{"length":20,"transform":{"y":-4,"scX":0.9955,"x":-43.8},"parent":"root","inheritScale":0,"name":"foot_r"},{"length":50,"transform":{"y":-0.04,"skX":97.9614,"skY":97.9621,"scX":0.9894,"scY":0.9971,"x":40.11},"parent":"thigh_l","inheritScale":0,"name":"thigh_1_l"},{"length":20,"transform":{"skX":-90,"skY":-90,"x":13.75},"parent":"pelvis","inheritScale":0,"name":"chest"},{"length":53,"transform":{"y":-0.01,"skX":105.4235,"skY":105.423,"scX":0.9984,"scY":0.9995,"x":41.52},"parent":"thigh_r","inheritScale":0,"name":"thigh_1_r"},{"length":20,"transform":{"y":31.28,"scX":0.9965,"scY":0.9969,"x":13.74},"parent":"chest","inheritScale":0,"name":"shouder_r"},{"length":20,"transform":{"y":46.59,"scX":0.9965,"scY":0.9969,"x":-2.41},"parent":"chest","inheritScale":0,"name":"shouder_l"},{"inheritRotation":0,"length":100,"transform":{"y":3.13,"skX":130,"skY":130,"x":11.65},"parent":"chest","inheritScale":0,"name":"effects_b"},{"length":64,"transform":{"y":0.01,"skX":-70.8583,"skY":-70.864,"scX":1.0149,"scY":0.9967,"x":50.91},"parent":"thigh_1_l","inheritScale":0,"name":"calf_l"},{"inheritRotation":0,"length":100,"transform":{"y":-13.37,"skX":90,"skY":90,"x":-20.82},"parent":"chest","inheritScale":0,"name":"effects_f"},{"length":66,"transform":{"y":-0.02,"skX":-88.4874,"skY":-88.4933,"scX":0.9852,"scY":0.9996,"x":53.26},"parent":"thigh_1_r","inheritScale":0,"name":"calf_r"},{"length":100,"transform":{"skX":180,"skY":180,"scX":0.9982,"scY":0.9994,"x":5.98},"parent":"shouder_r","inheritScale":0,"name":"weapon_r"},{"length":100,"transform":{"y":0.04,"skX":180,"skY":180,"scX":0.998,"scY":0.9993,"x":5.6},"parent":"shouder_l","inheritScale":0,"name":"weapon_l"}],"type":"Armature","frameRate":24,"aabb":{"width":187.45307710983226,"y":-280.97944052980597,"height":328.6282985398831,"x":-95.92274665260345},"slot":[{"name":"shouder_l","parent":"shouder_l","color":{}},{"z":1,"name":"foot_l","parent":"foot_l","color":{}},{"z":2,"name":"thigh_1_l","parent":"thigh_1_l","color":{}},{"z":3,"name":"calf_l","parent":"calf_l","color":{}},{"z":4,"name":"thigh_l","parent":"thigh_l","color":{}},{"z":5,"name":"pelvis","parent":"pelvis","color":{}},{"z":6,"name":"chest","parent":"chest","color":{}},{"z":7,"name":"foot_r","parent":"foot_r","color":{}},{"z":8,"name":"thigh_1_r","parent":"thigh_1_r","color":{}},{"z":9,"name":"calf_r","parent":"calf_r","color":{}},{"z":10,"name":"thigh_r","parent":"thigh_r","color":{}},{"z":11,"name":"shouder_r","parent":"shouder_r","color":{}}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"name":"skin_c","ik":[{"bone":"calf_l","chain":1,"bendPositive":"false","name":"calf_l","target":"foot_l"},{"bone":"calf_r","chain":1,"bendPositive":"false","name":"calf_r","target":"foot_r"}],"animation":[{"duration":0,"frame":[],"ffd":[],"bone":[{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"root"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"pelvis"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"foot_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"chest"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"thigh_1_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"shouder_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_b"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_l"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"effects_f"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"calf_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_r"},{"frame":[{"duration":0,"transform":{},"tweenEasing":null}],"name":"weapon_l"}],"slot":[],"name":"newAnimation","playTimes":0}]}],"name":"skin_1502b","version":"5.0"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_tex.json b/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_tex.json new file mode 100644 index 0000000..2e82d63 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_tex.json @@ -0,0 +1 @@ +{"width":512,"SubTexture":[{"width":63,"y":240,"height":42,"name":"mecha_1002_folder/upperarm_l_2","x":121},{"width":29,"y":88,"height":83,"name":"mecha_1004d_folder/foot_l_0","x":360},{"width":50,"y":348,"height":32,"name":"mecha_1502b_folder/thigh_1_l_0","x":101},{"width":92,"y":187,"height":51,"name":"mecha_1003_folder/calf_l_0","x":121},{"frameY":0,"y":449,"frameWidth":103,"frameX":-1,"frameHeight":57,"width":102,"height":56,"name":"mecha_1003d_folder/thigh_l_0","x":308},{"width":41,"y":245,"height":65,"name":"mecha_1502b_folder/pelvis","x":341},{"width":118,"y":187,"height":101,"name":"mecha_1004_folder/chest_1","x":1},{"width":30,"y":1,"height":85,"name":"mecha_1004d_folder/foot_r_1","x":360},{"width":55,"y":478,"height":32,"name":"mecha_1502b_folder/thigh_1_r_1","x":1},{"frameY":-1,"y":346,"frameWidth":95,"frameX":0,"frameHeight":52,"width":95,"height":51,"name":"mecha_1003_folder/calf_r_0","x":208},{"width":105,"y":449,"height":58,"name":"mecha_1003d_folder/thigh_r_0","x":98},{"width":67,"y":399,"height":38,"name":"mecha_1002_folder/upperarm_r_2","x":208},{"width":32,"y":348,"height":98,"name":"mecha_1003_folder/foot_l_0","x":390},{"frameY":0,"y":384,"frameWidth":116,"frameX":-3,"frameHeight":63,"width":108,"height":63,"name":"mecha_1008d_folder/thigh_l_0","x":98},{"width":34,"y":245,"height":101,"name":"mecha_1003_folder/foot_r_0","x":305},{"frameY":0,"y":290,"frameWidth":96,"frameX":-3,"frameHeight":54,"width":92,"height":54,"name":"mecha_1008d_folder/thigh_r_0","x":203},{"width":69,"y":187,"height":56,"name":"mecha_1004d_folder/shouder_l_2","x":289},{"width":40,"y":348,"height":80,"name":"mecha_1007d_folder/foot_l_1","x":348},{"frameY":0,"y":384,"frameWidth":96,"frameX":0,"frameHeight":92,"width":95,"height":92,"name":"mecha_1003d_folder/calf_l_0","x":1},{"width":100,"y":290,"height":56,"name":"mecha_1007d_folder/thigh_l_0","x":101},{"width":163,"y":1,"height":184,"name":"mecha_1004d_folder/chest_1","x":1},{"width":41,"y":348,"height":81,"name":"mecha_1007d_folder/foot_r_0","x":305},{"width":98,"y":290,"height":92,"name":"mecha_1003d_folder/calf_r_0","x":1},{"width":101,"y":449,"height":58,"name":"mecha_1007d_folder/thigh_r_0","x":205},{"width":72,"y":187,"height":59,"name":"mecha_1004d_folder/shouder_r_2","x":215}],"height":512,"name":"skin_1502b","imagePath":"skin_1502b_tex.png"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_tex.png b/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_tex.png new file mode 100644 index 0000000..eb1afbb Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/core_element/skin_1502b_tex.png differ diff --git a/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_ske.json b/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_ske.json new file mode 100644 index 0000000..4ec2ae2 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"armature":[{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_0","transform":{"y":-1,"x":-29.5}}],"name":"back"},{"display":[{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0001","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0002","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0003","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0004","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}},{"type":"image","name":"weapon_1005_folder/a_folder/boss_zhl.0005","transform":{"y":-1.9018,"skX":-2.0013,"x":42.5517,"skY":-2.0013}}],"name":"front"}]}],"aabb":{"width":150.05171561035348,"y":-21,"height":40,"x":-67},"type":"Armature","name":"weapon_1005","slot":[{"name":"back","parent":"root","color":{}},{"z":1,"name":"front","parent":"root","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-11,"x":81},"name":"fire","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/b_folder/0","transform":{"skX":0.0009,"x":0.05,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/1","transform":{"skX":0.0009,"x":0.05,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/2","transform":{"skX":0.0009,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/3","transform":{"skX":0.0009,"skY":0.0009}},{"type":"image","name":"weapon_1005_folder/b_folder/4","transform":{"y":-0.5,"skX":0.0009,"skY":0.0009}}],"name":"front"},{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_1","transform":{"y":-2,"x":-23.5}}],"name":"back"}]}],"aabb":{"width":184.0499391617343,"y":-32,"height":60,"x":-76},"type":"Armature","name":"weapon_1005b","slot":[{"name":"back","parent":"root","color":{}},{"z":1,"name":"front","parent":"front","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":0.05,"x":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":0.05,"x":0.1}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.95}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.45}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":0.05,"x":0.1}},{"tweenEasing":null,"duration":0,"transform":{"y":-0.45}}],"name":"front"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-13,"x":104},"name":"fire","parent":"root"},{"inheritScale":0,"transform":{"y":-1.4,"skX":-2.7082,"x":53,"skY":-2.7082},"name":"front","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_2","transform":{"y":-2,"x":-29}}],"name":"back"},{"display":[{"type":"image","name":"weapon_1005_folder/c_folder/0","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/1","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/2","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/3","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/4","transform":{"y":0.05,"skX":-0.0009,"x":0.05,"skY":-0.0009}}],"name":"front"}]}],"aabb":{"width":219.10213580747967,"y":-34,"height":64,"x":-83},"type":"Armature","name":"weapon_1005c","slot":[{"name":"back","parent":"root","color":{}},{"z":1,"name":"front","parent":"front","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5,"x":-0.05}},{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-1.4,"skX":-2.4482,"x":68.1,"skY":-2.4482},"name":"front","parent":"root"},{"inheritScale":0,"transform":{"y":-12,"x":133},"name":"fire","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_3","transform":{"y":-5.5,"x":-38}}],"name":"back"},{"display":[{"type":"image","name":"weapon_1005_folder/c_folder/0","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/1","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/2","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/3","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/4","transform":{"y":0.05,"skX":-0.0009,"x":0.05,"skY":-0.0009}}],"name":"front"}]}],"aabb":{"width":275.10213580747967,"y":-40,"height":69,"x":-139},"type":"Armature","name":"weapon_1005d","slot":[{"name":"front","parent":"front","color":{}},{"z":1,"name":"back","parent":"root","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5,"x":-0.05}},{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-1.4,"skX":-2.4482,"x":68.1,"skY":-2.4482},"name":"front","parent":"root"},{"inheritScale":0,"transform":{"y":-12,"x":133},"name":"fire","parent":"root"}],"frameRate":24},{"skin":[{"name":"","slot":[{"display":[{"type":"image","name":"weapon_1005_folder/c_folder/0","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/1","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/2","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/3","transform":{"y":0.05,"skX":-0.0009,"skY":-0.0009}},{"type":"image","name":"weapon_1005_folder/c_folder/4","transform":{"y":0.05,"skX":-0.0009,"x":0.05,"skY":-0.0009}}],"name":"front"},{"display":[{"type":"image","name":"weapon_1005_folder/weapon_r_4","transform":{"y":-2,"x":-18}}],"name":"back"}]}],"aabb":{"width":352.10213580747967,"y":-40,"height":76,"x":-158},"type":"Armature","name":"weapon_1005e","slot":[{"name":"front","parent":"front","color":{}},{"z":1,"name":"back","parent":"root","color":{}}],"ik":[],"animation":[{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":1,"transform":{}}],"name":"root"}],"slot":[],"name":"idle","duration":1,"playTimes":0},{"ffd":[],"frame":[],"bone":[{"frame":[{"tweenEasing":null,"duration":2,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5,"x":-0.05}},{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":5,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":3},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":4},{"color":{},"tweenEasing":null,"duration":0}],"name":"front"}],"name":"prepare_01","duration":5,"playTimes":0},{"ffd":[],"frame":[{"tweenEasing":null,"duration":0,"events":[{"name":"fire","bone":"fire"}]}],"bone":[{"frame":[{"tweenEasing":null,"duration":1,"transform":{}},{"tweenEasing":null,"duration":1,"transform":{"y":-0.5}},{"tweenEasing":null,"duration":0,"transform":{}}],"name":"front"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"fire"},{"frame":[{"tweenEasing":null,"duration":2,"transform":{}}],"name":"root"}],"slot":[{"frame":[{"color":{},"tweenEasing":null,"duration":1},{"color":{},"tweenEasing":null,"duration":1,"displayIndex":2},{"color":{},"tweenEasing":null,"duration":0,"displayIndex":4}],"name":"front"}],"name":"fire_01","duration":2}],"defaultActions":[{"gotoAndPlay":"idle"}],"bone":[{"name":"root","transform":{}},{"inheritScale":0,"transform":{"y":-0.4,"skX":-2.4482,"x":126.1,"skY":-2.4482},"name":"front","parent":"root"},{"inheritScale":0,"transform":{"y":-11,"x":191},"name":"fire","parent":"root"}],"frameRate":24}],"isGlobal":0,"name":"weapon_1000","version":"5.0"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_tex.json b/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_tex.json new file mode 100644 index 0000000..94b339f --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_tex.json @@ -0,0 +1 @@ +{"SubTexture":[{"width":75,"y":266,"height":40,"name":"weapon_1005_folder/weapon_r_0","x":111},{"frameHeight":37,"y":270,"frameX":0,"width":81,"frameY":0,"height":36,"name":"weapon_1005_folder/a_folder/boss_zhl.0002","frameWidth":81,"x":1},{"frameHeight":37,"y":237,"frameX":0,"width":81,"frameY":0,"height":36,"name":"weapon_1005_folder/a_folder/boss_zhl.0003","frameWidth":81,"x":277},{"width":81,"y":237,"height":37,"name":"weapon_1005_folder/a_folder/boss_zhl.0001","x":194},{"width":81,"y":227,"height":37,"name":"weapon_1005_folder/a_folder/boss_zhl.0005","x":111},{"width":81,"y":72,"height":37,"name":"weapon_1005_folder/a_folder/boss_zhl.0004","x":421},{"width":105,"y":128,"height":60,"name":"weapon_1005_folder/weapon_r_1","x":387},{"width":110,"y":178,"height":47,"name":"weapon_1005_folder/b_folder/0","x":1},{"width":108,"y":227,"height":41,"name":"weapon_1005_folder/b_folder/3","x":1},{"width":108,"y":180,"height":45,"name":"weapon_1005_folder/b_folder/2","x":113},{"width":108,"y":194,"height":41,"name":"weapon_1005_folder/b_folder/4","x":223},{"width":109,"y":190,"height":49,"name":"weapon_1005_folder/b_folder/1","x":387},{"width":108,"y":128,"height":64,"name":"weapon_1005_folder/weapon_r_2","x":277},{"width":136,"y":72,"height":54,"name":"weapon_1005_folder/c_folder/1","x":283},{"width":136,"y":132,"height":46,"name":"weapon_1005_folder/c_folder/4","x":139},{"width":136,"y":133,"height":43,"name":"weapon_1005_folder/c_folder/3","x":1},{"width":136,"y":79,"height":52,"name":"weapon_1005_folder/c_folder/0","x":1},{"width":136,"y":79,"height":51,"name":"weapon_1005_folder/c_folder/2","x":139},{"width":202,"y":1,"height":69,"name":"weapon_1005_folder/weapon_r_3","x":283},{"width":280,"y":1,"height":76,"name":"weapon_1005_folder/weapon_r_4","x":1}],"name":"weapon_1000","imagePath":"weapon_1000_tex.png"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_tex.png b/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_tex.png new file mode 100644 index 0000000..0d6c927 Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/core_element/weapon_1000_tex.png differ diff --git a/reference/Pixi/Demos/resource/assets/dragon_boy_ske.dbbin b/reference/Pixi/Demos/resource/assets/dragon_boy_ske.dbbin new file mode 100644 index 0000000..87418d4 Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/dragon_boy_ske.dbbin differ diff --git a/reference/Pixi/Demos/resource/assets/dragon_boy_ske.json b/reference/Pixi/Demos/resource/assets/dragon_boy_ske.json new file mode 100644 index 0000000..5d2ce0d --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/dragon_boy_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"armature":[{"aabb":{"width":693.2805749826739,"y":-702.3605101048755,"height":769.5863484320666,"x":-240.9677870990554},"type":"Armature","ik":[],"defaultActions":[{"gotoAndPlay":"stand"}],"skin":[{"name":"","slot":[{"display":[{"path":"parts/tail","type":"image","name":"parts/tail","transform":{"skX":45.2229,"y":-0.0768,"skY":45.2229,"x":30.247025}}],"name":"tail"},{"display":[{"path":"parts/armUpperR","type":"image","name":"parts/armUpperR","transform":{"skX":13.9232,"y":1.1848,"skY":13.9232,"x":14.130075}}],"name":"armUpperR"},{"display":[{"path":"parts/beardL","type":"image","name":"parts/beardL","transform":{"skX":-174.0434,"y":-1.088575,"skY":-174.0434,"x":12.496175}}],"name":"beardL"},{"display":[{"path":"parts/eyeL","type":"image","name":"parts/eyeL","transform":{"y":0.1,"x":0.075}}],"name":"eyeL"},{"display":[{"path":"parts/armL","type":"image","name":"parts/armL","transform":{"skX":98.2989,"y":-0.719275,"skY":98.2989,"x":6.6737}}],"name":"armL"},{"display":[{"path":"parts/body","type":"image","name":"parts/body","transform":{"skX":94.9653,"y":0.154875,"skY":94.9653,"x":-0.2393}}],"name":"body"},{"display":[{"path":"parts/armR","type":"image","name":"parts/armR","transform":{"skX":-85.2356,"y":0.697625,"skY":-85.2356,"x":3.554325}}],"name":"armR"},{"display":[{"path":"parts/clothes1","type":"image","name":"parts/clothes1","transform":{"skX":132.4995,"y":4.012475,"skY":132.4995,"x":8.099525}}],"name":"clothes"},{"display":[{"path":"parts/legR","type":"image","name":"parts/legR","transform":{"skX":-94.0239,"y":-1.50245,"skY":-94.0239,"x":20.645475}}],"name":"legR"},{"display":[{"path":"parts/handL","type":"image","name":"parts/handL","transform":{"skX":146.6156,"y":-0.362775,"skY":146.6156,"x":8.683125}}],"name":"handL"},{"display":[{"path":"parts/tailTip","type":"image","name":"parts/tailTip","transform":{"skX":82.7421,"y":-0.205475,"skY":82.7421,"x":20.4126}}],"name":"tailTip"},{"display":[{"path":"parts/hair","type":"image","name":"parts/hair","transform":{"skX":-4.9086,"y":0.099375,"skY":-4.9086,"x":0.01125}}],"name":"hair"},{"display":[{"path":"parts/eyeR","type":"image","name":"parts/eyeR","transform":{"y":-0.125,"x":0.375}}],"name":"eyeR"},{"display":[{"path":"parts/legL","type":"image","name":"parts/legL","transform":{"skX":-146.9135,"y":-1.6115,"skY":-146.9135,"x":25.27875}}],"name":"legL"},{"display":[{"path":"parts/handR","type":"image","name":"parts/handR","transform":{"skX":-88.1106,"y":1.26565,"skY":-88.1106,"x":5.7614}}],"name":"handR"},{"display":[{"path":"parts/head","type":"image","name":"parts/head","transform":{"skX":80.4531,"y":-2.634675,"skY":80.4531,"x":30.73875}}],"name":"head"},{"display":[{"path":"parts/armUpperL","type":"image","name":"parts/armUpperL","transform":{"skX":-148.2623,"y":1.080425,"skY":-148.2623,"x":6.9746}}],"name":"armUpperL"},{"display":[{"path":"parts/beardR","type":"image","name":"parts/beardR","transform":{"y":0.05,"x":15.4}}],"name":"beardR"}]}],"bone":[{"name":"root","transform":{"y":-67.63665,"x":-1.639675}},{"length":37.5,"transform":{"skX":-94.9653,"y":12.635475,"skY":-94.9653,"x":6.523525},"parent":"root","name":"body"},{"length":30,"transform":{"skX":-156.0107,"y":11.725,"skY":-156.0107,"x":-23.90455},"parent":"body","name":"legR"},{"length":37.5,"transform":{"skX":159.9921,"y":7.848175,"skY":159.9921,"x":20.146325},"parent":"body","name":"armUpperR"},{"length":37.5,"transform":{"skX":-154.3312,"y":-15.06895,"skY":-154.3312,"x":-17.7624},"parent":"body","name":"legL"},{"length":37.5,"transform":{"skX":11.4957,"y":-1.450925,"skY":11.4957,"x":40.778625},"parent":"body","name":"head"},{"length":17.5,"transform":{"skX":-171.7742,"y":-23.401175,"skY":-171.7742,"x":18.620325},"parent":"body","name":"armUpperL"},{"length":62.5,"transform":{"skX":79.7425,"y":17.53175,"skY":79.7425,"x":-29.2773},"parent":"body","name":"tail"},{"length":20,"transform":{"skX":-37.5342,"y":-7.9354,"skY":-37.5342,"x":0.35575},"parent":"body","name":"clothes"},{"length":15,"transform":{"skX":30.7088,"y":0.5564,"skY":30.7088,"x":16.6908},"parent":"armUpperL","name":"armL"},{"transform":{"skX":80.4531,"y":-5.998925,"skY":80.4531,"x":35.0657},"name":"eyeR","parent":"head"},{"length":37.5,"transform":{"skX":-37.5192,"y":-0.7752,"skY":-37.5192,"x":64.465525},"parent":"tail","name":"tailTip"},{"transform":{"skX":80.4531,"y":-25.297,"skY":80.4531,"x":33.442525},"name":"eyeL","parent":"head"},{"length":20,"transform":{"skX":-105.5036,"y":-33.4062,"skY":-105.5036,"x":1.8647},"parent":"head","name":"beardL"},{"length":12.5,"transform":{"skX":35.2088,"y":0.132125,"skY":35.2088,"x":34.6873},"parent":"armUpperR","name":"armR"},{"length":20,"transform":{"skX":80.4531,"y":-8.96425,"skY":80.4531,"x":5.818825},"parent":"head","name":"beardR"},{"length":12.5,"transform":{"skX":86.9099,"y":20.157725,"skY":86.9099,"x":26.206225},"parent":"head","name":"hair"},{"length":10,"transform":{"skX":17.875,"y":0.276975,"skY":17.875,"x":10.84685},"parent":"armR","name":"handR"},{"length":20,"transform":{"skX":4.4133,"y":-0.106825,"skY":4.4133,"x":16.657725},"parent":"armL","name":"handL"}],"slot":[{"name":"tailTip","parent":"tailTip","color":{}},{"z":1,"name":"armUpperL","parent":"armUpperL","color":{}},{"z":2,"name":"armL","parent":"armL","color":{}},{"z":3,"name":"handL","parent":"handL","color":{}},{"z":4,"name":"legL","parent":"legL","color":{}},{"z":5,"name":"body","parent":"body","color":{}},{"z":6,"name":"tail","parent":"tail","color":{}},{"z":7,"name":"clothes","parent":"clothes","color":{}},{"z":8,"name":"hair","parent":"hair","color":{}},{"z":9,"name":"head","parent":"head","color":{}},{"z":10,"name":"eyeL","parent":"eyeL","color":{}},{"z":11,"name":"eyeR","parent":"eyeR","color":{}},{"z":12,"name":"legR","parent":"legR","color":{}},{"z":13,"name":"armUpperR","parent":"armUpperR","color":{}},{"z":14,"name":"armR","parent":"armR","color":{}},{"z":15,"name":"handR","parent":"handR","color":{}},{"z":16,"name":"beardL","parent":"beardL","color":{}},{"z":17,"name":"beardR","parent":"beardR","color":{}}],"animation":[{"playTimes":0,"frame":[],"duration":30,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":30}],"name":"root"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"skX":4.95,"skY":4.95,"x":-1},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{},"tweenEasing":0,"duration":12},{"transform":{"y":-0.5,"x":-0.5},"tweenEasing":0,"duration":18},{"transform":{},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"y":-0.5},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"skX":-12.64,"y":-2.01435,"skY":-12.64,"x":1.2837},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{},"tweenEasing":0,"duration":8},{"transform":{"y":-0.5},"tweenEasing":0,"duration":22},{"transform":{},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{"skX":9.6205,"skY":9.6205},"tweenEasing":0,"duration":15},{"transform":{"skX":-1.4848,"skY":-1.4848},"tweenEasing":0,"duration":15},{"transform":{"skX":9.6205,"skY":9.6205},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":15},{"transform":{"skX":5.44,"skY":5.44},"tweenEasing":0,"duration":15},{"transform":{},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":12},{"transform":{"y":-1,"x":0.5},"tweenEasing":0,"duration":18},{"transform":{},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":30},{"transform":{},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":17},{"tweenEasing":null,"duration":1},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":8},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":30},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":7},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":1},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":7},{"tweenEasing":0,"duration":8},{"tweenEasing":0,"duration":12},{"tweenEasing":0,"duration":1},{"tweenEasing":null,"duration":2},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"stand"},{"playTimes":0,"frame":[],"duration":20,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":20},{"transform":{},"tweenEasing":null,"duration":0}],"name":"root"},{"frame":[{"transform":{"y":-1},"tweenEasing":0,"duration":10},{"transform":{"y":-0.5},"tweenEasing":0,"duration":10},{"transform":{"y":-1},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{"skX":-30,"y":-3.5,"skY":-30,"x":-1.5},"tweenEasing":0,"duration":10},{"transform":{"skX":30,"y":-0.5,"skY":30,"x":-0.975},"tweenEasing":0,"duration":10},{"transform":{"skX":-30,"y":-3.5,"skY":-30,"x":-1.5},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{"skX":45.5,"y":3.5,"skY":45.5,"x":-1.5},"tweenEasing":0,"duration":10},{"transform":{"skX":-22.15,"y":0.5,"skY":-22.15},"tweenEasing":0,"duration":10},{"transform":{"skX":45.5,"y":3.5,"skY":45.5,"x":-1.5},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{"skX":49.67,"y":7.100275,"skY":49.67,"x":-10.08605},"tweenEasing":0,"duration":10},{"transform":{"skX":-19.23,"y":-2.23195,"skY":-19.23,"x":-5.63015},"tweenEasing":0,"duration":10},{"transform":{"skX":49.67,"y":7.100275,"skY":49.67,"x":-10.08605},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{"y":1},"tweenEasing":0,"duration":10},{"transform":{"skX":2.95,"y":0.5,"skY":2.95},"tweenEasing":0,"duration":10},{"transform":{"y":1},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{"skX":-21.2,"y":1,"skY":-21.2},"tweenEasing":0,"duration":10},{"transform":{"skX":30,"y":0.5,"skY":30},"tweenEasing":0,"duration":10},{"transform":{"skX":-21.2,"y":1,"skY":-21.2},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{"x":-2},"tweenEasing":0,"duration":10},{"transform":{"skX":-8.7,"y":-1.5,"skY":-8.7,"x":-3},"tweenEasing":0,"duration":10},{"transform":{"x":-2},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-0.5,"x":-0.5},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":0,"duration":5},{"transform":{"y":-0.5,"x":-0.5},"tweenEasing":0,"duration":5},{"transform":{},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{"skX":-38.8,"y":-0.5503,"skY":-38.8,"x":-3.259675},"tweenEasing":0,"duration":10},{"transform":{"skX":38.55,"y":-1.461275,"skY":38.55,"x":0.976075},"tweenEasing":0,"duration":10},{"transform":{"skX":-38.8,"y":-0.5503,"skY":-38.8,"x":-3.259675},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{"y":0.125,"x":0.425},"tweenEasing":0,"duration":10},{"transform":{"skX":-2.95,"y":-0.069325,"skY":-2.95,"x":-1.0284},"tweenEasing":0,"duration":10},{"transform":{"y":0.125,"x":0.425},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{"y":-0.133975,"x":2.23205},"tweenEasing":0,"duration":10},{"transform":{"skX":17.93,"y":2.519025,"skY":17.93,"x":-0.749225},"tweenEasing":0,"duration":10},{"transform":{"y":-0.133975,"x":2.23205},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":-2.95,"y":1.047675,"skY":-2.95,"x":-1.887475},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":6.04,"y":-1.37935,"skY":6.04,"x":-0.879675},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{"skX":21.72,"y":2.488875,"skY":21.72,"x":-0.64355},"tweenEasing":0,"duration":5},{"transform":{"skX":31.7897,"y":1.249725,"skY":31.7897,"x":-0.683125},"tweenEasing":0,"duration":5},{"transform":{"skX":-15.63,"y":0.0106,"skY":-15.63,"x":-0.722675},"tweenEasing":0,"duration":5},{"transform":{"skX":-19.6672,"y":-1.40275,"skY":-19.6672,"x":-0.056175},"tweenEasing":0,"duration":5},{"transform":{"skX":21.72,"y":2.488875,"skY":21.72,"x":-0.64355},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":-10.45,"y":0.41485,"skY":-10.45,"x":-0.3614},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{},"tweenEasing":0,"duration":10},{"transform":{"skX":-2.95,"y":-1.79345,"skY":-2.95,"x":0.282225},"tweenEasing":0,"duration":10},{"transform":{},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{"skX":-45.48,"y":0.506125,"skY":-45.48,"x":-4.066475},"tweenEasing":0,"duration":10},{"transform":{"skX":-0.48,"y":0.541625,"skY":-0.48,"x":0.374075},"tweenEasing":0,"duration":10},{"transform":{"skX":-45.48,"y":0.506125,"skY":-45.48,"x":-4.066475},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{"skX":15,"y":0.225675,"skY":15,"x":-0.416425},"tweenEasing":0,"duration":10},{"transform":{"skX":6.45,"y":0.8498,"skY":6.45,"x":-0.69405},"tweenEasing":0,"duration":10},{"transform":{"skX":15,"y":0.225675,"skY":15,"x":-0.416425},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":10},{"tweenEasing":0,"duration":10},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"walk"},{"playTimes":0,"frame":[],"duration":5,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":5}],"name":"root"},{"frame":[{"transform":{"y":-16.5},"tweenEasing":0,"duration":5},{"transform":{"y":-16.5},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{"skX":-27.69,"y":0.2582,"skY":-27.69,"x":0.293925},"tweenEasing":0,"duration":2},{"transform":{"skX":-27.69,"y":0.16485,"skY":-27.69,"x":-0.7805},"tweenEasing":0,"duration":3},{"transform":{"skX":-27.69,"y":0.2582,"skY":-27.69,"x":0.293925},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{"skX":-24.65,"y":2.5,"skY":-24.65},"tweenEasing":0,"duration":2},{"transform":{"skX":-23.1904,"y":2.437775,"skY":-23.1904,"x":-0.716275},"tweenEasing":0,"duration":3},{"transform":{"skX":-24.65,"y":2.5,"skY":-24.65},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{"skX":-15.2954,"y":9.571825,"skY":-15.2954,"x":-5.1551},"tweenEasing":0,"duration":2},{"transform":{"skX":-15.2954,"y":9.44735,"skY":-15.2954,"x":-6.587675},"tweenEasing":0,"duration":3},{"transform":{"skX":-15.2954,"y":9.571825,"skY":-15.2954,"x":-5.1551},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{"skX":10,"y":0.475,"skY":10,"x":0.9},"tweenEasing":0,"duration":5},{"transform":{"skX":10,"y":0.475,"skY":10,"x":0.9},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{"skX":15,"y":1,"skY":15},"tweenEasing":0,"duration":2},{"transform":{"skX":15,"y":0.90665,"skY":15,"x":-1.074425},"tweenEasing":0,"duration":3},{"transform":{"skX":15,"y":1,"skY":15},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{"skX":9.3457,"y":-2.5,"skY":9.3457,"x":-6},"tweenEasing":0,"duration":2},{"transform":{"skX":13.7283,"y":-2.5,"skY":13.7283,"x":-6},"tweenEasing":0,"duration":3},{"transform":{"skX":9.3457,"y":-2.5,"skY":9.3457,"x":-6},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{"y":-1.1277,"x":-1.19205},"tweenEasing":0,"duration":2},{"transform":{"y":-1.22105,"x":-2.266475},"tweenEasing":0,"duration":3},{"transform":{"y":-1.1277,"x":-1.19205},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{"skX":8.55,"y":0.6382,"skY":8.55,"x":-0.149475},"tweenEasing":0,"duration":5},{"transform":{"skX":8.55,"y":0.6382,"skY":8.55,"x":-0.149475},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{"skX":-10,"y":-2.1757,"skY":-10,"x":2.220375},"tweenEasing":0,"duration":2},{"transform":{"skX":-10,"y":-2.264625,"skY":-10,"x":2.0302},"tweenEasing":0,"duration":3},{"transform":{"skX":-10,"y":-1.931525,"skY":-10,"x":2.25325},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{"skX":2.89,"y":1.575025,"skY":2.89,"x":0.54245},"tweenEasing":0,"duration":2},{"transform":{"skX":8.91,"y":-0.224,"skY":8.91,"x":0.159375},"tweenEasing":0,"duration":3},{"transform":{"skX":2.89,"y":1.575025,"skY":2.89,"x":0.54245},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{"skX":-10,"y":-1.57535,"skY":-10,"x":2.234775},"tweenEasing":0,"duration":2},{"transform":{"skX":-10,"y":-2.264625,"skY":-10,"x":2.0302},"tweenEasing":0,"duration":3},{"transform":{"skX":-10,"y":-1.57535,"skY":-10,"x":2.234775},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{"skX":-50.29,"y":4.806675,"skY":-50.29,"x":-4.944425},"tweenEasing":0,"duration":2},{"transform":{"skX":-58.5649,"y":4.806675,"skY":-58.5649,"x":-4.944425},"tweenEasing":0,"duration":3},{"transform":{"skX":-50.29,"y":4.806675,"skY":-50.29,"x":-4.944425},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{"skX":-13.13,"y":0.289775,"skY":-13.13,"x":-2.020225},"tweenEasing":0,"duration":5},{"transform":{"skX":-13.13,"y":0.289775,"skY":-13.13,"x":-2.020225},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{"skX":42.5,"y":1.6871,"skY":42.5,"x":-2.037225},"tweenEasing":0,"duration":2},{"transform":{"skX":50.23,"y":1.707375,"skY":50.23,"x":-2.008275},"tweenEasing":0,"duration":3},{"transform":{"skX":42.5,"y":1.6871,"skY":42.5,"x":-2.037225},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{"skX":-10,"y":-1.5109,"skY":-10,"x":-0.204525},"tweenEasing":0,"duration":2},{"transform":{"skX":-10,"y":-0.699725,"skY":-10,"x":0.953925},"tweenEasing":0,"duration":3},{"transform":{"skX":-10,"y":-1.5109,"skY":-10,"x":-0.204525},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{"skX":-0.48,"y":0.541625,"skY":-0.48,"x":0.374075},"tweenEasing":0,"duration":5},{"transform":{"skX":-0.48,"y":0.541625,"skY":-0.48,"x":0.374075},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{"skX":-8.55,"y":-0.962825,"skY":-8.55,"x":-3.527325},"tweenEasing":0,"duration":5},{"transform":{"skX":-8.55,"y":-0.962825,"skY":-8.55,"x":-3.527325},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"jump"},{"playTimes":0,"frame":[],"duration":5,"bone":[{"frame":[{"transform":{},"tweenEasing":null,"duration":5}],"name":"root"},{"frame":[{"transform":{"y":-16.5},"tweenEasing":0,"duration":5},{"transform":{"y":-16.5},"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"transform":{"skX":27.76,"y":2.2411,"skY":27.76,"x":1.544925},"tweenEasing":0,"duration":2},{"transform":{"skX":27.76,"y":2.144,"skY":27.76,"x":0.427375},"tweenEasing":0,"duration":3},{"transform":{"skX":27.76,"y":2.2411,"skY":27.76,"x":1.544925},"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"transform":{"skX":-69.64,"y":2.5,"skY":-69.64},"tweenEasing":0,"duration":2},{"transform":{"skX":-66.683,"y":2.467625,"skY":-66.683,"x":-0.3725},"tweenEasing":0,"duration":3},{"transform":{"skX":-69.64,"y":2.5,"skY":-69.64},"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"transform":{"skX":50.73,"y":1.975,"skY":50.73,"x":5.65},"tweenEasing":0,"duration":2},{"transform":{"skX":50.73,"y":1.910275,"skY":50.73,"x":4.904975},"tweenEasing":0,"duration":3},{"transform":{"skX":50.73,"y":1.975,"skY":50.73,"x":5.65},"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"transform":{"skX":-8.73,"y":-0.85,"skY":-8.73,"x":2.75},"tweenEasing":0,"duration":5},{"transform":{"skX":-8.73,"y":-0.85,"skY":-8.73,"x":2.75},"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"transform":{"skX":92.45,"y":1,"skY":92.45},"tweenEasing":0,"duration":2},{"transform":{"skX":89.9735,"y":1.064725,"skY":89.9735,"x":0.745025},"tweenEasing":0,"duration":3},{"transform":{"skX":92.45,"y":1,"skY":92.45},"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"transform":{"skX":-18.47,"y":-1.525,"skY":-18.47,"x":-0.975},"tweenEasing":0,"duration":2},{"transform":{"skX":-22.44,"y":-1.525,"skY":-22.44,"x":-0.975},"tweenEasing":0,"duration":3},{"transform":{"skX":-18.47,"y":-1.525,"skY":-18.47,"x":-0.975},"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"transform":{"y":-1.215525,"x":-1.50165},"tweenEasing":0,"duration":2},{"transform":{"y":-1.118425,"x":-0.384125},"tweenEasing":0,"duration":3},{"transform":{"y":-1.215525,"x":-1.50165},"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"transform":{"skX":-53.9,"y":1.45345,"skY":-53.9,"x":1.087275},"tweenEasing":0,"duration":5},{"transform":{"skX":-53.9,"y":1.45345,"skY":-53.9,"x":1.087275},"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"transform":{"skX":8.73,"y":-1.153625,"skY":8.73,"x":-4.44015},"tweenEasing":0,"duration":2},{"transform":{"skX":8.73,"y":-0.7513,"skY":8.73,"x":-3.707225},"tweenEasing":0,"duration":3},{"transform":{"skX":8.73,"y":-1.153625,"skY":8.73,"x":-4.44015},"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"transform":{"skX":0.14,"y":-0.289,"skY":0.14,"x":0.699575},"tweenEasing":0,"duration":2},{"transform":{"skX":-0.83,"y":0.44715,"skY":-0.83,"x":0.45425},"tweenEasing":0,"duration":3},{"transform":{"skX":0.14,"y":-0.289,"skY":0.14,"x":0.699575},"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"transform":{"skX":8.73,"y":-2.0383,"skY":8.73,"x":-3.25035},"tweenEasing":0,"duration":2},{"transform":{"skX":8.73,"y":-1.484225,"skY":8.73,"x":-3.304875},"tweenEasing":0,"duration":3},{"transform":{"skX":8.73,"y":-2.0383,"skY":8.73,"x":-3.25035},"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"transform":{"skX":-2.54,"y":1.945425,"skY":-2.54,"x":0.081175},"tweenEasing":0,"duration":2},{"transform":{"skX":25.1339,"y":1.945425,"skY":25.1339,"x":0.081175},"tweenEasing":0,"duration":3},{"transform":{"skX":-2.54,"y":1.945425,"skY":-2.54,"x":0.081175},"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"transform":{"skX":-13.14,"y":-0.799125,"skY":-13.14,"x":-2.801725},"tweenEasing":0,"duration":5},{"transform":{"skX":-13.14,"y":-0.799125,"skY":-13.14,"x":-2.801725},"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"transform":{"skX":8.96,"y":1.31275,"skY":8.96,"x":-1.966675},"tweenEasing":0,"duration":2},{"transform":{"skX":-6.04,"y":1.31275,"skY":-6.04,"x":-1.966675},"tweenEasing":0,"duration":3},{"transform":{"skX":8.96,"y":1.31275,"skY":8.96,"x":-1.966675},"tweenEasing":null,"duration":0}],"name":"beardR"},{"frame":[{"transform":{"skX":-6.27,"y":1.80955,"skY":-6.27,"x":0.147725},"tweenEasing":0,"duration":2},{"transform":{"skX":-7.09,"y":0.051875,"skY":-7.09,"x":-1.580525},"tweenEasing":0,"duration":3},{"transform":{"skX":-6.27,"y":1.80955,"skY":-6.27,"x":0.147725},"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"transform":{"skX":29.52,"y":-0.3423,"skY":29.52,"x":-0.984675},"tweenEasing":0,"duration":5},{"transform":{"skX":29.52,"y":-0.3423,"skY":29.52,"x":-0.984675},"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"transform":{"skX":21.45,"y":0.367025,"skY":21.45,"x":-0.899625},"tweenEasing":0,"duration":5},{"transform":{"skX":21.45,"y":0.367025,"skY":21.45,"x":-0.899625},"tweenEasing":null,"duration":0}],"name":"handL"}],"slot":[{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tailTip"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legL"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"body"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"tail"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"clothes"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"hair"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"head"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"eyeR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"legR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"armUpperR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"armR"},{"frame":[{"tweenEasing":0,"duration":5},{"tweenEasing":null,"duration":0}],"name":"handR"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardL"},{"frame":[{"tweenEasing":0,"duration":2},{"tweenEasing":0,"duration":3},{"tweenEasing":null,"duration":0}],"name":"beardR"}],"ffd":[],"name":"fall"}],"frameRate":24,"name":"DragonBoy"}],"name":"Dragon_1","version":"5.0"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/dragon_boy_tex.json b/reference/Pixi/Demos/resource/assets/dragon_boy_tex.json new file mode 100644 index 0000000..9021b7b --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/dragon_boy_tex.json @@ -0,0 +1 @@ +{"imagePath":"dragon_boy_tex.png","width":256,"SubTexture":[{"frameX":0,"y":174,"frameY":0,"frameWidth":28,"width":28,"frameHeight":53,"height":52,"name":"parts/tailTip","x":196},{"width":28,"y":174,"height":22,"name":"parts/armUpperL","x":226},{"width":12,"y":234,"height":20,"name":"parts/armL","x":90},{"width":24,"y":198,"height":20,"name":"parts/handL","x":226},{"frameX":0,"y":191,"frameY":0,"frameWidth":51,"width":51,"frameHeight":45,"height":45,"name":"parts/legL","x":1},{"frameX":0,"y":102,"frameY":0,"frameWidth":59,"width":59,"frameHeight":87,"height":87,"name":"parts/body","x":1},{"width":54,"y":102,"height":70,"name":"parts/tail","x":62},{"width":52,"y":174,"height":44,"name":"parts/clothes1","x":109},{"width":31,"y":174,"height":71,"name":"parts/hair","x":163},{"frameX":0,"y":1,"frameY":0,"frameWidth":85,"width":84,"frameHeight":99,"height":99,"name":"parts/head","x":1},{"width":7,"y":241,"height":12,"name":"parts/eyeL","x":238},{"frameX":0,"y":220,"frameY":0,"frameWidth":10,"width":9,"frameHeight":15,"height":15,"name":"parts/eyeR","x":136},{"frameX":0,"y":174,"frameY":0,"frameWidth":45,"width":45,"frameHeight":58,"height":58,"name":"parts/legR","x":62},{"width":40,"y":228,"height":24,"name":"parts/armUpperR","x":196},{"frameX":0,"y":220,"frameY":0,"frameWidth":12,"width":11,"frameHeight":20,"height":19,"name":"parts/armR","x":238},{"width":25,"y":220,"height":15,"name":"parts/handR","x":109},{"frameX":0,"y":245,"frameY":0,"frameWidth":30,"width":30,"frameHeight":9,"height":9,"name":"parts/beardL","x":54},{"width":34,"y":234,"height":9,"name":"parts/beardR","x":54}],"height":256,"name":"Dragon_1"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/dragon_boy_tex.png b/reference/Pixi/Demos/resource/assets/dragon_boy_tex.png new file mode 100644 index 0000000..02c8677 Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/dragon_boy_tex.png differ diff --git a/reference/Pixi/Demos/resource/assets/replace_slot_display/main_ske.json b/reference/Pixi/Demos/resource/assets/replace_slot_display/main_ske.json new file mode 100644 index 0000000..30eb04e --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/replace_slot_display/main_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"name":"main","version":"5.0","armature":[{"animation":[{"slot":[],"playTimes":0,"duration":30,"frame":[],"name":"idle","bone":[{"frame":[{"duration":30,"tweenEasing":null,"transform":{}}],"name":"root"},{"frame":[{"duration":10,"tweenEasing":0,"transform":{}},{"duration":10,"tweenEasing":0,"transform":{"skX":120,"skY":120}},{"duration":10,"tweenEasing":0,"transform":{"skX":-120,"skY":-120}},{"duration":0,"tweenEasing":null,"transform":{}}],"name":"ball"},{"frame":[{"duration":10,"tweenEasing":0,"transform":{}},{"duration":10,"tweenEasing":0,"transform":{"skX":120,"skY":120}},{"duration":10,"tweenEasing":0,"transform":{"skX":-120,"skY":-120}},{"duration":0,"tweenEasing":null,"transform":{}}],"name":"point"}],"ffd":[{"frame":[{"duration":10,"tweenEasing":0,"offset":0,"vertices":[]},{"duration":10,"tweenEasing":0,"offset":0,"vertices":[115.61,54.15,0,0,120.7,-60.04,0,0,0,0,0,0,0,0,0,0,113.3,49.94,119.03,-55.73,1,-5.66,-1.29,7.67,0,0,0,0,0,0,0,0]},{"duration":10,"tweenEasing":0,"offset":0,"vertices":[-36.97,-85.96,0,0,-21.37,108.42,0,0,0,0,0,0,0,0,0,0,-39.88,-82.14,-19.5,95.39,2.53,5.56,0.38,-2.85,0,0,0,0,0,0,0,0]},{"duration":0,"tweenEasing":null,"offset":0,"vertices":[]}],"scale":1,"skin":"","offset":0,"name":"display0005","slot":"mesh"}]}],"defaultActions":[{"gotoAndPlay":"idle"}],"type":"Armature","name":"MyArmature","slot":[{"color":{},"name":"point","parent":"point"},{"z":1,"color":{},"name":"mesh","parent":"point"},{"z":2,"color":{},"name":"ball","parent":"ball"},{"z":3,"color":{},"name":"weapon","parent":"ball"}],"ik":[],"aabb":{"width":674.9445000000001,"y":-80.1317,"height":160.1317,"x":-335},"bone":[{"name":"root","transform":{}},{"length":100,"transform":{},"parent":"root","name":"point"},{"length":100,"transform":{"x":100},"parent":"point","name":"ball"}],"frameRate":24,"skin":[{"name":"","slot":[{"display":[{"width":270,"userEdges":[6,7,7,13,13,4,6,15,15,5,9,10,10,6,7,11,11,8,8,9],"type":"mesh","vertices":[-135,-80,135,-80,-135,80,135,80,134.95,-31.85,134.95,31.45,73.3,31.25,73.2,-31.65,-121.4,-67.5,-122.1,66.7,88.45,66.3,89.25,-65.95,107.1,-80,106.3,-31.76,106.5,80,106.3,31.36],"transform":{"x":-200},"height":160,"edges":[2,0,1,4,4,5,5,3,0,12,12,1,3,14,14,2],"path":"display0005","uvs":[0,0,1,0,0,1,1,1,0.99981,0.30094,0.99981,0.69656,0.77148,0.69531,0.77111,0.30219,0.05037,0.07813,0.04778,0.91687,0.82759,0.91438,0.83056,0.08781,0.89667,0,0.89369,0.30152,0.89444,1,0.89369,0.69598],"name":"display0005","triangles":[9,2,10,0,8,11,0,11,12,10,2,14,15,10,14,12,11,13,12,13,4,12,4,1,14,3,5,15,14,5,4,13,5,13,15,5,6,10,15,11,7,13,6,15,13,7,6,13,6,9,10,8,7,11,8,9,6,8,6,7,8,0,9,0,2,9]}],"name":"mesh"},{"display":[{"path":"weapon_1004_1","type":"image","name":"weapon_1004_1","transform":{"y":5,"x":65}}],"name":"weapon"},{"display":[{"path":"display0001","type":"image","name":"display0001","transform":{}}],"name":"point"},{"display":[{"path":"display0009","type":"image","name":"display0009","transform":{"y":-0.1317,"x":104.9445}}],"name":"ball"}]}]}]} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/replace_slot_display/main_tex.json b/reference/Pixi/Demos/resource/assets/replace_slot_display/main_tex.json new file mode 100644 index 0000000..e114583 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/replace_slot_display/main_tex.json @@ -0,0 +1 @@ +{"imagePath":"main_tex.png","width":512,"SubTexture":[{"width":60,"y":325,"height":60,"name":"display0001","x":206},{"width":270,"y":1,"height":160,"name":"display0005","x":1},{"width":270,"y":163,"height":160,"name":"display0009","x":1},{"width":203,"y":325,"height":29,"name":"weapon_1004_1","x":1}],"height":512,"name":"main"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/replace_slot_display/main_tex.png b/reference/Pixi/Demos/resource/assets/replace_slot_display/main_tex.png new file mode 100644 index 0000000..3f6d6b2 Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/replace_slot_display/main_tex.png differ diff --git a/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_ske.json b/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_ske.json new file mode 100644 index 0000000..092f090 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_ske.json @@ -0,0 +1 @@ +{"frameRate":24,"isGlobal":0,"name":"replace","version":"5.0","armature":[{"animation":[{"slot":[],"playTimes":0,"duration":0,"frame":[],"name":"newAnimation","bone":[{"frame":[{"duration":0,"tweenEasing":null,"transform":{}}],"name":"root"}],"ffd":[]}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"type":"Armature","name":"MyMesh","slot":[{"color":{},"name":"meshA","parent":"root"},{"z":1,"color":{},"name":"meshB","parent":"root"},{"z":2,"color":{},"name":"mesh","parent":"root"}],"ik":[],"aabb":{"width":203,"y":-9.5,"height":29,"x":-36.5},"bone":[{"length":100,"name":"root","transform":{}}],"frameRate":24,"skin":[{"name":"","slot":[{"display":[{"path":"weapon_1004_1","type":"image","name":"weapon_1004_1","transform":{"y":5,"x":65}}],"name":"mesh"},{"display":[{"width":203,"userEdges":[7,4,4,5,5,6,6,7,12,11,10,11,10,13,14,6,7,15,14,15],"type":"mesh","vertices":[-101.35,-12.8,143.75,-70.95,-101.45,6.15,123.05,20,103.85,7,126.85,-44,13.75,-17.9,11.9,7.05,-46.25,-21.7,-44.75,20.2,-47.75,-9.4,-48.35,2.95,-101.5,5.9,-101.5,-12.15,-46.3,-10.75,-45.8,12.95,13.9,-25.51,26.61,16.69],"transform":{"y":5,"x":65},"height":29,"edges":[1,3,0,8,9,2,2,12,12,13,13,0,8,16,16,1,3,17,17,9],"path":"weapon_1004_1","uvs":[0,0,1,0,0,1,1,1,0.84852,0.6931,0.91256,0.26207,0.66034,0.2,0.59384,0.71379,0.27438,0.00172,0.26453,1,0.26478,0.17586,0.26182,0.60172,0,0.70345,0,0.08103,0.27685,0.2569,0.27906,0.67586,0.5734,0.00101,0.58153,1],"name":"weapon_1004_1","triangles":[6,5,1,16,6,1,4,17,3,1,5,3,5,4,3,6,4,5,6,7,4,7,17,4,15,9,17,8,14,16,11,9,15,11,15,14,10,11,14,0,10,8,10,14,8,12,2,9,0,13,10,12,9,11,10,13,11,13,12,11,14,7,6,15,17,7,14,15,7,16,14,6]}],"name":"meshB"},{"display":[{"width":203,"userEdges":[],"type":"mesh","vertices":[-101.5,-14.5,297.95,-14.5,-101.5,14.5,296.75,14.5,29.55,-14.5,29.1,14.5,262.95,-14.5,261.75,14.5],"transform":{"y":5,"x":65},"height":29,"edges":[1,3,2,0,0,4,5,2,4,6,6,1,3,7,7,5],"path":"weapon_1004_1","uvs":[0,0,1,0,0,1,1,1,0.64557,0,0.64335,1,0.83793,0,0.84384,1],"name":"weapon_1004_1","triangles":[6,7,1,1,7,3,4,5,6,6,5,7,0,2,5,0,5,4]}],"name":"meshA"}]}]},{"animation":[{"slot":[{"frame":[{"duration":1,"tweenEasing":null},{"duration":1,"tweenEasing":null,"displayIndex":6},{"duration":1,"tweenEasing":null,"displayIndex":1},{"duration":2,"tweenEasing":null,"displayIndex":5},{"duration":1,"tweenEasing":null,"displayIndex":7},{"duration":1,"tweenEasing":null,"displayIndex":8},{"duration":1,"tweenEasing":null,"displayIndex":2},{"duration":9,"tweenEasing":null,"displayIndex":4},{"duration":0,"tweenEasing":null,"displayIndex":3}],"name":"ball"}],"playTimes":0,"duration":17,"frame":[],"name":"newAnimation","bone":[{"frame":[{"duration":17,"tweenEasing":null,"transform":{}}],"name":"root"},{"frame":[{"duration":1,"tweenEasing":null,"transform":{"y":-70.4221,"x":-83.5006}},{"duration":1,"tweenEasing":null,"transform":{"y":-64.552,"x":0.4446}},{"duration":1,"tweenEasing":null,"transform":{"y":-65.0185,"x":105.0759}},{"duration":2,"tweenEasing":null,"transform":{"y":0.8148,"x":105.4037}},{"duration":1,"tweenEasing":null,"transform":{"y":65.3926,"x":0.2229}},{"duration":1,"tweenEasing":null,"transform":{"y":65.4336,"x":-105.0409}},{"duration":1,"tweenEasing":null,"transform":{"y":0.5252,"x":-104.8163}},{"duration":9,"tweenEasing":null,"transform":{}},{"duration":0,"tweenEasing":null,"transform":{"y":65.668,"x":105.3589}}],"name":"ball"}],"ffd":[]}],"defaultActions":[{"gotoAndPlay":"newAnimation"}],"type":"MovieClip","name":"MyDisplay","slot":[{"color":{},"name":"ball","parent":"ball","displayIndex":-1}],"ik":[],"aabb":{"width":270,"y":-151.2369,"height":160,"x":-323.90430000000003},"bone":[{"name":"root","transform":{}},{"transform":{},"name":"ball","parent":"root"}],"frameRate":24,"skin":[{"name":"","slot":[{"display":[{"path":"display0002","type":"image","name":"display0002","transform":{"y":64.6363,"x":104.7465}},{"path":"display0004","type":"image","name":"display0004","transform":{"y":65.0185,"x":-105.0759}},{"path":"display0009","type":"image","name":"display0009","transform":{"y":-0.5252,"x":104.8163}},{"path":"display0006","type":"image","name":"display0006","transform":{"y":-65.668,"x":-105.3589}},{"path":"display0010","type":"image","name":"display0010","transform":{}},{"path":"display0005","type":"image","name":"display0005","transform":{"y":-0.8148,"x":-105.4037}},{"path":"display0003","type":"image","name":"display0003","transform":{"y":64.552,"x":-0.4446}},{"path":"display0007","type":"image","name":"display0007","transform":{"y":-65.3926,"x":-0.2229}},{"path":"display0008","type":"image","name":"display0008","transform":{"y":-65.4336,"x":105.0409}},{"filterType":null,"path":"MyArmature","type":"armature","name":"MyArmature","transform":{}}],"name":"ball"}]}]}]} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_tex.json b/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_tex.json new file mode 100644 index 0000000..fdc44d1 --- /dev/null +++ b/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_tex.json @@ -0,0 +1 @@ +{"imagePath":"replace_tex.png","width":1024,"SubTexture":[{"width":203,"y":1,"height":29,"name":"weapon_1004_1","x":817},{"width":270,"y":1,"height":190,"name":"display0004","x":1},{"width":240,"y":193,"height":160,"name":"display0010","x":757},{"width":240,"y":193,"height":190,"name":"display0003","x":515},{"width":270,"y":1,"height":190,"name":"display0002","x":545},{"width":1,"y":1,"height":1,"name":"MyArmature","x":1022},{"width":270,"y":193,"height":190,"name":"display0008","x":1},{"width":270,"y":385,"height":160,"name":"display0009","x":1},{"width":240,"y":193,"height":190,"name":"display0007","x":273},{"width":270,"y":1,"height":190,"name":"display0006","x":273},{"width":270,"y":385,"height":160,"name":"display0005","x":273}],"height":1024,"name":"replace"} \ No newline at end of file diff --git a/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_tex.png b/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_tex.png new file mode 100644 index 0000000..0c85ad0 Binary files /dev/null and b/reference/Pixi/Demos/resource/assets/replace_slot_display/replace_tex.png differ diff --git a/reference/Pixi/Demos/src/AnimationBaseTest.ts b/reference/Pixi/Demos/src/AnimationBaseTest.ts new file mode 100644 index 0000000..c599c6b --- /dev/null +++ b/reference/Pixi/Demos/src/AnimationBaseTest.ts @@ -0,0 +1,111 @@ +class AnimationBaseTest extends BaseTest { + + private _armatureDisplay: dragonBones.PixiArmatureDisplay; + + protected _onStart(): void { + PIXI.loader + .add("dragonBonesData", "./resource/assets/animation_base_test_ske.json") + .add("textureData", "./resource/assets/animation_base_test_tex.json") + .add("texture", "./resource/assets/animation_base_test_tex.png"); + + PIXI.loader.once("complete", (loader: PIXI.loaders.Loader, resources: dragonBones.Map) => { + const factory = dragonBones.PixiFactory.factory; + factory.parseDragonBonesData(resources["dragonBonesData"].data); + factory.parseTextureAtlasData(resources["textureData"].data, resources["texture"].texture); + + this._armatureDisplay = factory.buildArmatureDisplay("progressBar"); + this._armatureDisplay.x = this.stage.width * 0.5; + this._armatureDisplay.y = this.stage.height * 0.5; + this.stage.addChild(this._armatureDisplay); + + // Test animation event + this._armatureDisplay.addListener(dragonBones.EventObject.START, this._animationEventHandler, this); + this._armatureDisplay.addListener(dragonBones.EventObject.LOOP_COMPLETE, this._animationEventHandler, this); + this._armatureDisplay.addListener(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this); + this._armatureDisplay.addListener(dragonBones.EventObject.FADE_IN, this._animationEventHandler, this); + this._armatureDisplay.addListener(dragonBones.EventObject.FADE_IN_COMPLETE, this._animationEventHandler, this); + this._armatureDisplay.addListener(dragonBones.EventObject.FADE_OUT, this._animationEventHandler, this); + this._armatureDisplay.addListener(dragonBones.EventObject.FADE_OUT_COMPLETE, this._animationEventHandler, this); + + // Test frame event + this._armatureDisplay.addListener(dragonBones.EventObject.FRAME_EVENT, this._animationEventHandler, this); + + // Test animation config. + // const animaitonConfig = this._armatureDisplay.animation.animationConfig; + // animaitonConfig.name = "test"; // Animation state name. + // animaitonConfig.animation = "idle"; // Animation name. + + // animaitonConfig.playTimes = 1; // Play one time. + // animaitonConfig.playTimes = 3; // Play several times. + // animaitonConfig.playTimes = 0; // Loop play. + + // animaitonConfig.timeScale = 1.0; // Play speed. + // animaitonConfig.timeScale = -1.0; // Reverse play. + + // animaitonConfig.position = 1.0; // Goto and play. + // animaitonConfig.duration = 3.0; // Interval play. + // this._armatureDisplay.animation.playConfig(animaitonConfig); + + this._armatureDisplay.animation.play("idle", 1); + + // + this.stage.interactive = true; + this.stage.addListener("touchstart", this._touchHandler, this); + this.stage.addListener("touchend", this._touchHandler, this); + this.stage.addListener("touchmove", this._touchHandler, this); + this.stage.addListener("mousedown", this._touchHandler, this); + this.stage.addListener("mouseup", this._touchHandler, this); + this.stage.addListener("mousemove", this._touchHandler, this); + + const text = new PIXI.Text("", { align: "center" }); + text.text = "Click to control animation play progress."; + text.scale.x = 0.7; + text.scale.y = 0.7; + text.x = (this.renderer.width - text.width) * 0.5; + text.y = this.renderer.height - 60; + this._stage.addChild(text); + + // + this._startRenderTick(); + }); + + PIXI.loader.load(); + } + + private _isTouched: boolean = false; + private _touchHandler(event: PIXI.interaction.InteractionEvent): void { + const progress = Math.min(Math.max((event.data.global.x - this._armatureDisplay.x + 300) / 600, 0.0), 1.0); + switch (event.type) { + case "touchstart": + case "mousedown": + this._isTouched = true; + // this._armatureDisplay.animation.gotoAndPlayByTime("idle", 0.5, 1); + // this._armatureDisplay.animation.gotoAndStopByTime("idle", 1); + + // this._armatureDisplay.animation.gotoAndPlayByFrame("idle", 25, 2); + // this._armatureDisplay.animation.gotoAndStopByFrame("idle", 50); + + // this._armatureDisplay.animation.gotoAndPlayByProgress("idle", progress, 3); + this._armatureDisplay.animation.gotoAndStopByProgress("idle", progress); + break; + + case "touchend": + case "mouseup": + this._isTouched = false; + this._armatureDisplay.animation.play(); + break; + + case "touchmove": + case "mousemove": + if (this._isTouched) { + const animationState = this._armatureDisplay.animation.getState("idle"); + animationState.currentTime = animationState.totalTime * progress; + } + break; + } + } + + private _animationEventHandler(event: dragonBones.EventObject): void { + console.log(event.animationState.name, event.type, event.name ? event.name : ""); + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/src/BaseTest.ts b/reference/Pixi/Demos/src/BaseTest.ts new file mode 100644 index 0000000..0c5980d --- /dev/null +++ b/reference/Pixi/Demos/src/BaseTest.ts @@ -0,0 +1,35 @@ +abstract class BaseTest { + protected readonly _renderer = new PIXI.WebGLRenderer(1136, 640); + protected readonly _stage = new PIXI.Container(); + protected readonly _backgroud: PIXI.Sprite = new PIXI.Sprite(PIXI.Texture.EMPTY); + + public constructor() { + this._renderer.backgroundColor = 0x666666; + this._backgroud.width = this._renderer.width; + this._backgroud.height = this._renderer.height; + this._stage.addChild(this._backgroud); + + document.body.appendChild(this._renderer.view); + + this._onStart(); + } + + private _renderHandler(deltaTime: number): void { + this._renderer.render(this._stage); + } + + protected _startRenderTick(): void { + // Make sure render after dragonBones update. + PIXI.ticker.shared.add(this._renderHandler, this); + } + + protected abstract _onStart(): void; + + public get renderer(): PIXI.WebGLRenderer { + return this._renderer; + } + + public get stage(): PIXI.Container { + return this._stage; + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/src/CoreElement.ts b/reference/Pixi/Demos/src/CoreElement.ts new file mode 100644 index 0000000..70cc4cf --- /dev/null +++ b/reference/Pixi/Demos/src/CoreElement.ts @@ -0,0 +1,570 @@ +namespace coreElement { + type PointType = PIXI.Point; + type ArmatureDisplayType = dragonBones.PixiArmatureDisplay; + type EventType = dragonBones.EventObject; + + export class Game extends BaseTest { + public static STAGE_WIDTH: number; + public static STAGE_HEIGHT: number; + public static GROUND: number; + public static G: number = 0.6; + public static instance: Game; + + private _left: boolean = false; + private _right: boolean = false; + private _player: Mecha; + private readonly _bullets: Array = []; + + protected _onStart(): void { + PIXI.loader + .add("dataA", "./resource/assets/core_element/mecha_1502b_ske.json") + .add("textureDataA", "./resource/assets/core_element/mecha_1502b_tex.json") + .add("textureA", "./resource/assets/core_element/mecha_1502b_tex.png") + .add("dataB", "./resource/assets/core_element/skin_1502b_ske.json") + .add("textureDataB", "./resource/assets/core_element/skin_1502b_tex.json") + .add("textureB", "./resource/assets/core_element/skin_1502b_tex.png") + .add("dataC", "./resource/assets/core_element/weapon_1000_ske.json") + .add("textureDataC", "./resource/assets/core_element/weapon_1000_tex.json") + .add("textureC", "./resource/assets/core_element/weapon_1000_tex.png"); + + PIXI.loader.once("complete", (loader: PIXI.loaders.Loader, resources: dragonBones.Map) => { + Game.STAGE_WIDTH = this._stage.width; + Game.STAGE_HEIGHT = this._stage.height; + Game.GROUND = Game.STAGE_HEIGHT - 150; + Game.instance = this; + PIXI.ticker.shared.add(this._enterFrameHandler, this); + + const factory = dragonBones.PixiFactory.factory; + factory.parseDragonBonesData(resources["dataA"].data); + factory.parseTextureAtlasData(resources["textureDataA"].data, resources["textureA"].texture); + factory.parseDragonBonesData(resources["dataB"].data); + factory.parseTextureAtlasData(resources["textureDataB"].data, resources["textureB"].texture); + factory.parseDragonBonesData(resources["dataC"].data); + factory.parseTextureAtlasData(resources["textureDataC"].data, resources["textureC"].texture); + + this._player = new Mecha(); + + // Listener. + this._stage.interactive = true; + this._stage.addListener('touchstart', this._touchHandler, this); + this._stage.addListener('touchend', this._touchHandler, this); + this._stage.addListener('touchmove', this._touchHandler, this); + this._stage.addListener('mousedown', this._touchHandler, this); + this._stage.addListener('mouseup', this._touchHandler, this); + this._stage.addListener('mousemove', this._touchHandler, this); + this._stage.addChild(this._backgroud); + document.addEventListener("keydown", this._keyHandler); + document.addEventListener("keyup", this._keyHandler); + + // Info. + const text = new PIXI.Text("", { align: "center" }); + text.text = "Press W/A/S/D to move. Press Q/E to switch weapons. Press SPACE to switch skin.\nMouse Move to aim. Click to fire."; + text.scale.x = 0.7; + text.scale.y = 0.7; + text.x = (Game.STAGE_WIDTH - text.width) * 0.5; + text.y = Game.STAGE_HEIGHT - 60; + this._stage.addChild(text); + + // + this._startRenderTick(); + }); + + PIXI.loader.load(); + } + + private _touchHandler(event: PIXI.interaction.InteractionEvent): void { + this._player.aim(event.data.global.x, event.data.global.y); + + if (event.type === 'touchstart' || event.type === 'mousedown') { + this._player.attack(true); + } + else if (event.type === 'touchend' || event.type === 'mouseup') { + this._player.attack(false); + } + } + + private _keyHandler(event: KeyboardEvent): void { + const isDown = event.type === "keydown"; + switch (event.keyCode) { + case 37: + case 65: + Game.instance._left = isDown; + Game.instance._updateMove(-1); + break; + + case 39: + case 68: + Game.instance._right = isDown; + Game.instance._updateMove(1); + break; + + case 38: + case 87: + if (isDown) { + Game.instance._player.jump(); + } + break; + + case 83: + case 40: + Game.instance._player.squat(isDown); + break; + + case 81: + if (isDown) { + Game.instance._player.switchWeaponR(); + } + break; + + case 69: + if (isDown) { + Game.instance._player.switchWeaponL(); + } + break; + + case 32: + if (isDown) { + Game.instance._player.switchSkin(); + } + break; + } + } + + private _enterFrameHandler(deltaTime: number): void { // Make sure game update before dragonBones update. + if (this._player) { + this._player.update(); + } + + let i = this._bullets.length; + while (i--) { + const bullet = this._bullets[i]; + if (bullet.update()) { + this._bullets.splice(i, 1); + } + } + } + + private _updateMove(dir: number): void { + if (this._left && this._right) { + this._player.move(dir); + } + else if (this._left) { + this._player.move(-1); + } + else if (this._right) { + this._player.move(1); + } + else { + this._player.move(0); + } + } + + public addBullet(bullet: Bullet): void { + this._bullets.push(bullet); + } + } + + class Mecha { + private static readonly JUMP_SPEED: number = 20; + private static readonly NORMALIZE_MOVE_SPEED: number = 3.6; + private static readonly MAX_MOVE_SPEED_FRONT: number = Mecha.NORMALIZE_MOVE_SPEED * 1.4; + private static readonly MAX_MOVE_SPEED_BACK: number = Mecha.NORMALIZE_MOVE_SPEED * 1.0; + private static readonly NORMAL_ANIMATION_GROUP: string = "normal"; + private static readonly AIM_ANIMATION_GROUP: string = "aim"; + private static readonly ATTACK_ANIMATION_GROUP: string = "attack"; + private static readonly WEAPON_L_LIST: Array = ["weapon_1502b_l", "weapon_1005", "weapon_1005b", "weapon_1005c", "weapon_1005d", "weapon_1005e"]; + private static readonly WEAPON_R_LIST: Array = ["weapon_1502b_r", "weapon_1005", "weapon_1005b", "weapon_1005c", "weapon_1005d"]; + private static readonly SKINS: Array = ["mecha_1502b", "skin_a", "skin_b", "skin_c"]; + + private _isJumpingA: boolean = false; + private _isJumpingB: boolean = false; + private _isSquating: boolean = false; + private _isAttackingA: boolean = false; + private _isAttackingB: boolean = false; + private _weaponRIndex: number = 0; + private _weaponLIndex: number = 0; + private _skinIndex: number = 0; + private _faceDir: number = 1; + private _aimDir: number = 0; + private _moveDir: number = 0; + private _aimRadian: number = 0.0; + private _speedX: number = 0.0; + private _speedY: number = 0.0; + private _armature: dragonBones.Armature; + private _armatureDisplay: ArmatureDisplayType; + private _weaponL: dragonBones.Armature; + private _weaponR: dragonBones.Armature; + private _aimState: dragonBones.AnimationState | null = null; + private _walkState: dragonBones.AnimationState | null = null; + private _attackState: dragonBones.AnimationState | null = null; + private readonly _target: PointType = new PIXI.Point(); + private readonly _helpPoint: PointType = new PIXI.Point(); + + public constructor() { + this._armatureDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay("mecha_1502b"); + this._armatureDisplay.x = Game.STAGE_WIDTH * 0.5; + this._armatureDisplay.y = Game.GROUND; + this._armature = this._armatureDisplay.armature; + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.FADE_IN_COMPLETE, this._animationEventHandler, this); + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.FADE_OUT_COMPLETE, this._animationEventHandler, this); + this._armature.eventDispatcher.addEvent(dragonBones.EventObject.COMPLETE, this._animationEventHandler, this); + + // Get weapon childArmature. + this._weaponL = this._armature.getSlot("weapon_l").childArmature; + this._weaponR = this._armature.getSlot("weapon_r").childArmature; + this._weaponL.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + this._weaponR.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + + Game.instance.stage.addChild(this._armatureDisplay); + this._updateAnimation(); + } + + public move(dir: number): void { + if (this._moveDir === dir) { + return; + } + + this._moveDir = dir; + this._updateAnimation(); + } + + public jump(): void { + if (this._isJumpingA) { + return; + } + + this._isJumpingA = true; + this._armature.animation.fadeIn( + "jump_1", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + + this._walkState = null; + } + + public squat(isSquating: boolean): void { + if (this._isSquating === isSquating) { + return; + } + + this._isSquating = isSquating; + this._updateAnimation(); + } + + public attack(isAttacking: boolean): void { + if (this._isAttackingA === isAttacking) { + return; + } + + this._isAttackingA = isAttacking; + } + + public switchWeaponL(): void { + this._weaponL.eventDispatcher.removeEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + + this._weaponLIndex++; + this._weaponLIndex %= Mecha.WEAPON_L_LIST.length; + const weaponName = Mecha.WEAPON_L_LIST[this._weaponLIndex]; + this._weaponL = dragonBones.PixiFactory.factory.buildArmature(weaponName); + this._armature.getSlot("weapon_l").childArmature = this._weaponL; + this._weaponL.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + } + + public switchWeaponR(): void { + this._weaponR.eventDispatcher.removeEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + + this._weaponRIndex++; + this._weaponRIndex %= Mecha.WEAPON_R_LIST.length; + const weaponName = Mecha.WEAPON_R_LIST[this._weaponRIndex]; + this._weaponR = dragonBones.PixiFactory.factory.buildArmature(weaponName); + this._armature.getSlot("weapon_r").childArmature = this._weaponR; + this._weaponR.eventDispatcher.addEvent(dragonBones.EventObject.FRAME_EVENT, this._frameEventHandler, this); + } + + public switchSkin(): void { + this._skinIndex++; + this._skinIndex %= Mecha.SKINS.length; + const skinName = Mecha.SKINS[this._skinIndex]; + const skinData = dragonBones.PixiFactory.factory.getArmatureData(skinName).defaultSkin; + dragonBones.PixiFactory.factory.changeSkin(this._armature, skinData, ["weapon_l", "weapon_r"]); + } + + public aim(x: number, y: number): void { + this._target.x = x; + this._target.y = y; + } + + public update(): void { + this._updatePosition(); + this._updateAim(); + this._updateAttack(); + } + + private _animationEventHandler(event: EventType): void { + switch (event.type) { + case dragonBones.EventObject.FADE_IN_COMPLETE: + if (event.animationState.name === "jump_1") { + this._isJumpingB = true; + this._speedY = -Mecha.JUMP_SPEED; + + if (this._moveDir !== 0) { + if (this._moveDir * this._faceDir > 0) { + this._speedX = Mecha.MAX_MOVE_SPEED_FRONT * this._faceDir; + } + else { + this._speedX = -Mecha.MAX_MOVE_SPEED_BACK * this._faceDir; + } + } + + this._armature.animation.fadeIn( + "jump_2", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + } + break; + + case dragonBones.EventObject.FADE_OUT_COMPLETE: + if (event.animationState.name === "attack_01") { + this._isAttackingB = false; + this._attackState = null; + } + break; + + case dragonBones.EventObject.COMPLETE: + if (event.animationState.name === "jump_4") { + this._isJumpingA = false; + this._isJumpingB = false; + this._updateAnimation(); + } + break; + } + } + + private _frameEventHandler(event: EventType): void { + if (event.name === "fire") { + this._helpPoint.x = event.bone.global.x; + this._helpPoint.y = event.bone.global.y; + this._helpPoint.copy((event.armature.display).toGlobal(this._helpPoint)); + + this._fire(this._helpPoint); + } + } + + private _fire(firePoint: PointType): void { + const radian = this._faceDir < 0 ? Math.PI - this._aimRadian : this._aimRadian; + const bullet = new Bullet("bullet_01", "fire_effect_01", radian + Math.random() * 0.02 - 0.01, 40, firePoint); + Game.instance.addBullet(bullet); + } + + private _updateAnimation(): void { + if (this._isJumpingA) { + return; + } + + if (this._isSquating) { + this._speedX = 0; + this._armature.animation.fadeIn( + "squat", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + + this._walkState = null; + return; + } + + if (this._moveDir === 0) { + this._speedX = 0; + this._armature.animation.fadeIn( + "idle", -1.0, -1, 0, + Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + + this._walkState = null; + } + else { + if (this._walkState === null) { + this._walkState = this._armature.animation.fadeIn( + "walk", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ); + + this._walkState.resetToPose = false; + } + + if (this._moveDir * this._faceDir > 0) { + this._walkState.timeScale = Mecha.MAX_MOVE_SPEED_FRONT / Mecha.NORMALIZE_MOVE_SPEED; + } + else { + this._walkState.timeScale = -Mecha.MAX_MOVE_SPEED_BACK / Mecha.NORMALIZE_MOVE_SPEED; + } + + if (this._moveDir * this._faceDir > 0) { + this._speedX = Mecha.MAX_MOVE_SPEED_FRONT * this._faceDir; + } + else { + this._speedX = -Mecha.MAX_MOVE_SPEED_BACK * this._faceDir; + } + } + } + + private _updatePosition(): void { + if (this._speedX !== 0.0) { + this._armatureDisplay.x += this._speedX; + if (this._armatureDisplay.x < 0) { + this._armatureDisplay.x = 0; + } + else if (this._armatureDisplay.x > Game.STAGE_WIDTH) { + this._armatureDisplay.x = Game.STAGE_WIDTH; + } + } + + if (this._speedY !== 0.0) { + if (this._speedY < 5.0 && this._speedY + Game.G >= 5.0) { + this._armature.animation.fadeIn( + "jump_3", -1.0, -1, 0 + , Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + } + + this._speedY += Game.G; + this._armatureDisplay.y += this._speedY; + + if (this._armatureDisplay.y > Game.GROUND) { + this._armatureDisplay.y = Game.GROUND; + this._speedY = 0.0; + this._armature.animation.fadeIn( + "jump_4", -1.0, -1, + 0, Mecha.NORMAL_ANIMATION_GROUP + ).resetToPose = false; + } + } + } + + private _updateAim(): void { + this._faceDir = this._target.x > this._armatureDisplay.x ? 1 : -1; + if (this._armatureDisplay.armature.flipX !== this._faceDir < 0) { + this._armatureDisplay.armature.flipX = !this._armatureDisplay.armature.flipX; + if (this._moveDir !== 0) { + this._updateAnimation(); + } + } + + const aimOffsetY = this._armature.getBone("chest").global.y * this._armatureDisplay.scale.y; + if (this._faceDir > 0) { + this._aimRadian = Math.atan2(this._target.y - this._armatureDisplay.y - aimOffsetY, this._target.x - this._armatureDisplay.x); + } + else { + this._aimRadian = Math.PI - Math.atan2(this._target.y - this._armatureDisplay.y - aimOffsetY, this._target.x - this._armatureDisplay.x); + if (this._aimRadian > Math.PI) { + this._aimRadian -= Math.PI * 2.0; + } + } + + let aimDir = 0; + if (this._aimRadian > 0.0) { + aimDir = -1; + } + else { + aimDir = 1; + } + + if (this._aimState === null || this._aimDir !== aimDir) { + this._aimDir = aimDir; + + // Animation mixing. + if (this._aimDir >= 0) { + this._aimState = this._armature.animation.fadeIn( + "aim_up", -1.0, -1, + 0, Mecha.AIM_ANIMATION_GROUP + ); + } + else { + this._aimState = this._armature.animation.fadeIn( + "aim_down", -1.0, -1, + 0, Mecha.AIM_ANIMATION_GROUP + ); + } + + this._aimState.resetToPose = false; + } + + this._aimState.weight = Math.abs(this._aimRadian / Math.PI * 2); + this._armature.invalidUpdate(); + } + + private _updateAttack(): void { + if (!this._isAttackingA || this._isAttackingB) { + return; + } + + this._isAttackingB = true; + this._attackState = this._armature.animation.fadeIn( + "attack_01", -1.0, -1, + 0, Mecha.ATTACK_ANIMATION_GROUP + ); + + this._attackState.resetToPose = false; + this._attackState.autoFadeOutTime = this._attackState.fadeTotalTime; + } + } + + class Bullet { + private _speedX: number = 0.0; + private _speedY: number = 0.0; + + private _armatureDisplay: ArmatureDisplayType; + private _effecDisplay: ArmatureDisplayType | null = null; + + public constructor(armatureName: string, effectArmatureName: string | null, radian: number, speed: number, position: PointType) { + this._speedX = Math.cos(radian) * speed; + this._speedY = Math.sin(radian) * speed; + + this._armatureDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay(armatureName); + this._armatureDisplay.x = position.x + Math.random() * 2 - 1; + this._armatureDisplay.y = position.y + Math.random() * 2 - 1; + this._armatureDisplay.rotation = radian; + + if (effectArmatureName !== null) { + this._effecDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay(effectArmatureName); + this._effecDisplay.rotation = radian; + this._effecDisplay.x = this._armatureDisplay.x; + this._effecDisplay.y = this._armatureDisplay.y; + this._effecDisplay.scale.set( + 1 + Math.random() * 1, + 1 + Math.random() * 0.5 + ); + if (Math.random() < 0.5) { + this._effecDisplay.scale.y *= -1; + } + + Game.instance.stage.addChild(this._effecDisplay); + this._effecDisplay.animation.play("idle"); + } + + Game.instance.stage.addChild(this._armatureDisplay); + this._armatureDisplay.animation.play("idle"); + } + + public update(): boolean { + this._armatureDisplay.x += this._speedX; + this._armatureDisplay.y += this._speedY; + + if ( + this._armatureDisplay.x < -100.0 || this._armatureDisplay.x >= Game.STAGE_WIDTH + 100.0 || + this._armatureDisplay.y < -100.0 || this._armatureDisplay.y >= Game.STAGE_HEIGHT + 100.0 + ) { + Game.instance.stage.removeChild(this._armatureDisplay); + this._armatureDisplay.dispose(); + + if (this._effecDisplay !== null) { + Game.instance.stage.removeChild(this._effecDisplay); + this._effecDisplay.dispose(); + } + + return true; + } + + return false; + } + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/src/HelloDragonBones.ts b/reference/Pixi/Demos/src/HelloDragonBones.ts new file mode 100644 index 0000000..42f53da --- /dev/null +++ b/reference/Pixi/Demos/src/HelloDragonBones.ts @@ -0,0 +1,44 @@ +/** + * How to use + * 1. Load data. + * + * 2. Parse data. + * factory.parseDragonBonesData(); + * factory.parseTextureAtlasData(); + * + * 3. Build armature. + * armatureDisplay = factory.buildArmatureDisplay("armatureName"); + * + * 4. Play animation. + * armatureDisplay.animation.play("animationName"); + * + * 5. Add armature to stage. + * addChild(armatureDisplay); + */ +class HelloDragonBones extends BaseTest { + protected _onStart(): void { + PIXI.loader + // .add("dragonBonesData", "./resource/assets/dragon_boy_ske.json") + .add("dragonBonesData", "./resource/assets/dragon_boy_ske.dbbin", { loadType: PIXI.loaders.Resource.LOAD_TYPE.XHR, xhrType: PIXI.loaders.Resource.XHR_RESPONSE_TYPE.BUFFER } as any) + .add("textureData", "./resource/assets/dragon_boy_tex.json") + .add("texture", "./resource/assets/dragon_boy_tex.png"); + + PIXI.loader.once("complete", (loader: PIXI.loaders.Loader, resources: dragonBones.Map) => { + const factory = dragonBones.PixiFactory.factory; + factory.parseDragonBonesData(resources["dragonBonesData"].data); + factory.parseTextureAtlasData(resources["textureData"].data, resources["texture"].texture); + + const armatureDisplay = factory.buildArmatureDisplay("DragonBoy"); + armatureDisplay.animation.play("walk"); + this.stage.addChild(armatureDisplay); + + armatureDisplay.x = this._renderer.width * 0.5; + armatureDisplay.y = this._renderer.height * 0.5 + 100; + + // + this._startRenderTick(); + }); + + PIXI.loader.load(); + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/src/PerformanceTest.ts b/reference/Pixi/Demos/src/PerformanceTest.ts new file mode 100644 index 0000000..b83491b --- /dev/null +++ b/reference/Pixi/Demos/src/PerformanceTest.ts @@ -0,0 +1,141 @@ +class PerformanceTest extends BaseTest { + private _addingArmature: boolean = false; + private _removingArmature: boolean = false; + private readonly _text: PIXI.Text = new PIXI.Text("", { align: "center" }); + private readonly _armatures: Array = []; + private _resources: dragonBones.Map; + + protected _onStart(): void { + PIXI.loader + .add("dragonBonesData", "./resource/assets/dragon_boy_ske.json") + .add("textureData", "./resource/assets/dragon_boy_tex.json") + .add("texture", "./resource/assets/dragon_boy_tex.png"); + + PIXI.loader.once("complete", (loader: PIXI.loaders.Loader, resources: dragonBones.Map) => { + this._resources = resources; + // + this._text.scale.x = 0.7; + this._text.scale.y = 0.7; + this.stage.addChild(this._text); + + // + this._stage.interactive = true; + this._stage.addListener("touchstart", this._touchHandler, this); + this._stage.addListener("touchend", this._touchHandler, this); + this._stage.addListener("mousedown", this._touchHandler, this); + this._stage.addListener("mouseup", this._touchHandler, this); + PIXI.ticker.shared.add(this._enterFrameHandler, this); + + for (let i = 0; i < 100; ++i) { + this._addArmature(); + } + + this._resetPosition(); + this._updateText(); + + // + this._startRenderTick(); + }); + + PIXI.loader.load(); + } + + private _enterFrameHandler(deltaTime: number): void { + if (this._addingArmature) { + for (let i = 0; i < 10; ++i) { + this._addArmature(); + } + + this._resetPosition(); + this._updateText(); + } + + if (this._removingArmature) { + for (let i = 0; i < 10; ++i) { + this._removeArmature(); + } + + this._resetPosition(); + this._updateText(); + } + } + + private _touchHandler(event: PIXI.interaction.InteractionEvent): void { + switch (event.type) { + case "touchstart": + case "mousedown": + const touchRight = event.data.global.x > this._renderer.width * 0.5; + this._addingArmature = touchRight; + this._removingArmature = !touchRight; + break; + + case "touchend": + case "mouseup": + this._addingArmature = false; + this._removingArmature = false; + break; + } + } + + private _addArmature(): void { + if (this._armatures.length === 0) { + dragonBones.PixiFactory.factory.parseDragonBonesData(this._resources["dragonBonesData"].data); + dragonBones.PixiFactory.factory.parseTextureAtlasData(this._resources["textureData"].data, this._resources["texture"].texture); + } + + const armatureDisplay = dragonBones.PixiFactory.factory.buildArmatureDisplay("DragonBoy"); + armatureDisplay.armature.cacheFrameRate = 24; + armatureDisplay.animation.play("walk", 0); + armatureDisplay.scale.set(0.7, 0.7); + this.stage.addChild(armatureDisplay); + + this._armatures.push(armatureDisplay); + } + + private _removeArmature(): void { + if (this._armatures.length === 0) { + return; + } + + const armatureDisplay = this._armatures.pop(); + this.stage.removeChild(armatureDisplay); + armatureDisplay.dispose(); + + if (this._armatures.length === 0) { + dragonBones.PixiFactory.factory.clear(true); + dragonBones.BaseObject.clearPool(); + } + } + + private _resetPosition(): void { + const armatureCount = this._armatures.length; + if (armatureCount === 0) { + return; + } + + const paddingH = 50; + const paddingV = 150; + const gapping = 100; + + const stageWidth = this.renderer.width - paddingH * 2; + const columnCount = Math.floor(stageWidth / gapping); + const paddingHModify = (this.renderer.width - columnCount * gapping) * 0.5; + const dX = stageWidth / columnCount; + const dY = (this.renderer.height - paddingV * 2) / Math.ceil(armatureCount / columnCount); + + for (let i = 0, l = armatureCount; i < l; ++i) { + const armatureDisplay = this._armatures[i]; + const lineY = Math.floor(i / columnCount); + + armatureDisplay.x = (i % columnCount) * dX + paddingHModify; + armatureDisplay.y = lineY * dY + paddingV; + } + } + + private _updateText(): void { + this._text.text = "Count: " + this._armatures.length + " \nTouch screen left to decrease count / right to increase count."; + this._text.x = (this.renderer.width - this._text.width) * 0.5; + this._text.y = this.renderer.height - 60; + this.stage.addChild(this._text); + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/src/ReplaceSlotDisplay.ts b/reference/Pixi/Demos/src/ReplaceSlotDisplay.ts new file mode 100644 index 0000000..7f0af5a --- /dev/null +++ b/reference/Pixi/Demos/src/ReplaceSlotDisplay.ts @@ -0,0 +1,129 @@ +class ReplaceSlotDisplay extends BaseTest { + + private _displayIndex: number = 0; + private readonly _replaceDisplays: string[] = [ + // Replace normal display. + "display0002", "display0003", "display0004", "display0005", "display0006", "display0007", "display0008", "display0009", "display0010", + // Replace mesh display. + "meshA", "meshB", "meshC", + ]; + + private readonly _factory: dragonBones.PixiFactory = dragonBones.PixiFactory.factory; + private _armatureDisplay: dragonBones.PixiArmatureDisplay; + + protected _onStart(): void { + PIXI.loader + .add("dragonBonesDataA", "./resource/assets/replace_slot_display/main_ske.json") + .add("textureDataA", "./resource/assets/replace_slot_display/main_tex.json") + .add("textureA", "./resource/assets/replace_slot_display/main_tex.png") + .add("dragonBonesDataB", "./resource/assets/replace_slot_display/replace_ske.json") + .add("textureDataB", "./resource/assets/replace_slot_display/replace_tex.json") + .add("textureB", "./resource/assets/replace_slot_display/replace_tex.png"); + + PIXI.loader.once("complete", (loader: PIXI.loaders.Loader, resources: dragonBones.Map) => { + this._factory.parseDragonBonesData(resources["dragonBonesDataA"].data); + this._factory.parseTextureAtlasData(resources["textureDataA"].data, resources["textureA"].texture); + this._factory.parseDragonBonesData(resources["dragonBonesDataB"].data); + this._factory.parseTextureAtlasData(resources["textureDataB"].data, resources["textureB"].texture); + + this._armatureDisplay = this._factory.buildArmatureDisplay("MyArmature"); + this._armatureDisplay.animation.timeScale = 0.1; + this._armatureDisplay.animation.play(); + + this._armatureDisplay.x = this.stage.width * 0.5; + this._armatureDisplay.y = this.stage.height * 0.5; + this.stage.addChild(this._armatureDisplay); + + const touchHandler = (event: PIXI.interaction.InteractionEvent): void => { + this._replaceDisplay(); + }; + this.stage.interactive = true; + this.stage.addListener("touchstart", touchHandler, this); + this.stage.addListener("mousedown", touchHandler, this); + + // + this._startRenderTick(); + }); + + PIXI.loader.load(); + } + + private _replaceDisplay(): void { + this._displayIndex = (this._displayIndex + 1) % this._replaceDisplays.length; + + const replaceDisplayName = this._replaceDisplays[this._displayIndex]; + + if (replaceDisplayName.indexOf("mesh") >= 0) { // Replace mesh display. + switch (replaceDisplayName) { + case "meshA": + // Normal to mesh. + this._factory.replaceSlotDisplay( + "replace", + "MyMesh", + "meshA", + "weapon_1004_1", + this._armatureDisplay.armature.getSlot("weapon") + ); + + // Replace mesh texture. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + "display0002", + this._armatureDisplay.armature.getSlot("mesh") + ); + break; + + case "meshB": + // Normal to mesh. + this._factory.replaceSlotDisplay( + "replace", + "MyMesh", + "meshB", + "weapon_1004_1", + this._armatureDisplay.armature.getSlot("weapon") + ); + + // Replace mesh texture. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + "display0003", + this._armatureDisplay.armature.getSlot("mesh") + ); + break; + + case "meshC": + // Back to normal. + this._factory.replaceSlotDisplay( + "replace", + "MyMesh", + "mesh", + "weapon_1004_1", + this._armatureDisplay.armature.getSlot("weapon") + ); + + // Replace mesh texture. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + "display0005", + this._armatureDisplay.armature.getSlot("mesh") + ); + break; + } + } + else { // Replace normal display. + this._factory.replaceSlotDisplay( + "replace", + "MyDisplay", + "ball", + replaceDisplayName, + this._armatureDisplay.armature.getSlot("ball") + ); + } + } +} \ No newline at end of file diff --git a/reference/Pixi/Demos/tsconfig.json b/reference/Pixi/Demos/tsconfig.json new file mode 100644 index 0000000..c2fc9e2 --- /dev/null +++ b/reference/Pixi/Demos/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "watch": false, + "sourceMap": false, + "declaration": false, + "alwaysStrict": true, + "noImplicitAny": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": false, + "strictNullChecks": false, + "experimentalDecorators": true, + "allowSyntheticDefaultImports": true, + "target": "es5", + "module": "commonjs", + "outDir": "./out" + }, + "exclude": [ + "node_modules", + "out" + ] +} \ No newline at end of file diff --git a/reference/Pixi/Demos/tslint.json b/reference/Pixi/Demos/tslint.json new file mode 100644 index 0000000..eeb58d1 --- /dev/null +++ b/reference/Pixi/Demos/tslint.json @@ -0,0 +1,15 @@ +{ + "rules": { + "no-unused-expression": true, + "no-unreachable": true, + "no-duplicate-variable": true, + "no-duplicate-key": true, + "no-unused-variable": true, + "curly": false, + "class-name": true, + "triple-equals": true, + "semicolon": [ + true + ] + } +} \ No newline at end of file diff --git a/reference/Pixi/README.md b/reference/Pixi/README.md new file mode 100644 index 0000000..7d77599 --- /dev/null +++ b/reference/Pixi/README.md @@ -0,0 +1,5 @@ +# DragonBones Pixi library + +## [Demos](./Demos/) + +## [Pixi](http://www.pixijs.com/) \ No newline at end of file diff --git a/reference/README.md b/reference/README.md new file mode 100644 index 0000000..71b7179 --- /dev/null +++ b/reference/README.md @@ -0,0 +1,21 @@ +# DragonBones JavaScript / TypeScript Runtime +* [DragonBones common library](./DragonBones/) +* Highly suggest use [DragonBones Pro](http://www.dragonbones.com/) to create aniamtion. + +## Supported engines +* [Egret](http://www.egret.com/) - [How to use DragonBones in Egret](./Egret/) +* [Pixi](http://www.pixijs.com/) - [How to use DragonBones in Pixi](./Pixi/) + +## To learn more about +* [DragonBones WebSite](http://www.dragonbones.com/) +* [DragonBones Pro WebSite](http://www.egret.com/products/dragonbones.html) +* [Demos](http://www.dragonbones.com/demo/index.html) + +## Release Notes +* [DragonBones 4.7 release notes](https://github.com/DragonBones/DragonBonesJS/blob/master/docs/DragonBones_4.7_release_notes_zh.md) + +## DragonBones data format +* [DragonBones 5.0 data format](https://github.com/DragonBones/DragonBonesJS/blob/master/docs/DragonBones_5.0_data_format_zh.md) +* [DragonBones 4.5 data format](https://github.com/DragonBones/DragonBonesJS/blob/master/docs/DragonBones_4.5_data_format_zh.md) + +Copyright 2012-2017 The DragonBones Team. \ No newline at end of file diff --git a/reference/docs/DragonBones_4.5_data_format_zh.md b/reference/docs/DragonBones_4.5_data_format_zh.md new file mode 100644 index 0000000..c557908 --- /dev/null +++ b/reference/docs/DragonBones_4.5_data_format_zh.md @@ -0,0 +1,421 @@ +# DragonBones 4.5 数据格式标准说明 +```javascript +{ + // DragonBones 数据名称 + "name": "dragonBonesName", + + // 数据版本 + "version": "4.5", + + // 动画帧频 + "frameRate": 24, + + // 是否使用绝对数据 [0: 使用相对数据, 1: 使用绝对数据] (可选属性 默认: 1) + "isGlobal": 1, + + // 自定义数据 [任何类型] (可选属性 默认: null) + "userData": null, + + // 骨架列表 + "armature": [{ + + // 骨架名称 (一个 DragonBones 数据可包含多个骨架) + "name": "armatureName", + + // 动画帧频 (可选属性 默认: 使用全局帧频) + "frameRate": 24, + + // 动画类型 (可选属性 默认: "Armature") + // ["Armature": 骨骼动画, "MovieClip": 基本动画, "Stage": 场景动画] + "type": "Armature", + + // 自定义数据 [任何类型] (可选属性 默认: null) + "userData": null, + + // 添加到舞台后的默认行为列表 (可选属性 默认: null) + "defaultActions": [ + + // 此骨架播放指定动画 + ["gotoAndPlay", "animationName"], + + // 此骨架播放指定动画并停止 + ["gotoAndStop", "animationName"], + ], + + // 此骨架包含的骨骼列表 + "bone": [{ + + // 骨骼名称 + "name": "boneName", + + // 父级骨骼的名称 + "parent": "parentBoneName", + + // 自定义数据 [任何类型] (可选属性 默认: null) + "userData": null, + + // 骨骼注册到骨架的位移/ 斜切/ 缩放 (可选属性 默认: null) + "transform": { + "x": 0.00, // 水平位移 (可选属性 默认: 0.00) + "y": 0.00, // 垂直位移 (可选属性 默认: 0.00) + "skX": 0.0000, // 水平斜切 (可选属性 默认: 0.0000) + "skY": 0.0000, // 垂直斜切 (可选属性 默认: 0.0000) + "scX": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + "scY": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + } + }], + + // 此骨架包含的插槽列表 + "slot": [{ + + // 插槽名称 + "name": "slotName", + + // 插槽所属的骨骼名称 + "parent": "parentBoneName", + + // 默认显示对象的索引 (可选属性 默认: 0) + "displayIndex": 0, + + // 混合模式 (可选属性 默认: null) + "blendMode": null, + + // 自定义数据 [任何类型] (可选属性 默认: null) + "userData": null, + + // 显示对象的颜色叠加 (可选属性 默认: null) + "color": { + "aM": 100, // 透明叠加 [0~100] (可选属性 默认: 100) + "rM": 100, // 红色叠加 [0~100] (可选属性 默认: 100) + "gM": 100, // 绿色叠加 [0~100] (可选属性 默认: 100) + "bM": 100, // 蓝色叠加 [0~100] (可选属性 默认: 100) + "aO": 0.00, // 透明偏移 [-255~255] (可选属性 默认: 0) + "rO": 0.00, // 红色偏移 [-255~255] (可选属性 默认: 0) + "gO": 0.00, // 绿色偏移 [-255~255] (可选属性 默认: 0) + "bO": 0.00, // 蓝色偏移 [-255~255] (可选属性 默认: 0) + }, + + // 添加到舞台后的行为列表 (可选属性 默认: null) + "actions": [ + + // 子骨架播放指定动画 (仅对显示对象为骨架时有效) + ["gotoAndPlay", "animationName"], + + // 子骨架播放指定动画并停止 (仅对显示对象为骨架时有效) + ["gotoAndStop", "animationName"], + ] + }], + + // 此骨架包含的皮肤列表 + "skin": [{ + + // 皮肤名称 + "name": "skinName", + + // 此皮肤包含的插槽列表 + "slot": [{ + + // 插槽名称 + "name": "slotName", + + // 此插槽包含的显示对象列表 + "display": [{ + + // 显示对象名称 + "name": "displayName", + + // 显示对象类型 (可选属性 默认: "image") + // ["image": 贴图, "armature": 骨架, "mesh": 网格, ... 其他扩展的类型] + "type": "image", + + // 显示对象相对于骨骼的位移/ 斜切/ 缩放 (可选属性 默认: null) + "transform": { + "x": 0.00, // 水平位移 (可选属性 默认: 0.00) + "y": 0.00, // y 垂直位移 (可选属性 默认: 0.00) + "skX": 0.0000, // 水平斜切 (可选属性 默认: 0.0000) + "skY": 0.0000, // 垂直斜切 (可选属性 默认: 0.0000) + "scX": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + "scY": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + }, + + // 显示对象的轴点 (可选属性 默认: null, 仅对贴图或网格有效) + "pivot": { + "x": 0.50, // 水平轴点 [0.00~1.00] (可选属性 默认: 0.50) + "y": 0.50, // 垂直轴点 [0.00~1.00] (可选属性 默认: 0.50) + }, + + // 顶点的 UV 坐标列表 (可选属性 默认: null, 仅对网格有效) + // [u0, v0, u1, v1, ...] + "uvs": [0.0000, 0.0000, 1.0000, 0.0000, 1.0000, 1.0000, 0.0000, 1.0000], + + // 三角形顶点索引列表 (可选属性 默认: null, 仅对网格有效) + "triangles": [0, 1, 2, 2, 3, 0], + + // 顶点相对显示对象轴点的坐标列表 (可选属性 默认: null, 仅对网格有效) + // [x0, y0, x1, y1, ...] + "vertices": [-64.00, -64.00, 64.00, -64.00, 64.00, 64.00, -64.00, 64.00], + + // 顶点权重列表 (可选属性 默认: null, 仅对网格有效) + // [骨骼数量, 骨骼索引, 权重, ..., ...] + "weights": [1, 0, 1.00, 2, 0, 0.50, 1, 0.50], + + // 蒙皮插槽注册的矩阵变换 (可选属性 默认: null, 仅对网格有效) + // [a, b, c, d, tx, ty] + "slotPose": [1.0000, 0.0000, 0.0000, 1.0000, 0.00, 0.00], + + // 蒙皮骨骼注册的矩阵变换 (可选属性 默认: null, 仅对网格有效) + // [骨骼索引, a, b, c, d, tx, ty, ...] + "bonePose": [0, 1.0000, 0.0000, 0.0000, 1.0000, 0.00, 0.00] + }] + }] + }], + + // 此骨架包含的 ik 约束列表 + "ik": [{ + + // ik 约束名称 + "name": "ikName", + + // 绑定骨骼的名称 + "bone": "boneName", + + // 目标骨骼的名称 + "target": "ikBoneName", + + // 弯曲方向 (可选属性 默认: true) + // [true: 正方向/ 顺时针, false: 反方向/ 逆时针] + "bendPositive": true, + + // 骨骼链的长度 (可选属性 默认: 0) + // [0: 只约束 bone, n: 约束 bone 及 bone 向上 n 级的父骨骼] + "chain": 0, + + // 权重 [0.00: 不约束 ~ 1.00: 完全约束] (可选属性 默认: 1.00) + "weight": 1.00 + }], + + // 此骨架包含的动画列表 + "animation": [{ + + // 动画名称 + "name": "animationName", + + // 循环播放次数 [0: 循环播放无限次, n: 循环播放 n 次] (可选属性 默认: 1) + "playTimes": 1, + + // 动画帧长度 (可选属性 默认: 1) + "duration": 1, + + // 此动画包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 帧事件 (可选属性 默认: null) + "event": "eventName", + + // 帧声音 (可选属性 默认: null) + "sound": "soundName", + + // 帧行为列表 (可选属性 默认: null) + "actions": [ + + // 此骨架播放指定动画 + ["gotoAndPlay", "animationName"], + + // 此骨架播放指定动画并停止 + ["gotoAndStop", "animationName"], + ] + }], + + // 深度排序移动时间轴 + "zOrder": { + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 插槽偏移 [slotIndexA, offsetA, slotIndexB, offsetB, ...] (可选属性 默认: null) + "zOrder": [0, 2, 4, 1, 6, -1] + }] + }, + + // 此动画包含的骨骼时间轴列表 (可选属性 默认: null) + "bone": [{ + + // 时间轴名称 (与骨骼名称对应) + "name": "boneName", + + // 时间轴缩放 (可选属性 默认: 1.00) + "scale": 1.00, + + // 时间轴偏移 (可选属性 默认: 0.00) + "offset": 0.00, + + // 此时间轴包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 补间缓动 [0.00: 线性, null: 无缓动] (可选属性 默认: null) + "tweenEasing": 0.00, + + // 补间缓动贝塞尔曲线 [x1, y1, x2, y2, ...] (可选属性 默认: null) + "curve": [0.00, 0.00, 1.00, 1.00], + + // 帧事件 (可选属性 默认: null) + "event": "eventName", + + // 帧声音 (可选属性 默认: null) + "sound": "soundName", + + // 骨骼的位移/ 斜切/ 缩放 (可选属性 默认: null) + "transform": { + "x": 0.00, // 水平位移 (可选属性 默认: 0.00) + "y": 0.00, // 垂直位移 (可选属性 默认: 0.00) + "skX": 0.0000, // 水平斜切 (可选属性 默认: 0.0000) + "skY": 0.0000, // 垂直斜切 (可选属性 默认: 0.0000) + "scX": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + "scY": 1.0000 // 垂直缩放 (可选属性 默认: 1.0000) + }, + }] + }], + + // 此动画包含的插槽时间轴列表 + "slot": [{ + + // 时间轴名称 (与插槽名称对应) + "name": "slotName", + + // 此时间轴包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 补间缓动 [0.00: 线性, null: 无缓动] (可选属性 默认: null) + "tweenEasing": 0.00, + + // 补间缓动贝塞尔曲线 [x1, y1, x2, y2, ...] (可选属性 默认: null) + "curve": [0.00, 0.00, 1.00, 1.00], + + // 此帧的显示对象索引 (皮肤中对应的插槽显示对象列表) (可选属性 默认: 0) + "displayIndex": 0, + + // 显示对象的颜色叠加 (可选属性 默认: null) + "color": { + "aM": 100, // 透明叠加 [0~100] (可选属性 默认: 100) + "rM": 100, // 红色叠加 [0~100] (可选属性 默认: 100) + "gM": 100, // 绿色叠加 [0~100] (可选属性 默认: 100) + "bM": 100, // 蓝色叠加 [0~100] (可选属性 默认: 100) + "aO": 0.00, // 透明偏移 [-255~255] (可选属性 默认: 0) + "rO": 0.00, // 红色偏移 [-255~255] (可选属性 默认: 0) + "gO": 0.00, // 绿色偏移 [-255~255] (可选属性 默认: 0) + "bO": 0.00, // 蓝色偏移 [-255~255] (可选属性 默认: 0) + }, + + // 播放到当前帧时,执行的动作行为列表 (可选属性 默认: null) + "actions": [ + + // 子骨架播放指定动画 (仅对显示对象为骨架时有效) + ["gotoAndPlay", "animationName"], + + // 子骨架播放指定动画并停止 (仅对显示对象为骨架时有效) + ["gotoAndStop", "animationName"], + ] + }], + }], + + // 此动画包含的自由变形时间轴列表 (可选属性 默认: null) + "ffd": [{ + + // 时间轴名称 (与皮肤名称对应) + "skin": "skinName", + + // 时间轴名称 (与插槽名称对应) + "name": "slotName", + + // 时间轴名称 (显示对象索引) + "displayIndex": 0, + + // 此时间轴包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 补间缓动 [0.00: 线性, null: 无缓动] (可选属性 默认: null) + "tweenEasing": 0.00, + + // 补间缓动贝塞尔曲线 [x1, y1, x2, y2, ...] (可选属性 默认: null) + "curve": [0.00, 0.00, 1.00, 1.00], + + // 顶点坐标列表索引偏移 (可选属性 默认: 0) + "offset": 0, + + // 顶点坐标相对位移列表 [x0, y0, x1, y1, ...] (可选属性 默认: null) + "vertices": [0.01, 0.01] + }] + }] + }] + }] +} +``` + +------------------------------ + +# 4.5 相对 4.0 格式变化 + +* Armature + 1. 增加 "frameRate" 属性: 可为每个骨架设置独立帧率 + 2. 增加 "type" 属性: 骨骼动画/基本动画/场景动画 + 3. 增加 "defaultActions" 列表: 可为骨架分配默认行为 (删除 "gotoAndPlay" 属性, 其功能与 "actions" 合并) + 4. 增加 "ik" 列表 + +* Slot + 1. 增加 "actions" 列表: 插槽可为子骨架分配默认行为 (删除 "gotoAndPlay" 属性, 其功能与 "actions" 合并) + +* Display + 1. "type" 属性增加 "mesh" 类型以及与其匹配的其他属性 + +* Animation + 1. 增加 "ffd" 时间轴 + +* Frame + 1. 增加 "actions" 列表: 控制子骨架行为 (删除 "action" "gotoAndPlay" 属性, 其功能与 "actions" 合并) + +* actions + 1. 暂时只支持 "gotoAndPlay" 行为, 后续会扩展更多对动画的控制行为和交互行为 + +------------------------------ + +# 4.0 相对 3.0 格式变化 + +* Armature 中包含Slot列表 + +* Skin 中增加默认Skin, 默认skin有如下特性: + 1. 在skin列表中排第一 + 2. 名字为空字符串“” + 3. 包含的slot会同时存在于其他的skin,相当于保存所有其他skin中共有的slot(相当于其他skin的基类) + +* Skin中包含的Slot的Display的transform属性中不在有pX,pY属性 + 1. Display不再有初始轴点属性,所有display的轴点均为中心点。 + 2. 因为display在运动时的轴点是骨骼的原点,所以这里的轴点信息可以在初始化时换算成display的位置信息,从而可以完美还原动画。 + +* Animation中有下面的改动 + 1. 去掉"tweenEasing": 动画不会覆盖关键帧的缓动值 + 2. 去掉"autoTween": 动画不会覆盖关键帧的补件值 + 3. "loop"改名为"playtime" + 4. "colorTransform"改名为"color" + +* 区分Bone时间轴和Slot时间轴 + 1. Bone时间轴包含平移旋转缩放,自定义事件和声音事件 + 2. Slot时间轴包含颜色变换,dispalyIndex变换和zorder变换 + +* Armature, Bone 和Slot中均添加了userData字段用于记录用户自定义信息,同时方便第三方扩展 + +* Frame中有如下改动 + 1. 中去掉了hide 属性,动画中如果想隐藏某个插槽,改为设置dispalyIndex为-1. visible属性完全留给开发者使用,用于动态设置slot是否隐藏。 + 2. 增加curve属性,使用贝塞尔曲线描述动画补间的缓动效果 diff --git a/reference/docs/DragonBones_4.7_release_notes_zh.md b/reference/docs/DragonBones_4.7_release_notes_zh.md new file mode 100644 index 0000000..9fff3da --- /dev/null +++ b/reference/docs/DragonBones_4.7_release_notes_zh.md @@ -0,0 +1,44 @@ +DragonBones 4.7 的运行库,相对之前的版本有较大的功能增加和改进,同时保证完美的向下兼容。 +全新的 TypeScript / JavaScript、ActionScript、C++ 的运行库支持,支持 DragonBones Pro 的全部功能。 +* [DragonBones Github](https://github.com/DragonBones) + +#### 合并 Armature 与 FastArmature,不再区分极速模式与普通模式,简化开启缓存的调用方式。 +* 不用再纠结是否需要使用极速模式了,因为 Armatue 已经合并了极速模式(FastArmature)的全部功能,包括支持开启缓存。 +* 通过 Armatrue.enableAnimationCache() 接口开启缓存。 +* FastArmatrue 以及 AnimationCacheManger 不再建议使用,但是功能依然保留用于实现向下兼容。 +* 【特别注意】TS版本,以下代码需要作调整才能编译通过: + * instanceof dragonBones.FastArmatre 改为 instanceof dragonBones.Armatre + * instanceof dragonBones.FastBone 改为 instanceof dragonBones.Bone + * 依次类推... + +#### 内置内存池,方便DragonBones对象的内存管理,大幅提升频繁创建对象的效率,减少发生内存泄漏的可能性。 +* 提供BaseObject基类,封装构建对象的方法,自动放入内存池,所有DragonBones体系中需要频繁动态创建的对象都是基于BaseObject的 +* 内存池提供setMaxCount接口,控制最大尺寸。 +* 内存池提供clear接口,清空内存池。 + +#### 增强了局部换装功能,解决轴点错位问题,支持一键整体换装,支持纹理延迟加载。 +* 增加 Factory.replaceSlotDisplay()、Factory.replaceSlotDisplayList() 接口用于解决局部换种轴点错位的问题。 +* 增加 Armature.replaceTexture() 接口,用于实现替换整个骨架的贴图。 +* 增加骨架脱离贴图运行机制,可以实现贴图延时加载,动画边运行,贴图边加载。 +* 具体的使用文档可以参见 [APISpec](http://edn.egret.com/cn/apidoc/) 和新功能教程。 + +#### 规范骨架显示对象的类型,构造简单的骨骼动画更方便 +* 增加 IArmatureDisplay 接口,规范 Armatrue 的 display 显示对象的类型。 +* 增加 Factory.buildArmatureDisplay() 接口,用于直接构建骨架的显示对象。使用该方法构建的骨骼动画能够自动运行,不需要再手动添加到 WorkClock 中。往场景中添加不需要独立控制的骨骼动画,使用该接口会非常方便,只需一行就能实现。 +stage.addChild(Factory.buildArmatureDisplay())。 + +#### 重构 Animation 的 gotoAndPlay() 接口,拆分动画的播放和混合功能,增加动画播放的接口,支持更多控制播放的参数。 +* 以前的 gotoAndPlay() 承载了动画的播放和融合两类功能,参数列表庞大,使用起来不方便容易出错。这个版本将这两类功能拆分为: + * play() 负责动画的播放。 + * fadeIn() 负责动画的融合。 +* 增加动画播放的接口,支持通过时间、帧和进度三个维度,控制动画播放开始和播放停止的位置: + * Armature.animation.gotoAndPlayByTime() + * Armature.animation.gotoAndPlayByFrame() + * Armature.animation.gotoAndPlayByProgress() + * Armature.animation.gotoAndStopByTime() + * Armature.animation.gotoAndStopByFrame() + * Armature.animation.gotoAndStopByProgress() +* 接口维持向下兼容,gotoAndPlay() 和 gotoAndStop() 功能仍然不变,但是改为不建议使用的状态。 +* 增加 fadeIn() 接口,用与实现多个动画同时播放的动画混合效果。 + + diff --git a/reference/docs/DragonBones_5.0_data_format_zh.md b/reference/docs/DragonBones_5.0_data_format_zh.md new file mode 100644 index 0000000..b14528b --- /dev/null +++ b/reference/docs/DragonBones_5.0_data_format_zh.md @@ -0,0 +1,450 @@ +# DragonBones 5.0 数据格式标准说明 +```javascript +{ + // DragonBones 数据名称 + "name": "dragonBonesName", + + // 数据版本 + "version": "5.0", + + // 最低兼容版本 + "compatibleVersion": "4.5", + + // 动画帧频 + "frameRate": 24, + + // 自定义数据 (可选属性 默认: null) + "userData": null, + + // 骨架列表 + "armature": [{ + + // 骨架名称 (一个 DragonBones 数据可包含多个骨架) + "name": "armatureName", + + // 动画帧频 (可选属性 默认: 使用全局帧频) + "frameRate": 24, + + // 动画类型 (可选属性 默认: "Armature") + // ["Armature": 骨骼动画, "MovieClip": 基本动画, "Stage": 场景动画] + "type": "Armature", + + // 自定义数据 (可选属性 默认: null) + "userData": null, + + // 添加到舞台后的默认行为列表 (可选属性 默认: null) + "defaultActions": [ + + // 此骨架播放指定动画 + ["gotoAndPlay", "animationName"], + + // 此骨架播放指定动画并停止 + ["gotoAndStop", "animationName"], + ], + + // 此骨架包含的骨骼列表 + "bone": [{ + + // 骨骼名称 + "name": "boneName", + + // 父级骨骼的名称 + "parent": "parentBoneName", + + // 自定义数据 [任何类型] (可选属性 默认: null) + "userData": null, + + // 骨骼注册到骨架的位移/ 斜切/ 缩放 (可选属性 默认: null) + "transform": { + "x": 0.00, // 水平位移 (可选属性 默认: 0.00) + "y": 0.00, // 垂直位移 (可选属性 默认: 0.00) + "skX": 0.0000, // 水平斜切 (可选属性 默认: 0.0000) + "skY": 0.0000, // 垂直斜切 (可选属性 默认: 0.0000) + "scX": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + "scY": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + } + }], + + // 此骨架包含的插槽列表 + "slot": [{ + + // 插槽名称 + "name": "slotName", + + // 插槽所属的骨骼名称 + "parent": "parentBoneName", + + // 默认显示对象的索引 (可选属性 默认: 0) + "displayIndex": 0, + + // 混合模式 (可选属性 默认: null) + "blendMode": null, + + // 自定义数据 [任何类型] (可选属性 默认: null) + "userData": null, + + // 显示对象的颜色叠加 (可选属性 默认: null) + "color": { + "aM": 100, // 透明叠加 [0~100] (可选属性 默认: 100) + "rM": 100, // 红色叠加 [0~100] (可选属性 默认: 100) + "gM": 100, // 绿色叠加 [0~100] (可选属性 默认: 100) + "bM": 100, // 蓝色叠加 [0~100] (可选属性 默认: 100) + "aO": 0.00, // 透明偏移 [-255~255] (可选属性 默认: 0) + "rO": 0.00, // 红色偏移 [-255~255] (可选属性 默认: 0) + "gO": 0.00, // 绿色偏移 [-255~255] (可选属性 默认: 0) + "bO": 0.00, // 蓝色偏移 [-255~255] (可选属性 默认: 0) + }, + + // 添加到舞台后的行为列表 (可选属性 默认: null) + "actions": [ + + // 子骨架播放指定动画 (仅对显示对象为骨架时有效) + ["gotoAndPlay", "animationName"], + + // 子骨架播放指定动画并停止 (仅对显示对象为骨架时有效) + ["gotoAndStop", "animationName"], + ] + }], + + // 此骨架包含的皮肤列表 + "skin": [{ + + // 皮肤名称 + "name": "skinName", + + // 此皮肤包含的插槽列表 + "slot": [{ + + // 插槽名称 + "name": "slotName", + + // 此插槽包含的显示对象列表 + "display": [{ + + // 显示对象名称 + "name": "displayName", + + // 显示对象类型 (可选属性 默认: "image") + // ["image": 贴图, "armature": 骨架, "mesh": 网格, "boundingBox": 边界框, ... 其他扩展的类型] + "type": "image", + + // 子骨架指向的骨架名、网格包含的贴图名 (可选属性 默认: null, 仅对子骨架、网格有效) + "path": "path", + + // 共享网格的索引 (可选属性 默认: null, 仅对网格有效) + "share": "meshName", + + // 是否继承动画 (可选属性 默认: true, 仅对共享网格有效) + "inheritFFD": true, + + // 边界框类型 (可选属性 默认: "rectangle", 仅对边界框有效) + // ["rectangle": 矩形, "ellipse": 椭圆, "polygon": 自定义多边形] + "subType": "rectangle", + + // 显示对象颜色 (可选属性 默认: 0, 仅对边界框有效) + "color": 0, + + // 显示对象相对于骨骼的位移/ 斜切/ 缩放 (可选属性 默认: null) + "transform": { + "x": 0.00, // 水平位移 (可选属性 默认: 0.00) + "y": 0.00, // y 垂直位移 (可选属性 默认: 0.00) + "skX": 0.0000, // 水平斜切 (可选属性 默认: 0.0000) + "skY": 0.0000, // 垂直斜切 (可选属性 默认: 0.0000) + "scX": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + "scY": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + }, + + // 显示对象的轴点 (可选属性 默认: null, 对骨架无效) + "pivot": { + "x": 0.50, // 水平轴点 [0.00~1.00] (可选属性 默认: 0.50) + "y": 0.50, // 垂直轴点 [0.00~1.00] (可选属性 默认: 0.50) + }, + + // 矩形或椭圆的宽高 (可选属性 默认: 0, 仅对边界框有效), + "width": 100, "height": 100, + + // 顶点相对显示对象轴点的坐标列表 (可选属性 默认: null, 仅对网格或自定义多边形边界框有效) + // [x0, y0, x1, y1, ...] + "vertices": [-64.00, -64.00, 64.00, -64.00, 64.00, 64.00, -64.00, 64.00], + + // 顶点的 UV 坐标列表 (可选属性 默认: null, 仅对网格有效) + // [u0, v0, u1, v1, ...] + "uvs": [0.0000, 0.0000, 1.0000, 0.0000, 1.0000, 1.0000, 0.0000, 1.0000], + + // 三角形顶点索引列表 (可选属性 默认: null, 仅对网格有效) + "triangles": [0, 1, 2, 2, 3, 0], + + // 顶点权重列表 (可选属性 默认: null, 仅对网格有效) + // [骨骼数量, 骨骼索引, 权重, ..., ...] + "weights": [1, 0, 1.00, 2, 0, 0.50, 1, 0.50], + + // 蒙皮插槽注册的矩阵变换 (可选属性 默认: null, 仅对网格有效) + // [a, b, c, d, tx, ty] + "slotPose": [1.0000, 0.0000, 0.0000, 1.0000, 0.00, 0.00], + + // 蒙皮骨骼注册的矩阵变换 (可选属性 默认: null, 仅对网格有效) + // [骨骼索引, a, b, c, d, tx, ty, ...] + "bonePose": [0, 1.0000, 0.0000, 0.0000, 1.0000, 0.00, 0.00] + }] + }] + }], + + // 此骨架包含的 ik 约束列表 + "ik": [{ + + // ik 约束名称 + "name": "ikName", + + // 绑定骨骼的名称 + "bone": "boneName", + + // 目标骨骼的名称 + "target": "ikBoneName", + + // 弯曲方向 (可选属性 默认: true) + // [true: 正方向/ 顺时针, false: 反方向/ 逆时针] + "bendPositive": true, + + // 骨骼链的长度 (可选属性 默认: 0) + // [0: 只约束 bone, n: 约束 bone 及 bone 向上 n 级的父骨骼] + "chain": 0, + + // 权重 [0.00: 不约束 ~ 1.00: 完全约束] (可选属性 默认: 1.00) + "weight": 1.00 + }], + + // 此骨架包含的动画列表 + "animation": [{ + + // 动画名称 + "name": "animationName", + + // 循环播放次数 [0: 循环播放无限次, n: 循环播放 n 次] (可选属性 默认: 1) + "playTimes": 1, + + // 动画帧长度 (可选属性 默认: 1) + "duration": 1, + + // 此动画包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 帧声音 (可选属性 默认: null) + "sound": "soundName", + + // 帧事件列表 (可选属性 默认: null) + "events": [{ + + // 事件名称 + "name": "eventName", + + // 骨骼名称 (可选属性 默认: null) + "bone": "boneName", + + // 插槽名称 (可选属性 默认: null) + "slot": "slotName", + + // 事件参数列表 (可选属性 默认: null) + "ints":[0, 1, 2], + "floats":[0.01, 1.01, 2.01], + "strings":["a", "b", "c"] + }], + + // 帧行为列表 (可选属性 默认: null) + "actions": [ + + // 此骨架播放指定动画 + ["gotoAndPlay", "animationName"], + + // 此骨架播放指定动画并停止 + ["gotoAndStop", "animationName"], + ] + }], + + // 深度排序时间轴 + "zOrder": { + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 插槽偏移 [slotIndexA, offsetA, slotIndexB, offsetB, ...] (可选属性 默认: null) + "zOrder": [0, 2, 4, 1, 6, -1] + }] + }, + + // 此动画包含的骨骼时间轴列表 (可选属性 默认: null) + "bone": [{ + + // 时间轴名称 (与骨骼名称对应) + "name": "boneName", + + // 时间轴缩放 (可选属性 默认: 1.00) + "scale": 1.00, + + // 时间轴偏移 (可选属性 默认: 0.00) + "offset": 0.00, + + // 此时间轴包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 缓动类型 [0: 由 tweenEasing 或 curve 描述缓动类型,1~N: 其他扩展缓动类型枚举(具体如何枚举未来再定义)] (可选属性 默认: 0) + "tweenType": 0, + + // 缓动值 [0.00: 线性, null: 无缓动] (可选属性 默认: null) + "tweenEasing": 0.00, + + // 贝塞尔曲线缓动参数列表 [x1, y1, x2, y2, ...] (可选属性 默认: null) + "curve": [0.00, 0.00, 1.00, 1.00], + + // 骨骼的位移/ 斜切/ 缩放 (可选属性 默认: null) + "transform": { + "x": 0.00, // 水平位移 (可选属性 默认: 0.00) + "y": 0.00, // 垂直位移 (可选属性 默认: 0.00) + "skX": 0.0000, // 水平斜切 (可选属性 默认: 0.0000) + "skY": 0.0000, // 垂直斜切 (可选属性 默认: 0.0000) + "scX": 1.0000, // 垂直缩放 (可选属性 默认: 1.0000) + "scY": 1.0000 // 垂直缩放 (可选属性 默认: 1.0000) + }, + }] + }], + + // 此动画包含的插槽时间轴列表 + "slot": [{ + + // 时间轴名称 (与插槽名称对应) + "name": "slotName", + + // 此时间轴包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 缓动类型 [0: 由 tweenEasing 描述缓动类型,N: 其他扩展缓动属性] (可选属性 默认: 0) + "tweenType": 0, + + // 补间缓动 [0.00: 线性, null: 无缓动] (可选属性 默认: null) + "tweenEasing": 0.00, + + // 补间缓动贝塞尔曲线 [x1, y1, x2, y2, ...] (可选属性 默认: null) + "curve": [0.00, 0.00, 1.00, 1.00], + + // 此帧的显示对象索引 (皮肤中对应的插槽显示对象列表) (可选属性 默认: 0) + "displayIndex": 0, + + // 显示对象的颜色叠加 (可选属性 默认: null) + "color": { + "aM": 100, // 透明叠加 [0~100] (可选属性 默认: 100) + "rM": 100, // 红色叠加 [0~100] (可选属性 默认: 100) + "gM": 100, // 绿色叠加 [0~100] (可选属性 默认: 100) + "bM": 100, // 蓝色叠加 [0~100] (可选属性 默认: 100) + "aO": 0.00, // 透明偏移 [-255~255] (可选属性 默认: 0) + "rO": 0.00, // 红色偏移 [-255~255] (可选属性 默认: 0) + "gO": 0.00, // 绿色偏移 [-255~255] (可选属性 默认: 0) + "bO": 0.00, // 蓝色偏移 [-255~255] (可选属性 默认: 0) + }, + + // 播放到当前帧时,执行的动作行为列表 (可选属性 默认: null) + "actions": [ + + // 子骨架播放指定动画 (仅对显示对象为骨架时有效) + ["gotoAndPlay", "animationName"], + + // 子骨架播放指定动画并停止 (仅对显示对象为骨架时有效) + ["gotoAndStop", "animationName"], + ] + }], + }], + + // 此动画包含的自由变形时间轴列表 (可选属性 默认: null) + "ffd": [{ + + // 时间轴名称 (与网格名称对应) + "name": "timelineName", + + // 皮肤名称 + "skin": "skinName", + + // 插槽名称 + "slot": "slotName", + + // 此时间轴包含的关键帧列表 (可选属性 默认: null) + "frame": [{ + + // 帧长度 (可选属性 默认: 1) + "duration": 1, + + // 缓动类型 [0: 由 tweenEasing 描述缓动类型,N: 其他扩展缓动属性] (可选属性 默认: 0) + "tweenType": 0, + + // 补间缓动 [0.00: 线性, null: 无缓动] (可选属性 默认: null) + "tweenEasing": 0.00, + + // 补间缓动贝塞尔曲线 [x1, y1, x2, y2, ...] (可选属性 默认: null) + "curve": [0.00, 0.00, 1.00, 1.00], + + // 顶点坐标列表索引偏移 (可选属性 默认: 0) + "offset": 0, + + // 顶点坐标相对位移列表 [x0, y0, x1, y1, ...] (可选属性 默认: null) + "vertices": [0.01, 0.01] + }] + }] + }] + }] +} +``` + +------------------------------ +# 5.0 相对 [4.5](DragonBones_4.5_data_format_zh.md) 格式变化 + +## Root +* 增加 "compatibleVersion" 属性,代表兼容的最低版本。 +* 删除 "isGlobal" 属性。 + * 不再支持绝对坐标,只支持相对坐标,相当于isGlobal设置为0。 + * isGlobal为1的情况(绝对坐标)只存在于使用2.3及以前的数据格式。 + * 从3.0开始支持相对坐标,于是引入isGlobal属性用于向下兼容,同时支持相对坐标和绝对坐标。 + * 从5.0开始不再支持绝对坐标。 + +## Display +* 增加 "path" 属性,与 name 区分,用于标识图片指向的贴图路径、Mesh包含的贴图路径或子骨架指向的骨架名。 +* name属性的意义变为display的唯一标示符,不再代表路径。 + +## 支持边界框 +* "display"的"type" 属性的值增加 "boundingBox" ,用于标记边界框。 +* 边界框类型的 display 会包含如下属性 + * "subType" : 标记边界框的类型,可能的值为"rectangle": 矩形, "ellipse": 椭圆, "polygon": 自定义多边形 + * "width", "height": 宽高(仅对矩形或椭圆类型的边界框生效) + * "vertices": 顶点列表(仅对自定义多边形类型的边界框生效) + +## 支持共享网格(Linked Mesh) +* 网格类型的Display增加 "share" 属性,可以通过设置share属性将之变为共享网格。 +* 共享网格可以通过 "inheritFFD" 属性控制共享网格是否继承主网格的FFD动画。 + +## 支持动画中改变插槽的显示顺序(ZOrder) +* "animation" 中增加 "zOrder" 属性,代表深度排序时间轴 +* "zOrder" 包含frames属性,代表时间轴上的关键帧列表。包含的每个关键帧对象会包含如下属性: + * "duration": 关键帧持续的长度。 + * "zOrder": 该关键帧上zOrder需要变化的插槽以及变化的幅度组成的数组。 + +## 事件统一由主时间轴抛出,支持多事件和事件参数列表 +* 去掉骨骼时间轴包含的关键帧的event属性。(版本升级的时候会把数据移动到主时间轴相同位置的关键帧上) +* "animation" 的 "frame"(主时间轴包含的关键帧列表)包含的关键帧数据的 event 属性改为 "events", 表示需要在该帧上抛出的事件列表。 +* 事件对象包含如下属性 + * "name": 事件名 + * "bone": 抛出事件的骨骼,默认为null(原骨骼时间轴包含的事件,将把骨骼名记录在这里) + * "slot": 抛出事件的插槽,默认为null(该属性和上面的bone属性不可能同时存在,都不存在代表事件由骨架抛出) + * "ints": 整形参数列表 + * "floats": 浮点形参数列表 + * "strings": 字符串形参数列表 + +## 增加更多缓动类型的定义 +* "frame"包含的关键帧数据增加 "tweenType" 属性。 +* "tweenType" 默认为0 代表由 tweenEasing 或 curve 描述缓动类型(和4.5一致) +* "tweenType" 不为0 代表使用其他扩展缓动类型的枚举,具体每个枚举代表的意义未来再定义。 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..f046d2b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,5 @@ +rootProject.name = 'dragonbones' + +include( + 'dragonbones-core', +)