@eva/plugin-renderer-spine 2.0.1-beta.0 → 2.0.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,4 +23,4 @@ function _extends(){return _extends=Object.assign?Object.assign.bind():function(
23
23
 
24
24
  finalColor.a = outColor.a * vColor.a;
25
25
  finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;
26
- `}};var DarkTintShader=class extends pixi_js.Shader{constructor(maxTextures){const glProgram=pixi_js.compileHighShaderGlProgram({name:'dark-tint-batch',bits:[pixi_js.colorBitGl,darkTintBitGl,pixi_js.generateTextureBatchBitGl(maxTextures),pixi_js.roundPixelsBitGl]});const gpuProgram=pixi_js.compileHighShaderGpuProgram({name:'dark-tint-batch',bits:[pixi_js.colorBit,darkTintBit,pixi_js.generateTextureBatchBit(maxTextures),pixi_js.roundPixelsBit]});super({glProgram,gpuProgram,resources:{batchSamplers:pixi_js.getBatchSamplersUniformGroup(maxTextures)}});}};var defaultShader=null;var _DarkTintBatcher=class extends pixi_js.Batcher{constructor(){super(...arguments);this.geometry=new DarkTintBatchGeometry();this.shader=defaultShader||(defaultShader=new DarkTintShader(this.maxTextures));this.name=_DarkTintBatcher.extension.name;this.vertexSize=7;}packAttributes(element,float32View,uint32View,index,textureId){const textureIdAndRound=textureId<<16|element.roundPixels&65535;const wt=element.transform;const a=wt.a;const b=wt.b;const c=wt.c;const d=wt.d;const tx=wt.tx;const ty=wt.ty;const{positions,uvs}=element;const argb=element.color;const worldAlpha=(argb>>24&255)/255;const darkColor=pixi_js.Color.shared.setValue(element.darkColor).premultiply(worldAlpha,true).toPremultiplied(1,false);const offset=element.attributeOffset;const end=offset+element.attributeSize;for(let i=offset;i<end;i++){const i2=i*2;const x=positions[i2];const y=positions[i2+1];float32View[index++]=a*x+c*y+tx;float32View[index++]=d*y+b*x+ty;float32View[index++]=uvs[i2];float32View[index++]=uvs[i2+1];uint32View[index++]=argb;uint32View[index++]=darkColor;uint32View[index++]=textureIdAndRound;}}packQuadAttributes(element,float32View,uint32View,index,textureId){const texture=element.texture;const wt=element.transform;const a=wt.a;const b=wt.b;const c=wt.c;const d=wt.d;const tx=wt.tx;const ty=wt.ty;const bounds=element.bounds;const w0=bounds.maxX;const w1=bounds.minX;const h0=bounds.maxY;const h1=bounds.minY;const uvs=texture.uvs;const argb=element.color;const darkColor=element.darkColor;const textureIdAndRound=textureId<<16|element.roundPixels&65535;float32View[index+0]=a*w1+c*h1+tx;float32View[index+1]=d*h1+b*w1+ty;float32View[index+2]=uvs.x0;float32View[index+3]=uvs.y0;uint32View[index+4]=argb;uint32View[index+5]=darkColor;uint32View[index+6]=textureIdAndRound;float32View[index+7]=a*w0+c*h1+tx;float32View[index+8]=d*h1+b*w0+ty;float32View[index+9]=uvs.x1;float32View[index+10]=uvs.y1;uint32View[index+11]=argb;uint32View[index+12]=darkColor;uint32View[index+13]=textureIdAndRound;float32View[index+14]=a*w0+c*h0+tx;float32View[index+15]=d*h0+b*w0+ty;float32View[index+16]=uvs.x2;float32View[index+17]=uvs.y2;uint32View[index+18]=argb;uint32View[index+19]=darkColor;uint32View[index+20]=textureIdAndRound;float32View[index+21]=a*w1+c*h0+tx;float32View[index+22]=d*h0+b*w1+ty;float32View[index+23]=uvs.x3;float32View[index+24]=uvs.y3;uint32View[index+25]=argb;uint32View[index+26]=darkColor;uint32View[index+27]=textureIdAndRound;}};var DarkTintBatcher=_DarkTintBatcher;DarkTintBatcher.extension={type:[pixi_js.ExtensionType.Batcher],name:'darkTint'};pixi_js.extensions.add(DarkTintBatcher);var BatchableSpineSlot=class{constructor(){this.indexOffset=0;this.attributeOffset=0;this.batcherName='darkTint';this.topology='triangle-list';this.packAsQuad=false;}get color(){const slotColor=this.data.color;const parentColor=this.renderable.groupColor;const parentAlpha=this.renderable.groupAlpha;let abgr;const mixedA=slotColor.a*parentAlpha*255;if(parentColor!==16777215){const parentB=parentColor>>16&255;const parentG=parentColor>>8&255;const parentR=parentColor&255;const mixedR=slotColor.r*parentR;const mixedG=slotColor.g*parentG;const mixedB=slotColor.b*parentB;abgr=mixedA<<24|mixedB<<16|mixedG<<8|mixedR;}else{abgr=mixedA<<24|slotColor.b*255<<16|slotColor.g*255<<8|slotColor.r*255;}return abgr;}get darkColor(){const darkColor=this.data.darkColor;return darkColor.b*255<<16|darkColor.g*255<<8|darkColor.r*255;}get groupTransform(){return this.renderable.groupTransform;}setData(renderable,data,blendMode,roundPixels){this.renderable=renderable;this.transform=renderable.groupTransform;this.data=data;if(data.clipped){const clippedData=data.clippedData;this.indexSize=clippedData.indicesCount;this.attributeSize=clippedData.vertexCount;this.positions=clippedData.vertices;this.indices=clippedData.indices;this.uvs=clippedData.uvs;}else{this.indexSize=data.indices.length;this.attributeSize=data.vertices.length/2;this.positions=data.vertices;this.indices=data.indices;this.uvs=data.uvs;}this.texture=data.texture;this.roundPixels=roundPixels;this.blendMode=blendMode;this.batcherName=data.darkTint?'darkTint':'default';}};var spineBlendModeMap={0:'normal',1:'add',2:'multiply',3:'screen'};var SpinePipe=class{constructor(renderer){this.gpuSpineData={};this._destroyRenderableBound=this.destroyRenderable.bind(this);this.renderer=renderer;}validateRenderable(spine){spine._validateAndTransformAttachments();if(spine.spineAttachmentsDirty){return true;}else if(spine.spineTexturesDirty){const drawOrder=spine.skeleton.drawOrder;const gpuSpine=this.gpuSpineData[spine.uid];for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();if(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);const batchableSpineSlot=gpuSpine.slotBatches[cacheData.id];const texture=cacheData.texture;if(texture!==batchableSpineSlot.texture){if(!batchableSpineSlot._batcher.checkAndUpdateTexture(batchableSpineSlot,texture)){return true;}}}}}return false;}addRenderable(spine,instructionSet){var _a,_b;const gpuSpine=this._getSpineData(spine);const batcher=this.renderer.renderPipes.batch;const drawOrder=spine.skeleton.drawOrder;const roundPixels=this.renderer._roundPixels|spine._roundPixels;spine._validateAndTransformAttachments();for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();const blendMode=spineBlendModeMap[slot.data.blendMode];if(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);const batchableSpineSlot=(_a=gpuSpine.slotBatches)[_b=cacheData.id]||(_a[_b]=new BatchableSpineSlot());batchableSpineSlot.setData(spine,cacheData,blendMode,roundPixels);if(!cacheData.skipRender){batcher.addToBatch(batchableSpineSlot,instructionSet);}}const containerAttachment=spine._slotsObject[slot.data.name];if(containerAttachment){const container=containerAttachment.container;container.includeInBuild=true;pixi_js.collectAllRenderables(container,instructionSet,this.renderer);container.includeInBuild=false;}}}updateRenderable(spine){var _a;const gpuSpine=this.gpuSpineData[spine.uid];spine._validateAndTransformAttachments();const drawOrder=spine.skeleton.drawOrder;for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();if(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);if(!cacheData.skipRender){const batchableSpineSlot=gpuSpine.slotBatches[spine._getCachedData(slot,attachment).id];(_a=batchableSpineSlot._batcher)==null?void 0:_a.updateElement(batchableSpineSlot);}}}}destroyRenderable(spine){this.gpuSpineData[spine.uid]=null;spine.off('destroyed',this._destroyRenderableBound);}destroy(){this.gpuSpineData=null;this.renderer=null;}_getSpineData(spine){return this.gpuSpineData[spine.uid]||this._initMeshData(spine);}_initMeshData(spine){this.gpuSpineData[spine.uid]={slotBatches:{}};spine.on('destroyed',this._destroyRenderableBound);return this.gpuSpineData[spine.uid];}};SpinePipe.extension={type:[pixi_js.ExtensionType.WebGLPipes,pixi_js.ExtensionType.WebGPUPipes,pixi_js.ExtensionType.CanvasPipes],name:'spine'};pixi_js.extensions.add(SpinePipe);var vectorAux=new Vector2();Skeleton.yDown=true;var clipper=new SkeletonClipping();var maskPool=new Pool(()=>new pixi_js.Graphics());var Spine$2=class extends pixi_js.ViewContainer{constructor(options){var _a;if(options instanceof SkeletonData){options={skeletonData:options};}super();this.batched=true;this.buildId=0;this.renderPipeId='spine';this._didSpineUpdate=false;this.beforeUpdateWorldTransforms=()=>{};this.afterUpdateWorldTransforms=()=>{};this.darkTint=false;this._debug=void 0;this._slotsObject=Object.create(null);this.clippingSlotToPixiMasks=Object.create(null);this.spineAttachmentsDirty=true;this.spineTexturesDirty=true;this._lastAttachments=[];this._stateChanged=true;this.attachmentCacheData=[];this._autoUpdate=true;this.hasNeverUpdated=true;const skeletonData=options instanceof SkeletonData?options:options.skeletonData;this.skeleton=new Skeleton(skeletonData);this.state=new AnimationState(new AnimationStateData(skeletonData));this.autoUpdate=(_a=options==null?void 0:options.autoUpdate)!=null?_a:true;this.darkTint=(options==null?void 0:options.darkTint)===void 0?this.skeleton.slots.some(slot=>!!slot.data.darkColor):options==null?void 0:options.darkTint;const slots=this.skeleton.slots;for(let i=0;i<slots.length;i++){this.attachmentCacheData[i]=Object.create(null);}}getSlotFromRef(slotRef){let slot;if(typeof slotRef==='number')slot=this.skeleton.slots[slotRef];else if(typeof slotRef==='string')slot=this.skeleton.findSlot(slotRef);else slot=slotRef;if(!slot)throw new Error(`No slot found with the given slot reference: ${slotRef}`);return slot;}get debug(){return this._debug;}set debug(value){if(this._debug){this._debug.unregisterSpine(this);}if(value){value.registerSpine(this);}this._debug=value;}get autoUpdate(){return this._autoUpdate;}set autoUpdate(value){if(value){pixi_js.Ticker.shared.add(this.internalUpdate,this);}else{pixi_js.Ticker.shared.remove(this.internalUpdate,this);}this._autoUpdate=value;}update(dt){this.internalUpdate(0,dt);}internalUpdate(_deltaFrame,deltaSeconds){this._updateAndApplyState(deltaSeconds!=null?deltaSeconds:pixi_js.Ticker.shared.deltaMS/1e3);}get bounds(){if(this._boundsDirty){this.updateBounds();}return this._bounds;}setBonePosition(bone,position){const boneAux=bone;if(typeof bone==='string'){bone=this.skeleton.findBone(bone);}if(!bone)throw Error(`Cant set bone position, bone ${String(boneAux)} not found`);vectorAux.set(position.x,position.y);if(bone.parent){const aux=bone.parent.worldToLocal(vectorAux);bone.x=aux.x;bone.y=-aux.y;}else{bone.x=vectorAux.x;bone.y=vectorAux.y;}}getBonePosition(bone,outPos){const boneAux=bone;if(typeof bone==='string'){bone=this.skeleton.findBone(bone);}if(!bone){console.error(`Cant set bone position! Bone ${String(boneAux)} not found`);return outPos;}if(!outPos){outPos={x:0,y:0};}outPos.x=bone.worldX;outPos.y=bone.worldY;return outPos;}_updateAndApplyState(time){this.hasNeverUpdated=false;this.state.update(time);this.skeleton.update(time);const{skeleton}=this;this.state.apply(skeleton);this.beforeUpdateWorldTransforms(this);skeleton.updateWorldTransform(2);this.afterUpdateWorldTransforms(this);this.updateSlotObjects();this._stateChanged=true;this._boundsDirty=true;this.onViewUpdate();}_validateAndTransformAttachments(){if(!this._stateChanged)return;this._stateChanged=false;this.validateAttachments();this.transformAttachments();}validateAttachments(){const currentDrawOrder=this.skeleton.drawOrder;const lastAttachments=this._lastAttachments;let index=0;let spineAttachmentsDirty=false;for(let i=0;i<currentDrawOrder.length;i++){const slot=currentDrawOrder[i];const attachment=slot.getAttachment();if(attachment){if(attachment!==lastAttachments[index]){spineAttachmentsDirty=true;lastAttachments[index]=attachment;}index++;}}if(index!==lastAttachments.length){spineAttachmentsDirty=true;lastAttachments.length=index;}this.spineAttachmentsDirty=spineAttachmentsDirty;}updateAndSetPixiMask(slot,last){var _a,_b;const attachment=slot.attachment;if(attachment&&attachment instanceof ClippingAttachment){const clip=(_a=this.clippingSlotToPixiMasks)[_b=slot.data.name]||(_a[_b]={slot,vertices:new Array()});clip.maskComputed=false;this.currentClippingSlot=this.clippingSlotToPixiMasks[slot.data.name];return;}let currentClippingSlot=this.currentClippingSlot;let slotObject=this._slotsObject[slot.data.name];if(currentClippingSlot&&slotObject){let slotClipping=currentClippingSlot.slot;let clippingAttachment=slotClipping.attachment;let mask=currentClippingSlot.mask;if(!mask){mask=maskPool.obtain();currentClippingSlot.mask=mask;this.addChild(mask);}if(!currentClippingSlot.maskComputed){currentClippingSlot.maskComputed=true;const worldVerticesLength=clippingAttachment.worldVerticesLength;const vertices=currentClippingSlot.vertices;clippingAttachment.computeWorldVertices(slotClipping,0,worldVerticesLength,vertices,0,2);mask.clear().poly(vertices).stroke({width:0}).fill({alpha:0.25});}slotObject.container.mask=mask;}else if(slotObject==null?void 0:slotObject.container.mask){slotObject.container.mask=null;}if(currentClippingSlot&&currentClippingSlot.slot.attachment.endSlot==slot.data){this.currentClippingSlot=void 0;}if(last){for(const key in this.clippingSlotToPixiMasks){const clippingSlotToPixiMask=this.clippingSlotToPixiMasks[key];if((!(clippingSlotToPixiMask.slot.attachment instanceof ClippingAttachment)||!clippingSlotToPixiMask.maskComputed)&&clippingSlotToPixiMask.mask){this.removeChild(clippingSlotToPixiMask.mask);maskPool.free(clippingSlotToPixiMask.mask);clippingSlotToPixiMask.mask=void 0;}}}}transformAttachments(){var _a;const currentDrawOrder=this.skeleton.drawOrder;for(let i=0;i<currentDrawOrder.length;i++){const slot=currentDrawOrder[i];this.updateAndSetPixiMask(slot,i===currentDrawOrder.length-1);const attachment=slot.getAttachment();if(attachment){if(attachment instanceof MeshAttachment||attachment instanceof RegionAttachment){const cacheData=this._getCachedData(slot,attachment);if(attachment instanceof RegionAttachment){attachment.computeWorldVertices(slot,cacheData.vertices,0,2);}else{attachment.computeWorldVertices(slot,0,attachment.worldVerticesLength,cacheData.vertices,0,2);}if(cacheData.uvs.length<attachment.uvs.length){cacheData.uvs=new Float32Array(attachment.uvs.length);}pixi_js.fastCopy(attachment.uvs.buffer,cacheData.uvs.buffer);const skeleton=slot.bone.skeleton;const skeletonColor=skeleton.color;const slotColor=slot.color;const attachmentColor=attachment.color;cacheData.color.set(skeletonColor.r*slotColor.r*attachmentColor.r,skeletonColor.g*slotColor.g*attachmentColor.g,skeletonColor.b*slotColor.b*attachmentColor.b,skeletonColor.a*slotColor.a*attachmentColor.a);if(slot.darkColor){cacheData.darkColor.setFromColor(slot.darkColor);}cacheData.skipRender=cacheData.clipped=false;const texture=((_a=attachment.region)==null?void 0:_a.texture.texture)||pixi_js.Texture.EMPTY;if(cacheData.texture!==texture){cacheData.texture=texture;this.spineTexturesDirty=true;}if(clipper.isClipping()){this.updateClippingData(cacheData);}}else if(attachment instanceof ClippingAttachment){clipper.clipStart(slot,attachment);continue;}}clipper.clipEndWithSlot(slot);}clipper.clipEnd();}updateClippingData(cacheData){cacheData.clipped=true;clipper.clipTrianglesUnpacked(cacheData.vertices,cacheData.indices,cacheData.indices.length,cacheData.uvs);const{clippedVertices,clippedUVs,clippedTriangles}=clipper;const verticesCount=clippedVertices.length/2;const indicesCount=clippedTriangles.length;if(!cacheData.clippedData){cacheData.clippedData={vertices:new Float32Array(verticesCount*2),uvs:new Float32Array(verticesCount*2),vertexCount:verticesCount,indices:new Uint16Array(indicesCount),indicesCount};this.spineAttachmentsDirty=true;}const clippedData=cacheData.clippedData;const sizeChange=clippedData.vertexCount!==verticesCount||indicesCount!==clippedData.indicesCount;cacheData.skipRender=verticesCount===0;if(sizeChange){this.spineAttachmentsDirty=true;if(clippedData.vertexCount<verticesCount){clippedData.vertices=new Float32Array(verticesCount*2);clippedData.uvs=new Float32Array(verticesCount*2);}if(clippedData.indices.length<indicesCount){clippedData.indices=new Uint16Array(indicesCount);}}const{vertices,uvs,indices}=clippedData;for(let i=0;i<verticesCount;i++){vertices[i*2]=clippedVertices[i*2];vertices[i*2+1]=clippedVertices[i*2+1];uvs[i*2]=clippedUVs[i*2];uvs[i*2+1]=clippedUVs[i*2+1];}clippedData.vertexCount=verticesCount;for(let i=0;i<indicesCount;i++){if(indices[i]!==clippedTriangles[i]){this.spineAttachmentsDirty=true;indices[i]=clippedTriangles[i];}}clippedData.indicesCount=indicesCount;}updateSlotObjects(){for(const i in this._slotsObject){const slotAttachment=this._slotsObject[i];if(!slotAttachment)continue;this.updateSlotObject(slotAttachment);}}updateSlotObject(slotAttachment){const{slot,container}=slotAttachment;container.visible=this.skeleton.drawOrder.includes(slot);if(container.visible){const bone=slot.bone;container.position.set(bone.worldX,bone.worldY);container.scale.x=bone.getWorldScaleX();container.scale.y=bone.getWorldScaleY();container.rotation=bone.getWorldRotationX()*pixi_js.DEG_TO_RAD;container.alpha=this.skeleton.color.a*slot.color.a;}}_getCachedData(slot,attachment){return this.attachmentCacheData[slot.data.index][attachment.name]||this.initCachedData(slot,attachment);}initCachedData(slot,attachment){var _a,_b;let vertices;if(attachment instanceof RegionAttachment){vertices=new Float32Array(8);this.attachmentCacheData[slot.data.index][attachment.name]={id:`${slot.data.index}-${attachment.name}`,vertices,clipped:false,indices:[0,1,2,0,2,3],uvs:new Float32Array(attachment.uvs.length),color:new Color(1,1,1,1),darkColor:new Color(0,0,0,0),darkTint:this.darkTint,skipRender:false,texture:(_a=attachment.region)==null?void 0:_a.texture.texture};}else{vertices=new Float32Array(attachment.worldVerticesLength);this.attachmentCacheData[slot.data.index][attachment.name]={id:`${slot.data.index}-${attachment.name}`,vertices,clipped:false,indices:attachment.triangles,uvs:new Float32Array(attachment.uvs.length),color:new Color(1,1,1,1),darkColor:new Color(0,0,0,0),darkTint:this.darkTint,skipRender:false,texture:(_b=attachment.region)==null?void 0:_b.texture.texture};}return this.attachmentCacheData[slot.data.index][attachment.name];}onViewUpdate(){var _a;this._didViewChangeTick++;this._boundsDirty=true;if(this.didViewUpdate)return;this.didViewUpdate=true;const renderGroup=this.renderGroup||this.parentRenderGroup;if(renderGroup){renderGroup.onChildViewUpdate(this);}(_a=this.debug)==null?void 0:_a.renderDebug(this);}addSlotObject(slot,container){var _a;slot=this.getSlotFromRef(slot);for(const i in this._slotsObject){if(((_a=this._slotsObject[i])==null?void 0:_a.container)===container){this.removeSlotObject(this._slotsObject[i].slot);}}this.removeSlotObject(slot);container.includeInBuild=false;this.addChild(container);const slotObject={container,slot};this._slotsObject[slot.data.name]=slotObject;this.updateSlotObject(slotObject);}removeSlotObject(slotOrContainer){var _a,_b;let containerToRemove;if(slotOrContainer instanceof pixi_js.Container){for(const i in this._slotsObject){if(((_a=this._slotsObject[i])==null?void 0:_a.container)===slotOrContainer){this._slotsObject[i]=null;containerToRemove=slotOrContainer;break;}}}else{const slot=this.getSlotFromRef(slotOrContainer);containerToRemove=(_b=this._slotsObject[slot.data.name])==null?void 0:_b.container;this._slotsObject[slot.data.name]=null;}if(containerToRemove){this.removeChild(containerToRemove);containerToRemove.includeInBuild=true;}}getSlotObject(slot){var _a;slot=this.getSlotFromRef(slot);return(_a=this._slotsObject[slot.data.name])==null?void 0:_a.container;}updateBounds(){this._boundsDirty=false;this.skeletonBounds||(this.skeletonBounds=new SkeletonBounds());const skeletonBounds=this.skeletonBounds;skeletonBounds.update(this.skeleton,true);if(skeletonBounds.minX===Infinity){if(this.hasNeverUpdated){this._updateAndApplyState(0);this._boundsDirty=false;}this._validateAndTransformAttachments();const drawOrder=this.skeleton.drawOrder;const bounds=this._bounds;bounds.clear();for(let i=0;i<drawOrder.length;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();if(attachment&&(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment)){const cacheData=this._getCachedData(slot,attachment);bounds.addVertexData(cacheData.vertices,0,cacheData.vertices.length);}}}else{this._bounds.minX=skeletonBounds.minX;this._bounds.minY=skeletonBounds.minY;this._bounds.maxX=skeletonBounds.maxX;this._bounds.maxY=skeletonBounds.maxY;}}addBounds(bounds){bounds.addBounds(this.bounds);}destroy(options=false){super.destroy(options);pixi_js.Ticker.shared.remove(this.internalUpdate,this);this.state.clearListeners();this.debug=void 0;this.skeleton=null;this.state=null;this._slotsObject=null;this._lastAttachments.length=0;this.attachmentCacheData=null;}skeletonToPixiWorldCoordinates(point){this.worldTransform.apply(point,point);}pixiWorldCoordinatesToSkeleton(point){this.worldTransform.applyInverse(point,point);}pixiWorldCoordinatesToBone(point,bone){this.pixiWorldCoordinatesToSkeleton(point);if(bone.parent){bone.parent.worldToLocal(point);}else{bone.worldToLocal(point);}}static from({skeleton,atlas,scale=1,darkTint,autoUpdate=true}){const cacheKey=`${skeleton}-${atlas}-${scale}`;if(pixi_js.Cache.has(cacheKey)){return new Spine$2(pixi_js.Cache.get(cacheKey));}const skeletonAsset=pixi_js.Assets.get(skeleton);const atlasAsset=pixi_js.Assets.get(atlas);const attachmentLoader=new AtlasAttachmentLoader(atlasAsset);const parser=skeletonAsset instanceof Uint8Array?new SkeletonBinary(attachmentLoader):new SkeletonJson(attachmentLoader);parser.scale=scale;const skeletonData=parser.readSkeletonData(skeletonAsset);console.log('>>>skeletonData',skeletonData);pixi_js.Cache.set(cacheKey,skeletonData);return new Spine$2({skeletonData,darkTint,autoUpdate});}};var SpineDebugRenderer=class{constructor(){this.registeredSpines=new Map();this.drawMeshHull=true;this.drawMeshTriangles=true;this.drawBones=true;this.drawPaths=true;this.drawBoundingBoxes=true;this.drawClipping=true;this.drawRegionAttachments=true;this.drawEvents=true;this.lineWidth=1;this.regionAttachmentsColor=30975;this.meshHullColor=30975;this.meshTrianglesColor=16763904;this.clippingPolygonColor=16711935;this.boundingBoxesRectColor=65280;this.boundingBoxesPolygonColor=65280;this.boundingBoxesCircleColor=65280;this.pathsCurveColor=16711680;this.pathsLineColor=16711935;this.skeletonXYColor=16711680;this.bonesColor=61132;this.eventFontSize=24;this.eventFontColor=0;}registerSpine(spine){if(this.registeredSpines.has(spine)){console.warn('SpineDebugRenderer.registerSpine() - this spine is already registered!',spine);return;}const debugDisplayObjects={parentDebugContainer:new pixi_js.Container(),bones:new pixi_js.Container(),skeletonXY:new pixi_js.Graphics(),regionAttachmentsShape:new pixi_js.Graphics(),meshTrianglesLine:new pixi_js.Graphics(),meshHullLine:new pixi_js.Graphics(),clippingPolygon:new pixi_js.Graphics(),boundingBoxesRect:new pixi_js.Graphics(),boundingBoxesCircle:new pixi_js.Graphics(),boundingBoxesPolygon:new pixi_js.Graphics(),pathsCurve:new pixi_js.Graphics(),pathsLine:new pixi_js.Graphics(),eventText:new pixi_js.Container(),eventCallback:{event:(_,event)=>{if(this.drawEvents){const scale=Math.abs(spine.scale.x||spine.scale.y||1);const text=new pixi_js.Text({text:event.data.name,style:{fontSize:this.eventFontSize/scale,fill:this.eventFontColor,fontFamily:'monospace'}});text.scale.x=Math.sign(spine.scale.x);text.anchor.set(0.5);debugDisplayObjects.eventText.addChild(text);setTimeout(()=>{if(!text.destroyed){text.destroy();}},250);}}}};debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.bones);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.skeletonXY);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.regionAttachmentsShape);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.meshTrianglesLine);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.meshHullLine);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.clippingPolygon);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesRect);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesCircle);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesPolygon);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.pathsCurve);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.pathsLine);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.eventText);debugDisplayObjects.parentDebugContainer.zIndex=9999999;debugDisplayObjects.parentDebugContainer.accessibleChildren=false;debugDisplayObjects.parentDebugContainer.eventMode='none';debugDisplayObjects.parentDebugContainer.interactiveChildren=false;spine.addChild(debugDisplayObjects.parentDebugContainer);spine.state.addListener(debugDisplayObjects.eventCallback);this.registeredSpines.set(spine,debugDisplayObjects);}renderDebug(spine){if(!this.registeredSpines.has(spine)){this.registerSpine(spine);}const debugDisplayObjects=this.registeredSpines.get(spine);if(!debugDisplayObjects){return;}spine.addChild(debugDisplayObjects.parentDebugContainer);debugDisplayObjects.skeletonXY.clear();debugDisplayObjects.regionAttachmentsShape.clear();debugDisplayObjects.meshTrianglesLine.clear();debugDisplayObjects.meshHullLine.clear();debugDisplayObjects.clippingPolygon.clear();debugDisplayObjects.boundingBoxesRect.clear();debugDisplayObjects.boundingBoxesCircle.clear();debugDisplayObjects.boundingBoxesPolygon.clear();debugDisplayObjects.pathsCurve.clear();debugDisplayObjects.pathsLine.clear();for(let len=debugDisplayObjects.bones.children.length;len>0;len--){debugDisplayObjects.bones.children[len-1].destroy({children:true,texture:true,textureSource:true});}const scale=Math.abs(spine.scale.x||spine.scale.y||1);const lineWidth=this.lineWidth/scale;if(this.drawBones){this.drawBonesFunc(spine,debugDisplayObjects,lineWidth,scale);}if(this.drawPaths){this.drawPathsFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawBoundingBoxes){this.drawBoundingBoxesFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawClipping){this.drawClippingFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawMeshHull||this.drawMeshTriangles){this.drawMeshHullAndMeshTriangles(spine,debugDisplayObjects,lineWidth);}if(this.drawRegionAttachments){this.drawRegionAttachmentsFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawEvents){for(const child of debugDisplayObjects.eventText.children){child.alpha-=0.05;child.y-=2;}}}drawBonesFunc(spine,debugDisplayObjects,lineWidth,scale){const skeleton=spine.skeleton;const skeletonX=skeleton.x;const skeletonY=skeleton.y;const bones=skeleton.bones;debugDisplayObjects.skeletonXY.strokeStyle={width:lineWidth,color:this.skeletonXYColor};for(let i=0,len=bones.length;i<len;i++){const bone=bones[i];const boneLen=bone.data.length;const starX=skeletonX+bone.worldX;const starY=skeletonY+bone.worldY;const endX=skeletonX+boneLen*bone.a+bone.worldX;const endY=skeletonY+boneLen*bone.b+bone.worldY;if(bone.data.name==='root'||bone.data.parent===null){continue;}const w=Math.abs(starX-endX);const h=Math.abs(starY-endY);const a2=Math.pow(w,2);const b=h;const b2=Math.pow(h,2);const c=Math.sqrt(a2+b2);const c2=Math.pow(c,2);const rad=Math.PI/180;const B=Math.acos((c2+b2-a2)/(2*b*c))||0;if(c===0){continue;}const gp=new pixi_js.Graphics();debugDisplayObjects.bones.addChild(gp);const refRation=c/50/scale;gp.context.poly([0,0,0-refRation,c-refRation*3,0,c-refRation,0+refRation,c-refRation*3]).fill(this.bonesColor);gp.x=starX;gp.y=starY;gp.pivot.y=c;let rotation=0;if(starX<endX&&starY<endY){rotation=-B+180*rad;}else if(starX>endX&&starY<endY){rotation=180*rad+B;}else if(starX>endX&&starY>endY){rotation=-B;}else if(starX<endX&&starY>endY){rotation=B;}else if(starY===endY&&starX<endX){rotation=90*rad;}else if(starY===endY&&starX>endX){rotation=-90*rad;}else if(starX===endX&&starY<endY){rotation=180*rad;}else if(starX===endX&&starY>endY){rotation=0;}gp.rotation=rotation;gp.circle(0,c,refRation*1.2).fill({color:0,alpha:0.6}).stroke({width:lineWidth+refRation/2.4,color:this.bonesColor});}const startDotSize=lineWidth*3;debugDisplayObjects.skeletonXY.context.moveTo(skeletonX-startDotSize,skeletonY-startDotSize).lineTo(skeletonX+startDotSize,skeletonY+startDotSize).moveTo(skeletonX+startDotSize,skeletonY-startDotSize).lineTo(skeletonX-startDotSize,skeletonY+startDotSize).stroke();}drawRegionAttachmentsFunc(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof RegionAttachment)){continue;}const regionAttachment=attachment;const vertices=new Float32Array(8);regionAttachment.computeWorldVertices(slot,vertices,0,2);debugDisplayObjects.regionAttachmentsShape.poly(Array.from(vertices.slice(0,8)));}debugDisplayObjects.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:lineWidth});}drawMeshHullAndMeshTriangles(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];if(!slot.bone.active){continue;}const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof MeshAttachment)){continue;}const meshAttachment=attachment;const vertices=new Float32Array(meshAttachment.worldVerticesLength);const triangles=meshAttachment.triangles;let hullLength=meshAttachment.hullLength;meshAttachment.computeWorldVertices(slot,0,meshAttachment.worldVerticesLength,vertices,0,2);if(this.drawMeshTriangles){for(let i2=0,len2=triangles.length;i2<len2;i2+=3){const v1=triangles[i2]*2;const v2=triangles[i2+1]*2;const v3=triangles[i2+2]*2;debugDisplayObjects.meshTrianglesLine.context.moveTo(vertices[v1],vertices[v1+1]).lineTo(vertices[v2],vertices[v2+1]).lineTo(vertices[v3],vertices[v3+1]);}}if(this.drawMeshHull&&hullLength>0){hullLength=(hullLength>>1)*2;let lastX=vertices[hullLength-2];let lastY=vertices[hullLength-1];for(let i2=0,len2=hullLength;i2<len2;i2+=2){const x=vertices[i2];const y=vertices[i2+1];debugDisplayObjects.meshHullLine.context.moveTo(x,y).lineTo(lastX,lastY);lastX=x;lastY=y;}}}debugDisplayObjects.meshHullLine.stroke({width:lineWidth,color:this.meshHullColor});debugDisplayObjects.meshTrianglesLine.stroke({width:lineWidth,color:this.meshTrianglesColor});}drawClippingFunc(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];if(!slot.bone.active){continue;}const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof ClippingAttachment)){continue;}const clippingAttachment=attachment;const nn=clippingAttachment.worldVerticesLength;const world=new Float32Array(nn);clippingAttachment.computeWorldVertices(slot,0,nn,world,0,2);debugDisplayObjects.clippingPolygon.poly(Array.from(world));}debugDisplayObjects.clippingPolygon.stroke({width:lineWidth,color:this.clippingPolygonColor,alpha:1});}drawBoundingBoxesFunc(spine,debugDisplayObjects,lineWidth){const bounds=new SkeletonBounds();bounds.update(spine.skeleton,true);if(bounds.minX!==Infinity){debugDisplayObjects.boundingBoxesRect.rect(bounds.minX,bounds.minY,bounds.getWidth(),bounds.getHeight()).stroke({width:lineWidth,color:this.boundingBoxesRectColor});}const polygons=bounds.polygons;const drawPolygon=(polygonVertices,_offset,count)=>{if(count<3){throw new Error('Polygon must contain at least 3 vertices');}const paths=[];const dotSize=lineWidth*2;for(let i=0,len=polygonVertices.length;i<len;i+=2){const x1=polygonVertices[i];const y1=polygonVertices[i+1];debugDisplayObjects.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor);debugDisplayObjects.boundingBoxesCircle.drawCircle(x1,y1,dotSize);debugDisplayObjects.boundingBoxesCircle.fill(0);debugDisplayObjects.boundingBoxesCircle.circle(x1,y1,dotSize).fill({color:this.boundingBoxesCircleColor});paths.push(x1,y1);}debugDisplayObjects.boundingBoxesPolygon.poly(paths).fill({color:this.boundingBoxesPolygonColor,alpha:0.1}).stroke({width:lineWidth,color:this.boundingBoxesPolygonColor});};for(let i=0,len=polygons.length;i<len;i++){const polygon=polygons[i];drawPolygon(polygon,0,polygon.length);}}drawPathsFunc(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];if(!slot.bone.active){continue;}const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof PathAttachment)){continue;}const pathAttachment=attachment;let nn=pathAttachment.worldVerticesLength;const world=new Float32Array(nn);pathAttachment.computeWorldVertices(slot,0,nn,world,0,2);let x1=world[2];let y1=world[3];let x2=0;let y2=0;if(pathAttachment.closed){const cx1=world[0];const cy1=world[1];const cx2=world[nn-2];const cy2=world[nn-1];x2=world[nn-4];y2=world[nn-3];debugDisplayObjects.pathsCurve.moveTo(x1,y1);debugDisplayObjects.pathsCurve.bezierCurveTo(cx1,cy1,cx2,cy2,x2,y2);debugDisplayObjects.pathsLine.moveTo(x1,y1);debugDisplayObjects.pathsLine.lineTo(cx1,cy1);debugDisplayObjects.pathsLine.moveTo(x2,y2);debugDisplayObjects.pathsLine.lineTo(cx2,cy2);}nn-=4;for(let ii=4;ii<nn;ii+=6){const cx1=world[ii];const cy1=world[ii+1];const cx2=world[ii+2];const cy2=world[ii+3];x2=world[ii+4];y2=world[ii+5];debugDisplayObjects.pathsCurve.moveTo(x1,y1);debugDisplayObjects.pathsCurve.bezierCurveTo(cx1,cy1,cx2,cy2,x2,y2);debugDisplayObjects.pathsLine.moveTo(x1,y1);debugDisplayObjects.pathsLine.lineTo(cx1,cy1);debugDisplayObjects.pathsLine.moveTo(x2,y2);debugDisplayObjects.pathsLine.lineTo(cx2,cy2);x1=x2;y1=y2;}}debugDisplayObjects.pathsCurve.stroke({width:lineWidth,color:this.pathsCurveColor});debugDisplayObjects.pathsLine.stroke({width:lineWidth,color:this.pathsLineColor});}unregisterSpine(spine){if(!this.registeredSpines.has(spine)){console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",spine);}const debugDisplayObjects=this.registeredSpines.get(spine);if(!debugDisplayObjects){return;}spine.state.removeListener(debugDisplayObjects.eventCallback);debugDisplayObjects.parentDebugContainer.destroy({textureSource:true,children:true,texture:true});this.registeredSpines.delete(spine);}};var pixiSpine={AlphaTimeline,Animation,AnimationState,AnimationStateAdapter,AnimationStateData,AssetManagerBase,AtlasAttachmentLoader,Attachment,AttachmentTimeline,BinaryInput,BlendMode,Bone,BoneData,BoundingBoxAttachment,CURRENT,ClippingAttachment,Color,ConstraintData,CurveTimeline,CurveTimeline1,CurveTimeline2,DebugUtils,DeformTimeline,Downloader,DrawOrderTimeline,Event,EventData,EventQueue,EventTimeline,EventType,FIRST,FakeTexture,HOLD_FIRST,HOLD_MIX,HOLD_SUBSEQUENT,IkConstraint,IkConstraintData,IkConstraintTimeline,Inherit,InheritTimeline,IntSet,Interpolation,MathUtils,MeshAttachment,MixBlend,MixDirection,PathAttachment,PathConstraint,PathConstraintData,PathConstraintMixTimeline,PathConstraintPositionTimeline,PathConstraintSpacingTimeline,Physics,PhysicsConstraintDampingTimeline,PhysicsConstraintGravityTimeline,PhysicsConstraintInertiaTimeline,PhysicsConstraintMassTimeline,PhysicsConstraintMixTimeline,PhysicsConstraintResetTimeline,PhysicsConstraintStrengthTimeline,PhysicsConstraintTimeline,PhysicsConstraintWindTimeline,PointAttachment,Pool,PositionMode,Pow,PowOut,RGB2Timeline,RGBA2Timeline,RGBATimeline,RGBTimeline,RegionAttachment,RotateMode,RotateTimeline,SETUP,SUBSEQUENT,ScaleTimeline,ScaleXTimeline,ScaleYTimeline,SequenceTimeline,ShearTimeline,ShearXTimeline,ShearYTimeline,Skeleton,SkeletonBinary,SkeletonBounds,SkeletonClipping,SkeletonData,SkeletonJson,Skin,SkinEntry,Slot,SlotData,SpacingMode,Spine:Spine$2,SpineDebugRenderer,SpinePipe,SpineTexture,StringSet,Texture,TextureAtlas,TextureAtlasPage,TextureAtlasRegion,TextureFilter,TextureRegion,TextureWrap,TimeKeeper,Timeline,TrackEntry,TransformConstraint,TransformConstraintData,TransformConstraintTimeline,TranslateTimeline,TranslateXTimeline,TranslateYTimeline,Triangulator,Utils,Vector2,VertexAttachment,WindowedMean};function getIDEPropsPropertyObj(target,propertyKey){if(!target.constructor.IDEProps){target.constructor.IDEProps={};}if(!target.constructor.IDEProps[propertyKey]){target.constructor.IDEProps[propertyKey]={};}var propertyObj=target.constructor.IDEProps[propertyKey];return propertyObj;}function type(type){return function(target,propertyKey){var prop=getIDEPropsPropertyObj(target,propertyKey);prop.key=propertyKey;prop.type=type;};}function __decorate(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r;}function __awaiter(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}}function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value);}).then(fulfilled,rejected);}step((generator=generator.apply(thisArg,_arguments||[])).next());});}class Spine$1 extends eva_js.Component{constructor(){super(...arguments);this.resource='';this.scale=1;this.animationName='';this.autoPlay=true;this.waitExecuteInfos=[];}set armature(val){this._armature=val;if(!val)return;if(this.autoPlay){this.play(this.animationName);}for(const info of this.waitExecuteInfos){if(info.playType){const{name,loop,track}=info;this.play(name,loop,track);}else{this.stop(info.track);}}this.waitExecuteInfos=[];}get armature(){return this._armature;}init(obj){if(!obj)return;_extends(this,obj);}onDestroy(){this.destroied=true;}play(name,loop,track){try{if(name)this.animationName=name;if(!this.armature){this.waitExecuteInfos.push({playType:true,name,loop:loop!==null&&loop!==void 0?loop:this.autoPlay,track});}else{if(track===undefined){track=0;}this.armature.state.setAnimation(track,this.animationName,loop);}}catch(e){console.log(e);}}stop(track){if(!this.armature){this.waitExecuteInfos.push({playType:false,track});return;}if(track===undefined){track=0;}this.armature.state.setEmptyAnimation(track,0);}addAnimation(name,delay,loop,track){try{if(!this.armature){}else{if(track===undefined){track=0;}this.armature.state.addAnimation(track,name,loop,delay);}}catch(e){console.log(e);}}setMix(from,to,duration){if(!this.armature);else{this.armature.state.data.setMix(from,to,duration);}}getAnim(track=0){try{if(!this.armature){}else{return this.armature.state.tracks[track].animation.name;}}catch(e){console.log(e);}}setDefaultMix(duration){if(!this.armature);else{this.armature.state.data.defaultMix=duration;}}setAttachment(slotName,attachmentName){if(!this.armature){return;}this.armature.skeleton.setAttachment(slotName,attachmentName);}getBone(boneName){if(!this.armature){return;}return this.armature.skeleton.findBone(boneName);}}Spine$1.componentName='Spine';__decorate([type('string')],Spine$1.prototype,"resource",void 0);__decorate([type('number')],Spine$1.prototype,"scale",void 0);__decorate([type('string')],Spine$1.prototype,"animationName",void 0);__decorate([type('boolean')],Spine$1.prototype,"autoPlay",void 0);let texCache={};function cacheImage(data){const oldImg=data.image;return{tex:oldImg instanceof pixi_js.Texture?oldImg:pixi_js.Texture.from(oldImg),count:0};}function retainTexture(name,data){let cache=texCache[name];if(!cache){cache=cacheImage(data);texCache[name]=cache;}cache.count++;return cache.tex;}function releaseTexture(imageSrc){if(!imageSrc)return;setTimeout(()=>__awaiter(this,void 0,void 0,function*(){const cache=texCache[imageSrc];if(cache){cache.count--;if(cache.count<=0){if(cache.tex){yield pixi_js.Assets.unload(imageSrc);cache.tex.destroy(true);cache.tex=null;}delete texCache[imageSrc];}}}),100);}let dataMap={};function createSpineData(name,data,scale,pixiSpine){const skeletonAsset=data.ske;const atlasAsset=data.atlas;const attachmentLoader=new pixiSpine.AtlasAttachmentLoader(atlasAsset);const parser=skeletonAsset instanceof Uint8Array?new pixiSpine.SkeletonBinary(attachmentLoader):new pixiSpine.SkeletonJson(attachmentLoader);parser.scale=scale||1;const skeletonData=parser.readSkeletonData(skeletonAsset);const obj={spineData:skeletonData,ref:0,imageSrc:data.image.label};dataMap[name]=obj;return obj;}function getSpineData(res,scale,pixiSpine){return __awaiter(this,void 0,void 0,function*(){let data=dataMap[res.name];if(!data){if(res.complete){data=createSpineData(res.name,res.data,scale,pixiSpine);}else if(!data){return;}}retainTexture(res.data.image.label,res.data);data.ref++;return data.spineData;});}function releaseSpineData(res,imageSrc){return __awaiter(this,void 0,void 0,function*(){const resourceName=res.name;yield pixi_js.Assets.unload([res.src.image.url,res.src.atlas.url,res.src.ske.url]);const resolver=pixi_js.Assets.resolver;delete resolver._assetMap[res.src.image.url];delete resolver._assetMap[res.src.atlas.url];delete resolver._assetMap[res.src.ske.url];delete resolver._resolverHash[res.src.image.url];delete resolver._resolverHash[res.src.atlas.url];delete resolver._resolverHash[res.src.ske.url];const data=dataMap[resourceName];if(!data){return;}data.ref--;if(data.ref<=0){releaseTexture(imageSrc);eva_js.resource.destroy(resourceName);delete dataMap[resourceName];}});}const MaxRetryCount=20;let SpineSystem$1=class SpineSystem extends pluginRenderer.Renderer{constructor(){super(...arguments);this.armatures={};}init({pixiSpine}){this.renderSystem=this.game.getSystem(pluginRenderer.RendererSystem);this.renderSystem.rendererManager.register(this);this.pixiSpine=pixiSpine;this.game.canvas.addEventListener('webglcontextrestored',()=>{const objs=this.game.gameObjects;let toAdd=[];for(let k in this.armatures){const id=+k;for(let i=0;i<objs.length;++i){let obj=objs[i];if(obj.id===id){let sp=obj.getComponent(Spine$1);if(sp){this.remove({type:eva_js.OBSERVER_TYPE.REMOVE,gameObject:obj,component:sp,componentName:Spine$1.componentName});toAdd.push({type:eva_js.OBSERVER_TYPE.ADD,gameObject:obj,component:sp,componentName:Spine$1.componentName});}break;}}}setTimeout(()=>{toAdd.forEach(obj=>{this.add(obj);});},1000);},false);}update(e){for(let key in this.armatures){this.armatures[key].update(e.deltaTime*0.001);}super.update();}componentChanged(changed){return __awaiter(this,void 0,void 0,function*(){if(changed.componentName==='Spine'){if(changed.type===eva_js.OBSERVER_TYPE.ADD){this.add(changed);}else if(changed.type===eva_js.OBSERVER_TYPE.CHANGE){switch(changed.prop.prop[0]){case'resource':this.change(changed);break;}}else if(changed.type===eva_js.OBSERVER_TYPE.REMOVE){this.remove(changed);}}});}add(changed,count){var _a,_b;return __awaiter(this,void 0,void 0,function*(){const component=changed.component;clearTimeout(component.addHandler);const gameObjectId=changed.gameObject.id;const asyncId=this.increaseAsyncId(gameObjectId);const res=yield eva_js.resource.getResource(component.resource);if(!this.validateAsyncId(gameObjectId,asyncId))return;const spineData=yield getSpineData(res,component.scale,this.pixiSpine);if(!this.validateAsyncId(gameObjectId,asyncId))return;if(!spineData){component.addHandler=setTimeout(()=>{if(!component.destroied){if(count===undefined){count=MaxRetryCount;}count--;if(count>0){this.add(changed,count);}else{console.log('retry exceed max times',component.resource);}}},1000);return;}this.remove(changed);const container=(_b=(_a=this.renderSystem)===null||_a===void 0?void 0:_a.containerManager)===null||_b===void 0?void 0:_b.getContainer(changed.gameObject.id);if(!container){return;}component.lastResource=component.resource;const armature=new this.pixiSpine.Spine({skeletonData:spineData,autoUpdate:false});this.armatures[changed.gameObject.id]=armature;if(changed.gameObject&&changed.gameObject.transform){const tran=changed.gameObject.transform;armature.x=tran.size.width*tran.origin.x;armature.y=tran.size.height*tran.origin.y;}container.addChildAt(armature,0);armature.update();component.armature=armature;component.emit('loaded',{resource:component.resource});armature.state.addListener({start:(track,event)=>{component.emit('start',{track,name:track.animation.name});},complete:(track,event)=>{component.emit('complete',{track,name:track.animation.name});},interrupt:(track,event)=>{component.emit('interrupt',{track,name:track.animation.name});},end:(track,event)=>{component.emit('end',{track,name:track.animation.name});},event:(track,event)=>{component.emit('event',track,event);}});});}change(changed){this.remove(changed);this.add(changed);}remove(changed){var _a,_b,_c,_d,_e,_f;return __awaiter(this,void 0,void 0,function*(){this.increaseAsyncId(changed.gameObject.id);const component=changed.component;clearTimeout(component.addHandler);const armature=this.armatures[changed.gameObject.id];const container=(_b=(_a=this.renderSystem)===null||_a===void 0?void 0:_a.containerManager)===null||_b===void 0?void 0:_b.getContainer(changed.gameObject.id);if(container&&armature){container.removeChild(armature);}if(component.armature){component.armature.destroy({children:true});const res=yield eva_js.resource.getResource(component.lastResource);const imageSrc=((_d=(_c=res.data)===null||_c===void 0?void 0:_c.image)===null||_d===void 0?void 0:_d.src)||((_f=(_e=res.data)===null||_e===void 0?void 0:_e.image)===null||_f===void 0?void 0:_f.label);yield releaseSpineData(res,imageSrc);}component.armature=null;delete this.armatures[changed.gameObject.id];if(changed.type===eva_js.OBSERVER_TYPE.CHANGE);});}};SpineSystem$1.systemName='SpineSystem';SpineSystem$1=__decorate([eva_js.decorators.componentObserver({Spine:['resource']})],SpineSystem$1);var SpineSystem$1$1=SpineSystem$1;eva_js.resource.registerResourceType('SPINE');class SpineSystem extends SpineSystem$1$1{init(){super.init({pixiSpine});}}class Spine extends Spine$1{}exports.PixiSpine=pixiSpine;exports.Spine=Spine;exports.SpineSystem=SpineSystem;Object.defineProperty(exports,'__esModule',{value:true});return exports;}({},PIXI,EVA,EVA.plugin.renderer);globalThis.EVA.plugin.renderer.spine=globalThis.EVA.plugin.renderer.spine||_EVA_IIFE_spine;
26
+ `}};var DarkTintShader=class extends pixi_js.Shader{constructor(maxTextures){const glProgram=pixi_js.compileHighShaderGlProgram({name:'dark-tint-batch',bits:[pixi_js.colorBitGl,darkTintBitGl,pixi_js.generateTextureBatchBitGl(maxTextures),pixi_js.roundPixelsBitGl]});const gpuProgram=pixi_js.compileHighShaderGpuProgram({name:'dark-tint-batch',bits:[pixi_js.colorBit,darkTintBit,pixi_js.generateTextureBatchBit(maxTextures),pixi_js.roundPixelsBit]});super({glProgram,gpuProgram,resources:{batchSamplers:pixi_js.getBatchSamplersUniformGroup(maxTextures)}});}};var defaultShader=null;var _DarkTintBatcher=class extends pixi_js.Batcher{constructor(){super(...arguments);this.geometry=new DarkTintBatchGeometry();this.shader=defaultShader||(defaultShader=new DarkTintShader(this.maxTextures));this.name=_DarkTintBatcher.extension.name;this.vertexSize=7;}packAttributes(element,float32View,uint32View,index,textureId){const textureIdAndRound=textureId<<16|element.roundPixels&65535;const wt=element.transform;const a=wt.a;const b=wt.b;const c=wt.c;const d=wt.d;const tx=wt.tx;const ty=wt.ty;const{positions,uvs}=element;const argb=element.color;const worldAlpha=(argb>>24&255)/255;const darkColor=pixi_js.Color.shared.setValue(element.darkColor).premultiply(worldAlpha,true).toPremultiplied(1,false);const offset=element.attributeOffset;const end=offset+element.attributeSize;for(let i=offset;i<end;i++){const i2=i*2;const x=positions[i2];const y=positions[i2+1];float32View[index++]=a*x+c*y+tx;float32View[index++]=d*y+b*x+ty;float32View[index++]=uvs[i2];float32View[index++]=uvs[i2+1];uint32View[index++]=argb;uint32View[index++]=darkColor;uint32View[index++]=textureIdAndRound;}}packQuadAttributes(element,float32View,uint32View,index,textureId){const texture=element.texture;const wt=element.transform;const a=wt.a;const b=wt.b;const c=wt.c;const d=wt.d;const tx=wt.tx;const ty=wt.ty;const bounds=element.bounds;const w0=bounds.maxX;const w1=bounds.minX;const h0=bounds.maxY;const h1=bounds.minY;const uvs=texture.uvs;const argb=element.color;const darkColor=element.darkColor;const textureIdAndRound=textureId<<16|element.roundPixels&65535;float32View[index+0]=a*w1+c*h1+tx;float32View[index+1]=d*h1+b*w1+ty;float32View[index+2]=uvs.x0;float32View[index+3]=uvs.y0;uint32View[index+4]=argb;uint32View[index+5]=darkColor;uint32View[index+6]=textureIdAndRound;float32View[index+7]=a*w0+c*h1+tx;float32View[index+8]=d*h1+b*w0+ty;float32View[index+9]=uvs.x1;float32View[index+10]=uvs.y1;uint32View[index+11]=argb;uint32View[index+12]=darkColor;uint32View[index+13]=textureIdAndRound;float32View[index+14]=a*w0+c*h0+tx;float32View[index+15]=d*h0+b*w0+ty;float32View[index+16]=uvs.x2;float32View[index+17]=uvs.y2;uint32View[index+18]=argb;uint32View[index+19]=darkColor;uint32View[index+20]=textureIdAndRound;float32View[index+21]=a*w1+c*h0+tx;float32View[index+22]=d*h0+b*w1+ty;float32View[index+23]=uvs.x3;float32View[index+24]=uvs.y3;uint32View[index+25]=argb;uint32View[index+26]=darkColor;uint32View[index+27]=textureIdAndRound;}};var DarkTintBatcher=_DarkTintBatcher;DarkTintBatcher.extension={type:[pixi_js.ExtensionType.Batcher],name:'darkTint'};pixi_js.extensions.add(DarkTintBatcher);var BatchableSpineSlot=class{constructor(){this.indexOffset=0;this.attributeOffset=0;this.batcherName='darkTint';this.topology='triangle-list';this.packAsQuad=false;}get color(){const slotColor=this.data.color;const parentColor=this.renderable.groupColor;const parentAlpha=this.renderable.groupAlpha;let abgr;const mixedA=slotColor.a*parentAlpha*255;if(parentColor!==16777215){const parentB=parentColor>>16&255;const parentG=parentColor>>8&255;const parentR=parentColor&255;const mixedR=slotColor.r*parentR;const mixedG=slotColor.g*parentG;const mixedB=slotColor.b*parentB;abgr=mixedA<<24|mixedB<<16|mixedG<<8|mixedR;}else{abgr=mixedA<<24|slotColor.b*255<<16|slotColor.g*255<<8|slotColor.r*255;}return abgr;}get darkColor(){const darkColor=this.data.darkColor;return darkColor.b*255<<16|darkColor.g*255<<8|darkColor.r*255;}get groupTransform(){return this.renderable.groupTransform;}setData(renderable,data,blendMode,roundPixels){this.renderable=renderable;this.transform=renderable.groupTransform;this.data=data;if(data.clipped){const clippedData=data.clippedData;this.indexSize=clippedData.indicesCount;this.attributeSize=clippedData.vertexCount;this.positions=clippedData.vertices;this.indices=clippedData.indices;this.uvs=clippedData.uvs;}else{this.indexSize=data.indices.length;this.attributeSize=data.vertices.length/2;this.positions=data.vertices;this.indices=data.indices;this.uvs=data.uvs;}this.texture=data.texture;this.roundPixels=roundPixels;this.blendMode=blendMode;this.batcherName=data.darkTint?'darkTint':'default';}};var spineBlendModeMap={0:'normal',1:'add',2:'multiply',3:'screen'};var SpinePipe=class{constructor(renderer){this.gpuSpineData={};this._destroyRenderableBound=this.destroyRenderable.bind(this);this.renderer=renderer;}validateRenderable(spine){spine._validateAndTransformAttachments();if(spine.spineAttachmentsDirty){return true;}else if(spine.spineTexturesDirty){const drawOrder=spine.skeleton.drawOrder;const gpuSpine=this.gpuSpineData[spine.uid];for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();if(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);const batchableSpineSlot=gpuSpine.slotBatches[cacheData.id];const texture=cacheData.texture;if(texture!==batchableSpineSlot.texture){if(!batchableSpineSlot._batcher.checkAndUpdateTexture(batchableSpineSlot,texture)){return true;}}}}}return false;}addRenderable(spine,instructionSet){var _a,_b;const gpuSpine=this._getSpineData(spine);const batcher=this.renderer.renderPipes.batch;const drawOrder=spine.skeleton.drawOrder;const roundPixels=this.renderer._roundPixels|spine._roundPixels;spine._validateAndTransformAttachments();for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();const blendMode=spineBlendModeMap[slot.data.blendMode];if(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);const batchableSpineSlot=(_a=gpuSpine.slotBatches)[_b=cacheData.id]||(_a[_b]=new BatchableSpineSlot());batchableSpineSlot.setData(spine,cacheData,blendMode,roundPixels);if(!cacheData.skipRender){batcher.addToBatch(batchableSpineSlot,instructionSet);}}const containerAttachment=spine._slotsObject[slot.data.name];if(containerAttachment){const container=containerAttachment.container;container.includeInBuild=true;pixi_js.collectAllRenderables(container,instructionSet,this.renderer);container.includeInBuild=false;}}}updateRenderable(spine){var _a;const gpuSpine=this.gpuSpineData[spine.uid];spine._validateAndTransformAttachments();const drawOrder=spine.skeleton.drawOrder;for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();if(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);if(!cacheData.skipRender){const batchableSpineSlot=gpuSpine.slotBatches[spine._getCachedData(slot,attachment).id];(_a=batchableSpineSlot._batcher)==null?void 0:_a.updateElement(batchableSpineSlot);}}}}destroyRenderable(spine){this.gpuSpineData[spine.uid]=null;spine.off('destroyed',this._destroyRenderableBound);}destroy(){this.gpuSpineData=null;this.renderer=null;}_getSpineData(spine){return this.gpuSpineData[spine.uid]||this._initMeshData(spine);}_initMeshData(spine){this.gpuSpineData[spine.uid]={slotBatches:{}};spine.on('destroyed',this._destroyRenderableBound);return this.gpuSpineData[spine.uid];}};SpinePipe.extension={type:[pixi_js.ExtensionType.WebGLPipes,pixi_js.ExtensionType.WebGPUPipes,pixi_js.ExtensionType.CanvasPipes],name:'spine'};pixi_js.extensions.add(SpinePipe);var vectorAux=new Vector2();Skeleton.yDown=true;var clipper=new SkeletonClipping();var maskPool=new Pool(()=>new pixi_js.Graphics());var Spine$2=class extends pixi_js.ViewContainer{constructor(options){var _a;if(options instanceof SkeletonData){options={skeletonData:options};}super();this.batched=true;this.buildId=0;this.renderPipeId='spine';this._didSpineUpdate=false;this.beforeUpdateWorldTransforms=()=>{};this.afterUpdateWorldTransforms=()=>{};this.darkTint=false;this._debug=void 0;this._slotsObject=Object.create(null);this.clippingSlotToPixiMasks=Object.create(null);this.spineAttachmentsDirty=true;this.spineTexturesDirty=true;this._lastAttachments=[];this._stateChanged=true;this.attachmentCacheData=[];this._autoUpdate=true;this.hasNeverUpdated=true;const skeletonData=options instanceof SkeletonData?options:options.skeletonData;this.skeleton=new Skeleton(skeletonData);this.state=new AnimationState(new AnimationStateData(skeletonData));this.autoUpdate=(_a=options==null?void 0:options.autoUpdate)!=null?_a:true;this.darkTint=(options==null?void 0:options.darkTint)===void 0?this.skeleton.slots.some(slot=>!!slot.data.darkColor):options==null?void 0:options.darkTint;const slots=this.skeleton.slots;for(let i=0;i<slots.length;i++){this.attachmentCacheData[i]=Object.create(null);}}getSlotFromRef(slotRef){let slot;if(typeof slotRef==='number')slot=this.skeleton.slots[slotRef];else if(typeof slotRef==='string')slot=this.skeleton.findSlot(slotRef);else slot=slotRef;if(!slot)throw new Error(`No slot found with the given slot reference: ${slotRef}`);return slot;}get debug(){return this._debug;}set debug(value){if(this._debug){this._debug.unregisterSpine(this);}if(value){value.registerSpine(this);}this._debug=value;}get autoUpdate(){return this._autoUpdate;}set autoUpdate(value){if(value){pixi_js.Ticker.shared.add(this.internalUpdate,this);}else{pixi_js.Ticker.shared.remove(this.internalUpdate,this);}this._autoUpdate=value;}update(dt){this.internalUpdate(0,dt);}internalUpdate(_deltaFrame,deltaSeconds){this._updateAndApplyState(deltaSeconds!=null?deltaSeconds:pixi_js.Ticker.shared.deltaMS/1e3);}get bounds(){if(this._boundsDirty){this.updateBounds();}return this._bounds;}setBonePosition(bone,position){const boneAux=bone;if(typeof bone==='string'){bone=this.skeleton.findBone(bone);}if(!bone)throw Error(`Cant set bone position, bone ${String(boneAux)} not found`);vectorAux.set(position.x,position.y);if(bone.parent){const aux=bone.parent.worldToLocal(vectorAux);bone.x=aux.x;bone.y=-aux.y;}else{bone.x=vectorAux.x;bone.y=vectorAux.y;}}getBonePosition(bone,outPos){const boneAux=bone;if(typeof bone==='string'){bone=this.skeleton.findBone(bone);}if(!bone){console.error(`Cant set bone position! Bone ${String(boneAux)} not found`);return outPos;}if(!outPos){outPos={x:0,y:0};}outPos.x=bone.worldX;outPos.y=bone.worldY;return outPos;}_updateAndApplyState(time){this.hasNeverUpdated=false;this.state.update(time);this.skeleton.update(time);const{skeleton}=this;this.state.apply(skeleton);this.beforeUpdateWorldTransforms(this);skeleton.updateWorldTransform(2);this.afterUpdateWorldTransforms(this);this.updateSlotObjects();this._stateChanged=true;this._boundsDirty=true;this.onViewUpdate();}_validateAndTransformAttachments(){if(!this._stateChanged)return;this._stateChanged=false;this.validateAttachments();this.transformAttachments();}validateAttachments(){const currentDrawOrder=this.skeleton.drawOrder;const lastAttachments=this._lastAttachments;let index=0;let spineAttachmentsDirty=false;for(let i=0;i<currentDrawOrder.length;i++){const slot=currentDrawOrder[i];const attachment=slot.getAttachment();if(attachment){if(attachment!==lastAttachments[index]){spineAttachmentsDirty=true;lastAttachments[index]=attachment;}index++;}}if(index!==lastAttachments.length){spineAttachmentsDirty=true;lastAttachments.length=index;}this.spineAttachmentsDirty=spineAttachmentsDirty;}updateAndSetPixiMask(slot,last){var _a,_b;const attachment=slot.attachment;if(attachment&&attachment instanceof ClippingAttachment){const clip=(_a=this.clippingSlotToPixiMasks)[_b=slot.data.name]||(_a[_b]={slot,vertices:new Array()});clip.maskComputed=false;this.currentClippingSlot=this.clippingSlotToPixiMasks[slot.data.name];return;}let currentClippingSlot=this.currentClippingSlot;let slotObject=this._slotsObject[slot.data.name];if(currentClippingSlot&&slotObject){let slotClipping=currentClippingSlot.slot;let clippingAttachment=slotClipping.attachment;let mask=currentClippingSlot.mask;if(!mask){mask=maskPool.obtain();currentClippingSlot.mask=mask;this.addChild(mask);}if(!currentClippingSlot.maskComputed){currentClippingSlot.maskComputed=true;const worldVerticesLength=clippingAttachment.worldVerticesLength;const vertices=currentClippingSlot.vertices;clippingAttachment.computeWorldVertices(slotClipping,0,worldVerticesLength,vertices,0,2);mask.clear().poly(vertices).stroke({width:0}).fill({alpha:0.25});}slotObject.container.mask=mask;}else if(slotObject==null?void 0:slotObject.container.mask){slotObject.container.mask=null;}if(currentClippingSlot&&currentClippingSlot.slot.attachment.endSlot==slot.data){this.currentClippingSlot=void 0;}if(last){for(const key in this.clippingSlotToPixiMasks){const clippingSlotToPixiMask=this.clippingSlotToPixiMasks[key];if((!(clippingSlotToPixiMask.slot.attachment instanceof ClippingAttachment)||!clippingSlotToPixiMask.maskComputed)&&clippingSlotToPixiMask.mask){this.removeChild(clippingSlotToPixiMask.mask);maskPool.free(clippingSlotToPixiMask.mask);clippingSlotToPixiMask.mask=void 0;}}}}transformAttachments(){var _a;const currentDrawOrder=this.skeleton.drawOrder;for(let i=0;i<currentDrawOrder.length;i++){const slot=currentDrawOrder[i];this.updateAndSetPixiMask(slot,i===currentDrawOrder.length-1);const attachment=slot.getAttachment();if(attachment){if(attachment instanceof MeshAttachment||attachment instanceof RegionAttachment){const cacheData=this._getCachedData(slot,attachment);if(attachment instanceof RegionAttachment){attachment.computeWorldVertices(slot,cacheData.vertices,0,2);}else{attachment.computeWorldVertices(slot,0,attachment.worldVerticesLength,cacheData.vertices,0,2);}if(cacheData.uvs.length<attachment.uvs.length){cacheData.uvs=new Float32Array(attachment.uvs.length);}pixi_js.fastCopy(attachment.uvs.buffer,cacheData.uvs.buffer);const skeleton=slot.bone.skeleton;const skeletonColor=skeleton.color;const slotColor=slot.color;const attachmentColor=attachment.color;cacheData.color.set(skeletonColor.r*slotColor.r*attachmentColor.r,skeletonColor.g*slotColor.g*attachmentColor.g,skeletonColor.b*slotColor.b*attachmentColor.b,skeletonColor.a*slotColor.a*attachmentColor.a);if(slot.darkColor){cacheData.darkColor.setFromColor(slot.darkColor);}cacheData.skipRender=cacheData.clipped=false;const texture=((_a=attachment.region)==null?void 0:_a.texture.texture)||pixi_js.Texture.EMPTY;if(cacheData.texture!==texture){cacheData.texture=texture;this.spineTexturesDirty=true;}if(clipper.isClipping()){this.updateClippingData(cacheData);}}else if(attachment instanceof ClippingAttachment){clipper.clipStart(slot,attachment);continue;}}clipper.clipEndWithSlot(slot);}clipper.clipEnd();}updateClippingData(cacheData){cacheData.clipped=true;clipper.clipTrianglesUnpacked(cacheData.vertices,cacheData.indices,cacheData.indices.length,cacheData.uvs);const{clippedVertices,clippedUVs,clippedTriangles}=clipper;const verticesCount=clippedVertices.length/2;const indicesCount=clippedTriangles.length;if(!cacheData.clippedData){cacheData.clippedData={vertices:new Float32Array(verticesCount*2),uvs:new Float32Array(verticesCount*2),vertexCount:verticesCount,indices:new Uint16Array(indicesCount),indicesCount};this.spineAttachmentsDirty=true;}const clippedData=cacheData.clippedData;const sizeChange=clippedData.vertexCount!==verticesCount||indicesCount!==clippedData.indicesCount;cacheData.skipRender=verticesCount===0;if(sizeChange){this.spineAttachmentsDirty=true;if(clippedData.vertexCount<verticesCount){clippedData.vertices=new Float32Array(verticesCount*2);clippedData.uvs=new Float32Array(verticesCount*2);}if(clippedData.indices.length<indicesCount){clippedData.indices=new Uint16Array(indicesCount);}}const{vertices,uvs,indices}=clippedData;for(let i=0;i<verticesCount;i++){vertices[i*2]=clippedVertices[i*2];vertices[i*2+1]=clippedVertices[i*2+1];uvs[i*2]=clippedUVs[i*2];uvs[i*2+1]=clippedUVs[i*2+1];}clippedData.vertexCount=verticesCount;for(let i=0;i<indicesCount;i++){if(indices[i]!==clippedTriangles[i]){this.spineAttachmentsDirty=true;indices[i]=clippedTriangles[i];}}clippedData.indicesCount=indicesCount;}updateSlotObjects(){for(const i in this._slotsObject){const slotAttachment=this._slotsObject[i];if(!slotAttachment)continue;this.updateSlotObject(slotAttachment);}}updateSlotObject(slotAttachment){const{slot,container}=slotAttachment;container.visible=this.skeleton.drawOrder.includes(slot);if(container.visible){const bone=slot.bone;container.position.set(bone.worldX,bone.worldY);container.scale.x=bone.getWorldScaleX();container.scale.y=bone.getWorldScaleY();container.rotation=bone.getWorldRotationX()*pixi_js.DEG_TO_RAD;container.alpha=this.skeleton.color.a*slot.color.a;}}_getCachedData(slot,attachment){return this.attachmentCacheData[slot.data.index][attachment.name]||this.initCachedData(slot,attachment);}initCachedData(slot,attachment){var _a,_b;let vertices;if(attachment instanceof RegionAttachment){vertices=new Float32Array(8);this.attachmentCacheData[slot.data.index][attachment.name]={id:`${slot.data.index}-${attachment.name}`,vertices,clipped:false,indices:[0,1,2,0,2,3],uvs:new Float32Array(attachment.uvs.length),color:new Color(1,1,1,1),darkColor:new Color(0,0,0,0),darkTint:this.darkTint,skipRender:false,texture:(_a=attachment.region)==null?void 0:_a.texture.texture};}else{vertices=new Float32Array(attachment.worldVerticesLength);this.attachmentCacheData[slot.data.index][attachment.name]={id:`${slot.data.index}-${attachment.name}`,vertices,clipped:false,indices:attachment.triangles,uvs:new Float32Array(attachment.uvs.length),color:new Color(1,1,1,1),darkColor:new Color(0,0,0,0),darkTint:this.darkTint,skipRender:false,texture:(_b=attachment.region)==null?void 0:_b.texture.texture};}return this.attachmentCacheData[slot.data.index][attachment.name];}onViewUpdate(){var _a;this._didViewChangeTick++;this._boundsDirty=true;if(this.didViewUpdate)return;this.didViewUpdate=true;const renderGroup=this.renderGroup||this.parentRenderGroup;if(renderGroup){renderGroup.onChildViewUpdate(this);}(_a=this.debug)==null?void 0:_a.renderDebug(this);}addSlotObject(slot,container){var _a;slot=this.getSlotFromRef(slot);for(const i in this._slotsObject){if(((_a=this._slotsObject[i])==null?void 0:_a.container)===container){this.removeSlotObject(this._slotsObject[i].slot);}}this.removeSlotObject(slot);container.includeInBuild=false;this.addChild(container);const slotObject={container,slot};this._slotsObject[slot.data.name]=slotObject;this.updateSlotObject(slotObject);}removeSlotObject(slotOrContainer){var _a,_b;let containerToRemove;if(slotOrContainer instanceof pixi_js.Container){for(const i in this._slotsObject){if(((_a=this._slotsObject[i])==null?void 0:_a.container)===slotOrContainer){this._slotsObject[i]=null;containerToRemove=slotOrContainer;break;}}}else{const slot=this.getSlotFromRef(slotOrContainer);containerToRemove=(_b=this._slotsObject[slot.data.name])==null?void 0:_b.container;this._slotsObject[slot.data.name]=null;}if(containerToRemove){this.removeChild(containerToRemove);containerToRemove.includeInBuild=true;}}getSlotObject(slot){var _a;slot=this.getSlotFromRef(slot);return(_a=this._slotsObject[slot.data.name])==null?void 0:_a.container;}updateBounds(){this._boundsDirty=false;this.skeletonBounds||(this.skeletonBounds=new SkeletonBounds());const skeletonBounds=this.skeletonBounds;skeletonBounds.update(this.skeleton,true);if(skeletonBounds.minX===Infinity){if(this.hasNeverUpdated){this._updateAndApplyState(0);this._boundsDirty=false;}this._validateAndTransformAttachments();const drawOrder=this.skeleton.drawOrder;const bounds=this._bounds;bounds.clear();for(let i=0;i<drawOrder.length;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();if(attachment&&(attachment instanceof RegionAttachment||attachment instanceof MeshAttachment)){const cacheData=this._getCachedData(slot,attachment);bounds.addVertexData(cacheData.vertices,0,cacheData.vertices.length);}}}else{this._bounds.minX=skeletonBounds.minX;this._bounds.minY=skeletonBounds.minY;this._bounds.maxX=skeletonBounds.maxX;this._bounds.maxY=skeletonBounds.maxY;}}addBounds(bounds){bounds.addBounds(this.bounds);}destroy(options=false){super.destroy(options);pixi_js.Ticker.shared.remove(this.internalUpdate,this);this.state.clearListeners();this.debug=void 0;this.skeleton=null;this.state=null;this._slotsObject=null;this._lastAttachments.length=0;this.attachmentCacheData=null;}skeletonToPixiWorldCoordinates(point){this.worldTransform.apply(point,point);}pixiWorldCoordinatesToSkeleton(point){this.worldTransform.applyInverse(point,point);}pixiWorldCoordinatesToBone(point,bone){this.pixiWorldCoordinatesToSkeleton(point);if(bone.parent){bone.parent.worldToLocal(point);}else{bone.worldToLocal(point);}}static from({skeleton,atlas,scale=1,darkTint,autoUpdate=true}){const cacheKey=`${skeleton}-${atlas}-${scale}`;if(pixi_js.Cache.has(cacheKey)){return new Spine$2(pixi_js.Cache.get(cacheKey));}const skeletonAsset=pixi_js.Assets.get(skeleton);const atlasAsset=pixi_js.Assets.get(atlas);const attachmentLoader=new AtlasAttachmentLoader(atlasAsset);const parser=skeletonAsset instanceof Uint8Array?new SkeletonBinary(attachmentLoader):new SkeletonJson(attachmentLoader);parser.scale=scale;const skeletonData=parser.readSkeletonData(skeletonAsset);console.log('>>>skeletonData',skeletonData);pixi_js.Cache.set(cacheKey,skeletonData);return new Spine$2({skeletonData,darkTint,autoUpdate});}};var SpineDebugRenderer=class{constructor(){this.registeredSpines=new Map();this.drawMeshHull=true;this.drawMeshTriangles=true;this.drawBones=true;this.drawPaths=true;this.drawBoundingBoxes=true;this.drawClipping=true;this.drawRegionAttachments=true;this.drawEvents=true;this.lineWidth=1;this.regionAttachmentsColor=30975;this.meshHullColor=30975;this.meshTrianglesColor=16763904;this.clippingPolygonColor=16711935;this.boundingBoxesRectColor=65280;this.boundingBoxesPolygonColor=65280;this.boundingBoxesCircleColor=65280;this.pathsCurveColor=16711680;this.pathsLineColor=16711935;this.skeletonXYColor=16711680;this.bonesColor=61132;this.eventFontSize=24;this.eventFontColor=0;}registerSpine(spine){if(this.registeredSpines.has(spine)){console.warn('SpineDebugRenderer.registerSpine() - this spine is already registered!',spine);return;}const debugDisplayObjects={parentDebugContainer:new pixi_js.Container(),bones:new pixi_js.Container(),skeletonXY:new pixi_js.Graphics(),regionAttachmentsShape:new pixi_js.Graphics(),meshTrianglesLine:new pixi_js.Graphics(),meshHullLine:new pixi_js.Graphics(),clippingPolygon:new pixi_js.Graphics(),boundingBoxesRect:new pixi_js.Graphics(),boundingBoxesCircle:new pixi_js.Graphics(),boundingBoxesPolygon:new pixi_js.Graphics(),pathsCurve:new pixi_js.Graphics(),pathsLine:new pixi_js.Graphics(),eventText:new pixi_js.Container(),eventCallback:{event:(_,event)=>{if(this.drawEvents){const scale=Math.abs(spine.scale.x||spine.scale.y||1);const text=new pixi_js.Text({text:event.data.name,style:{fontSize:this.eventFontSize/scale,fill:this.eventFontColor,fontFamily:'monospace'}});text.scale.x=Math.sign(spine.scale.x);text.anchor.set(0.5);debugDisplayObjects.eventText.addChild(text);setTimeout(()=>{if(!text.destroyed){text.destroy();}},250);}}}};debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.bones);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.skeletonXY);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.regionAttachmentsShape);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.meshTrianglesLine);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.meshHullLine);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.clippingPolygon);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesRect);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesCircle);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.boundingBoxesPolygon);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.pathsCurve);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.pathsLine);debugDisplayObjects.parentDebugContainer.addChild(debugDisplayObjects.eventText);debugDisplayObjects.parentDebugContainer.zIndex=9999999;debugDisplayObjects.parentDebugContainer.accessibleChildren=false;debugDisplayObjects.parentDebugContainer.eventMode='none';debugDisplayObjects.parentDebugContainer.interactiveChildren=false;spine.addChild(debugDisplayObjects.parentDebugContainer);spine.state.addListener(debugDisplayObjects.eventCallback);this.registeredSpines.set(spine,debugDisplayObjects);}renderDebug(spine){if(!this.registeredSpines.has(spine)){this.registerSpine(spine);}const debugDisplayObjects=this.registeredSpines.get(spine);if(!debugDisplayObjects){return;}spine.addChild(debugDisplayObjects.parentDebugContainer);debugDisplayObjects.skeletonXY.clear();debugDisplayObjects.regionAttachmentsShape.clear();debugDisplayObjects.meshTrianglesLine.clear();debugDisplayObjects.meshHullLine.clear();debugDisplayObjects.clippingPolygon.clear();debugDisplayObjects.boundingBoxesRect.clear();debugDisplayObjects.boundingBoxesCircle.clear();debugDisplayObjects.boundingBoxesPolygon.clear();debugDisplayObjects.pathsCurve.clear();debugDisplayObjects.pathsLine.clear();for(let len=debugDisplayObjects.bones.children.length;len>0;len--){debugDisplayObjects.bones.children[len-1].destroy({children:true,texture:true,textureSource:true});}const scale=Math.abs(spine.scale.x||spine.scale.y||1);const lineWidth=this.lineWidth/scale;if(this.drawBones){this.drawBonesFunc(spine,debugDisplayObjects,lineWidth,scale);}if(this.drawPaths){this.drawPathsFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawBoundingBoxes){this.drawBoundingBoxesFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawClipping){this.drawClippingFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawMeshHull||this.drawMeshTriangles){this.drawMeshHullAndMeshTriangles(spine,debugDisplayObjects,lineWidth);}if(this.drawRegionAttachments){this.drawRegionAttachmentsFunc(spine,debugDisplayObjects,lineWidth);}if(this.drawEvents){for(const child of debugDisplayObjects.eventText.children){child.alpha-=0.05;child.y-=2;}}}drawBonesFunc(spine,debugDisplayObjects,lineWidth,scale){const skeleton=spine.skeleton;const skeletonX=skeleton.x;const skeletonY=skeleton.y;const bones=skeleton.bones;debugDisplayObjects.skeletonXY.strokeStyle={width:lineWidth,color:this.skeletonXYColor};for(let i=0,len=bones.length;i<len;i++){const bone=bones[i];const boneLen=bone.data.length;const starX=skeletonX+bone.worldX;const starY=skeletonY+bone.worldY;const endX=skeletonX+boneLen*bone.a+bone.worldX;const endY=skeletonY+boneLen*bone.b+bone.worldY;if(bone.data.name==='root'||bone.data.parent===null){continue;}const w=Math.abs(starX-endX);const h=Math.abs(starY-endY);const a2=Math.pow(w,2);const b=h;const b2=Math.pow(h,2);const c=Math.sqrt(a2+b2);const c2=Math.pow(c,2);const rad=Math.PI/180;const B=Math.acos((c2+b2-a2)/(2*b*c))||0;if(c===0){continue;}const gp=new pixi_js.Graphics();debugDisplayObjects.bones.addChild(gp);const refRation=c/50/scale;gp.context.poly([0,0,0-refRation,c-refRation*3,0,c-refRation,0+refRation,c-refRation*3]).fill(this.bonesColor);gp.x=starX;gp.y=starY;gp.pivot.y=c;let rotation=0;if(starX<endX&&starY<endY){rotation=-B+180*rad;}else if(starX>endX&&starY<endY){rotation=180*rad+B;}else if(starX>endX&&starY>endY){rotation=-B;}else if(starX<endX&&starY>endY){rotation=B;}else if(starY===endY&&starX<endX){rotation=90*rad;}else if(starY===endY&&starX>endX){rotation=-90*rad;}else if(starX===endX&&starY<endY){rotation=180*rad;}else if(starX===endX&&starY>endY){rotation=0;}gp.rotation=rotation;gp.circle(0,c,refRation*1.2).fill({color:0,alpha:0.6}).stroke({width:lineWidth+refRation/2.4,color:this.bonesColor});}const startDotSize=lineWidth*3;debugDisplayObjects.skeletonXY.context.moveTo(skeletonX-startDotSize,skeletonY-startDotSize).lineTo(skeletonX+startDotSize,skeletonY+startDotSize).moveTo(skeletonX+startDotSize,skeletonY-startDotSize).lineTo(skeletonX-startDotSize,skeletonY+startDotSize).stroke();}drawRegionAttachmentsFunc(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof RegionAttachment)){continue;}const regionAttachment=attachment;const vertices=new Float32Array(8);regionAttachment.computeWorldVertices(slot,vertices,0,2);debugDisplayObjects.regionAttachmentsShape.poly(Array.from(vertices.slice(0,8)));}debugDisplayObjects.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:lineWidth});}drawMeshHullAndMeshTriangles(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];if(!slot.bone.active){continue;}const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof MeshAttachment)){continue;}const meshAttachment=attachment;const vertices=new Float32Array(meshAttachment.worldVerticesLength);const triangles=meshAttachment.triangles;let hullLength=meshAttachment.hullLength;meshAttachment.computeWorldVertices(slot,0,meshAttachment.worldVerticesLength,vertices,0,2);if(this.drawMeshTriangles){for(let i2=0,len2=triangles.length;i2<len2;i2+=3){const v1=triangles[i2]*2;const v2=triangles[i2+1]*2;const v3=triangles[i2+2]*2;debugDisplayObjects.meshTrianglesLine.context.moveTo(vertices[v1],vertices[v1+1]).lineTo(vertices[v2],vertices[v2+1]).lineTo(vertices[v3],vertices[v3+1]);}}if(this.drawMeshHull&&hullLength>0){hullLength=(hullLength>>1)*2;let lastX=vertices[hullLength-2];let lastY=vertices[hullLength-1];for(let i2=0,len2=hullLength;i2<len2;i2+=2){const x=vertices[i2];const y=vertices[i2+1];debugDisplayObjects.meshHullLine.context.moveTo(x,y).lineTo(lastX,lastY);lastX=x;lastY=y;}}}debugDisplayObjects.meshHullLine.stroke({width:lineWidth,color:this.meshHullColor});debugDisplayObjects.meshTrianglesLine.stroke({width:lineWidth,color:this.meshTrianglesColor});}drawClippingFunc(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];if(!slot.bone.active){continue;}const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof ClippingAttachment)){continue;}const clippingAttachment=attachment;const nn=clippingAttachment.worldVerticesLength;const world=new Float32Array(nn);clippingAttachment.computeWorldVertices(slot,0,nn,world,0,2);debugDisplayObjects.clippingPolygon.poly(Array.from(world));}debugDisplayObjects.clippingPolygon.stroke({width:lineWidth,color:this.clippingPolygonColor,alpha:1});}drawBoundingBoxesFunc(spine,debugDisplayObjects,lineWidth){const bounds=new SkeletonBounds();bounds.update(spine.skeleton,true);if(bounds.minX!==Infinity){debugDisplayObjects.boundingBoxesRect.rect(bounds.minX,bounds.minY,bounds.getWidth(),bounds.getHeight()).stroke({width:lineWidth,color:this.boundingBoxesRectColor});}const polygons=bounds.polygons;const drawPolygon=(polygonVertices,_offset,count)=>{if(count<3){throw new Error('Polygon must contain at least 3 vertices');}const paths=[];const dotSize=lineWidth*2;for(let i=0,len=polygonVertices.length;i<len;i+=2){const x1=polygonVertices[i];const y1=polygonVertices[i+1];debugDisplayObjects.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor);debugDisplayObjects.boundingBoxesCircle.drawCircle(x1,y1,dotSize);debugDisplayObjects.boundingBoxesCircle.fill(0);debugDisplayObjects.boundingBoxesCircle.circle(x1,y1,dotSize).fill({color:this.boundingBoxesCircleColor});paths.push(x1,y1);}debugDisplayObjects.boundingBoxesPolygon.poly(paths).fill({color:this.boundingBoxesPolygonColor,alpha:0.1}).stroke({width:lineWidth,color:this.boundingBoxesPolygonColor});};for(let i=0,len=polygons.length;i<len;i++){const polygon=polygons[i];drawPolygon(polygon,0,polygon.length);}}drawPathsFunc(spine,debugDisplayObjects,lineWidth){const skeleton=spine.skeleton;const slots=skeleton.slots;for(let i=0,len=slots.length;i<len;i++){const slot=slots[i];if(!slot.bone.active){continue;}const attachment=slot.getAttachment();if(attachment===null||!(attachment instanceof PathAttachment)){continue;}const pathAttachment=attachment;let nn=pathAttachment.worldVerticesLength;const world=new Float32Array(nn);pathAttachment.computeWorldVertices(slot,0,nn,world,0,2);let x1=world[2];let y1=world[3];let x2=0;let y2=0;if(pathAttachment.closed){const cx1=world[0];const cy1=world[1];const cx2=world[nn-2];const cy2=world[nn-1];x2=world[nn-4];y2=world[nn-3];debugDisplayObjects.pathsCurve.moveTo(x1,y1);debugDisplayObjects.pathsCurve.bezierCurveTo(cx1,cy1,cx2,cy2,x2,y2);debugDisplayObjects.pathsLine.moveTo(x1,y1);debugDisplayObjects.pathsLine.lineTo(cx1,cy1);debugDisplayObjects.pathsLine.moveTo(x2,y2);debugDisplayObjects.pathsLine.lineTo(cx2,cy2);}nn-=4;for(let ii=4;ii<nn;ii+=6){const cx1=world[ii];const cy1=world[ii+1];const cx2=world[ii+2];const cy2=world[ii+3];x2=world[ii+4];y2=world[ii+5];debugDisplayObjects.pathsCurve.moveTo(x1,y1);debugDisplayObjects.pathsCurve.bezierCurveTo(cx1,cy1,cx2,cy2,x2,y2);debugDisplayObjects.pathsLine.moveTo(x1,y1);debugDisplayObjects.pathsLine.lineTo(cx1,cy1);debugDisplayObjects.pathsLine.moveTo(x2,y2);debugDisplayObjects.pathsLine.lineTo(cx2,cy2);x1=x2;y1=y2;}}debugDisplayObjects.pathsCurve.stroke({width:lineWidth,color:this.pathsCurveColor});debugDisplayObjects.pathsLine.stroke({width:lineWidth,color:this.pathsLineColor});}unregisterSpine(spine){if(!this.registeredSpines.has(spine)){console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",spine);}const debugDisplayObjects=this.registeredSpines.get(spine);if(!debugDisplayObjects){return;}spine.state.removeListener(debugDisplayObjects.eventCallback);debugDisplayObjects.parentDebugContainer.destroy({textureSource:true,children:true,texture:true});this.registeredSpines.delete(spine);}};var pixiSpine={AlphaTimeline,Animation,AnimationState,AnimationStateAdapter,AnimationStateData,AssetManagerBase,AtlasAttachmentLoader,Attachment,AttachmentTimeline,BinaryInput,BlendMode,Bone,BoneData,BoundingBoxAttachment,CURRENT,ClippingAttachment,Color,ConstraintData,CurveTimeline,CurveTimeline1,CurveTimeline2,DebugUtils,DeformTimeline,Downloader,DrawOrderTimeline,Event,EventData,EventQueue,EventTimeline,EventType,FIRST,FakeTexture,HOLD_FIRST,HOLD_MIX,HOLD_SUBSEQUENT,IkConstraint,IkConstraintData,IkConstraintTimeline,Inherit,InheritTimeline,IntSet,Interpolation,MathUtils,MeshAttachment,MixBlend,MixDirection,PathAttachment,PathConstraint,PathConstraintData,PathConstraintMixTimeline,PathConstraintPositionTimeline,PathConstraintSpacingTimeline,Physics,PhysicsConstraintDampingTimeline,PhysicsConstraintGravityTimeline,PhysicsConstraintInertiaTimeline,PhysicsConstraintMassTimeline,PhysicsConstraintMixTimeline,PhysicsConstraintResetTimeline,PhysicsConstraintStrengthTimeline,PhysicsConstraintTimeline,PhysicsConstraintWindTimeline,PointAttachment,Pool,PositionMode,Pow,PowOut,RGB2Timeline,RGBA2Timeline,RGBATimeline,RGBTimeline,RegionAttachment,RotateMode,RotateTimeline,SETUP,SUBSEQUENT,ScaleTimeline,ScaleXTimeline,ScaleYTimeline,SequenceTimeline,ShearTimeline,ShearXTimeline,ShearYTimeline,Skeleton,SkeletonBinary,SkeletonBounds,SkeletonClipping,SkeletonData,SkeletonJson,Skin,SkinEntry,Slot,SlotData,SpacingMode,Spine:Spine$2,SpineDebugRenderer,SpinePipe,SpineTexture,StringSet,Texture,TextureAtlas,TextureAtlasPage,TextureAtlasRegion,TextureFilter,TextureRegion,TextureWrap,TimeKeeper,Timeline,TrackEntry,TransformConstraint,TransformConstraintData,TransformConstraintTimeline,TranslateTimeline,TranslateXTimeline,TranslateYTimeline,Triangulator,Utils,Vector2,VertexAttachment,WindowedMean};function getIDEPropsPropertyObj(target,propertyKey){if(!target.constructor.IDEProps){target.constructor.IDEProps={};}if(!target.constructor.IDEProps[propertyKey]){target.constructor.IDEProps[propertyKey]={};}var propertyObj=target.constructor.IDEProps[propertyKey];return propertyObj;}function type(type){return function(target,propertyKey){var prop=getIDEPropsPropertyObj(target,propertyKey);prop.key=propertyKey;prop.type=type;};}function __decorate(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r;}function __awaiter(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}}function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value);}).then(fulfilled,rejected);}step((generator=generator.apply(thisArg,_arguments||[])).next());});}class Spine$1 extends eva_js.Component{constructor(){super(...arguments);this.resource='';this.scale=1;this.animationName='';this.autoPlay=true;this.waitExecuteInfos=[];}set armature(val){this._armature=val;if(!val)return;if(this.autoPlay){this.play(this.animationName);}for(const info of this.waitExecuteInfos){if(info.playType){const{name,loop,track}=info;this.play(name,loop,track);}else{this.stop(info.track);}}this.waitExecuteInfos=[];}get armature(){return this._armature;}init(obj){if(!obj)return;_extends(this,obj);}onDestroy(){this.destroied=true;}play(name,loopAnimation,track){try{const loop=loopAnimation!==null&&loopAnimation!==void 0?loopAnimation:this.autoPlay;if(name)this.animationName=name;if(!this.armature){this.waitExecuteInfos.push({playType:true,name,loop,track});}else{if(track===undefined){track=0;}this.armature.state.setAnimation(track,this.animationName,loop);}}catch(e){console.log(e);}}stop(track){if(!this.armature){this.waitExecuteInfos.push({playType:false,track});return;}if(track===undefined){track=0;}this.armature.state.setEmptyAnimation(track,0);}addAnimation(name,delay,loop,track){try{if(!this.armature){}else{if(track===undefined){track=0;}this.armature.state.addAnimation(track,name,loop,delay);}}catch(e){console.log(e);}}setMix(from,to,duration){if(!this.armature);else{this.armature.state.data.setMix(from,to,duration);}}getAnim(track=0){try{if(!this.armature){}else{return this.armature.state.tracks[track].animation.name;}}catch(e){console.log(e);}}setDefaultMix(duration){if(!this.armature);else{this.armature.state.data.defaultMix=duration;}}setAttachment(slotName,attachmentName){if(!this.armature){return;}this.armature.skeleton.setAttachment(slotName,attachmentName);}getBone(boneName){if(!this.armature){return;}return this.armature.skeleton.findBone(boneName);}}Spine$1.componentName='Spine';__decorate([type('string')],Spine$1.prototype,"resource",void 0);__decorate([type('number')],Spine$1.prototype,"scale",void 0);__decorate([type('string')],Spine$1.prototype,"animationName",void 0);__decorate([type('boolean')],Spine$1.prototype,"autoPlay",void 0);let dataMap={};function createSpineData(name,data,scale,pixiSpine){const skeletonAsset=data.ske;const atlasAsset=data.atlas;const attachmentLoader=new pixiSpine.AtlasAttachmentLoader(atlasAsset);const parser=skeletonAsset instanceof Uint8Array?new pixiSpine.SkeletonBinary(attachmentLoader):new pixiSpine.SkeletonJson(attachmentLoader);parser.scale=scale||1;const skeletonData=parser.readSkeletonData(skeletonAsset);const obj={spineData:skeletonData,ref:0,imageSrc:data.image.label};dataMap[name]=obj;return obj;}function getSpineData(res,scale,pixiSpine){return __awaiter(this,void 0,void 0,function*(){let data=dataMap[res.name];if(!data){if(res.complete){data=createSpineData(res.name,res.data,scale,pixiSpine);}else if(!data){return;}}data.ref++;return data.spineData;});}function releaseSpineData(res,_imageSrc){const resourceName=res.name;const data=dataMap[resourceName];if(!data){return;}data.ref--;setTimeout(()=>__awaiter(this,void 0,void 0,function*(){if(data.ref<=0){yield pixi_js.Assets.unload([res.src.image.url,res.src.atlas.url,res.src.ske.url]);const resolver=pixi_js.Assets.resolver;delete resolver._assetMap[res.src.image.url];delete resolver._assetMap[res.src.atlas.url];delete resolver._assetMap[res.src.ske.url];delete resolver._resolverHash[res.src.image.url];delete resolver._resolverHash[res.src.atlas.url];delete resolver._resolverHash[res.src.ske.url];eva_js.resource.destroy(resourceName);delete dataMap[resourceName];}}),100);}const MaxRetryCount=20;let SpineSystem$1=class SpineSystem extends pluginRenderer.Renderer{constructor(){super(...arguments);this.armatures={};}init({pixiSpine}){this.renderSystem=this.game.getSystem(pluginRenderer.RendererSystem);this.renderSystem.rendererManager.register(this);this.pixiSpine=pixiSpine;this.game.canvas.addEventListener('webglcontextrestored',()=>{const objs=this.game.gameObjects;let toAdd=[];for(let k in this.armatures){const id=+k;for(let i=0;i<objs.length;++i){let obj=objs[i];if(obj.id===id){let sp=obj.getComponent(Spine$1);if(sp){this.remove({type:eva_js.OBSERVER_TYPE.REMOVE,gameObject:obj,component:sp,componentName:Spine$1.componentName});toAdd.push({type:eva_js.OBSERVER_TYPE.ADD,gameObject:obj,component:sp,componentName:Spine$1.componentName});}break;}}}setTimeout(()=>{toAdd.forEach(obj=>{this.add(obj);});},1000);},false);}update(e){for(let key in this.armatures){this.armatures[key].update(e.deltaTime*0.001);}super.update();}componentChanged(changed){return __awaiter(this,void 0,void 0,function*(){if(changed.componentName==='Spine'){if(changed.type===eva_js.OBSERVER_TYPE.ADD){this.add(changed);}else if(changed.type===eva_js.OBSERVER_TYPE.CHANGE){switch(changed.prop.prop[0]){case'resource':this.change(changed);break;}}else if(changed.type===eva_js.OBSERVER_TYPE.REMOVE){this.remove(changed);}}});}add(changed,count){var _a,_b;return __awaiter(this,void 0,void 0,function*(){const component=changed.component;clearTimeout(component.addHandler);const gameObjectId=changed.gameObject.id;const asyncId=this.increaseAsyncId(gameObjectId);const res=yield eva_js.resource.getResource(component.resource);if(!this.validateAsyncId(gameObjectId,asyncId))return;const spineData=yield getSpineData(res,component.scale,this.pixiSpine);if(!this.validateAsyncId(gameObjectId,asyncId))return;if(!spineData){component.addHandler=setTimeout(()=>{if(!component.destroied){if(count===undefined){count=MaxRetryCount;}count--;if(count>0){this.add(changed,count);}else{console.log('retry exceed max times',component.resource);}}},1000);return;}this.remove(changed);const container=(_b=(_a=this.renderSystem)===null||_a===void 0?void 0:_a.containerManager)===null||_b===void 0?void 0:_b.getContainer(changed.gameObject.id);if(!container){return;}component.lastResource=component.resource;const armature=new this.pixiSpine.Spine({skeletonData:spineData,autoUpdate:false});this.armatures[changed.gameObject.id]=armature;if(changed.gameObject&&changed.gameObject.transform){const tran=changed.gameObject.transform;armature.x=tran.size.width*tran.origin.x;armature.y=tran.size.height*tran.origin.y;}container.addChildAt(armature,0);armature.update();component.armature=armature;component.emit('loaded',{resource:component.resource});armature.state.addListener({start:(track,event)=>{component.emit('start',{track,name:track.animation.name});},complete:(track,event)=>{component.emit('complete',{track,name:track.animation.name});},interrupt:(track,event)=>{component.emit('interrupt',{track,name:track.animation.name});},end:(track,event)=>{component.emit('end',{track,name:track.animation.name});},event:(track,event)=>{component.emit('event',track,event);}});});}change(changed){this.remove(changed);this.add(changed);}remove(changed){var _a,_b,_c,_d,_e,_f;return __awaiter(this,void 0,void 0,function*(){this.increaseAsyncId(changed.gameObject.id);const component=changed.component;clearTimeout(component.addHandler);const armature=this.armatures[changed.gameObject.id];const container=(_b=(_a=this.renderSystem)===null||_a===void 0?void 0:_a.containerManager)===null||_b===void 0?void 0:_b.getContainer(changed.gameObject.id);if(container&&armature){container.removeChild(armature);}if(component.armature){component.armature.destroy({children:true});const res=yield eva_js.resource.getResource(component.lastResource);((_d=(_c=res.data)===null||_c===void 0?void 0:_c.image)===null||_d===void 0?void 0:_d.src)||((_f=(_e=res.data)===null||_e===void 0?void 0:_e.image)===null||_f===void 0?void 0:_f.label);releaseSpineData(res);}component.armature=null;delete this.armatures[changed.gameObject.id];if(changed.type===eva_js.OBSERVER_TYPE.CHANGE);});}};SpineSystem$1.systemName='SpineSystem';SpineSystem$1=__decorate([eva_js.decorators.componentObserver({Spine:['resource']})],SpineSystem$1);var SpineSystem$1$1=SpineSystem$1;eva_js.resource.registerResourceType('SPINE');class SpineSystem extends SpineSystem$1$1{init(){super.init({pixiSpine});}}class Spine extends Spine$1{}exports.PixiSpine=pixiSpine;exports.Spine=Spine;exports.SpineSystem=SpineSystem;Object.defineProperty(exports,'__esModule',{value:true});return exports;}({},PIXI,EVA,EVA.plugin.renderer);globalThis.EVA.plugin.renderer.spine=globalThis.EVA.plugin.renderer.spine||_EVA_IIFE_spine;