pixi-dragonbones-runtime
Version:
DragonBones Runtime for Pixi.js
3 lines (2 loc) • 38.3 kB
JavaScript
import{BaseObject as t}from"../core/BaseObject.mjs";import"../core/DragonBones.mjs";import{ColorTransform as e}from"../geom/ColorTransform.mjs";import{Matrix as r}from"../geom/Matrix.mjs";import{Point as a}from"../geom/Point.mjs";import{Transform as i}from"../geom/Transform.mjs";import{AnimationData as s,AnimationTimelineData as n,TimelineData as o}from"../model/AnimationData.mjs";import{ArmatureData as l,BoneData as h,SurfaceData as _,SlotData as m}from"../model/ArmatureData.mjs";import{EllipseBoundingBoxData as f,RectangleBoundingBoxData as A,PolygonBoundingBoxData as g}from"../model/BoundingBoxData.mjs";import{CanvasData as c}from"../model/CanvasData.mjs";import{IKConstraintData as u,PathConstraintData as y}from"../model/ConstraintData.mjs";import{PathDisplayData as E,BoundingBoxDisplayData as p,MeshDisplayData as T,ArmatureDisplayData as S,ImageDisplayData as N,WeightData as d}from"../model/DisplayData.mjs";import{DragonBonesData as b}from"../model/DragonBonesData.mjs";import{SkinData as F}from"../model/SkinData.mjs";import{TextureData as I}from"../model/TextureAtlasData.mjs";import{ActionData as O,UserData as R}from"../model/UserData.mjs";import{DataParser as M}from"./DataParser.mjs";class D extends M{constructor(){super(...arguments),this._rawTextureAtlasIndex=0,this._rawBones=[],this._data=null,this._armature=null,this._bone=null,this._geometry=null,this._slot=null,this._skin=null,this._mesh=null,this._animation=null,this._timeline=null,this._rawTextureAtlases=null,this._frameValueType=0,this._defaultColorOffset=-1,this._prevClockwise=0,this._prevRotation=0,this._frameDefaultValue=0,this._frameValueScale=1,this._helpMatrixA=new r,this._helpMatrixB=new r,this._helpTransform=new i,this._helpColorTransform=new e,this._helpPoint=new a,this._helpArray=[],this._intArray=[],this._floatArray=[],this._frameIntArray=[],this._frameFloatArray=[],this._frameArray=[],this._timelineArray=[],this._colorArray=[],this._cacheRawMeshes=[],this._cacheMeshes=[],this._actionFrames=[],this._weightSlotPose={},this._weightBonePoses={},this._cacheBones={},this._slotChildActions={}}static _getBoolean(t,e,r){if(e in t){const r=t[e],a=typeof r;if("boolean"===a)return r;if("string"!==a)return!!r;switch(r){case"0":case"NaN":case"":case"false":case"null":case"undefined":return!1;default:return!0}}return r}static _getNumber(t,e,r){if(e in t){const a=t[e];return null===a||"NaN"===a?r:+a||0}return r}static _getString(t,e,r){if(e in t){const r=t[e];return"string"===typeof r?r:r.toString()}return r}_getCurvePoint(t,e,r,a,i,s,n,o,l,h){const _=1-l,m=_*_,f=l*l,A=_*m,g=3*l*m,c=3*_*f,u=l*f;h.x=A*t+g*r+c*i+u*n,h.y=A*e+g*a+c*s+u*o}_samplingEasingCurve(t,e){const r=t.length;if(r%3==1){let a=-2;for(let i=0,s=e.length;i<s;++i){let n=(i+1)/(s+1);for(;(a+6<r?t[a+6]:1)<n;)a+=6;const o=a>=0&&a+6<r,l=o?t[a]:0,h=o?t[a+1]:0,_=t[a+2],m=t[a+3],f=t[a+4],A=t[a+5],g=o?t[a+6]:1,c=o?t[a+7]:1;let u=0,y=1;for(;y-u>1e-4;){const t=.5*(y+u);this._getCurvePoint(l,h,_,m,f,A,g,c,t,this._helpPoint),n-this._helpPoint.x>0?u=t:y=t}e[i]=this._helpPoint.y}return!0}{let r=0;for(let a=0,i=e.length;a<i;++a){let s=(a+1)/(i+1);for(;t[r+6]<s;)r+=6;const n=t[r],o=t[r+1],l=t[r+2],h=t[r+3],_=t[r+4],m=t[r+5],f=t[r+6],A=t[r+7];let g=0,c=1;for(;c-g>1e-4;){const t=.5*(c+g);this._getCurvePoint(n,o,l,h,_,m,f,A,t,this._helpPoint),s-this._helpPoint.x>0?g=t:c=t}e[a]=this._helpPoint.y}return!1}}_parseActionDataInFrame(t,e,r,a){M.EVENT in t&&this._mergeActionFrame(t[M.EVENT],e,10,r,a),M.SOUND in t&&this._mergeActionFrame(t[M.SOUND],e,11,r,a),M.ACTION in t&&this._mergeActionFrame(t[M.ACTION],e,0,r,a),M.EVENTS in t&&this._mergeActionFrame(t[M.EVENTS],e,10,r,a),M.ACTIONS in t&&this._mergeActionFrame(t[M.ACTIONS],e,0,r,a)}_mergeActionFrame(t,e,r,a,i){const s=this._armature.actions.length,n=this._parseActionData(t,r,a,i);let o=0,l=null;for(const t of n)this._armature.addAction(t,!1);0===this._actionFrames.length&&(l=new B,l.frameStart=0,this._actionFrames.push(l),l=null);for(const t of this._actionFrames){if(t.frameStart===e){l=t;break}if(t.frameStart>e)break;o++}null===l&&(l=new B,l.frameStart=e,this._actionFrames.splice(o,0,l));for(let t=0;t<n.length;++t)l.actions.push(s+t)}_parseArmature(e,r){const a=t.borrowObject(l);if(a.name=D._getString(e,M.NAME,""),a.frameRate=D._getNumber(e,M.FRAME_RATE,this._data.frameRate),a.scale=r,M.TYPE in e&&"string"==typeof e[M.TYPE]?a.type=M._getArmatureType(e[M.TYPE]):a.type=D._getNumber(e,M.TYPE,0),0===a.frameRate&&(a.frameRate=24),this._armature=a,M.CANVAS in e){const r=e[M.CANVAS],i=t.borrowObject(c);M.COLOR in r?i.hasBackground=!0:i.hasBackground=!1,i.color=D._getNumber(r,M.COLOR,0),i.x=D._getNumber(r,M.X,0)*a.scale,i.y=D._getNumber(r,M.Y,0)*a.scale,i.width=D._getNumber(r,M.WIDTH,0)*a.scale,i.height=D._getNumber(r,M.HEIGHT,0)*a.scale,a.canvas=i}if(M.AABB in e){const t=e[M.AABB];a.aabb.x=D._getNumber(t,M.X,0)*a.scale,a.aabb.y=D._getNumber(t,M.Y,0)*a.scale,a.aabb.width=D._getNumber(t,M.WIDTH,0)*a.scale,a.aabb.height=D._getNumber(t,M.HEIGHT,0)*a.scale}if(M.BONE in e){const t=e[M.BONE];for(const e of t){const t=D._getString(e,M.PARENT,""),r=this._parseBone(e);if(t.length>0){const e=a.getBone(t);null!==e?r.parent=e:(t in this._cacheBones||(this._cacheBones[t]=[]),this._cacheBones[t].push(r))}if(r.name in this._cacheBones){for(const t of this._cacheBones[r.name])t.parent=r;delete this._cacheBones[r.name]}a.addBone(r),this._rawBones.push(r)}}if(M.IK in e){const t=e[M.IK];for(const e of t){const t=this._parseIKConstraint(e);t&&a.addConstraint(t)}}if(a.sortBones(),M.SLOT in e){let t=0;const r=e[M.SLOT];for(const e of r)a.addSlot(this._parseSlot(e,t++))}if(M.SKIN in e){const t=e[M.SKIN];for(const e of t)a.addSkin(this._parseSkin(e))}if(M.PATH_CONSTRAINT in e){const t=e[M.PATH_CONSTRAINT];for(const e of t){const t=this._parsePathConstraint(e);t&&a.addConstraint(t)}}for(let t=0,e=this._cacheRawMeshes.length;t<e;++t){const e=this._cacheRawMeshes[t],r=D._getString(e,M.SHARE,"");if(0===r.length)continue;let i=D._getString(e,M.SKIN,M.DEFAULT_NAME);0===i.length&&(i=M.DEFAULT_NAME);const s=a.getMesh(i,"",r);if(null===s)continue;this._cacheMeshes[t].geometry.shareFrom(s.geometry)}if(M.ANIMATION in e){const t=e[M.ANIMATION];for(const e of t){const t=this._parseAnimation(e);a.addAnimation(t)}}if(M.DEFAULT_ACTIONS in e){const t=this._parseActionData(e[M.DEFAULT_ACTIONS],0,null,null);for(const e of t)if(a.addAction(e,!0),0===e.type){const t=a.getAnimation(e.name);null!==t&&(a.defaultAnimation=t)}}if(M.ACTIONS in e){const t=this._parseActionData(e[M.ACTIONS],0,null,null);for(const e of t)a.addAction(e,!1)}this._rawBones.length=0,this._cacheRawMeshes.length=0,this._cacheMeshes.length=0,this._armature=null;for(let t in this._weightSlotPose)delete this._weightSlotPose[t];for(let t in this._weightBonePoses)delete this._weightBonePoses[t];for(let t in this._cacheBones)delete this._cacheBones[t];for(let t in this._slotChildActions)delete this._slotChildActions[t];return a}_parseBone(e){let r=0;if(r=M.TYPE in e&&"string"==typeof e[M.TYPE]?M._getBoneType(e[M.TYPE]):D._getNumber(e,M.TYPE,0),0===r){const r=this._armature.scale,a=t.borrowObject(h);return a.inheritTranslation=D._getBoolean(e,M.INHERIT_TRANSLATION,!0),a.inheritRotation=D._getBoolean(e,M.INHERIT_ROTATION,!0),a.inheritScale=D._getBoolean(e,M.INHERIT_SCALE,!0),a.inheritReflection=D._getBoolean(e,M.INHERIT_REFLECTION,!0),a.length=D._getNumber(e,M.LENGTH,0)*r,a.alpha=D._getNumber(e,M.ALPHA,1),a.name=D._getString(e,M.NAME,""),M.TRANSFORM in e&&this._parseTransform(e[M.TRANSFORM],a.transform,r),a}const a=t.borrowObject(_);return a.alpha=D._getNumber(e,M.ALPHA,1),a.name=D._getString(e,M.NAME,""),a.segmentX=D._getNumber(e,M.SEGMENT_X,0),a.segmentY=D._getNumber(e,M.SEGMENT_Y,0),this._parseGeometry(e,a.geometry),a}_parseIKConstraint(e){const r=this._armature.getBone(D._getString(e,M.BONE,""));if(null===r)return null;const a=this._armature.getBone(D._getString(e,M.TARGET,""));if(null===a)return null;const i=D._getNumber(e,M.CHAIN,0),s=t.borrowObject(u);return s.scaleEnabled=D._getBoolean(e,M.SCALE,!1),s.bendPositive=D._getBoolean(e,M.BEND_POSITIVE,!0),s.weight=D._getNumber(e,M.WEIGHT,1),s.name=D._getString(e,M.NAME,""),s.type=0,s.target=a,i>0&&null!==r.parent?(s.root=r.parent,s.bone=r):(s.root=r,s.bone=null),s}_parsePathConstraint(e){const r=this._armature.getSlot(D._getString(e,M.TARGET,""));if(null===r)return null;const a=this._armature.defaultSkin;if(null===a)return null;const i=a.getDisplay(r.name,D._getString(e,M.TARGET_DISPLAY,r.name));if(null===i||!(i instanceof E))return null;const s=e[M.BONES];if(null===s||0===s.length)return null;const n=t.borrowObject(y);for(var o of(n.name=D._getString(e,M.NAME,""),n.type=1,n.pathSlot=r,n.pathDisplayData=i,n.target=r.parent,n.positionMode=M._getPositionMode(D._getString(e,M.POSITION_MODE,"")),n.spacingMode=M._getSpacingMode(D._getString(e,M.SPACING_MODE,"")),n.rotateMode=M._getRotateMode(D._getString(e,M.ROTATE_MODE,"")),n.position=D._getNumber(e,M.POSITION,0),n.spacing=D._getNumber(e,M.SPACING,0),n.rotateOffset=D._getNumber(e,M.ROTATE_OFFSET,0),n.rotateMix=D._getNumber(e,M.ROTATE_MIX,1),n.translateMix=D._getNumber(e,M.TRANSLATE_MIX,1),s)){const t=this._armature.getBone(o);null!==t&&(n.AddBone(t),null===n.root&&(n.root=t))}return n}_parseSlot(e,r){const a=t.borrowObject(m);return a.displayIndex=D._getNumber(e,M.DISPLAY_INDEX,0),a.zOrder=r,a.zIndex=D._getNumber(e,M.Z_INDEX,0),a.alpha=D._getNumber(e,M.ALPHA,1),a.name=D._getString(e,M.NAME,""),a.parent=this._armature.getBone(D._getString(e,M.PARENT,"")),M.BLEND_MODE in e&&"string"==typeof e[M.BLEND_MODE]?a.blendMode=M._getBlendMode(e[M.BLEND_MODE]):a.blendMode=D._getNumber(e,M.BLEND_MODE,0),M.COLOR in e?(a.color=m.createColor(),this._parseColorTransform(e[M.COLOR],a.color)):a.color=m.DEFAULT_COLOR,M.ACTIONS in e&&(this._slotChildActions[a.name]=this._parseActionData(e[M.ACTIONS],0,null,null)),a}_parseSkin(e){const r=t.borrowObject(F);if(r.name=D._getString(e,M.NAME,M.DEFAULT_NAME),0===r.name.length&&(r.name=M.DEFAULT_NAME),M.SLOT in e){const t=e[M.SLOT];this._skin=r;for(const e of t){const t=D._getString(e,M.NAME,""),a=this._armature.getSlot(t);if(null!==a){if(this._slot=a,M.DISPLAY in e){const a=e[M.DISPLAY];for(const e of a)e?r.addDisplay(t,this._parseDisplay(e)):r.addDisplay(t,null)}this._slot=null}}this._skin=null}return r}_parseDisplay(e){const r=D._getString(e,M.NAME,""),a=D._getString(e,M.PATH,"");let i=0,s=null;switch(i=M.TYPE in e&&"string"==typeof e[M.TYPE]?M._getDisplayType(e[M.TYPE]):D._getNumber(e,M.TYPE,i),i){case 0:{const i=s=t.borrowObject(N);i.name=r,i.path=a.length>0?a:r,this._parsePivot(e,i);break}case 1:{const i=s=t.borrowObject(S);if(i.name=r,i.path=a.length>0?a:r,i.inheritAnimation=!0,M.ACTIONS in e){const t=this._parseActionData(e[M.ACTIONS],0,null,null);for(const e of t)i.addAction(e)}else if(this._slot.name in this._slotChildActions){const t=this._skin.getDisplays(this._slot.name);if(null===t?0===this._slot.displayIndex:this._slot.displayIndex===t.length){for(const t of this._slotChildActions[this._slot.name])i.addAction(t);delete this._slotChildActions[this._slot.name]}}break}case 2:{const i=s=t.borrowObject(T);i.geometry.inheritDeform=D._getBoolean(e,M.INHERIT_DEFORM,!0),i.name=r,i.path=a.length>0?a:r,M.SHARE in e?(i.geometry.data=this._data,this._cacheRawMeshes.push(e),this._cacheMeshes.push(i)):this._parseMesh(e,i);break}case 3:{const i=this._parseBoundingBox(e);if(null!==i){const e=s=t.borrowObject(p);e.name=r,e.path=a.length>0?a:r,e.boundingBox=i}break}case 4:{const i=e[M.LENGTHS],n=s=t.borrowObject(E);n.closed=D._getBoolean(e,M.CLOSED,!1),n.constantSpeed=D._getBoolean(e,M.CONSTANT_SPEED,!1),n.name=r,n.path=a.length>0?a:r,n.curveLengths.length=i.length;for(let t=0,e=i.length;t<e;++t)n.curveLengths[t]=i[t];this._parsePath(e,n);break}}return null!==s&&M.TRANSFORM in e&&this._parseTransform(e[M.TRANSFORM],s.transform,this._armature.scale),s}_parsePath(t,e){this._parseGeometry(t,e.geometry)}_parsePivot(t,e){if(M.PIVOT in t){const r=t[M.PIVOT];e.pivot.x=D._getNumber(r,M.X,0),e.pivot.y=D._getNumber(r,M.Y,0)}else e.pivot.x=.5,e.pivot.y=.5}_parseMesh(t,e){if(this._parseGeometry(t,e.geometry),M.WEIGHTS in t){const r=t[M.SLOT_POSE],a=t[M.BONE_POSE],i=this._skin.name+"_"+this._slot.name+"_"+e.name;this._weightSlotPose[i]=r,this._weightBonePoses[i]=a}}_parseBoundingBox(e){let r=null,a=0;switch(a=M.SUB_TYPE in e&&"string"==typeof e[M.SUB_TYPE]?M._getBoundingBoxType(e[M.SUB_TYPE]):D._getNumber(e,M.SUB_TYPE,a),a){case 0:r=t.borrowObject(A);break;case 1:r=t.borrowObject(f);break;case 2:r=this._parsePolygonBoundingBox(e)}return null!==r&&(r.color=D._getNumber(e,M.COLOR,0),0!==r.type&&1!==r.type||(r.width=D._getNumber(e,M.WIDTH,0),r.height=D._getNumber(e,M.HEIGHT,0))),r}_parsePolygonBoundingBox(e){const r=t.borrowObject(g);if(M.VERTICES in e){const t=this._armature.scale,a=e[M.VERTICES],i=r.vertices;i.length=a.length;for(let e=0,s=a.length;e<s;e+=2){const s=a[e]*t,n=a[e+1]*t;i[e]=s,i[e+1]=n,0===e?(r.x=s,r.y=n,r.width=s,r.height=n):(s<r.x?r.x=s:s>r.width&&(r.width=s),n<r.y?r.y=n:n>r.height&&(r.height=n))}r.width-=r.x,r.height-=r.y}else console.warn("Data error.\n Please reexport DragonBones Data to fixed the bug.");return r}_parseAnimation(e){const r=t.borrowObject(s);if(r.blendType=M._getAnimationBlendType(D._getString(e,M.BLEND_TYPE,"")),r.frameCount=D._getNumber(e,M.DURATION,0),r.playTimes=D._getNumber(e,M.PLAY_TIMES,1),r.duration=r.frameCount/this._armature.frameRate,r.fadeInTime=D._getNumber(e,M.FADE_IN_TIME,0),r.scale=D._getNumber(e,M.SCALE,1),r.name=D._getString(e,M.NAME,M.DEFAULT_NAME),0===r.name.length&&(r.name=M.DEFAULT_NAME),r.frameIntOffset=this._frameIntArray.length,r.frameFloatOffset=this._frameFloatArray.length,r.frameOffset=this._frameArray.length,this._animation=r,M.FRAME in e){const t=e[M.FRAME],r=t.length;if(r>0)for(let e=0,a=0;e<r;++e){const r=t[e];this._parseActionDataInFrame(r,a,null,null),a+=D._getNumber(r,M.DURATION,1)}}if(M.Z_ORDER in e&&(this._animation.zOrderTimeline=this._parseTimeline(e[M.Z_ORDER],null,M.FRAME,1,0,0,this._parseZOrderFrame)),M.BONE in e){const t=e[M.BONE];for(const e of t)this._parseBoneTimeline(e)}if(M.SLOT in e){const t=e[M.SLOT];for(const e of t)this._parseSlotTimeline(e)}if(M.FFD in e){const t=e[M.FFD];for(const e of t){let t=D._getString(e,M.SKIN,M.DEFAULT_NAME);const r=D._getString(e,M.SLOT,""),a=D._getString(e,M.NAME,"");if(0===t.length&&(t=M.DEFAULT_NAME),this._slot=this._armature.getSlot(r),this._mesh=this._armature.getMesh(t,r,a),null===this._slot||null===this._mesh)continue;const i=this._parseTimeline(e,null,M.FRAME,22,2,0,this._parseSlotDeformFrame);null!==i&&this._animation.addSlotTimeline(r,i),this._slot=null,this._mesh=null}}if(M.IK in e){const t=e[M.IK];for(const e of t){const t=D._getString(e,M.NAME,"");if(null===this._armature.getConstraint(t))continue;const r=this._parseTimeline(e,null,M.FRAME,30,1,2,this._parseIKConstraintFrame);null!==r&&this._animation.addConstraintTimeline(t,r)}}if(this._actionFrames.length>0&&(this._animation.actionTimeline=this._parseTimeline(null,this._actionFrames,"",0,0,0,this._parseActionFrame),this._actionFrames.length=0),M.TIMELINE in e){const a=e[M.TIMELINE];for(const e of a){const a=D._getNumber(e,M.TYPE,0),s=D._getString(e,M.NAME,"");let o=null;switch(a){case 0:case 1:break;case 20:case 23:case 60:case 24:case 40:case 41:if(20===a?(this._frameValueType=0,this._frameValueScale=1):(this._frameValueType=1,this._frameValueScale=23===a?1:40===a||41===a?1e4:100),this._frameDefaultValue=60===a||24===a||41===a?1:0,40===a&&0!==r.blendType){o=t.borrowObject(n);const r=o;r.x=D._getNumber(e,M.X,0),r.y=D._getNumber(e,M.Y,0)}o=this._parseTimeline(e,null,M.FRAME,a,this._frameValueType,1,this._parseSingleValueFrame,o);break;case 11:case 12:case 13:case 30:case 42:30===a||42===a?(this._frameValueType=1,this._frameValueScale=42===a?1e4:100):(this._frameValueScale=12===a?i.DEG_RAD:1,this._frameValueType=2),this._frameDefaultValue=13===a||30===a?1:0,o=this._parseTimeline(e,null,M.FRAME,a,this._frameValueType,2,this._parseDoubleValueFrame);break;case 50:{const t=this._armature.getBone(s);if(null===t)continue;this._geometry=t.geometry,o=this._parseTimeline(e,null,M.FRAME,a,2,0,this._parseDeformFrame),this._geometry=null;break}case 22:this._geometry=null;for(const t in this._armature.skins){const e=this._armature.skins[t];for(const t in e.displays){const r=e.displays[t];for(const t of r)if(null!==t&&t.name===s){this._geometry=t.geometry;break}}}if(null===this._geometry)continue;o=this._parseTimeline(e,null,M.FRAME,a,2,0,this._parseDeformFrame),this._geometry=null;break;case 21:o=this._parseTimeline(e,null,M.FRAME,a,1,1,this._parseSlotColorFrame)}if(null!==o)switch(a){case 0:case 1:break;case 11:case 12:case 13:case 50:case 60:this._animation.addBoneTimeline(s,o);break;case 20:case 21:case 22:case 23:case 24:this._animation.addSlotTimeline(s,o);break;case 30:this._animation.addConstraintTimeline(s,o);break;case 40:case 41:case 42:this._animation.addAnimationTimeline(s,o)}}}return this._animation=null,r}_parseTimeline(e,r,a,i,s,n,l,h=null){if(null!==e&&a.length>0&&a in e&&(r=e[a]),null===r)return null;const _=r.length;if(0===_)return null;const m=this._frameIntArray.length,f=this._frameFloatArray.length,A=this._timelineArray.length;switch(null===h&&(h=t.borrowObject(o)),h.type=i,h.offset=A,this._frameValueType=s,this._timeline=h,this._timelineArray.length+=5+_,null!==e?(this._timelineArray[A+0]=Math.round(100*D._getNumber(e,M.SCALE,1)),this._timelineArray[A+1]=Math.round(100*D._getNumber(e,M.OFFSET,0))):(this._timelineArray[A+0]=100,this._timelineArray[A+1]=0),this._timelineArray[A+2]=_,this._timelineArray[A+3]=n,this._frameValueType){case 0:this._timelineArray[A+4]=0;break;case 1:this._timelineArray[A+4]=m-this._animation.frameIntOffset;break;case 2:this._timelineArray[A+4]=f-this._animation.frameFloatOffset}if(1===_)h.frameIndicesOffset=-1,this._timelineArray[A+5+0]=l.call(this,r[0],0,0)-this._animation.frameOffset;else{const t=this._animation.frameCount+1,e=this._data.frameIndices,a=e.length;e.length+=t,h.frameIndicesOffset=a;for(let i=0,s=0,n=0,o=0;i<t;++i){if(n+o<=i&&s<_){const t=r[s];n=i,o=s===_-1?this._animation.frameCount-n:t instanceof B?this._actionFrames[s+1].frameStart-n:D._getNumber(t,M.DURATION,1),this._timelineArray[A+5+s]=l.call(this,t,n,o)-this._animation.frameOffset,s++}e[a+i]=s-1}}return this._timeline=null,h}_parseBoneTimeline(t){const e=this._armature.getBone(D._getString(t,M.NAME,""));if(null!==e){if(this._bone=e,this._slot=this._armature.getSlot(this._bone.name),M.TRANSLATE_FRAME in t){this._frameDefaultValue=0,this._frameValueScale=1;const r=this._parseTimeline(t,null,M.TRANSLATE_FRAME,11,2,2,this._parseDoubleValueFrame);null!==r&&this._animation.addBoneTimeline(e.name,r)}if(M.ROTATE_FRAME in t){this._frameDefaultValue=0,this._frameValueScale=1;const r=this._parseTimeline(t,null,M.ROTATE_FRAME,12,2,2,this._parseBoneRotateFrame);null!==r&&this._animation.addBoneTimeline(e.name,r)}if(M.SCALE_FRAME in t){this._frameDefaultValue=1,this._frameValueScale=1;const r=this._parseTimeline(t,null,M.SCALE_FRAME,13,2,2,this._parseBoneScaleFrame);null!==r&&this._animation.addBoneTimeline(e.name,r)}if(M.FRAME in t){const r=this._parseTimeline(t,null,M.FRAME,10,2,6,this._parseBoneAllFrame);null!==r&&this._animation.addBoneTimeline(e.name,r)}this._bone=null,this._slot=null}}_parseSlotTimeline(t){const e=this._armature.getSlot(D._getString(t,M.NAME,""));if(null===e)return;let r=null,a=null;this._slot=e,r=M.DISPLAY_FRAME in t?this._parseTimeline(t,null,M.DISPLAY_FRAME,20,0,0,this._parseSlotDisplayFrame):this._parseTimeline(t,null,M.FRAME,20,0,0,this._parseSlotDisplayFrame),a=M.COLOR_FRAME in t?this._parseTimeline(t,null,M.COLOR_FRAME,21,1,1,this._parseSlotColorFrame):this._parseTimeline(t,null,M.FRAME,21,1,1,this._parseSlotColorFrame),null!==r&&this._animation.addSlotTimeline(e.name,r),null!==a&&this._animation.addSlotTimeline(e.name,a),this._slot=null}_parseFrame(t,e,r){const a=this._frameArray.length;return this._frameArray.length+=1,this._frameArray[a+0]=e,a}_parseTweenFrame(t,e,r){const a=this._parseFrame(t,e,r);if(r>0)if(M.CURVE in t){const e=r+1;this._helpArray.length=e;const i=this._samplingEasingCurve(t[M.CURVE],this._helpArray);this._frameArray.length+=2+this._helpArray.length,this._frameArray[a+1]=2,this._frameArray[a+2]=i?e:-e;for(let t=0;t<e;++t)this._frameArray[a+3+t]=Math.round(1e4*this._helpArray[t])}else{const e=-2;let r=e;M.TWEEN_EASING in t&&(r=D._getNumber(t,M.TWEEN_EASING,e)),r===e?(this._frameArray.length+=1,this._frameArray[a+1]=0):0===r?(this._frameArray.length+=1,this._frameArray[a+1]=1):r<0?(this._frameArray.length+=2,this._frameArray[a+1]=3,this._frameArray[a+2]=Math.round(100*-r)):r<=1?(this._frameArray.length+=2,this._frameArray[a+1]=4,this._frameArray[a+2]=Math.round(100*r)):(this._frameArray.length+=2,this._frameArray[a+1]=5,this._frameArray[a+2]=Math.round(100*r-100))}else this._frameArray.length+=1,this._frameArray[a+1]=0;return a}_parseSingleValueFrame(t,e,r){let a=0;switch(this._frameValueType){case 0:a=this._parseFrame(t,e,r),this._frameArray.length+=1,this._frameArray[a+1]=D._getNumber(t,M.VALUE,this._frameDefaultValue);break;case 1:{a=this._parseTweenFrame(t,e,r);const i=this._frameIntArray.length;this._frameIntArray.length+=1,this._frameIntArray[i]=Math.round(D._getNumber(t,M.VALUE,this._frameDefaultValue)*this._frameValueScale);break}case 2:{a=this._parseTweenFrame(t,e,r);const i=this._frameFloatArray.length;this._frameFloatArray.length+=1,this._frameFloatArray[i]=D._getNumber(t,M.VALUE,this._frameDefaultValue)*this._frameValueScale;break}}return a}_parseDoubleValueFrame(t,e,r){let a=0;switch(this._frameValueType){case 0:a=this._parseFrame(t,e,r),this._frameArray.length+=2,this._frameArray[a+1]=D._getNumber(t,M.X,this._frameDefaultValue),this._frameArray[a+2]=D._getNumber(t,M.Y,this._frameDefaultValue);break;case 1:{a=this._parseTweenFrame(t,e,r);const i=this._frameIntArray.length;this._frameIntArray.length+=2,this._frameIntArray[i]=Math.round(D._getNumber(t,M.X,this._frameDefaultValue)*this._frameValueScale),this._frameIntArray[i+1]=Math.round(D._getNumber(t,M.Y,this._frameDefaultValue)*this._frameValueScale);break}case 2:{a=this._parseTweenFrame(t,e,r);const i=this._frameFloatArray.length;this._frameFloatArray.length+=2,this._frameFloatArray[i]=D._getNumber(t,M.X,this._frameDefaultValue)*this._frameValueScale,this._frameFloatArray[i+1]=D._getNumber(t,M.Y,this._frameDefaultValue)*this._frameValueScale;break}}return a}_parseActionFrame(t,e,r){const a=this._frameArray.length,i=t.actions.length;this._frameArray.length+=2+i,this._frameArray[a+0]=e,this._frameArray[a+0+1]=i;for(let e=0;e<i;++e)this._frameArray[a+0+2+e]=t.actions[e];return a}_parseZOrderFrame(t,e,r){const a=this._parseFrame(t,e,r);if(M.Z_ORDER in t){const e=t[M.Z_ORDER];if(e.length>0){const t=this._armature.sortedSlots.length,r=new Array(t-e.length/2),i=new Array(t);for(let t=0;t<r.length;++t)r[t]=0;for(let e=0;e<t;++e)i[e]=-1;let s=0,n=0;for(let t=0,a=e.length;t<a;t+=2){const a=e[t],o=e[t+1];for(;s!==a;)r[n++]=s++;i[s+o]=s++}for(;s<t;)r[n++]=s++;this._frameArray.length+=1+t,this._frameArray[a+1]=t;let o=t;for(;o--;)-1===i[o]?this._frameArray[a+2+o]=r[--n]||0:this._frameArray[a+2+o]=i[o]||0;return a}}return this._frameArray.length+=1,this._frameArray[a+1]=0,a}_parseBoneAllFrame(t,e,r){this._helpTransform.identity(),M.TRANSFORM in t&&this._parseTransform(t[M.TRANSFORM],this._helpTransform,1);let a=this._helpTransform.rotation;0!==e&&(0===this._prevClockwise?a=this._prevRotation+i.normalizeRadian(a-this._prevRotation):((this._prevClockwise>0?a>=this._prevRotation:a<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),a=this._prevRotation+a-this._prevRotation+i.PI_D*this._prevClockwise)),this._prevClockwise=D._getNumber(t,M.TWEEN_ROTATE,0),this._prevRotation=a;const s=this._parseTweenFrame(t,e,r);let n=this._frameFloatArray.length;return this._frameFloatArray.length+=6,this._frameFloatArray[n++]=this._helpTransform.x,this._frameFloatArray[n++]=this._helpTransform.y,this._frameFloatArray[n++]=a,this._frameFloatArray[n++]=this._helpTransform.skew,this._frameFloatArray[n++]=this._helpTransform.scaleX,this._frameFloatArray[n++]=this._helpTransform.scaleY,this._parseActionDataInFrame(t,e,this._bone,this._slot),s}_parseBoneTranslateFrame(t,e,r){const a=this._parseTweenFrame(t,e,r);let i=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[i++]=D._getNumber(t,M.X,0),this._frameFloatArray[i++]=D._getNumber(t,M.Y,0),a}_parseBoneRotateFrame(t,e,r){let a=D._getNumber(t,M.ROTATE,0)*i.DEG_RAD;0!==e&&(0===this._prevClockwise?a=this._prevRotation+i.normalizeRadian(a-this._prevRotation):((this._prevClockwise>0?a>=this._prevRotation:a<=this._prevRotation)&&(this._prevClockwise=this._prevClockwise>0?this._prevClockwise-1:this._prevClockwise+1),a=this._prevRotation+a-this._prevRotation+i.PI_D*this._prevClockwise)),this._prevClockwise=D._getNumber(t,M.CLOCK_WISE,0),this._prevRotation=a;const s=this._parseTweenFrame(t,e,r);let n=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[n++]=a,this._frameFloatArray[n++]=D._getNumber(t,M.SKEW,0)*i.DEG_RAD,s}_parseBoneScaleFrame(t,e,r){const a=this._parseTweenFrame(t,e,r);let i=this._frameFloatArray.length;return this._frameFloatArray.length+=2,this._frameFloatArray[i++]=D._getNumber(t,M.X,1),this._frameFloatArray[i++]=D._getNumber(t,M.Y,1),a}_parseSlotDisplayFrame(t,e,r){const a=this._parseFrame(t,e,r);return this._frameArray.length+=1,M.VALUE in t?this._frameArray[a+1]=D._getNumber(t,M.VALUE,0):this._frameArray[a+1]=D._getNumber(t,M.DISPLAY_INDEX,0),this._parseActionDataInFrame(t,e,this._slot.parent,this._slot),a}_parseSlotColorFrame(t,e,r){const a=this._parseTweenFrame(t,e,r);let i=-1;if(M.VALUE in t||M.COLOR in t){const e=M.VALUE in t?t[M.VALUE]:t[M.COLOR];for(let t in e){this._parseColorTransform(e,this._helpColorTransform),i=this._colorArray.length,this._colorArray.length+=8,this._colorArray[i++]=Math.round(100*this._helpColorTransform.alphaMultiplier),this._colorArray[i++]=Math.round(100*this._helpColorTransform.redMultiplier),this._colorArray[i++]=Math.round(100*this._helpColorTransform.greenMultiplier),this._colorArray[i++]=Math.round(100*this._helpColorTransform.blueMultiplier),this._colorArray[i++]=Math.round(this._helpColorTransform.alphaOffset),this._colorArray[i++]=Math.round(this._helpColorTransform.redOffset),this._colorArray[i++]=Math.round(this._helpColorTransform.greenOffset),this._colorArray[i++]=Math.round(this._helpColorTransform.blueOffset),i-=8;break}}i<0&&(this._defaultColorOffset<0&&(this._defaultColorOffset=i=this._colorArray.length,this._colorArray.length+=8,this._colorArray[i++]=100,this._colorArray[i++]=100,this._colorArray[i++]=100,this._colorArray[i++]=100,this._colorArray[i++]=0,this._colorArray[i++]=0,this._colorArray[i++]=0,this._colorArray[i++]=0),i=this._defaultColorOffset);const s=this._frameIntArray.length;return this._frameIntArray.length+=1,this._frameIntArray[s]=i,a}_parseSlotDeformFrame(t,e,r){const a=this._frameFloatArray.length,i=this._parseTweenFrame(t,e,r),s=M.VERTICES in t?t[M.VERTICES]:null,n=D._getNumber(t,M.OFFSET,0),o=this._intArray[this._mesh.geometry.offset+0],l=this._mesh.parent.name+"_"+this._slot.name+"_"+this._mesh.name,h=this._mesh.geometry.weight;let _=0,m=0,f=0,A=0;if(null!==h){const t=this._weightSlotPose[l];this._helpMatrixA.copyFromArray(t,0),this._frameFloatArray.length+=2*h.count,f=h.offset+2+h.bones.length}else this._frameFloatArray.length+=2*o;for(let t=0;t<2*o;t+=2)if(null===s?(_=0,m=0):(_=t<n||t-n>=s.length?0:s[t-n],m=t+1<n||t+1-n>=s.length?0:s[t+1-n]),null!==h){const t=this._weightBonePoses[l],e=this._intArray[f++];this._helpMatrixA.transformPoint(_,m,this._helpPoint,!0),_=this._helpPoint.x,m=this._helpPoint.y;for(let r=0;r<e;++r){const e=this._intArray[f++];this._helpMatrixB.copyFromArray(t,7*e+1),this._helpMatrixB.invert(),this._helpMatrixB.transformPoint(_,m,this._helpPoint,!0),this._frameFloatArray[a+A++]=this._helpPoint.x,this._frameFloatArray[a+A++]=this._helpPoint.y}}else this._frameFloatArray[a+t]=_,this._frameFloatArray[a+t+1]=m;if(0===e){const t=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[t+0]=this._mesh.geometry.offset,this._frameIntArray[t+1]=this._frameFloatArray.length-a,this._frameIntArray[t+2]=this._frameFloatArray.length-a,this._frameIntArray[t+3]=0,this._frameIntArray[t+4]=a-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=t-this._animation.frameIntOffset}return i}_parseIKConstraintFrame(t,e,r){const a=this._parseTweenFrame(t,e,r);let i=this._frameIntArray.length;return this._frameIntArray.length+=2,this._frameIntArray[i++]=D._getBoolean(t,M.BEND_POSITIVE,!0)?1:0,this._frameIntArray[i++]=Math.round(100*D._getNumber(t,M.WEIGHT,1)),a}_parseActionData(e,r,a,i){const s=new Array;if("string"==typeof e){const n=t.borrowObject(O);n.type=r,n.name=e,n.bone=a,n.slot=i,s.push(n)}else if(e instanceof Array)for(const n of e){const e=t.borrowObject(O);if(M.GOTO_AND_PLAY in n?(e.type=0,e.name=D._getString(n,M.GOTO_AND_PLAY,"")):(M.TYPE in n&&"string"==typeof n[M.TYPE]?e.type=M._getActionType(n[M.TYPE]):e.type=D._getNumber(n,M.TYPE,r),e.name=D._getString(n,M.NAME,"")),M.BONE in n){const t=D._getString(n,M.BONE,"");e.bone=this._armature.getBone(t)}else e.bone=a;if(M.SLOT in n){const t=D._getString(n,M.SLOT,"");e.slot=this._armature.getSlot(t)}else e.slot=i;let o=null;if(M.INTS in n){null===o&&(o=t.borrowObject(R));const e=n[M.INTS];for(const t of e)o.addInt(t)}if(M.FLOATS in n){null===o&&(o=t.borrowObject(R));const e=n[M.FLOATS];for(const t of e)o.addFloat(t)}if(M.STRINGS in n){null===o&&(o=t.borrowObject(R));const e=n[M.STRINGS];for(const t of e)o.addString(t)}e.data=o,s.push(e)}return s}_parseDeformFrame(t,e,r){const a=this._frameFloatArray.length,i=this._parseTweenFrame(t,e,r),s=M.VERTICES in t?t[M.VERTICES]:M.VALUE in t?t[M.VALUE]:null,n=D._getNumber(t,M.OFFSET,0),o=this._intArray[this._geometry.offset+0];let l=0,h=0;if(null!==this._geometry.weight);else{this._frameFloatArray.length+=2*o;for(let t=0;t<2*o;t+=2)null!==s?(l=t<n||t-n>=s.length?0:s[t-n],h=t+1<n||t+1-n>=s.length?0:s[t+1-n]):(l=0,h=0),this._frameFloatArray[a+t]=l,this._frameFloatArray[a+t+1]=h}if(0===e){const t=this._frameIntArray.length;this._frameIntArray.length+=5,this._frameIntArray[t+0]=this._geometry.offset,this._frameIntArray[t+1]=this._frameFloatArray.length-a,this._frameIntArray[t+2]=this._frameFloatArray.length-a,this._frameIntArray[t+3]=0,this._frameIntArray[t+4]=a-this._animation.frameFloatOffset,this._timelineArray[this._timeline.offset+3]=t-this._animation.frameIntOffset}return i}_parseTransform(t,e,r){e.x=D._getNumber(t,M.X,0)*r,e.y=D._getNumber(t,M.Y,0)*r,M.ROTATE in t||M.SKEW in t?(e.rotation=i.normalizeRadian(D._getNumber(t,M.ROTATE,0)*i.DEG_RAD),e.skew=i.normalizeRadian(D._getNumber(t,M.SKEW,0)*i.DEG_RAD)):(M.SKEW_X in t||M.SKEW_Y in t)&&(e.rotation=i.normalizeRadian(D._getNumber(t,M.SKEW_Y,0)*i.DEG_RAD),e.skew=i.normalizeRadian(D._getNumber(t,M.SKEW_X,0)*i.DEG_RAD)-e.rotation),e.scaleX=D._getNumber(t,M.SCALE_X,1),e.scaleY=D._getNumber(t,M.SCALE_Y,1)}_parseColorTransform(t,e){e.alphaMultiplier=.01*D._getNumber(t,M.ALPHA_MULTIPLIER,100),e.redMultiplier=.01*D._getNumber(t,M.RED_MULTIPLIER,100),e.greenMultiplier=.01*D._getNumber(t,M.GREEN_MULTIPLIER,100),e.blueMultiplier=.01*D._getNumber(t,M.BLUE_MULTIPLIER,100),e.alphaOffset=D._getNumber(t,M.ALPHA_OFFSET,0),e.redOffset=D._getNumber(t,M.RED_OFFSET,0),e.greenOffset=D._getNumber(t,M.GREEN_OFFSET,0),e.blueOffset=D._getNumber(t,M.BLUE_OFFSET,0)}_parseGeometry(e,r){const a=e[M.VERTICES],i=Math.floor(a.length/2);let s=0;const n=this._intArray.length,o=this._floatArray.length;r.offset=n,r.data=this._data,this._intArray.length+=4,this._intArray[n+0]=i,this._intArray[n+2]=o,this._intArray[n+3]=-1,this._floatArray.length+=2*i;for(let t=0,e=2*i;t<e;++t)this._floatArray[o+t]=a[t];if(M.TRIANGLES in e){const t=e[M.TRIANGLES];s=Math.floor(t.length/3),this._intArray.length+=3*s;for(let e=0,r=3*s;e<r;++e)this._intArray[n+4+e]=t[e]}if(this._intArray[n+1]=s,M.UVS in e){const t=e[M.UVS],r=o+2*i;this._floatArray.length+=2*i;for(let e=0,a=2*i;e<a;++e)this._floatArray[r+e]=t[e]}if(M.WEIGHTS in e){const s=e[M.WEIGHTS],n=Math.floor(s.length-i)/2,l=this._intArray.length,h=this._floatArray.length;let _=0;const m=this._armature.sortedBones,f=t.borrowObject(d);if(f.count=n,f.offset=l,this._intArray.length+=2+_+i+n,this._intArray[l+1]=h,M.BONE_POSE in e){const t=e[M.SLOT_POSE],r=e[M.BONE_POSE],a=new Array;_=Math.floor(r.length/7),a.length=_;for(let t=0;t<_;++t){const e=r[7*t],i=this._rawBones[e];f.addBone(i),a[t]=e,this._intArray[l+2+t]=m.indexOf(i)}this._floatArray.length+=3*n,this._helpMatrixA.copyFromArray(t,0);for(let t=0,e=0,n=l+2+_,m=h;t<i;++t){const i=2*t,l=this._intArray[n++]=s[e++];let h=this._floatArray[o+i],_=this._floatArray[o+i+1];this._helpMatrixA.transformPoint(h,_,this._helpPoint),h=this._helpPoint.x,_=this._helpPoint.y;for(let t=0;t<l;++t){const t=s[e++],i=a.indexOf(t);this._helpMatrixB.copyFromArray(r,7*i+1),this._helpMatrixB.invert(),this._helpMatrixB.transformPoint(h,_,this._helpPoint),this._intArray[n++]=i,this._floatArray[m++]=s[e++],this._floatArray[m++]=this._helpPoint.x,this._floatArray[m++]=this._helpPoint.y}}}else{const t=e[M.BONES];_=t.length;for(let e=0;e<_;e++){const r=t[e],a=this._rawBones[r];f.addBone(a),this._intArray[l+2+e]=m.indexOf(a)}this._floatArray.length+=3*n;for(let e=0,r=0,i=0,o=l+2+_,m=h;e<n;e++){const e=s[r++];this._intArray[o++]=e;for(let n=0;n<e;n++){const e=s[r++],n=s[r++],l=a[i++],h=a[i++];this._intArray[o++]=t.indexOf(e),this._floatArray[m++]=n,this._floatArray[m++]=l,this._floatArray[m++]=h}}}r.weight=f}}_parseArray(t){this._intArray.length=0,this._floatArray.length=0,this._frameIntArray.length=0,this._frameFloatArray.length=0,this._frameArray.length=0,this._timelineArray.length=0,this._colorArray.length=0}_modifyArray(){this._intArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._intArray.push(0),this._frameIntArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._frameIntArray.push(0),this._frameArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._frameArray.push(0),this._timelineArray.length%Uint16Array.BYTES_PER_ELEMENT!=0&&this._timelineArray.push(0),this._timelineArray.length%Int16Array.BYTES_PER_ELEMENT!=0&&this._colorArray.push(0);const t=this._intArray.length*Int16Array.BYTES_PER_ELEMENT,e=this._floatArray.length*Float32Array.BYTES_PER_ELEMENT,r=this._frameIntArray.length*Int16Array.BYTES_PER_ELEMENT,a=this._frameFloatArray.length*Float32Array.BYTES_PER_ELEMENT,i=this._frameArray.length*Int16Array.BYTES_PER_ELEMENT,s=this._timelineArray.length*Uint16Array.BYTES_PER_ELEMENT,n=this._colorArray.length*Int16Array.BYTES_PER_ELEMENT,o=new ArrayBuffer(t+e+r+a+i+s+n),l=new Int16Array(o,0,this._intArray.length),h=new Float32Array(o,t,this._floatArray.length),_=new Int16Array(o,t+e,this._frameIntArray.length),m=new Float32Array(o,t+e+r,this._frameFloatArray.length),f=new Int16Array(o,t+e+r+a,this._frameArray.length),A=new Uint16Array(o,t+e+r+a+i,this._timelineArray.length),g=new Int16Array(o,t+e+r+a+i+s,this._colorArray.length);for(let t=0,e=this._intArray.length;t<e;++t)l[t]=this._intArray[t];for(let t=0,e=this._floatArray.length;t<e;++t)h[t]=this._floatArray[t];for(let t=0,e=this._frameIntArray.length;t<e;++t)_[t]=this._frameIntArray[t];for(let t=0,e=this._frameFloatArray.length;t<e;++t)m[t]=this._frameFloatArray[t];for(let t=0,e=this._frameArray.length;t<e;++t)f[t]=this._frameArray[t];for(let t=0,e=this._timelineArray.length;t<e;++t)A[t]=this._timelineArray[t];for(let t=0,e=this._colorArray.length;t<e;++t)g[t]=this._colorArray[t];this._data.binary=o,this._data.intArray=l,this._data.floatArray=h,this._data.frameIntArray=_,this._data.frameFloatArray=m,this._data.frameArray=f,this._data.timelineArray=A,this._data.colorArray=g,this._defaultColorOffset=-1}parseDragonBonesData(e,r=1){console.assert(null!=e,"Data error.");const a=D._getString(e,M.VERSION,""),i=D._getString(e,M.COMPATIBLE_VERSION,"");if(M.DATA_VERSIONS.indexOf(a)>=0||M.DATA_VERSIONS.indexOf(i)>=0){const i=t.borrowObject(b);if(i.version=a,i.name=D._getString(e,M.NAME,""),i.frameRate=D._getNumber(e,M.FRAME_RATE,24),0===i.frameRate&&(i.frameRate=24),M.ARMATURE in e){this._data=i,this._parseArray(e);const t=e[M.ARMATURE];for(const e of t)i.addArmature(this._parseArmature(e,r));this._data.binary||this._modifyArray(),M.STAGE in e?i.stage=i.getArmature(D._getString(e,M.STAGE,"")):i.armatureNames.length>0&&(i.stage=i.getArmature(i.armatureNames[0])),this._data=null}return M.TEXTURE_ATLAS in e&&(this._rawTextureAtlases=e[M.TEXTURE_ATLAS]),i}return console.assert(!1,"Nonsupport data version: "+a+"\nPlease convert DragonBones data to support version.\nRead more: https://github.com/DragonBones/Tools/"),null}parseTextureAtlasData(t,e,r=1){if(console.assert(void 0!==t),null===t){if(null===this._rawTextureAtlases||0===this._rawTextureAtlases.length)return!1;const t=this._rawTextureAtlases[this._rawTextureAtlasIndex++];return this.parseTextureAtlasData(t,e,r),this._rawTextureAtlasIndex>=this._rawTextureAtlases.length&&(this._rawTextureAtlasIndex=0,this._rawTextureAtlases=null),!0}if(e.width=D._getNumber(t,M.WIDTH,0),e.height=D._getNumber(t,M.HEIGHT,0),e.scale=1===r?1/D._getNumber(t,M.SCALE,1):r,e.name=D._getString(t,M.NAME,""),e.imagePath=D._getString(t,M.IMAGE_PATH,""),M.SUB_TEXTURE in t){const r=t[M.SUB_TEXTURE];for(let t=0,a=r.length;t<a;++t){const a=r[t],i=D._getNumber(a,M.FRAME_WIDTH,-1),s=D._getNumber(a,M.FRAME_HEIGHT,-1),n=e.createTexture();n.rotated=D._getBoolean(a,M.ROTATED,!1),n.name=D._getString(a,M.NAME,""),n.region.x=D._getNumber(a,M.X,0),n.region.y=D._getNumber(a,M.Y,0),n.region.width=D._getNumber(a,M.WIDTH,0),n.region.height=D._getNumber(a,M.HEIGHT,0),i>0&&s>0&&(n.frame=I.createRectangle(),n.frame.x=D._getNumber(a,M.FRAME_X,0),n.frame.y=D._getNumber(a,M.FRAME_Y,0),n.frame.width=i,n.frame.height=s),e.addTexture(n)}}return!0}static getInstance(){return null===D._objectDataParserInstance&&(D._objectDataParserInstance=new D),D._objectDataParserInstance}}D._objectDataParserInstance=null;class B{constructor(){this.frameStart=0,this.actions=[]}}export{B as ActionFrame,D as ObjectDataParser};
//# sourceMappingURL=ObjectDataParser.mjs.map