!function(t,e){"use strict";class i{}i.Skeleton=null,i.AnimationTemplet=null,i.Templet=null;class a{}class r{}class s{}class n{static parse(t,n){var h,l,o,u,_,p,d,c=n.__getBuffer(),m=n.readUTFString();t._aniClassName=m;var x,y=n.readUTFString().split("\n"),g=n.getUint8(),f=n.getUint32(),M=n.getUint32();f>0&&(x=c.slice(f,M));var D=new e.Byte(x);for(M>0&&(t._publicExtData=c.slice(M,c.byteLength)),t._useParent=!!n.getUint8(),t._anis.length=g,h=0;h=0&&(S.name=y[T],v.bone3DMap[S.name]=l),S.keyFrame=[],S.parentIndex=n.getInt16(),-1==S.parentIndex?S.parent=null:S.parent=v.nodes[S.parentIndex],S.lerpType=n.getUint8();var b=n.getUint32();D.pos=b;var C=S.keyframeWidth=D.getUint16();if(v.totalKeyframeDatasLength+=C,0===S.lerpType||1===S.lerpType)for(S.interpolationMethod=[],S.interpolationMethod.length=C,o=0;o0&&(S.extenData=c.slice(n.pos,n.pos+F),n.pos+=F);var w=n.getUint16();S.keyFrame.length=w;var k,P=0;for(o=0,u=w;o-1e-8&&k.data[_]<1e-8&&(k.data[_]=0);P+=k.duration}k.startTime=v.playTime,S.playTime=v.playTime,t._calculateKeyFrame(S,w,C)}}}}class h{static READ_DATA(){h._DATA.offset=h._reader.getUint32(),h._DATA.size=h._reader.getUint32()}static READ_BLOCK(){for(var t=h._BLOCK.count=h._reader.getUint16(),e=h._BLOCK.blockStarts=[],i=h._BLOCK.blockLengths=[],a=0;a=0&&(y.name=h._strings[g],c.bone3DMap[y.name]=e),y.keyFrame=[],y.parentIndex=o.getInt16(),-1==y.parentIndex?y.parent=null:y.parent=c.nodes[y.parentIndex],c.totalKeyframeDatasLength+=_,y.interpolationMethod=p,null!=y.parent&&y.parent.childs.push(y);var f=o.getUint16();y.keyFrame.length=f;var M=null,D=null;for(n=0,l=f;nthis._playEnd)throw new Error("AnimationPlayer:value must large than playStartTime,small than playEndTime.");this._startUpdateLoopCount=e.Stat.loopCount;var i=this._cacheFrameRateInterval*this._cachePlayRate;this._currentTime=t,this._currentKeyframeIndex=Math.floor(this.currentPlayTime/i),this._currentFrameTime=this._currentKeyframeIndex*i}}get paused(){return this._paused}set paused(t){this._paused=t,t&&this.event(e.Event.PAUSED)}get cacheFrameRateInterval(){return this._cacheFrameRateInterval}get state(){return-1===this._currentAnimationClipIndex?l.stopped:this._paused?l.paused:l.playing}get destroyed(){return this._destroyed}_onTempletLoadedComputeFullKeyframeIndices(t,e,i){this._templet===i&&this._cachePlayRate===t&&this._cacheFrameRate===e&&this._computeFullKeyframeIndices()}_computeFullKeyframeIndices(){}_onAnimationTempletLoaded(){this.destroyed||this._calculatePlayDuration()}_calculatePlayDuration(){if(this.state!==l.stopped){var t=this._templet.getAniDuration(this._currentAnimationClipIndex);0===this._playEnd&&(this._playEnd=t),this._playEnd>t&&(this._playEnd=t),this._playDuration=this._playEnd-this._playStart}}_setPlayParams(t,e){this._currentTime=t,this._currentKeyframeIndex=Math.floor(this.currentPlayTime/e+.01),this._currentFrameTime=this._currentKeyframeIndex*e}_setPlayParamsWhenStop(t,e,i=-1){this._currentTime=t;var a=i>0?i:t;this._currentKeyframeIndex=Math.floor(a/e+.01),this._currentKeyframeIndex=Math.floor(t/e+.01),this._currentFrameTime=this._currentKeyframeIndex*e,this._currentAnimationClipIndex=-1}_update(t){if(-1!==this._currentAnimationClipIndex&&!this._paused&&this._templet){var i=this._cacheFrameRateInterval*this._cachePlayRate,a=0;this._startUpdateLoopCount!==e.Stat.loopCount&&(a=t*this.playbackRate,this._elapsedPlaybackTime+=a);var r=this.playDuration;if(a+=this._currentTime,0!==this._overallDuration&&this._elapsedPlaybackTime>=this._overallDuration||0===this._overallDuration&&this._elapsedPlaybackTime>=r||0===this._overallDuration&&a>=this.playEnd)return this._setPlayParamsWhenStop(r,i,this.playEnd),void this.event(e.Event.STOPPED);if(r>0){if(a>=r)return this._stopWhenCircleFinish?(this._setPlayParamsWhenStop(r,i),this._stopWhenCircleFinish=!1,void this.event(e.Event.STOPPED)):(a%=r,this._setPlayParams(a,i),void this.event(e.Event.COMPLETE));this._setPlayParams(a,i)}else{if(this._stopWhenCircleFinish)return this._setPlayParamsWhenStop(r,i),this._stopWhenCircleFinish=!1,void this.event(e.Event.STOPPED);this._currentTime=this._currentFrameTime=this._currentKeyframeIndex=0,this.event(e.Event.COMPLETE)}}}_destroy(){this.offAll(),this._templet=null,this._destroyed=!0}play(t=0,i=1,a=2147483647,r=0,s=0){if(!this._templet)throw new Error("AnimationPlayer:templet must not be null,maybe you need to set url.");if(a<0||r<0||s<0)throw new Error("AnimationPlayer:overallDuration,playStart and playEnd must large than zero.");if(0!==s&&r>s)throw new Error("AnimationPlayer:start must less than end.");this._currentTime=0,this._currentFrameTime=0,this._elapsedPlaybackTime=0,this.playbackRate=i,this._overallDuration=a,this._playStart=r,this._playEnd=s,this._paused=!1,this._currentAnimationClipIndex=t,this._currentKeyframeIndex=0,this._startUpdateLoopCount=e.Stat.loopCount,this.event(e.Event.PLAYED),this._calculatePlayDuration(),this._update(0)}playByFrame(t=0,e=1,i=2147483647,a=0,r=0,s=30){var n=1e3/s;this.play(t,e,i,a*n,r*n)}stop(t=!0){t?(this._currentTime=this._currentFrameTime=this._currentKeyframeIndex=0,this._currentAnimationClipIndex=-1,this.event(e.Event.STOPPED)):this._stopWhenCircleFinish=!0}destroy(){}}class u{constructor(){}static getBezierRate(t,e,i,a,r){var s=u._getBezierParamKey(e,i,a,r),n=100*s+t;if(u._bezierResultCache[n])return u._bezierResultCache[n];var h,l,o=u._getBezierPoints(e,i,a,r,s);for(l=o.length,h=0;h=r)&&(a=this._boneCurKeyFrm[e]=0);var s=t[a],n=i-s.startTime;if(0==n||n>0&&s.duration>n)return a;var h=0;if(n>0){for(i+=.01,h=a+1;hi)return this._boneCurKeyFrm[e]=h,h;return r-1}for(h=0;hi)return this._boneCurKeyFrm[e]=h,h;return a}getOriginalData(t,e,i,a,r){var s=this._anis[t].nodes,n=this._boneCurKeyFrm;n.lengththis.unfixedCurrentTimes[a]);)this.unfixedCurrentFrameIndexes[a]++;this.unfixedCurrentFrameIndexes[a]--}return this.unfixedCurrentFrameIndexes}getOriginalDataUnfixedRate(t,e,i){var a=this._anis[t].nodes;t!==this.unfixedLastAniIndex&&(this.unfixedCurrentFrameIndexes=new Uint32Array(a.length),this.unfixedCurrentTimes=new Float32Array(a.length),this.unfixedKeyframes=[],this.unfixedLastAniIndex=t);for(var r=0,s=0,n=a.length,h=0;sthis.unfixedCurrentTimes[s]);)this.unfixedKeyframes[s]=l.keyFrame[this.unfixedCurrentFrameIndexes[s]],this.unfixedCurrentFrameIndexes[s]++;var o=this.unfixedKeyframes[s];l.dataOffset=h;var u=i-o.startTime;if(l.lerpType)switch(l.lerpType){case 0:case 1:for(r=0;r-1&&tthis.currDisplayData.uvs[5]&&(u.d=-1),this.currDisplayData.uvs[0]>this.currDisplayData.uvs[4]&&this.currDisplayData.uvs[1]>this.currDisplayData.uvs[5]&&(l=!0,u.rotate(-Math.PI/2)),e.Matrix.mul(u,e.Matrix.TEMP,o)}else e.Matrix.TEMP.copyTo(o);a||(o=this.getSaveMatrix(o)),o._checkTransform(),l?t.drawTexture(n,-this.currDisplayData.height/2,-this.currDisplayData.width/2,this.currDisplayData.height,this.currDisplayData.width,o,r):t.drawTexture(n,-this.currDisplayData.width/2,-this.currDisplayData.height/2,this.currDisplayData.width,this.currDisplayData.height,o,r)}}}break;case 1:if(a?(null==this._skinSprite&&(this._skinSprite=g.createSkinMesh()),s=this._skinSprite):s=g.createSkinMesh(),null==s)return;var _;if(null==this.currDisplayData.bones){var p,d=this.currDisplayData.weights;this.deformData&&(d=this.deformData),this._diyTexture?(this._curDiyUV||(this._curDiyUV=[]),0==this._curDiyUV.length&&(this._curDiyUV=m.getRelativeUV(this.currTexture.uv,this.currDisplayData.uvs,this._curDiyUV),this._curDiyUV=m.getAbsoluteUV(this._diyTexture.uv,this._curDiyUV,this._curDiyUV)),p=this._curDiyUV):p=this.currDisplayData.uvs,this._mVerticleArr=d;this.currDisplayData.triangles.length;_=this.currDisplayData.triangles,this.deformData&&(a||(this._mVerticleArr=this.getSaveVerticle(this._mVerticleArr))),s.init2(n,_,this._mVerticleArr,p);var c,x=this.getDisplayMatrix();if(this._parentMatrix)if(x)e.Matrix.mul(x,this._parentMatrix,e.Matrix.TEMP),a?(null==this._resultMatrix&&(this._resultMatrix=new e.Matrix),c=this._resultMatrix):c=g._tempResultMatrix,e.Matrix.TEMP.copyTo(c),a||(c=this.getSaveMatrix(c)),s.transform=c}else this.skinMesh(i,s);t.drawSkin(s,r);break;case 2:if(a?(null==this._skinSprite&&(this._skinSprite=g.createSkinMesh()),s=this._skinSprite):s=g.createSkinMesh(),null==s)return;this.skinMesh(i,s),t.drawSkin(s,r)}}}skinMesh(t,e){var i,a=this.currTexture,r=this.currDisplayData.bones;this._diyTexture?(a=this._diyTexture,this._curDiyUV||(this._curDiyUV=[]),0==this._curDiyUV.length&&(this._curDiyUV=m.getRelativeUV(this.currTexture.uv,this.currDisplayData.uvs,this._curDiyUV),this._curDiyUV=m.getAbsoluteUV(this._diyTexture.uv,this._curDiyUV,this._curDiyUV)),i=this._curDiyUV):i=this.currDisplayData.uvs;var s,n,h,l,o,u=this.currDisplayData.weights,_=this.currDisplayData.triangles,p=0,d=0,c=0,x=0,y=0,f=0,M=0;if(g._tempVerticleArr.length=0,o=g._tempVerticleArr,this.deformData&&this.deformData.length>0){var D=0;for(f=0,M=r.length;f>>1;;){if(t[Math.floor(r+1)]<=e?i=r+1:a=r,i==a)return i+1;r=i+a>>>1}return 0}apply(t,e,i=1){if(t+=.05,!(this.timeList.length<=0)){var a=0;if(!(t=this.timeList[this.timeList.length-1]){var h=this.vectices[this.vectices.length-1];if(i<1)for(a=0;a180?u-=360:u<-180&&(u+=360),t.transform.skX=t.transform.skY=t.transform.skX+u*a,t.update()}updatePos(t,e){this._sp&&this._sp.pos(t,e)}_applyIk2(t,i,a,r,s,n){if(0!=n){var h,l,o,u=t.resultTransform.x,_=t.resultTransform.y,p=t.transform.scX,d=t.transform.scY,c=i.transform.scX;p<0?(p=-p,h=180,o=-1):(h=0,o=1),d<0&&(d=-d,o=-o),c<0?(c=-c,l=180):l=0;var m,x,y,g=i.resultTransform.x,f=t.resultMatrix.a,M=t.resultMatrix.c,D=t.resultMatrix.b,v=t.resultMatrix.d,I=Math.abs(p-d)<=1e-4;I?(x=f*g+M*(m=i.resultTransform.y)+t.resultMatrix.tx,y=D*g+v*m+t.resultMatrix.ty):(m=0,x=f*g+t.resultMatrix.tx,y=D*g+t.resultMatrix.ty),this.isDebug&&(this._sp||(this._sp=new e.Sprite,e.ILaya.stage.addChild(this._sp)),this._sp.graphics.clear(),this._sp.graphics.drawCircle(a,r,15,"#ffff00"),this._sp.graphics.drawCircle(x,y,15,"#ff00ff")),t.setRotation(Math.atan2(y-t.resultMatrix.ty,x-t.resultMatrix.tx));var S=t.parentBone;f=S.resultMatrix.a,M=S.resultMatrix.c,D=S.resultMatrix.b;var T,b,C=1/(f*(v=S.resultMatrix.d)-M*D),F=a-S.resultMatrix.tx,w=r-S.resultMatrix.ty,k=(F*v-w*M)*C-u,P=(w*f-F*D)*C-_,L=((F=x-S.resultMatrix.tx)*v-(w=y-S.resultMatrix.ty)*M)*C-u,U=(w*f-F*D)*C-_,B=Math.sqrt(L*L+U*U),E=i.length*c;if(I){var R=(k*k+P*P-B*B-(E*=p)*E)/(2*B*E);R<-1?R=-1:R>1&&(R=1),b=Math.acos(R)*s,f=B+E*R,M=E*Math.sin(b),T=Math.atan2(P*f-k*M,k*f+P*M)}else{var N=(f=p*E)*f,O=(M=d*E)*M,V=k*k+P*P,Y=Math.atan2(P,k),K=-2*O*B,X=O-N;if((v=K*K-4*X*(D=O*B*B+N*V-N*O))>0){var W=Math.sqrt(v);K<0&&(W=-W);var z=(W=-(K+W)/2)/X,G=D/W,q=Math.abs(z)$&&(J=0,$=v,tt=F),(v=(F=B-f)*F)$&&(J=it,$=v,tt=F,et=w),V<=(Q+$)/2?(T=Y-Math.atan2(j*s,Z),b=H*s):(T=Y-Math.atan2(et*s,tt),b=J*s)}var at=Math.atan2(m,g)*o,rt=t.resultTransform.skX;(T=(T-at)*A.radDeg+h-rt)>180?T-=360:T<-180&&(T+=360),t.resultTransform.x=u,t.resultTransform.y=_,t.resultTransform.skX=t.resultTransform.skY=rt+T*n,rt=i.resultTransform.skX,rt%=360,(b=((b+at)*A.radDeg-0)*o+l-rt)>180?b-=360:b<-180&&(b+=360),i.resultTransform.x=g,i.resultTransform.y=m,i.resultTransform.skX=i.resultTransform.skY=i.resultTransform.skY+b*n,t.update()}}_applyIk3(t,i,a,r,s,n){if(0==n)return;var h,l;const o=i.resultMatrix.a*i.length,u=i.resultMatrix.b*i.length,_=o*o+u*u,p=Math.sqrt(_);var d=t.resultMatrix.tx,c=t.resultMatrix.ty,m=i.resultMatrix.tx,x=i.resultMatrix.ty,y=m-d,g=x-c;const f=y*y+g*g,M=Math.sqrt(f),D=(y=a-t.resultMatrix.tx)*y+(g=r-t.resultMatrix.ty)*g,v=Math.sqrt(D);if(p+M<=v||v+p<=M||v+M<=p){var I;m=d+(I=p+M<=v?1:-1)*(a-d)*M/v,x=c+I*(r-c)*M/v}else{const t=(f-_+D)/(2*D),e=Math.sqrt(f-t*t*D)/v,i=d+y*t,a=c+g*t,r=-g*e,n=y*e;s>0?(m=i-r,x=a-n):(m=i+r,x=a+n)}var S,T,b,C;h=m,l=x,this.isDebug&&(this._sp||(this._sp=new e.Sprite,e.ILaya.stage.addChild(this._sp)),this._sp.graphics.clear(),this._sp.graphics.drawCircle(d,c,15,"#ff00ff"),this._sp.graphics.drawCircle(a,r,15,"#ffff00"),this._sp.graphics.drawCircle(h,l,15,"#ff00ff")),S=Math.atan2(l-t.resultMatrix.ty,h-t.resultMatrix.tx),t.setRotation(S),(T=A._tempMatrix).identity(),T.rotate(S),T.scale(t.resultMatrix.getScaleX(),t.resultMatrix.getScaleY()),T.translate(t.resultMatrix.tx,t.resultMatrix.ty),T.copyTo(t.resultMatrix),t.updateChild(),b=Math.atan2(r-l,a-h),i.setRotation(b),(C=A._tempMatrix).identity(),C.rotate(b),C.scale(i.resultMatrix.getScaleX(),i.resultMatrix.getScaleY()),C.translate(h,l),T.copyTo(i.resultMatrix),i.updateChild()}}A.radDeg=180/Math.PI,A.degRad=Math.PI/180,A._tempMatrix=new e.Matrix;class S{constructor(){this.boneNames=[],this.bendDirection=1,this.mix=1,this.isSpine=!0,this.targetBoneIndex=-1,this.boneIndexs=[]}}class T{constructor(t,e){this._debugKey=!1,this._segments=[],this._curves=[],this.data=t,this.position=t.position,this.spacing=t.spacing,this.rotateMix=t.rotateMix,this.translateMix=t.translateMix,this.bones=[];for(var i=this.data.bones,a=0,r=i.length;a0,s=this.data.spacingMode,n="length"==s,h=this.data.rotateMode,l="tangent"==h,o="chainScale"==h,u=[],_=this.bones.length,p=l?_:_+1,d=[];this._spaces=d,d[0]=this.position;var c=this.spacing;if(o||n)for(var m=0,x=p-1;mMath.PI?k-=2*Math.PI:k<-Math.PI&&(k+=2*Math.PI),k*=a,P=Math.cos(k),L=Math.sin(k),y.resultMatrix.a=P*U-L*E,y.resultMatrix.c=P*B-L*R,y.resultMatrix.b=L*U+P*E,y.resultMatrix.d=L*B+P*R}}}}computeWorldVertices2(t,e,i,a,r,s){var n,h,l,o=t.currDisplayData.bones,u=t.currDisplayData.weights,_=t.currDisplayData.triangles,p=0,d=0,c=0,m=0,x=0,y=0,g=0,f=0,M=0,D=0;if(null!=o){for(p=0;pl)this.addAfterPosition(_-l,h,y-4,M,o);else{for(;;u++)if(!(_>(c=I[u]))){0==u?_/=c:_=(_-(d=I[u-1]))/(c-d);break}if(u!=v){v=u;var W=6*u;for(C=2*(A=.03*((L=h[W])-2*(B=h[W+2])+(R=h[W+4])))+(T=.006*(3*(B-R)-L+(O=h[W+6]))),F=2*(S=.03*((U=h[W+1])-2*(E=h[W+3])+(N=h[W+5])))+(b=.006*(3*(E-N)-U+(V=h[W+7]))),w=.3*(B-L)+A+.16666667*T,k=.3*(E-U)+S+.16666667*b,X=Math.sqrt(w*w+k*k),K[0]=X,W=1;W<8;W++)w+=C,k+=F,C+=T,F+=b,X+=Math.sqrt(w*w+k*k),K[W]=X;w+=C,k+=F,X+=Math.sqrt(w*w+k*k),K[8]=X,w+=C+T,k+=F+b,X+=Math.sqrt(w*w+k*k),K[9]=X,Y=0}for(_*=X;;Y++)if(!(_>(c=K[Y]))){0==Y?_/=c:_=Y+(_-(d=K[Y-1]))/(c-d);break}this.addCurvePosition(.1*_,L,U,B,E,R,N,O,V,M,o,r||x>0&&0==p)}return M}addBeforePosition(t,e,i,a,r){var s=e[i],n=e[i+1],h=e[i+2]-s,l=e[i+3]-n,o=Math.atan2(l,h);a[r]=s+t*Math.cos(o),a[r+1]=n+t*Math.sin(o),a[r+2]=o}addAfterPosition(t,e,i,a,r){var s=e[i+2],n=e[i+3],h=s-e[i],l=n-e[i+1],o=Math.atan2(l,h);a[r]=s+t*Math.cos(o),a[r+1]=n+t*Math.sin(o),a[r+2]=o}addCurvePosition(t,e,i,a,r,s,n,h,l,o,u,_){0==t&&(t=1e-4);var p=t*t,d=p*t,c=1-t,m=c*c,x=m*c,y=c*t,g=3*y,f=c*g,M=g*t,D=e*x+a*f+s*M+h*d,v=i*x+r*f+n*M+l*d;o[u]=D,o[u+1]=v,o[u+2]=_?Math.atan2(v-(i*m+r*y*2+n*p),D-(e*m+a*y*2+s*p)):0}}T.BEFORE=-2,T.AFTER=-3,T._tempMt=new e.Matrix;class b{constructor(){this.bones=[]}}class C{constructor(t,e){var i,a;for(this._temp=[],this._data=t,null==this._bones&&(this._bones=[]),this.target=e[t.targetIndex],i=0,a=t.boneIndexs.length;i0){var h=t.resultMatrix.a,l=t.resultMatrix.b,o=t.resultMatrix.c,u=t.resultMatrix.d,_=Math.atan2(a,e)-Math.atan2(o,h)+this._data.offsetRotation*Math.PI/180;_>Math.PI?_-=2*Math.PI:_<-Math.PI&&(_+=2*Math.PI),_*=this.rotateMix;var p=Math.cos(_),d=Math.sin(_);t.resultMatrix.a=p*h-d*o,t.resultMatrix.b=p*l-d*u,t.resultMatrix.c=d*h+p*o,t.resultMatrix.d=d*l+p*u}if(this.translateMix&&(this._temp[0]=this._data.offsetX,this._temp[1]=this._data.offsetY,this.target.localToWorld(this._temp),t.resultMatrix.tx+=(this._temp[0]-t.resultMatrix.tx)*this.translateMix,t.resultMatrix.ty+=(this._temp[1]-t.resultMatrix.ty)*this.translateMix,t.updateChild()),this.scaleMix>0){var c=Math.sqrt(t.resultMatrix.a*t.resultMatrix.a+t.resultMatrix.c*t.resultMatrix.c),m=Math.sqrt(e*e+a*a),x=c>1e-5?(c+(m-c+this._data.offsetScaleX)*this.scaleMix)/c:0;t.resultMatrix.a*=x,t.resultMatrix.c*=x,c=Math.sqrt(t.resultMatrix.b*t.resultMatrix.b+t.resultMatrix.d*t.resultMatrix.d),m=Math.sqrt(i*i+r*r),x=c>1e-5?(c+(m-c+this._data.offsetScaleY)*this.scaleMix)/c:0,t.resultMatrix.b*=x,t.resultMatrix.d*=x}if(this.shearMix>0){l=t.resultMatrix.b,u=t.resultMatrix.d;var y=Math.atan2(u,l);(_=Math.atan2(r,i)-Math.atan2(a,e)-(y-Math.atan2(t.resultMatrix.c,t.resultMatrix.a)))>Math.PI?_-=2*Math.PI:_<-Math.PI&&(_+=2*Math.PI),_=y+(_+this._data.offsetShearY*Math.PI/180)*this.shearMix,x=Math.sqrt(l*l+u*u),t.resultMatrix.b=Math.cos(_)*x,t.resultMatrix.d=Math.sin(_)*x}}}}class F extends e.Sprite{constructor(t=null,e=0){super(),this._boneMatrixArray=[],this._lastTime=0,this._currAniIndex=-1,this._pause=!0,this._aniClipIndex=-1,this._clipIndex=-1,this._skinIndex=0,this._skinName="default",this._aniMode=0,this._index=-1,this._total=-1,this._indexControl=!1,this._eventIndex=0,this._drawOrderIndex=0,this._drawOrder=null,this._lastAniClipIndex=-1,this._lastUpdateAniClipIndex=-1,this._playAudio=!0,this._soundChannelArr=[],t&&this.init(t,e)}init(t,i=0){var a,r,s,n,h=0;if(1==i)for(this._graphicsCache=[],h=0,a=t.getAnimationCount();h0)for(this._ikArr=[],h=0,a=t.ikArr.length;h0)for(null==this._pathDic&&(this._pathDic={}),h=0,a=t.pathArr.length;h0)for(this._tfArr=[],h=0,a=t.tfArr.length;h0){var l=this._templet.skinDataArray[this._skinIndex];this._skinName=l.name}this._player.on(e.Event.PLAYED,this,this._onPlay),this._player.on(e.Event.STOPPED,this,this._onStop),this._player.on(e.Event.PAUSED,this,this._onPause)}get url(){return this._aniPath}set url(t){this.load(t)}load(t,i=null,a=0){this._aniPath=t,this._complete=i,this._loadAniMode=a,e.ILaya.loader.load([{url:t,type:e.ILaya.Loader.BUFFER}],e.Handler.create(this,this._onLoaded))}_onLoaded(){var t,a=e.ILaya.Loader.getRes(this._aniPath);null!=a&&(null==i.Templet.TEMPLET_DICTIONARY&&(i.Templet.TEMPLET_DICTIONARY={}),(t=i.Templet.TEMPLET_DICTIONARY[this._aniPath])?t.isParseFail?this._parseFail():t.isParserComplete?this._parseComplete():(t.on(e.Event.COMPLETE,this,this._parseComplete),t.on(e.Event.ERROR,this,this._parseFail)):((t=new i.Templet)._setCreateURL(this._aniPath),i.Templet.TEMPLET_DICTIONARY[this._aniPath]=t,t.on(e.Event.COMPLETE,this,this._parseComplete),t.on(e.Event.ERROR,this,this._parseFail),t.isParserComplete=!1,t.parseData(null,a)))}_parseComplete(){var t=i.Templet.TEMPLET_DICTIONARY[this._aniPath];t&&(this.init(t,this._loadAniMode),this.play(0,!0)),this._complete&&this._complete.runWith(this)}_parseFail(){console.log("[Error]:"+this._aniPath+"解析失败")}_onPlay(){this.event(e.Event.PLAYED)}_onStop(){var t,i=this._templet.eventAniArr[this._aniClipIndex];if(i&&this._eventIndex=this._player.playStart&&t.time<=this._player.playEnd&&this.event(e.Event.LABEL,t);this._drawOrder=null,this.event(e.Event.STOPPED)}_onPause(){this.event(e.Event.PAUSED)}_parseSrcBoneMatrix(){var t=0,i=0;for(i=this._templet.srcBoneMatrixArr.length,t=0;t=this._player.playStart&&n.time<=this._player.playEnd&&this.event(e.Event.LABEL,n)}}_update(t=!0){if(!(this._pause||t&&this._indexControl)){var i=this.timer.currTimer,a=this._player.currentKeyframeIndex,r=i-this._lastTime;if(t?this._player._update(r):a=-1,this._lastTime=i,this._player&&(this._index=this._clipIndex=this._player.currentKeyframeIndex,!(this._index<0||r>0&&this._clipIndex==a&&this._lastUpdateAniClipIndex==this._aniClipIndex))){this._lastUpdateAniClipIndex=this._aniClipIndex,a>this._clipIndex&&0!=this._eventIndex&&(this._emitMissedEvents(this._player.playStart,this._player.playEnd,this._eventIndex),this._eventIndex=0);var s,n,h=this._templet.eventAniArr[this._aniClipIndex];if(h&&this._eventIndex=this._player.playStart&&l.time<=this._player.playEnd?this._player.currentPlayTime>=l.time&&(this.event(e.Event.LABEL,l),this._eventIndex++,this._playAudio&&l.audioValue&&"null"!==l.audioValue&&"undefined"!==l.audioValue&&(s=e.SoundManager.playSound(this._player.templet._path+l.audioValue,1,e.Handler.create(this,this._onAniSoundStoped)),e.SoundManager.playbackRate=this._player.playbackRate,s&&this._soundChannelArr.push(s))):l.time0)for(this._drawOrderIndex=0,i=r[this._drawOrderIndex];a>=i.time&&(this._drawOrder=i.drawOrder,this._drawOrderIndex++,!(this._drawOrderIndex>=r.length));)i=r[this._drawOrderIndex];0==this._aniMode||1==this._aniMode?this.graphics=p.create():this.graphics instanceof p?this.graphics.clear():this.graphics=p.create();var s=this.graphics,n=this._templet.getNodes(this._aniClipIndex),h=0==this._player.state;this._templet.getOriginalData(this._aniClipIndex,this._curOriginalData,null,t,h?a+this._player.cacheFrameRateInterval:a);var l,o,u,_,d=this._aniSectionDic[this._aniClipIndex],c=0,m=0,x=0,y=0,g=0,f=this._templet.srcBoneMatrixArr.length,M=this._curOriginalData;for(m=0,g=d[0];m0){if(this._lastAniClipIndex!=this._aniClipIndex)for(this._lastAniClipIndex=this._aniClipIndex,m=0,g=this._boneSlotArray.length;m-1&&o0&&this._onAniSoundStoped(!0),this.timer.clear(this,this._update))}playbackRate(t){this._player&&(this._player.playbackRate=t)}paused(){if(!this._pause){if(this._pause=!0,this._player&&(this._player.paused=!0),this._soundChannelArr.length>0)for(var t,e=this._soundChannelArr.length,i=0;i0)for(var t,i=this._soundChannelArr.length,a=0;a0&&this._onAniSoundStoped(!0)}get index(){return this._index}set index(t){this.player&&(this._index=t,this._player.currentTime=1e3*this._index/this._player.cacheFrameRate,this._indexControl=!0,this._update(!1))}get total(){return this._templet&&this._player?this._total=Math.floor(this._templet.getAniDuration(this._player.currentAnimationClipIndex)/1e3*this._player.cacheFrameRate):this._total=-1,this._total}get player(){return this._player}get templet(){return this._templet}}F.useSimpleMeshInCanvas=!1,i.Skeleton=F,e.ILaya.regClass(F),e.ClassUtils.regClass("laya.ani.bone.Skeleton",F),e.ClassUtils.regClass("Laya.Skeleton",F);class w{constructor(){this.slotArr=[]}}class k{createTexture(t){return this.texture||(this.texture=new e.Texture(t.bitmap,this.uvs),this.uvs[0]>this.uvs[4]&&this.uvs[1]>this.uvs[5]?(this.texture.width=t.height,this.texture.height=t.width,this.texture.offsetX=-t.offsetX,this.texture.offsetY=-t.offsetY,this.texture.sourceWidth=t.sourceHeight,this.texture.sourceHeight=t.sourceWidth):(this.texture.width=t.width,this.texture.height=t.height,this.texture.offsetX=-t.offsetX,this.texture.offsetY=-t.offsetY,this.texture.sourceWidth=t.sourceWidth,this.texture.sourceHeight=t.sourceHeight)),this.texture}destory(){this.texture&&this.texture.destroy()}}class P{constructor(){this.displayArr=[]}getDisplayByName(t){for(var e=0,i=this.displayArr.length;e0?a.slice(0,r)+"/":""}}this._mainTexture=t,this._rate=i,this.parse(e)}buildArmature(t=0){return new F(this,t)}parse(t){super.parse(t),this.event(e.Event.LOADED,this),this._aniVersion===U.LAYA_ANIMATION_VISION?this._isParseAudio=!0:this._aniVersion!=U.LAYA_ANIMATION_160_VISION&&console.log("[Error] 版本不一致,请使用IDE版本配套的重新导出"+this._aniVersion+"->"+U.LAYA_ANIMATION_VISION),this._mainTexture?this._parsePublicExtData():this._parseTexturePath()}_parseTexturePath(){if(this._isDestroyed)this.destroy();else{var t=0;this._loadList=[];var i,a=new e.Byte(this.getPublicExtData()),r=a.getInt32(),s=a.readUTFString(),n=s.split("\n");for(t=0;t0)for(this.attachmentNames=[],i=0;i0)for(Pt.bones=[],s=0;s0)for(Pt.uvs=[],s=0;s0)for(Pt.weights=[],s=0;s0)for(Pt.triangles=[],s=0;s0)for(Pt.vertices=[],s=0;s0)for(Pt.lengths=[],s=0;s=this.skinDataArray.length)return!1;var a,r,s,n,h=this.skinDataArray[e];if(h){for(a=0,r=h.slotArr.length;a=this._count){if(!this.loop)return this._playIndex--,void this.stop();this._playIndex=0}if(this._parseFrame(this._playIndex),this._labels&&this._labels[this._playIndex]&&this.event(e.Event.LABEL,this._labels[this._playIndex]),-1!=this._endFrame&&this._endFrame==this._playIndex){if(this._endFrame=-1,null!=this._completeHandler){var t=this._completeHandler;this._completeHandler=null,t.run()}this.stop()}}}stop(){this._playing=!1}gotoAndStop(t){this.index=t,this.stop()}_clear(){if(this.stop(),this._idOfSprite.length=0,!this._parentMovieClip){var t,i;for(this.timer.clear(this,this.updates),i=this._movieClipList.length,t=0;tt&&this._reset(),this._parseFrame(t))}_reset(t=!0){t&&1!=this._curIndex&&this.removeChildren(),this._preIndex=this._curIndex=-1,this._Pos=this._start}_parseFrame(t){var i,a,r,s,n,h,l=!1,o=this._idOfSprite,u=this._data;for(this._ended&&this._reset(),u.pos=this._Pos,this._ended=!1,this._playIndex=t,this._curIndex>t&&t0;break;case 7:var m=(a=o[u.getUint16()]).transform||e.Matrix.create();m.setTo(u.getFloat32(),u.getFloat32(),u.getFloat32(),u.getFloat32(),u.getFloat32(),u.getFloat32()),a.transform=m;break;case 8:o[u.getUint16()].setPos(u.getFloat32(),u.getFloat32());break;case 9:o[u.getUint16()].setSize(u.getFloat32(),u.getFloat32());break;case 10:o[u.getUint16()].alpha=u.getFloat32();break;case 11:o[u.getUint16()].setScale(u.getFloat32(),u.getFloat32());break;case 98:h=u.getString(),this.event(h),"stop"==h&&this.stop();break;case 99:this._curIndex=u.getUint16(),l&&this.updateZOrder();break;case 100:this._count=this._curIndex+1,this._ended=!0,this._playing&&(this.event(e.Event.FRAME),this.event(e.Event.END),this.event(e.Event.COMPLETE)),this._reset(!1)}this._playing&&!this._ended&&this.event(e.Event.FRAME),this._Pos=u.pos}_setData(t,e){this._data=t,this._start=e+3}set url(t){this.load(t)}load(t,i=!1,a=null){var r;this._url=t,i&&(this._atlasPath=a||t.split(".swf")[0]+".json"),this.stop(),this._clear(),this._movieClipList=[this],r=[{url:t,type:e.ILaya.Loader.BUFFER}],this._atlasPath&&r.push({url:this._atlasPath,type:e.ILaya.Loader.ATLAS}),e.ILaya.loader.load(r,e.Handler.create(this,this._onLoaded))}_onLoaded(){var t;(t=e.ILaya.Loader.getRes(this._url))?!this._atlasPath||e.ILaya.Loader.getAtlas(this._atlasPath)?(this.basePath=this._atlasPath?e.ILaya.Loader.getAtlas(this._atlasPath).dir:this._url.split(".swf")[0]+"/image/",this._initData(t)):this.event(e.Event.ERROR,"Atlas not find"):this.event(e.Event.ERROR,"file not find")}_initState(){this._reset(),this._ended=!1;var t=this._playing;for(this._playing=!1,this._curIndex=0;!this._ended;)this._parseFrame(++this._curIndex);this._playing=t}_initData(t){this._data=new e.Byte(t);var i,a=this._data.getUint16();for(i=0;i