@eva/plugin-renderer-spine 2.0.1-beta.39 → 2.0.1-beta.40

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 _DarkTintBatcher2=class _DarkTintBatcher extends pixi_js.Batcher{constructor(...args){super(...args);this.geometry=new DarkTintBatchGeometry();this.shader=defaultShader||(defaultShader=new DarkTintShader(this.maxTextures));this.name=_DarkTintBatcher2.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=_DarkTintBatcher2;__publicField(DarkTintBatcher,"extension",{type:[pixi_js.ExtensionType.Batcher],name:"darkTint"});pixi_js.extensions.add(DarkTintBatcher);var worldVertices=Utils.newFloatArray(8);var _SkeletonRenderer2=class _SkeletonRenderer{constructor(context){this.ctx=void 0;this.triangleRendering=false;this.debugRendering=false;this.vertices=Utils.newFloatArray(8*1024);this.tempColor=new Color();this.ctx=context;}draw(skeleton){if(this.triangleRendering)this.drawTriangles(skeleton);else this.drawImages(skeleton);}drawImages(skeleton){let ctx=this.ctx;let color=this.tempColor;let skeletonColor=skeleton.color;let drawOrder=skeleton.drawOrder;if(this.debugRendering)ctx.strokeStyle="green";for(let i=0,n=drawOrder.length;i<n;i++){let slot=drawOrder[i];let bone=slot.bone;if(!bone.active)continue;let attachment=slot.getAttachment();if(!(attachment instanceof RegionAttachment))continue;attachment.computeWorldVertices(slot,worldVertices,0,2);let region=attachment.region;let image=region.texture.getImage();let slotColor=slot.color;let regionColor=attachment.color;color.set(skeletonColor.r*slotColor.r*regionColor.r,skeletonColor.g*slotColor.g*regionColor.g,skeletonColor.b*slotColor.b*regionColor.b,skeletonColor.a*slotColor.a*regionColor.a);ctx.save();ctx.transform(bone.a,bone.c,bone.b,bone.d,bone.worldX,bone.worldY);ctx.translate(attachment.offset[0],attachment.offset[1]);ctx.rotate(attachment.rotation*Math.PI/180);let atlasScale=attachment.width/region.originalWidth;ctx.scale(atlasScale*attachment.scaleX,atlasScale*attachment.scaleY);let w=region.width,h=region.height;ctx.translate(w/2,h/2);if(attachment.region.degrees==90){let t=w;w=h;h=t;ctx.rotate(-Math.PI/2);}ctx.scale(1,-1);ctx.translate(-w/2,-h/2);ctx.globalAlpha=color.a;ctx.drawImage(image,image.width*region.u,image.height*region.v,w,h,0,0,w,h);if(this.debugRendering)ctx.strokeRect(0,0,w,h);ctx.restore();}}drawTriangles(skeleton){let ctx=this.ctx;let color=this.tempColor;let skeletonColor=skeleton.color;let drawOrder=skeleton.drawOrder;let blendMode=null;let vertices=this.vertices;let triangles=null;for(let i=0,n=drawOrder.length;i<n;i++){let slot=drawOrder[i];let attachment=slot.getAttachment();let texture;if(attachment instanceof RegionAttachment){let regionAttachment=attachment;vertices=this.computeRegionVertices(slot,regionAttachment,false);triangles=_SkeletonRenderer2.QUAD_TRIANGLES;texture=regionAttachment.region.texture.getImage();}else if(attachment instanceof _MeshAttachment){let mesh=attachment;vertices=this.computeMeshVertices(slot,mesh,false);triangles=mesh.triangles;texture=mesh.region.texture.getImage();}else continue;if(texture){if(slot.data.blendMode!=blendMode)blendMode=slot.data.blendMode;let slotColor=slot.color;let attachmentColor=attachment.color;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);ctx.globalAlpha=color.a;for(var j=0;j<triangles.length;j+=3){let t1=triangles[j]*8,t2=triangles[j+1]*8,t3=triangles[j+2]*8;let x0=vertices[t1],y0=vertices[t1+1],u0=vertices[t1+6],v0=vertices[t1+7];let x1=vertices[t2],y1=vertices[t2+1],u1=vertices[t2+6],v1=vertices[t2+7];let x2=vertices[t3],y2=vertices[t3+1],u2=vertices[t3+6],v2=vertices[t3+7];this.drawTriangle(texture,x0,y0,u0,v0,x1,y1,u1,v1,x2,y2,u2,v2);if(this.debugRendering){ctx.strokeStyle="green";ctx.beginPath();ctx.moveTo(x0,y0);ctx.lineTo(x1,y1);ctx.lineTo(x2,y2);ctx.lineTo(x0,y0);ctx.stroke();}}}}this.ctx.globalAlpha=1;}drawTriangle(img,x0,y0,u0,v0,x1,y1,u1,v1,x2,y2,u2,v2){let ctx=this.ctx;const width=img.width-1;const height=img.height-1;u0*=width;v0*=height;u1*=width;v1*=height;u2*=width;v2*=height;ctx.beginPath();ctx.moveTo(x0,y0);ctx.lineTo(x1,y1);ctx.lineTo(x2,y2);ctx.closePath();x1-=x0;y1-=y0;x2-=x0;y2-=y0;u1-=u0;v1-=v0;u2-=u0;v2-=v0;let det=u1*v2-u2*v1;if(det==0)return;det=1/det;const a=(v2*x1-v1*x2)*det;const b=(v2*y1-v1*y2)*det;const c=(u1*x2-u2*x1)*det;const d=(u1*y2-u2*y1)*det;const e=x0-a*u0-c*v0;const f=y0-b*u0-d*v0;ctx.save();ctx.transform(a,b,c,d,e,f);ctx.clip();ctx.drawImage(img,0,0);ctx.restore();}computeRegionVertices(slot,region,pma){let skeletonColor=slot.bone.skeleton.color;let slotColor=slot.color;let regionColor=region.color;let alpha=skeletonColor.a*slotColor.a*regionColor.a;let multiplier=pma?alpha:1;let color=this.tempColor;color.set(skeletonColor.r*slotColor.r*regionColor.r*multiplier,skeletonColor.g*slotColor.g*regionColor.g*multiplier,skeletonColor.b*slotColor.b*regionColor.b*multiplier,alpha);region.computeWorldVertices(slot,this.vertices,0,_SkeletonRenderer2.VERTEX_SIZE);let vertices=this.vertices;let uvs=region.uvs;vertices[RegionAttachment.C1R]=color.r;vertices[RegionAttachment.C1G]=color.g;vertices[RegionAttachment.C1B]=color.b;vertices[RegionAttachment.C1A]=color.a;vertices[RegionAttachment.U1]=uvs[0];vertices[RegionAttachment.V1]=uvs[1];vertices[RegionAttachment.C2R]=color.r;vertices[RegionAttachment.C2G]=color.g;vertices[RegionAttachment.C2B]=color.b;vertices[RegionAttachment.C2A]=color.a;vertices[RegionAttachment.U2]=uvs[2];vertices[RegionAttachment.V2]=uvs[3];vertices[RegionAttachment.C3R]=color.r;vertices[RegionAttachment.C3G]=color.g;vertices[RegionAttachment.C3B]=color.b;vertices[RegionAttachment.C3A]=color.a;vertices[RegionAttachment.U3]=uvs[4];vertices[RegionAttachment.V3]=uvs[5];vertices[RegionAttachment.C4R]=color.r;vertices[RegionAttachment.C4G]=color.g;vertices[RegionAttachment.C4B]=color.b;vertices[RegionAttachment.C4A]=color.a;vertices[RegionAttachment.U4]=uvs[6];vertices[RegionAttachment.V4]=uvs[7];return vertices;}computeMeshVertices(slot,mesh,pma){let skeletonColor=slot.bone.skeleton.color;let slotColor=slot.color;let regionColor=mesh.color;let alpha=skeletonColor.a*slotColor.a*regionColor.a;let multiplier=pma?alpha:1;let color=this.tempColor;color.set(skeletonColor.r*slotColor.r*regionColor.r*multiplier,skeletonColor.g*slotColor.g*regionColor.g*multiplier,skeletonColor.b*slotColor.b*regionColor.b*multiplier,alpha);let vertexCount=mesh.worldVerticesLength/2;let vertices=this.vertices;if(vertices.length<mesh.worldVerticesLength)this.vertices=vertices=Utils.newFloatArray(mesh.worldVerticesLength);mesh.computeWorldVertices(slot,0,mesh.worldVerticesLength,vertices,0,_SkeletonRenderer2.VERTEX_SIZE);let uvs=mesh.uvs;for(let i=0,u=0,v=2;i<vertexCount;i++){vertices[v++]=color.r;vertices[v++]=color.g;vertices[v++]=color.b;vertices[v++]=color.a;vertices[v++]=uvs[u++];vertices[v++]=uvs[u++];v+=2;}return vertices;}};var SkeletonRenderer=_SkeletonRenderer2;__publicField(SkeletonRenderer,"QUAD_TRIANGLES",[0,1,2,2,3,0]);__publicField(SkeletonRenderer,"VERTEX_SIZE",2+2+4);var BatchableSpineSlot=class BatchableSpineSlot{constructor(){this.indexOffset=0;this.attributeOffset=0;this.indexSize=void 0;this.attributeSize=void 0;this.batcherName="darkTint";this.topology="triangle-list";this.packAsQuad=false;this.renderable=void 0;this.positions=void 0;this.indices=void 0;this.uvs=void 0;this.roundPixels=void 0;this.data=void 0;this.blendMode=void 0;this.darkTint=void 0;this.texture=void 0;this.transform=void 0;this._textureId=void 0;this._attributeStart=void 0;this._indexStart=void 0;this._batcher=void 0;this._batch=void 0;}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 SpinePipe{constructor(renderer){this.renderer=void 0;this.canvasSkeletonRenderer=void 0;this.gpuSpineData={};this._destroyRenderableBound=this.destroyRenderable.bind(this);this.renderer=renderer;}validateRenderable(spine){if(this.renderer.type===pixi_js.RendererType.CANVAS){return true;}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===null||batchableSpineSlot===void 0?void 0:batchableSpineSlot.texture)){if(!(batchableSpineSlot!==null&&batchableSpineSlot!==void 0&&batchableSpineSlot._batcher.checkAndUpdateTexture(batchableSpineSlot,texture))){return true;}}}}}return false;}execute(spine){if(this.renderer.type===pixi_js.RendererType.CANVAS){const renderer=this.renderer;const groupAlpha=(spine.groupColorAlpha>>>24&255)/255;const contextSystem=renderer.canvasContext;const context=contextSystem.activeContext;context.save();if(!this.canvasSkeletonRenderer){this.canvasSkeletonRenderer=new SkeletonRenderer(context);this.canvasSkeletonRenderer.triangleRendering=true;}contextSystem.setContextTransform(spine.groupTransform,(renderer._roundPixels|spine._roundPixels)===1);const oldAlpha=spine.skeleton.color.a;spine.skeleton.color.a*=groupAlpha;this.canvasSkeletonRenderer.draw(spine.skeleton);spine.skeleton.color.a=oldAlpha;context.restore();}}addRenderable(spine,instructionSet){if(this.renderer.type===pixi_js.RendererType.CANVAS){this.renderer.renderPipes.batch.break(instructionSet);instructionSet.add(spine);return;}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();spine.spineAttachmentsDirty=false;spine.spineTexturesDirty=false;for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();const blendMode=spineBlendModeMap[slot.data.blendMode];let skipRender=false;if(attachment instanceof RegionAttachment||attachment instanceof _MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);const batchableSpineSlot=gpuSpine.slotBatches[cacheData.id]||=new BatchableSpineSlot();batchableSpineSlot.setData(spine,cacheData,blendMode,roundPixels);skipRender=cacheData.skipRender;if(!skipRender){batcher.addToBatch(batchableSpineSlot,instructionSet);}}const containerAttachment=spine._slotsObject[slot.data.name];if(containerAttachment){const container=containerAttachment.container;if(!skipRender){container.includeInBuild=true;container.collectRenderables(instructionSet,this.renderer,null);}container.includeInBuild=false;}}}updateRenderable(spine){const gpuSpine=this.gpuSpineData[spine.uid];spine._validateAndTransformAttachments();spine.spineAttachmentsDirty=false;spine.spineTexturesDirty=false;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){var _batchableSpineSlot$_;const batchableSpineSlot=gpuSpine.slotBatches[cacheData.id];batchableSpineSlot===null||batchableSpineSlot===void 0?void 0:(_batchableSpineSlot$_=batchableSpineSlot._batcher)===null||_batchableSpineSlot$_===void 0?void 0:_batchableSpineSlot$_.updateElement(batchableSpineSlot);}}}}destroyRenderable(spine){this.gpuSpineData[spine.uid]=null;spine.off("destroyed",this._destroyRenderableBound);}destroy(){this.gpuSpineData=null;this.renderer=null;this.canvasSkeletonRenderer=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];}};__publicField(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 AABBRectangleBoundsProvider=class{constructor(x,y,width,height){this.x=x;this.y=y;this.width=width;this.height=height;}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height};}};var SetupPoseBoundsProvider=class{constructor(clipping=false){this.clipping=clipping;}calculateBounds(gameObject){if(!gameObject.skeleton)return{x:0,y:0,width:0,height:0};const skeleton=new Skeleton(gameObject.skeleton.data);skeleton.setToSetupPose();skeleton.updateWorldTransform(Physics.update);const bounds=skeleton.getBoundsRect(this.clipping?new _SkeletonClipping():void 0);return bounds.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:bounds;}};var SkinsAndAnimationBoundsProvider=class{constructor(animation,skins=[],timeStep=0.05,clipping=false){this.animation=animation;this.skins=skins;this.timeStep=timeStep;this.clipping=clipping;}calculateBounds(gameObject){if(!gameObject.skeleton||!gameObject.state)return{x:0,y:0,width:0,height:0};const animationState=new AnimationState(gameObject.state.data);const skeleton=new Skeleton(gameObject.skeleton.data);const clipper2=this.clipping?new _SkeletonClipping():void 0;const data=skeleton.data;if(this.skins.length>0){let customSkin=new Skin("custom-skin");for(const skinName of this.skins){const skin=data.findSkin(skinName);if(skin==null)continue;customSkin.addSkin(skin);}skeleton.setSkin(customSkin);}skeleton.setToSetupPose();const animation=this.animation!=null?data.findAnimation(this.animation):null;if(animation==null){skeleton.updateWorldTransform(Physics.update);const bounds=skeleton.getBoundsRect(clipper2);return bounds.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:bounds;}else{let minX=Number.POSITIVE_INFINITY,minY=Number.POSITIVE_INFINITY,maxX=Number.NEGATIVE_INFINITY,maxY=Number.NEGATIVE_INFINITY;animationState.clearTracks();animationState.setAnimationWith(0,animation,false);const steps=Math.max(animation.duration/this.timeStep,1);for(let i=0;i<steps;i++){const delta=i>0?this.timeStep:0;animationState.update(delta);animationState.apply(skeleton);skeleton.update(delta);skeleton.updateWorldTransform(Physics.update);const bounds2=skeleton.getBoundsRect(clipper2);minX=Math.min(minX,bounds2.x);minY=Math.min(minY,bounds2.y);maxX=Math.max(maxX,bounds2.x+bounds2.width);maxY=Math.max(maxY,bounds2.y+bounds2.height);}const bounds={x:minX,y:minY,width:maxX-minX,height:maxY-minY};return bounds.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:bounds;}}};var maskPool=new Pool(()=>new pixi_js.Graphics());var _Spine$=class Spine$2 extends pixi_js.ViewContainer{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&&!this._autoUpdate){this._ticker.add(this.internalUpdate,this);}else if(!value&&this._autoUpdate){this._ticker.remove(this.internalUpdate,this);}this._autoUpdate=value;}get ticker(){return this._ticker;}set ticker(value){value=value??pixi_js.Ticker.shared;if(this._ticker===value)return;if(this._autoUpdate){this._ticker.remove(this.internalUpdate,this);value.add(this.internalUpdate,this);}this._ticker=value;}get boundsProvider(){return this._boundsProvider;}set boundsProvider(value){this._boundsProvider=value;if(value){this._boundsDirty=false;}this.updateBounds();}constructor(options){var _options,_options2,_options3,_options4;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.skeleton=void 0;this.state=void 0;this.skeletonBounds=void 0;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=false;this._ticker=pixi_js.Ticker.shared;this._boundsProvider=void 0;this.hasNeverUpdated=true;this.currentClippingSlot=void 0;this.allowChildren=true;const skeletonData=options instanceof SkeletonData?options:options.skeletonData;this.skeleton=new Skeleton(skeletonData);this.state=new AnimationState(new AnimationStateData(skeletonData));if((_options=options)!==null&&_options!==void 0&&_options.ticker)this._ticker=options.ticker;this.autoUpdate=((_options2=options)===null||_options2===void 0?void 0:_options2.autoUpdate)??true;this.darkTint=((_options3=options)===null||_options3===void 0?void 0:_options3.darkTint)===void 0?this.skeleton.slots.some(slot=>!!slot.data.darkColor):(_options4=options)===null||_options4===void 0?void 0:_options4.darkTint;const slots=this.skeleton.slots;for(let i=0;i<slots.length;i++){this.attachmentCacheData[i]=Object.create(null);}this._boundsProvider=options.boundsProvider;}update(dt){this.internalUpdate(0,dt);}internalUpdate(_deltaFrame,deltaSeconds){this._updateAndApplyState(deltaSeconds??this._ticker.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(Physics.update);this.afterUpdateWorldTransforms(this);this.updateSlotObjects();this._stateChanged=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){const attachment=slot.attachment;if(attachment&&attachment instanceof _ClippingAttachment){const clip=this.clippingSlotToPixiMasks[slot.data.name]||={slot,vertices:new Array()};clip.maskComputed=false;this.currentClippingSlot=clip;return;}let currentClippingSlot=this.currentClippingSlot;let slotObject=this._slotsObject[slot.data.name];if(currentClippingSlot&&slotObject){let mask=currentClippingSlot.mask;if(!mask){mask=maskPool.obtain();currentClippingSlot.mask=mask;this.addChild(mask);}if(!currentClippingSlot.maskComputed){let slotClipping=currentClippingSlot.slot;let clippingAttachment=slotClipping.attachment;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&&slotObject!==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;}}this.currentClippingSlot=void 0;}}transformAttachments(){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;const alpha=skeletonColor.a*slotColor.a*attachmentColor.a;cacheData.color.set(skeletonColor.r*slotColor.r*attachmentColor.r,skeletonColor.g*slotColor.g*attachmentColor.g,skeletonColor.b*slotColor.b*attachmentColor.b,alpha);if(this.alpha===0||alpha===0){if(!cacheData.skipRender)this.spineAttachmentsDirty=true;cacheData.skipRender=true;}else{var _attachment$region;if(cacheData.skipRender)this.spineAttachmentsDirty=true;cacheData.skipRender=cacheData.clipped=false;if(slot.darkColor){cacheData.darkColor.setFromColor(slot.darkColor);}const texture=((_attachment$region=attachment.region)===null||_attachment$region===void 0?void 0:_attachment$region.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;const followAttachmentValue=slotAttachment.followAttachmentTimeline?Boolean(slot.attachment):true;container.visible=this.skeleton.drawOrder.includes(slot)&&followAttachmentValue;if(container.visible){let bone=slot.bone;const matrix=container.localTransform;matrix.a=bone.a;matrix.b=bone.c;matrix.c=-bone.b;matrix.d=-bone.d;matrix.tx=bone.worldX;matrix.ty=bone.worldY;container.setFromMatrix(matrix);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){let vertices;if(attachment instanceof RegionAttachment){var _attachment$region2;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:(_attachment$region2=attachment.region)===null||_attachment$region2===void 0?void 0:_attachment$region2.texture.texture};}else{var _attachment$region3;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:(_attachment$region3=attachment.region)===null||_attachment$region3===void 0?void 0:_attachment$region3.texture.texture};}return this.attachmentCacheData[slot.data.index][attachment.name];}onViewUpdate(){var _this$debug;this._didViewChangeTick++;if(!this._boundsProvider){this._boundsDirty=true;}if(this.didViewUpdate)return;this.didViewUpdate=true;const renderGroup=this.renderGroup||this.parentRenderGroup;if(renderGroup){renderGroup.onChildViewUpdate(this);}(_this$debug=this.debug)===null||_this$debug===void 0?void 0:_this$debug.renderDebug(this);}addSlotObject(slot,container,options){slot=this.getSlotFromRef(slot);for(const i in this._slotsObject){var _this$_slotsObject$i;if(((_this$_slotsObject$i=this._slotsObject[i])===null||_this$_slotsObject$i===void 0?void 0:_this$_slotsObject$i.container)===container){this.removeSlotObject(this._slotsObject[i].slot);}}this.removeSlotObject(slot);container.includeInBuild=false;this.addChild(container);const slotObject={container,slot,followAttachmentTimeline:(options===null||options===void 0?void 0:options.followAttachmentTimeline)||false};this._slotsObject[slot.data.name]=slotObject;this.updateSlotObject(slotObject);}removeSlotObject(slotOrContainer){let containerToRemove;if(slotOrContainer instanceof pixi_js.Container){for(const i in this._slotsObject){var _this$_slotsObject$i2;if(((_this$_slotsObject$i2=this._slotsObject[i])===null||_this$_slotsObject$i2===void 0?void 0:_this$_slotsObject$i2.container)===slotOrContainer){this._slotsObject[i]=null;containerToRemove=slotOrContainer;break;}}}else{var _this$_slotsObject$sl;const slot=this.getSlotFromRef(slotOrContainer);containerToRemove=(_this$_slotsObject$sl=this._slotsObject[slot.data.name])===null||_this$_slotsObject$sl===void 0?void 0:_this$_slotsObject$sl.container;this._slotsObject[slot.data.name]=null;}if(containerToRemove){this.removeChild(containerToRemove);containerToRemove.includeInBuild=true;}}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([slotName,slotObject])=>{if(slotObject)slotObject.container.removeFromParent();delete this._slotsObject[slotName];});}getSlotObject(slot){var _this$_slotsObject$sl2;slot=this.getSlotFromRef(slot);return(_this$_slotsObject$sl2=this._slotsObject[slot.data.name])===null||_this$_slotsObject$sl2===void 0?void 0:_this$_slotsObject$sl2.container;}updateBounds(){this._boundsDirty=false;this.skeletonBounds||=new SkeletonBounds();const skeletonBounds=this.skeletonBounds;skeletonBounds.update(this.skeleton,true);if(this._boundsProvider){const boundsSpine=this._boundsProvider.calculateBounds(this);const bounds=this._bounds;bounds.clear();bounds.x=boundsSpine.x;bounds.y=boundsSpine.y;bounds.width=boundsSpine.width;bounds.height=boundsSpine.height;}else 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);this._ticker.remove(this.internalUpdate,this);this._ticker=null;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,boundsProvider,ticker}){const cacheKey=`${skeleton}-${atlas}-${scale}`;if(pixi_js.Cache.has(cacheKey)){return new _Spine$({skeletonData:pixi_js.Cache.get(cacheKey),darkTint,autoUpdate,boundsProvider,ticker});}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);pixi_js.Cache.set(cacheKey,skeletonData);return new _Spine$({skeletonData,darkTint,autoUpdate,boundsProvider,ticker});}};var SpineDebugRenderer=class SpineDebugRenderer{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={AABBRectangleBoundsProvider,AlphaTimeline,Animation,AnimationState,AnimationStateAdapter,AnimationStateData,AssetManagerBase,AtlasAttachmentLoader,Attachment,AttachmentTimeline,BinaryInput,BlendMode,Bone,BoneData,BoundingBoxAttachment:_BoundingBoxAttachment,CURRENT,ClippingAttachment:_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:_MeshAttachment,MixBlend,MixDirection,PathAttachment:_PathAttachment,PathConstraint,PathConstraintData,PathConstraintMixTimeline,PathConstraintPositionTimeline,PathConstraintSpacingTimeline,Physics,PhysicsConstraintDampingTimeline,PhysicsConstraintGravityTimeline,PhysicsConstraintInertiaTimeline,PhysicsConstraintMassTimeline,PhysicsConstraintMixTimeline,PhysicsConstraintResetTimeline,PhysicsConstraintStrengthTimeline,PhysicsConstraintTimeline,PhysicsConstraintWindTimeline,PointAttachment:_PointAttachment,Pool,PositionMode,Pow,PowOut,RGB2Timeline,RGBA2Timeline,RGBATimeline,RGBTimeline,RegionAttachment,RotateMode,RotateTimeline,SETUP,SUBSEQUENT,ScaleTimeline,ScaleXTimeline,ScaleYTimeline,SequenceTimeline,SetupPoseBoundsProvider,ShearTimeline,ShearXTimeline,ShearYTimeline,Skeleton,SkeletonBinary,SkeletonBounds,SkeletonClipping:_SkeletonClipping,SkeletonData,SkeletonJson,Skin,SkinEntry,SkinsAndAnimationBoundsProvider,Slot,SlotData,SpacingMode,Spine:_Spine$,SpineDebugRenderer,SpinePipe,SpineTexture,StringSet,Texture,TextureAtlas,TextureAtlasPage,TextureAtlasRegion,TextureFilter,TextureRegion,TextureWrap,TimeKeeper,Timeline,TrackEntry,TransformConstraint,TransformConstraintData,TransformConstraintTimeline,TranslateTimeline,TranslateXTimeline,TranslateYTimeline,Triangulator:_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.keepResource=false;this._slotGameObjects=new Map();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);}addSlotObject(slot,gameObject,options){if(!this.armature){console.warn('Spine armature is not ready, cannot addSlotObject');return;}if(!this._containerManager){console.warn('ContainerManager is not available');return;}const container=this._containerManager.getContainer(gameObject.id);if(!container){console.warn('GameObject does not have a render container');return;}this.armature.addSlotObject(slot,container,options);this._slotGameObjects.set(gameObject,slot);}removeSlotObject(gameObject){if(!this.armature)return;if(!this._containerManager)return;const container=this._containerManager.getContainer(gameObject.id);if(container){this.armature.removeSlotObject(container);}this._slotGameObjects.delete(gameObject);}_destroySlotGameObjects(){var _a;for(const[gameObject]of this._slotGameObjects){if(!gameObject.destroyed){const container=(_a=this._containerManager)===null||_a===void 0?void 0:_a.getContainer(gameObject.id);if(container&&this.armature){this.armature.removeSlotObject(container);}gameObject.destroy();}}this._slotGameObjects.clear();}}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);__decorate([type('boolean')],Spine$1.prototype,"keepResource",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){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,_c;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._containerManager=(_c=this.renderSystem)===null||_c===void 0?void 0:_c.containerManager;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._destroySlotGameObjects();component.armature.destroy({children:true});if(!component.keepResource){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;
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 _DarkTintBatcher2=class _DarkTintBatcher extends pixi_js.Batcher{constructor(...args){super(...args);this.geometry=new DarkTintBatchGeometry();this.shader=defaultShader||(defaultShader=new DarkTintShader(this.maxTextures));this.name=_DarkTintBatcher2.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=_DarkTintBatcher2;__publicField(DarkTintBatcher,"extension",{type:[pixi_js.ExtensionType.Batcher],name:"darkTint"});pixi_js.extensions.add(DarkTintBatcher);var worldVertices=Utils.newFloatArray(8);var _SkeletonRenderer2=class _SkeletonRenderer{constructor(context){this.ctx=void 0;this.triangleRendering=false;this.debugRendering=false;this.vertices=Utils.newFloatArray(8*1024);this.tempColor=new Color();this.ctx=context;}draw(skeleton){if(this.triangleRendering)this.drawTriangles(skeleton);else this.drawImages(skeleton);}drawImages(skeleton){let ctx=this.ctx;let color=this.tempColor;let skeletonColor=skeleton.color;let drawOrder=skeleton.drawOrder;if(this.debugRendering)ctx.strokeStyle="green";for(let i=0,n=drawOrder.length;i<n;i++){let slot=drawOrder[i];let bone=slot.bone;if(!bone.active)continue;let attachment=slot.getAttachment();if(!(attachment instanceof RegionAttachment))continue;attachment.computeWorldVertices(slot,worldVertices,0,2);let region=attachment.region;let image=region.texture.getImage();let slotColor=slot.color;let regionColor=attachment.color;color.set(skeletonColor.r*slotColor.r*regionColor.r,skeletonColor.g*slotColor.g*regionColor.g,skeletonColor.b*slotColor.b*regionColor.b,skeletonColor.a*slotColor.a*regionColor.a);ctx.save();ctx.transform(bone.a,bone.c,bone.b,bone.d,bone.worldX,bone.worldY);ctx.translate(attachment.offset[0],attachment.offset[1]);ctx.rotate(attachment.rotation*Math.PI/180);let atlasScale=attachment.width/region.originalWidth;ctx.scale(atlasScale*attachment.scaleX,atlasScale*attachment.scaleY);let w=region.width,h=region.height;ctx.translate(w/2,h/2);if(attachment.region.degrees==90){let t=w;w=h;h=t;ctx.rotate(-Math.PI/2);}ctx.scale(1,-1);ctx.translate(-w/2,-h/2);ctx.globalAlpha=color.a;ctx.drawImage(image,image.width*region.u,image.height*region.v,w,h,0,0,w,h);if(this.debugRendering)ctx.strokeRect(0,0,w,h);ctx.restore();}}drawTriangles(skeleton){let ctx=this.ctx;let color=this.tempColor;let skeletonColor=skeleton.color;let drawOrder=skeleton.drawOrder;let blendMode=null;let vertices=this.vertices;let triangles=null;for(let i=0,n=drawOrder.length;i<n;i++){let slot=drawOrder[i];let attachment=slot.getAttachment();let texture;if(attachment instanceof RegionAttachment){let regionAttachment=attachment;vertices=this.computeRegionVertices(slot,regionAttachment,false);triangles=_SkeletonRenderer2.QUAD_TRIANGLES;texture=regionAttachment.region.texture.getImage();}else if(attachment instanceof _MeshAttachment){let mesh=attachment;vertices=this.computeMeshVertices(slot,mesh,false);triangles=mesh.triangles;texture=mesh.region.texture.getImage();}else continue;if(texture){if(slot.data.blendMode!=blendMode)blendMode=slot.data.blendMode;let slotColor=slot.color;let attachmentColor=attachment.color;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);ctx.globalAlpha=color.a;for(var j=0;j<triangles.length;j+=3){let t1=triangles[j]*8,t2=triangles[j+1]*8,t3=triangles[j+2]*8;let x0=vertices[t1],y0=vertices[t1+1],u0=vertices[t1+6],v0=vertices[t1+7];let x1=vertices[t2],y1=vertices[t2+1],u1=vertices[t2+6],v1=vertices[t2+7];let x2=vertices[t3],y2=vertices[t3+1],u2=vertices[t3+6],v2=vertices[t3+7];this.drawTriangle(texture,x0,y0,u0,v0,x1,y1,u1,v1,x2,y2,u2,v2);if(this.debugRendering){ctx.strokeStyle="green";ctx.beginPath();ctx.moveTo(x0,y0);ctx.lineTo(x1,y1);ctx.lineTo(x2,y2);ctx.lineTo(x0,y0);ctx.stroke();}}}}this.ctx.globalAlpha=1;}drawTriangle(img,x0,y0,u0,v0,x1,y1,u1,v1,x2,y2,u2,v2){let ctx=this.ctx;const width=img.width-1;const height=img.height-1;u0*=width;v0*=height;u1*=width;v1*=height;u2*=width;v2*=height;ctx.beginPath();ctx.moveTo(x0,y0);ctx.lineTo(x1,y1);ctx.lineTo(x2,y2);ctx.closePath();x1-=x0;y1-=y0;x2-=x0;y2-=y0;u1-=u0;v1-=v0;u2-=u0;v2-=v0;let det=u1*v2-u2*v1;if(det==0)return;det=1/det;const a=(v2*x1-v1*x2)*det;const b=(v2*y1-v1*y2)*det;const c=(u1*x2-u2*x1)*det;const d=(u1*y2-u2*y1)*det;const e=x0-a*u0-c*v0;const f=y0-b*u0-d*v0;ctx.save();ctx.transform(a,b,c,d,e,f);ctx.clip();ctx.drawImage(img,0,0);ctx.restore();}computeRegionVertices(slot,region,pma){let skeletonColor=slot.bone.skeleton.color;let slotColor=slot.color;let regionColor=region.color;let alpha=skeletonColor.a*slotColor.a*regionColor.a;let multiplier=pma?alpha:1;let color=this.tempColor;color.set(skeletonColor.r*slotColor.r*regionColor.r*multiplier,skeletonColor.g*slotColor.g*regionColor.g*multiplier,skeletonColor.b*slotColor.b*regionColor.b*multiplier,alpha);region.computeWorldVertices(slot,this.vertices,0,_SkeletonRenderer2.VERTEX_SIZE);let vertices=this.vertices;let uvs=region.uvs;vertices[RegionAttachment.C1R]=color.r;vertices[RegionAttachment.C1G]=color.g;vertices[RegionAttachment.C1B]=color.b;vertices[RegionAttachment.C1A]=color.a;vertices[RegionAttachment.U1]=uvs[0];vertices[RegionAttachment.V1]=uvs[1];vertices[RegionAttachment.C2R]=color.r;vertices[RegionAttachment.C2G]=color.g;vertices[RegionAttachment.C2B]=color.b;vertices[RegionAttachment.C2A]=color.a;vertices[RegionAttachment.U2]=uvs[2];vertices[RegionAttachment.V2]=uvs[3];vertices[RegionAttachment.C3R]=color.r;vertices[RegionAttachment.C3G]=color.g;vertices[RegionAttachment.C3B]=color.b;vertices[RegionAttachment.C3A]=color.a;vertices[RegionAttachment.U3]=uvs[4];vertices[RegionAttachment.V3]=uvs[5];vertices[RegionAttachment.C4R]=color.r;vertices[RegionAttachment.C4G]=color.g;vertices[RegionAttachment.C4B]=color.b;vertices[RegionAttachment.C4A]=color.a;vertices[RegionAttachment.U4]=uvs[6];vertices[RegionAttachment.V4]=uvs[7];return vertices;}computeMeshVertices(slot,mesh,pma){let skeletonColor=slot.bone.skeleton.color;let slotColor=slot.color;let regionColor=mesh.color;let alpha=skeletonColor.a*slotColor.a*regionColor.a;let multiplier=pma?alpha:1;let color=this.tempColor;color.set(skeletonColor.r*slotColor.r*regionColor.r*multiplier,skeletonColor.g*slotColor.g*regionColor.g*multiplier,skeletonColor.b*slotColor.b*regionColor.b*multiplier,alpha);let vertexCount=mesh.worldVerticesLength/2;let vertices=this.vertices;if(vertices.length<mesh.worldVerticesLength)this.vertices=vertices=Utils.newFloatArray(mesh.worldVerticesLength);mesh.computeWorldVertices(slot,0,mesh.worldVerticesLength,vertices,0,_SkeletonRenderer2.VERTEX_SIZE);let uvs=mesh.uvs;for(let i=0,u=0,v=2;i<vertexCount;i++){vertices[v++]=color.r;vertices[v++]=color.g;vertices[v++]=color.b;vertices[v++]=color.a;vertices[v++]=uvs[u++];vertices[v++]=uvs[u++];v+=2;}return vertices;}};var SkeletonRenderer=_SkeletonRenderer2;__publicField(SkeletonRenderer,"QUAD_TRIANGLES",[0,1,2,2,3,0]);__publicField(SkeletonRenderer,"VERTEX_SIZE",2+2+4);var BatchableSpineSlot=class BatchableSpineSlot{constructor(){this.indexOffset=0;this.attributeOffset=0;this.indexSize=void 0;this.attributeSize=void 0;this.batcherName="darkTint";this.topology="triangle-list";this.packAsQuad=false;this.renderable=void 0;this.positions=void 0;this.indices=void 0;this.uvs=void 0;this.roundPixels=void 0;this.data=void 0;this.blendMode=void 0;this.darkTint=void 0;this.texture=void 0;this.transform=void 0;this._textureId=void 0;this._attributeStart=void 0;this._indexStart=void 0;this._batcher=void 0;this._batch=void 0;}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 SpinePipe{constructor(renderer){this.renderer=void 0;this.canvasSkeletonRenderer=void 0;this.gpuSpineData={};this._destroyRenderableBound=this.destroyRenderable.bind(this);this.renderer=renderer;}validateRenderable(spine){if(this.renderer.type===pixi_js.RendererType.CANVAS){return true;}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===null||batchableSpineSlot===void 0?void 0:batchableSpineSlot.texture)){if(!(batchableSpineSlot!==null&&batchableSpineSlot!==void 0&&batchableSpineSlot._batcher.checkAndUpdateTexture(batchableSpineSlot,texture))){return true;}}}}}return false;}execute(spine){if(this.renderer.type===pixi_js.RendererType.CANVAS){const renderer=this.renderer;const groupAlpha=(spine.groupColorAlpha>>>24&255)/255;const contextSystem=renderer.canvasContext;const context=contextSystem.activeContext;context.save();if(!this.canvasSkeletonRenderer){this.canvasSkeletonRenderer=new SkeletonRenderer(context);this.canvasSkeletonRenderer.triangleRendering=true;}contextSystem.setContextTransform(spine.groupTransform,(renderer._roundPixels|spine._roundPixels)===1);const oldAlpha=spine.skeleton.color.a;spine.skeleton.color.a*=groupAlpha;this.canvasSkeletonRenderer.draw(spine.skeleton);spine.skeleton.color.a=oldAlpha;context.restore();}}addRenderable(spine,instructionSet){if(this.renderer.type===pixi_js.RendererType.CANVAS){this.renderer.renderPipes.batch.break(instructionSet);instructionSet.add(spine);return;}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();spine.spineAttachmentsDirty=false;spine.spineTexturesDirty=false;for(let i=0,n=drawOrder.length;i<n;i++){const slot=drawOrder[i];const attachment=slot.getAttachment();const blendMode=spineBlendModeMap[slot.data.blendMode];let skipRender=false;if(attachment instanceof RegionAttachment||attachment instanceof _MeshAttachment){const cacheData=spine._getCachedData(slot,attachment);const batchableSpineSlot=gpuSpine.slotBatches[cacheData.id]||=new BatchableSpineSlot();batchableSpineSlot.setData(spine,cacheData,blendMode,roundPixels);skipRender=cacheData.skipRender;if(!skipRender){batcher.addToBatch(batchableSpineSlot,instructionSet);}}const containerAttachment=spine._slotsObject[slot.data.name];if(containerAttachment){const container=containerAttachment.container;if(!skipRender){container.includeInBuild=true;container.collectRenderables(instructionSet,this.renderer,null);}container.includeInBuild=false;}}}updateRenderable(spine){const gpuSpine=this.gpuSpineData[spine.uid];spine._validateAndTransformAttachments();spine.spineAttachmentsDirty=false;spine.spineTexturesDirty=false;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){var _batchableSpineSlot$_;const batchableSpineSlot=gpuSpine.slotBatches[cacheData.id];batchableSpineSlot===null||batchableSpineSlot===void 0?void 0:(_batchableSpineSlot$_=batchableSpineSlot._batcher)===null||_batchableSpineSlot$_===void 0?void 0:_batchableSpineSlot$_.updateElement(batchableSpineSlot);}}}}destroyRenderable(spine){this.gpuSpineData[spine.uid]=null;spine.off("destroyed",this._destroyRenderableBound);}destroy(){this.gpuSpineData=null;this.renderer=null;this.canvasSkeletonRenderer=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];}};__publicField(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 AABBRectangleBoundsProvider=class{constructor(x,y,width,height){this.x=x;this.y=y;this.width=width;this.height=height;}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height};}};var SetupPoseBoundsProvider=class{constructor(clipping=false){this.clipping=clipping;}calculateBounds(gameObject){if(!gameObject.skeleton)return{x:0,y:0,width:0,height:0};const skeleton=new Skeleton(gameObject.skeleton.data);skeleton.setToSetupPose();skeleton.updateWorldTransform(Physics.update);const bounds=skeleton.getBoundsRect(this.clipping?new _SkeletonClipping():void 0);return bounds.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:bounds;}};var SkinsAndAnimationBoundsProvider=class{constructor(animation,skins=[],timeStep=0.05,clipping=false){this.animation=animation;this.skins=skins;this.timeStep=timeStep;this.clipping=clipping;}calculateBounds(gameObject){if(!gameObject.skeleton||!gameObject.state)return{x:0,y:0,width:0,height:0};const animationState=new AnimationState(gameObject.state.data);const skeleton=new Skeleton(gameObject.skeleton.data);const clipper2=this.clipping?new _SkeletonClipping():void 0;const data=skeleton.data;if(this.skins.length>0){let customSkin=new Skin("custom-skin");for(const skinName of this.skins){const skin=data.findSkin(skinName);if(skin==null)continue;customSkin.addSkin(skin);}skeleton.setSkin(customSkin);}skeleton.setToSetupPose();const animation=this.animation!=null?data.findAnimation(this.animation):null;if(animation==null){skeleton.updateWorldTransform(Physics.update);const bounds=skeleton.getBoundsRect(clipper2);return bounds.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:bounds;}else{let minX=Number.POSITIVE_INFINITY,minY=Number.POSITIVE_INFINITY,maxX=Number.NEGATIVE_INFINITY,maxY=Number.NEGATIVE_INFINITY;animationState.clearTracks();animationState.setAnimationWith(0,animation,false);const steps=Math.max(animation.duration/this.timeStep,1);for(let i=0;i<steps;i++){const delta=i>0?this.timeStep:0;animationState.update(delta);animationState.apply(skeleton);skeleton.update(delta);skeleton.updateWorldTransform(Physics.update);const bounds2=skeleton.getBoundsRect(clipper2);minX=Math.min(minX,bounds2.x);minY=Math.min(minY,bounds2.y);maxX=Math.max(maxX,bounds2.x+bounds2.width);maxY=Math.max(maxY,bounds2.y+bounds2.height);}const bounds={x:minX,y:minY,width:maxX-minX,height:maxY-minY};return bounds.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:bounds;}}};var maskPool=new Pool(()=>new pixi_js.Graphics());var _Spine$=class Spine$2 extends pixi_js.ViewContainer{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&&!this._autoUpdate){this._ticker.add(this.internalUpdate,this);}else if(!value&&this._autoUpdate){this._ticker.remove(this.internalUpdate,this);}this._autoUpdate=value;}get ticker(){return this._ticker;}set ticker(value){value=value??pixi_js.Ticker.shared;if(this._ticker===value)return;if(this._autoUpdate){this._ticker.remove(this.internalUpdate,this);value.add(this.internalUpdate,this);}this._ticker=value;}get boundsProvider(){return this._boundsProvider;}set boundsProvider(value){this._boundsProvider=value;if(value){this._boundsDirty=false;}this.updateBounds();}constructor(options){var _options,_options2,_options3,_options4;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.skeleton=void 0;this.state=void 0;this.skeletonBounds=void 0;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=false;this._ticker=pixi_js.Ticker.shared;this._boundsProvider=void 0;this.hasNeverUpdated=true;this.currentClippingSlot=void 0;this.allowChildren=true;const skeletonData=options instanceof SkeletonData?options:options.skeletonData;this.skeleton=new Skeleton(skeletonData);this.state=new AnimationState(new AnimationStateData(skeletonData));if((_options=options)!==null&&_options!==void 0&&_options.ticker)this._ticker=options.ticker;this.autoUpdate=((_options2=options)===null||_options2===void 0?void 0:_options2.autoUpdate)??true;this.darkTint=((_options3=options)===null||_options3===void 0?void 0:_options3.darkTint)===void 0?this.skeleton.slots.some(slot=>!!slot.data.darkColor):(_options4=options)===null||_options4===void 0?void 0:_options4.darkTint;const slots=this.skeleton.slots;for(let i=0;i<slots.length;i++){this.attachmentCacheData[i]=Object.create(null);}this._boundsProvider=options.boundsProvider;}update(dt){this.internalUpdate(0,dt);}internalUpdate(_deltaFrame,deltaSeconds){this._updateAndApplyState(deltaSeconds??this._ticker.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(Physics.update);this.afterUpdateWorldTransforms(this);this.updateSlotObjects();this._stateChanged=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){const attachment=slot.attachment;if(attachment&&attachment instanceof _ClippingAttachment){const clip=this.clippingSlotToPixiMasks[slot.data.name]||={slot,vertices:new Array()};clip.maskComputed=false;this.currentClippingSlot=clip;return;}let currentClippingSlot=this.currentClippingSlot;let slotObject=this._slotsObject[slot.data.name];if(currentClippingSlot&&slotObject){let mask=currentClippingSlot.mask;if(!mask){mask=maskPool.obtain();currentClippingSlot.mask=mask;this.addChild(mask);}if(!currentClippingSlot.maskComputed){let slotClipping=currentClippingSlot.slot;let clippingAttachment=slotClipping.attachment;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&&slotObject!==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;}}this.currentClippingSlot=void 0;}}transformAttachments(){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;const alpha=skeletonColor.a*slotColor.a*attachmentColor.a;cacheData.color.set(skeletonColor.r*slotColor.r*attachmentColor.r,skeletonColor.g*slotColor.g*attachmentColor.g,skeletonColor.b*slotColor.b*attachmentColor.b,alpha);if(this.alpha===0||alpha===0){if(!cacheData.skipRender)this.spineAttachmentsDirty=true;cacheData.skipRender=true;}else{var _attachment$region;if(cacheData.skipRender)this.spineAttachmentsDirty=true;cacheData.skipRender=cacheData.clipped=false;if(slot.darkColor){cacheData.darkColor.setFromColor(slot.darkColor);}const texture=((_attachment$region=attachment.region)===null||_attachment$region===void 0?void 0:_attachment$region.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;const followAttachmentValue=slotAttachment.followAttachmentTimeline?Boolean(slot.attachment):true;container.visible=this.skeleton.drawOrder.includes(slot)&&followAttachmentValue;if(container.visible){let bone=slot.bone;const matrix=container.localTransform;matrix.a=bone.a;matrix.b=bone.c;matrix.c=-bone.b;matrix.d=-bone.d;matrix.tx=bone.worldX;matrix.ty=bone.worldY;container.setFromMatrix(matrix);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){let vertices;if(attachment instanceof RegionAttachment){var _attachment$region2;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:(_attachment$region2=attachment.region)===null||_attachment$region2===void 0?void 0:_attachment$region2.texture.texture};}else{var _attachment$region3;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:(_attachment$region3=attachment.region)===null||_attachment$region3===void 0?void 0:_attachment$region3.texture.texture};}return this.attachmentCacheData[slot.data.index][attachment.name];}onViewUpdate(){var _this$debug;this._didViewChangeTick++;if(!this._boundsProvider){this._boundsDirty=true;}if(this.didViewUpdate)return;this.didViewUpdate=true;const renderGroup=this.renderGroup||this.parentRenderGroup;if(renderGroup){renderGroup.onChildViewUpdate(this);}(_this$debug=this.debug)===null||_this$debug===void 0?void 0:_this$debug.renderDebug(this);}addSlotObject(slot,container,options){slot=this.getSlotFromRef(slot);for(const i in this._slotsObject){var _this$_slotsObject$i;if(((_this$_slotsObject$i=this._slotsObject[i])===null||_this$_slotsObject$i===void 0?void 0:_this$_slotsObject$i.container)===container){this.removeSlotObject(this._slotsObject[i].slot);}}this.removeSlotObject(slot);container.includeInBuild=false;this.addChild(container);const slotObject={container,slot,followAttachmentTimeline:(options===null||options===void 0?void 0:options.followAttachmentTimeline)||false};this._slotsObject[slot.data.name]=slotObject;this.updateSlotObject(slotObject);}removeSlotObject(slotOrContainer){let containerToRemove;if(slotOrContainer instanceof pixi_js.Container){for(const i in this._slotsObject){var _this$_slotsObject$i2;if(((_this$_slotsObject$i2=this._slotsObject[i])===null||_this$_slotsObject$i2===void 0?void 0:_this$_slotsObject$i2.container)===slotOrContainer){this._slotsObject[i]=null;containerToRemove=slotOrContainer;break;}}}else{var _this$_slotsObject$sl;const slot=this.getSlotFromRef(slotOrContainer);containerToRemove=(_this$_slotsObject$sl=this._slotsObject[slot.data.name])===null||_this$_slotsObject$sl===void 0?void 0:_this$_slotsObject$sl.container;this._slotsObject[slot.data.name]=null;}if(containerToRemove){this.removeChild(containerToRemove);containerToRemove.includeInBuild=true;}}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([slotName,slotObject])=>{if(slotObject)slotObject.container.removeFromParent();delete this._slotsObject[slotName];});}getSlotObject(slot){var _this$_slotsObject$sl2;slot=this.getSlotFromRef(slot);return(_this$_slotsObject$sl2=this._slotsObject[slot.data.name])===null||_this$_slotsObject$sl2===void 0?void 0:_this$_slotsObject$sl2.container;}updateBounds(){this._boundsDirty=false;this.skeletonBounds||=new SkeletonBounds();const skeletonBounds=this.skeletonBounds;skeletonBounds.update(this.skeleton,true);if(this._boundsProvider){const boundsSpine=this._boundsProvider.calculateBounds(this);const bounds=this._bounds;bounds.clear();bounds.x=boundsSpine.x;bounds.y=boundsSpine.y;bounds.width=boundsSpine.width;bounds.height=boundsSpine.height;}else 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);this._ticker.remove(this.internalUpdate,this);this._ticker=null;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,boundsProvider,ticker}){const cacheKey=`${skeleton}-${atlas}-${scale}`;if(pixi_js.Cache.has(cacheKey)){return new _Spine$({skeletonData:pixi_js.Cache.get(cacheKey),darkTint,autoUpdate,boundsProvider,ticker});}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);pixi_js.Cache.set(cacheKey,skeletonData);return new _Spine$({skeletonData,darkTint,autoUpdate,boundsProvider,ticker});}};var SpineDebugRenderer=class SpineDebugRenderer{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={AABBRectangleBoundsProvider,AlphaTimeline,Animation,AnimationState,AnimationStateAdapter,AnimationStateData,AssetManagerBase,AtlasAttachmentLoader,Attachment,AttachmentTimeline,BinaryInput,BlendMode,Bone,BoneData,BoundingBoxAttachment:_BoundingBoxAttachment,CURRENT,ClippingAttachment:_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:_MeshAttachment,MixBlend,MixDirection,PathAttachment:_PathAttachment,PathConstraint,PathConstraintData,PathConstraintMixTimeline,PathConstraintPositionTimeline,PathConstraintSpacingTimeline,Physics,PhysicsConstraintDampingTimeline,PhysicsConstraintGravityTimeline,PhysicsConstraintInertiaTimeline,PhysicsConstraintMassTimeline,PhysicsConstraintMixTimeline,PhysicsConstraintResetTimeline,PhysicsConstraintStrengthTimeline,PhysicsConstraintTimeline,PhysicsConstraintWindTimeline,PointAttachment:_PointAttachment,Pool,PositionMode,Pow,PowOut,RGB2Timeline,RGBA2Timeline,RGBATimeline,RGBTimeline,RegionAttachment,RotateMode,RotateTimeline,SETUP,SUBSEQUENT,ScaleTimeline,ScaleXTimeline,ScaleYTimeline,SequenceTimeline,SetupPoseBoundsProvider,ShearTimeline,ShearXTimeline,ShearYTimeline,Skeleton,SkeletonBinary,SkeletonBounds,SkeletonClipping:_SkeletonClipping,SkeletonData,SkeletonJson,Skin,SkinEntry,SkinsAndAnimationBoundsProvider,Slot,SlotData,SpacingMode,Spine:_Spine$,SpineDebugRenderer,SpinePipe,SpineTexture,StringSet,Texture,TextureAtlas,TextureAtlasPage,TextureAtlasRegion,TextureFilter,TextureRegion,TextureWrap,TimeKeeper,Timeline,TrackEntry,TransformConstraint,TransformConstraintData,TransformConstraintTimeline,TranslateTimeline,TranslateXTimeline,TranslateYTimeline,Triangulator:_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.keepResource=false;this._slotGameObjects=new Map();this._pendingSlotObjects=[];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);}addSlotObject(slot,gameObject,options){if(!this.armature){console.warn('Spine armature is not ready, cannot addSlotObject');return;}if(!this._containerManager){console.warn('ContainerManager is not available');return;}const container=this._containerManager.getContainer(gameObject.id);if(!container){this._pendingSlotObjects.push({slot,gameObject,options});return;}this._doAddSlotObject(slot,gameObject,container,options);}_doAddSlotObject(slot,gameObject,container,options){const wrapper=new pixi_js.Container();wrapper.addChild(container);this.armature.addSlotObject(slot,wrapper,options);this._slotGameObjects.set(gameObject,{slot,wrapper});this._syncTransformTree(gameObject);}_syncTransformTree(gameObject){var _a;if(!this._containerManager)return;this._containerManager.updateTransform({name:gameObject.id,transform:gameObject.transform});if((_a=gameObject.transform)===null||_a===void 0?void 0:_a.children){for(const childTransform of gameObject.transform.children){if(childTransform.gameObject){this._syncTransformTree(childTransform.gameObject);}}}}_flushPendingSlotObjects(){if(this._pendingSlotObjects.length===0)return;if(!this.armature||!this._containerManager)return;const still=[];for(const pending of this._pendingSlotObjects){const container=this._containerManager.getContainer(pending.gameObject.id);if(container){this._doAddSlotObject(pending.slot,pending.gameObject,container,pending.options);}else{still.push(pending);}}this._pendingSlotObjects=still;}removeSlotObject(gameObject){this._pendingSlotObjects=this._pendingSlotObjects.filter(p=>p.gameObject!==gameObject);const entry=this._slotGameObjects.get(gameObject);if(entry&&this.armature){this.armature.removeSlotObject(entry.wrapper);entry.wrapper.destroy({children:false});}this._slotGameObjects.delete(gameObject);}_destroySlotGameObjects(){for(const[gameObject,entry]of this._slotGameObjects){if(!gameObject.destroyed){if(this.armature){this.armature.removeSlotObject(entry.wrapper);}entry.wrapper.destroy({children:false});gameObject.destroy();}}this._slotGameObjects.clear();this._pendingSlotObjects=[];}}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);__decorate([type('boolean')],Spine$1.prototype,"keepResource",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){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={};this._spineComponents={};}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);}for(let key in this._spineComponents){this._spineComponents[key]._flushPendingSlotObjects();}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,_c;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;this._spineComponents[changed.gameObject.id]=component;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._containerManager=(_c=this.renderSystem)===null||_c===void 0?void 0:_c.containerManager;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._destroySlotGameObjects();component.armature.destroy({children:true});if(!component.keepResource){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];delete this._spineComponents[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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eva/plugin-renderer-spine",
3
- "version": "2.0.1-beta.39",
3
+ "version": "2.0.1-beta.40",
4
4
  "description": "@eva/plugin-renderer-spine",
5
5
  "main": "index.js",
6
6
  "module": "dist/plugin-renderer-spine.esm.js",
@@ -19,9 +19,9 @@
19
19
  "homepage": "https://eva.js.org",
20
20
  "dependencies": {
21
21
  "@eva/inspector-decorator": "^0.0.5",
22
- "@eva/plugin-renderer": "2.0.1-beta.39",
23
- "@eva/eva.js": "2.0.1-beta.39",
24
- "@eva/spine-base": "2.0.1-beta.39",
22
+ "@eva/plugin-renderer": "2.0.1-beta.40",
23
+ "@eva/eva.js": "2.0.1-beta.40",
24
+ "@eva/spine-base": "2.0.1-beta.40",
25
25
  "pixi.js": "^8.17.0"
26
26
  }
27
27
  }