@esotericsoftware/spine-pixi-v8 4.2.87 → 4.2.88

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.
@@ -24,4 +24,4 @@
24
24
 
25
25
  finalColor.a = outColor.a * vColor.a;
26
26
  finalColor.rgb = ((outColor.a - 1.0) * vDarkColor.a + 1.0 - outColor.rgb) * vDarkColor.rgb + outColor.rgb * vColor.rgb;
27
- `}},gr=class extends gt.Shader{constructor(e){const t=(0,gt.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[gt.colorBitGl,mr,(0,gt.generateTextureBatchBitGl)(e),gt.roundPixelsBitGl]}),s=(0,gt.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[gt.colorBit,fr,(0,gt.generateTextureBatchBit)(e),gt.roundPixelsBit]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:(0,gt.getBatchSamplersUniformGroup)(e)}})}},Hs=null,pr=class hi extends Kt.Batcher{static extension={type:[Kt.ExtensionType.Batcher],name:"darkTint"};geometry=new ur;shader=Hs||(Hs=new gr(this.maxTextures));name=hi.extension.name;vertexSize=7;packAttributes(t,s,r,i,l){const o=l<<16|t.roundPixels&65535,n=t.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,{positions:f,uvs:p}=t,b=t.color,w=(b>>24&255)/255,g=Kt.Color.shared.setValue(t.darkColor).premultiply(w,!0).toPremultiplied(1,!1),x=t.attributeOffset,y=x+t.attributeSize;for(let v=x;v<y;v++){const C=v*2,S=f[C],k=f[C+1];s[i++]=a*S+c*k+d,s[i++]=u*k+h*S+m,s[i++]=p[C],s[i++]=p[C+1],r[i++]=b,r[i++]=g,r[i++]=o}}packQuadAttributes(t,s,r,i,l){const o=t.texture,n=t.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,f=t.bounds,p=f.maxX,b=f.minX,w=f.maxY,g=f.minY,x=o.uvs,y=t.color,v=t.darkColor,C=l<<16|t.roundPixels&65535;s[i+0]=a*b+c*g+d,s[i+1]=u*g+h*b+m,s[i+2]=x.x0,s[i+3]=x.y0,r[i+4]=y,r[i+5]=v,r[i+6]=C,s[i+7]=a*p+c*g+d,s[i+8]=u*g+h*p+m,s[i+9]=x.x1,s[i+10]=x.y1,r[i+11]=y,r[i+12]=v,r[i+13]=C,s[i+14]=a*p+c*w+d,s[i+15]=u*w+h*p+m,s[i+16]=x.x2,s[i+17]=x.y2,r[i+18]=y,r[i+19]=v,r[i+20]=C,s[i+21]=a*b+c*w+d,s[i+22]=u*w+h*b+m,s[i+23]=x.x3,s[i+24]=x.y3,r[i+25]=y,r[i+26]=v,r[i+27]=C}};Kt.extensions.add(pr);var Nt=pt("pixi.js"),xr=class{indexOffset=0;attributeOffset=0;indexSize;attributeSize;batcherName="darkTint";topology="triangle-list";packAsQuad=!1;renderable;positions;indices;uvs;roundPixels;data;blendMode;darkTint;texture;transform;_textureId;_attributeStart;_indexStart;_batcher;_batch;get color(){const e=this.data.color,t=this.renderable.groupColor,s=this.renderable.groupAlpha;let r;const i=e.a*s*255;if(t!==16777215){const l=t>>16&255,o=t>>8&255,n=t&255,a=e.r*n,h=e.g*o,c=e.b*l;r=i<<24|c<<16|h<<8|a}else r=i<<24|e.b*255<<16|e.g*255<<8|e.r*255;return r}get darkColor(){const e=this.data.darkColor;return e.b*255<<16|e.g*255<<8|e.r*255}get groupTransform(){return this.renderable.groupTransform}setData(e,t,s,r){if(this.renderable=e,this.transform=e.groupTransform,this.data=t,t.clipped){const i=t.clippedData;this.indexSize=i.indicesCount,this.attributeSize=i.vertexCount,this.positions=i.vertices,this.indices=i.indices,this.uvs=i.uvs}else this.indexSize=t.indices.length,this.attributeSize=t.vertices.length/2,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs;this.texture=t.texture,this.roundPixels=r,this.blendMode=s,this.batcherName=t.darkTint?"darkTint":"default"}},br={0:"normal",1:"add",2:"multiply",3:"screen"},$s=class{static extension={type:[Nt.ExtensionType.WebGLPipes,Nt.ExtensionType.WebGPUPipes,Nt.ExtensionType.CanvasPipes],name:"spine"};renderer;gpuSpineData={};_destroyRenderableBound=this.destroyRenderable.bind(this);constructor(e){this.renderer=e}validateRenderable(e){if(e._validateAndTransformAttachments(),e.spineAttachmentsDirty)return!0;if(e.spineTexturesDirty){const t=e.skeleton.drawOrder,s=this.gpuSpineData[e.uid];for(let r=0,i=t.length;r<i;r++){const l=t[r],o=l.getAttachment();if(o instanceof ot||o instanceof ut){const n=e._getCachedData(l,o),a=s.slotBatches[n.id],h=n.texture;if(h!==a.texture&&!a._batcher.checkAndUpdateTexture(a,h))return!0}}}return!1}addRenderable(e,t){const s=this._getSpineData(e),r=this.renderer.renderPipes.batch,i=e.skeleton.drawOrder,l=this.renderer._roundPixels|e._roundPixels;e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;for(let o=0,n=i.length;o<n;o++){const a=i[o],h=a.getAttachment(),c=br[a.data.blendMode];if(h instanceof ot||h instanceof ut){const d=e._getCachedData(a,h),m=s.slotBatches[d.id]||=new xr;m.setData(e,d,c,l),d.skipRender||r.addToBatch(m,t)}const u=e._slotsObject[a.data.name];if(u){const d=u.container;d.includeInBuild=!0,(0,Nt.collectAllRenderables)(d,t,this.renderer),d.includeInBuild=!1}}}updateRenderable(e){const t=this.gpuSpineData[e.uid];e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;const s=e.skeleton.drawOrder;for(let r=0,i=s.length;r<i;r++){const l=s[r],o=l.getAttachment();if((o instanceof ot||o instanceof ut)&&!e._getCachedData(l,o).skipRender){const a=t.slotBatches[e._getCachedData(l,o).id];a._batcher?.updateElement(a)}}}destroyRenderable(e){this.gpuSpineData[e.uid]=null,e.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(e){return this.gpuSpineData[e.uid]||this._initMeshData(e)}_initMeshData(e){return this.gpuSpineData[e.uid]={slotBatches:{}},e.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[e.uid]}};Nt.extensions.add($s);var it=pt("pixi.js"),Qt=new Et;Yt.yDown=!0;var Pt=new Jt,wr=class{constructor(e,t,s,r){this.x=e,this.y=t,this.width=s,this.height=r}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},yr=class{constructor(e=!1){this.clipping=e}calculateBounds(e){if(!e.skeleton)return{x:0,y:0,width:0,height:0};const t=new Yt(e.skeleton.data);t.setToSetupPose(),t.updateWorldTransform(2);const s=t.getBoundsRect(this.clipping?new Jt:void 0);return s.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},vr=class{constructor(e,t=[],s=.05,r=!1){this.animation=e,this.skins=t,this.timeStep=s,this.clipping=r}calculateBounds(e){if(!e.skeleton||!e.state)return{x:0,y:0,width:0,height:0};const t=new Ve(e.state.data),s=new Yt(e.skeleton.data),r=this.clipping?new Jt:void 0,i=s.data;if(this.skins.length>0){let o=new Vt("custom-skin");for(const n of this.skins){const a=i.findSkin(n);a!=null&&o.addSkin(a)}s.setSkin(o)}s.setToSetupPose();const l=this.animation!=null?i.findAnimation(this.animation):null;if(l==null){s.updateWorldTransform(2);const o=s.getBoundsRect(r);return o.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:o}else{let o=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;t.clearTracks(),t.setAnimationWith(0,l,!1);const c=Math.max(l.duration/this.timeStep,1);for(let d=0;d<c;d++){const m=d>0?this.timeStep:0;t.update(m),t.apply(s),s.update(m),s.updateWorldTransform(2);const f=s.getBoundsRect(r);o=Math.min(o,f.x),n=Math.min(n,f.y),a=Math.max(a,f.x+f.width),h=Math.max(h,f.y+f.height)}const u={x:o,y:n,width:a-o,height:h-n};return u.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:u}}},js=new Tt(()=>new it.Graphics),Cr=class gs extends it.ViewContainer{batched=!0;buildId=0;renderPipeId="spine";_didSpineUpdate=!1;beforeUpdateWorldTransforms=()=>{};afterUpdateWorldTransforms=()=>{};skeleton;state;skeletonBounds;darkTint=!1;_debug=void 0;_slotsObject=Object.create(null);clippingSlotToPixiMasks=Object.create(null);getSlotFromRef(t){let s;if(typeof t=="number"?s=this.skeleton.slots[t]:typeof t=="string"?s=this.skeleton.findSlot(t):s=t,!s)throw new Error(`No slot found with the given slot reference: ${t}`);return s}spineAttachmentsDirty=!0;spineTexturesDirty=!0;_lastAttachments=[];_stateChanged=!0;attachmentCacheData=[];get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}_autoUpdate=!0;get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t?it.Ticker.shared.add(this.internalUpdate,this):it.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=t}_boundsProvider;get boundsProvider(){return this._boundsProvider}set boundsProvider(t){this._boundsProvider=t,t&&(this._boundsDirty=!1),this.updateBounds()}hasNeverUpdated=!0;constructor(t){t instanceof Lt&&(t={skeletonData:t}),super({}),this.allowChildren=!0;const s=t instanceof Lt?t:t.skeletonData;this.skeleton=new Yt(s),this.state=new Ve(new Ys(s)),this.autoUpdate=t?.autoUpdate??!0,this.darkTint=t?.darkTint===void 0?this.skeleton.slots.some(i=>!!i.data.darkColor):t?.darkTint;const r=this.skeleton.slots;for(let i=0;i<r.length;i++)this.attachmentCacheData[i]=Object.create(null);this._boundsProvider=t.boundsProvider}update(t){this.internalUpdate(0,t)}internalUpdate(t,s){this._updateAndApplyState(s??it.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,s){const r=t;if(typeof t=="string"&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(r)} not found`);if(Qt.set(s.x,s.y),t.parent){const i=t.parent.worldToLocal(Qt);t.x=i.x,t.y=-i.y}else t.x=Qt.x,t.y=Qt.y}getBonePosition(t,s){const r=t;return typeof t=="string"&&(t=this.skeleton.findBone(t)),t?(s||(s={x:0,y:0}),s.x=t.worldX,s.y=t.worldY,s):(console.error(`Cant set bone position! Bone ${String(r)} not found`),s)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:s}=this;this.state.apply(s),this.beforeUpdateWorldTransforms(this),s.updateWorldTransform(2),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder,s=this._lastAttachments;let r=0,i=!1;for(let l=0;l<t.length;l++){const n=t[l].getAttachment();n&&(n!==s[r]&&(i=!0,s[r]=n),r++)}r!==s.length&&(i=!0,s.length=r),this.spineAttachmentsDirty||=i}currentClippingSlot;updateAndSetPixiMask(t,s){const r=t.attachment;if(r&&r instanceof St){const o=this.clippingSlotToPixiMasks[t.data.name]||={slot:t,vertices:new Array};o.maskComputed=!1,this.currentClippingSlot=o;return}let i=this.currentClippingSlot,l=this._slotsObject[t.data.name];if(i&&l){let o=i.mask;if(o||(o=js.obtain(),i.mask=o,this.addChild(o)),!i.maskComputed){let n=i.slot,a=n.attachment;i.maskComputed=!0;const h=a.worldVerticesLength,c=i.vertices;a.computeWorldVertices(n,0,h,c,0,2),o.clear().poly(c).stroke({width:0}).fill({alpha:.25})}l.container.mask=o}else l?.container.mask&&(l.container.mask=null);if(i&&i.slot.attachment.endSlot==t.data&&(this.currentClippingSlot=void 0),s){for(const o in this.clippingSlotToPixiMasks){const n=this.clippingSlotToPixiMasks[o];(!(n.slot.attachment instanceof St)||!n.maskComputed)&&n.mask&&(this.removeChild(n.mask),js.free(n.mask),n.mask=void 0)}this.currentClippingSlot=void 0}}transformAttachments(){const t=this.skeleton.drawOrder;for(let s=0;s<t.length;s++){const r=t[s];this.updateAndSetPixiMask(r,s===t.length-1);const i=r.getAttachment();if(i){if(i instanceof ut||i instanceof ot){const l=this._getCachedData(r,i);i instanceof ot?i.computeWorldVertices(r,l.vertices,0,2):i.computeWorldVertices(r,0,i.worldVerticesLength,l.vertices,0,2),l.uvs.length<i.uvs.length&&(l.uvs=new Float32Array(i.uvs.length)),(0,it.fastCopy)(i.uvs.buffer,l.uvs.buffer);const n=r.bone.skeleton.color,a=r.color,h=i.color;l.color.set(n.r*a.r*h.r,n.g*a.g*h.g,n.b*a.b*h.b,n.a*a.a*h.a),r.darkColor&&l.darkColor.setFromColor(r.darkColor),l.skipRender=l.clipped=!1;const c=i.region?.texture.texture||it.Texture.EMPTY;l.texture!==c&&(l.texture=c,this.spineTexturesDirty=!0),Pt.isClipping()&&this.updateClippingData(l)}else if(i instanceof St){Pt.clipStart(r,i);continue}}Pt.clipEndWithSlot(r)}Pt.clipEnd()}updateClippingData(t){t.clipped=!0,Pt.clipTrianglesUnpacked(t.vertices,t.indices,t.indices.length,t.uvs);const{clippedVertices:s,clippedUVs:r,clippedTriangles:i}=Pt,l=s.length/2,o=i.length;t.clippedData||(t.clippedData={vertices:new Float32Array(l*2),uvs:new Float32Array(l*2),vertexCount:l,indices:new Uint16Array(o),indicesCount:o},this.spineAttachmentsDirty=!0);const n=t.clippedData,a=n.vertexCount!==l||o!==n.indicesCount;t.skipRender=l===0,a&&(this.spineAttachmentsDirty=!0,n.vertexCount<l&&(n.vertices=new Float32Array(l*2),n.uvs=new Float32Array(l*2)),n.indices.length<o&&(n.indices=new Uint16Array(o)));const{vertices:h,uvs:c,indices:u}=n;for(let d=0;d<l;d++)h[d*2]=s[d*2],h[d*2+1]=s[d*2+1],c[d*2]=r[d*2],c[d*2+1]=r[d*2+1];n.vertexCount=l;for(let d=0;d<o;d++)u[d]!==i[d]&&(this.spineAttachmentsDirty=!0,u[d]=i[d]);n.indicesCount=o}updateSlotObjects(){for(const t in this._slotsObject){const s=this._slotsObject[t];s&&this.updateSlotObject(s)}}updateSlotObject(t){const{slot:s,container:r}=t,i=t.followAttachmentTimeline?!!s.attachment:!0;if(r.visible=this.skeleton.drawOrder.includes(s)&&i,r.visible){let l=s.bone;r.position.set(l.worldX,l.worldY),r.angle=l.getWorldRotationX();let o=1,n=1;for(;l;)o*=l.scaleX,n*=l.scaleY,l=l.parent;o<0&&(r.angle-=180),r.scale.set(s.bone.getWorldScaleX()*Math.sign(o),s.bone.getWorldScaleY()*Math.sign(n)),r.alpha=this.skeleton.color.a*s.color.a}}_getCachedData(t,s){return this.attachmentCacheData[t.data.index][s.name]||this.initCachedData(t,s)}initCachedData(t,s){let r;return s instanceof ot?(r=new Float32Array(8),this.attachmentCacheData[t.data.index][s.name]={id:`${t.data.index}-${s.name}`,vertices:r,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(s.uvs.length),color:new V(1,1,1,1),darkColor:new V(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:s.region?.texture.texture}):(r=new Float32Array(s.worldVerticesLength),this.attachmentCacheData[t.data.index][s.name]={id:`${t.data.index}-${s.name}`,vertices:r,clipped:!1,indices:s.triangles,uvs:new Float32Array(s.uvs.length),color:new V(1,1,1,1),darkColor:new V(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:s.region?.texture.texture}),this.attachmentCacheData[t.data.index][s.name]}onViewUpdate(){if(this._didViewChangeTick++,this._boundsProvider||(this._boundsDirty=!0),this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this),this.debug?.renderDebug(this)}addSlotObject(t,s,r){t=this.getSlotFromRef(t);for(const l in this._slotsObject)this._slotsObject[l]?.container===s&&this.removeSlotObject(this._slotsObject[l].slot);this.removeSlotObject(t),s.includeInBuild=!1,this.addChild(s);const i={container:s,slot:t,followAttachmentTimeline:r?.followAttachmentTimeline||!1};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){let s;if(t instanceof it.Container){for(const r in this._slotsObject)if(this._slotsObject[r]?.container===t){this._slotsObject[r]=null,s=t;break}}else{const r=this.getSlotFromRef(t);s=this._slotsObject[r.data.name]?.container,this._slotsObject[r.data.name]=null}s&&(this.removeChild(s),s.includeInBuild=!0)}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([t,s])=>{s&&s.container.removeFromParent(),delete this._slotsObject[t]})}getSlotObject(t){return t=this.getSlotFromRef(t),this._slotsObject[t.data.name]?.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||=new ns;const t=this.skeletonBounds;if(t.update(this.skeleton,!0),this._boundsProvider){const s=this._boundsProvider.calculateBounds(this),r=this._bounds;r.clear(),r.x=s.x,r.y=s.y,r.width=s.width,r.height=s.height}else if(t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const s=this.skeleton.drawOrder,r=this._bounds;r.clear();for(let i=0;i<s.length;i++){const l=s[i],o=l.getAttachment();if(o&&(o instanceof ot||o instanceof ut)){const n=this._getCachedData(l,o);r.addVertexData(n.vertices,0,n.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),it.Ticker.shared.remove(this.internalUpdate,this),this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this._lastAttachments.length=0,this.attachmentCacheData=null}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,s){this.pixiWorldCoordinatesToSkeleton(t),s.parent?s.parent.worldToLocal(t):s.worldToLocal(t)}static from({skeleton:t,atlas:s,scale:r=1,darkTint:i,autoUpdate:l=!0,boundsProvider:o}){const n=`${t}-${s}-${r}`;if(it.Cache.has(n))return new gs({skeletonData:it.Cache.get(n),darkTint:i,autoUpdate:l,boundsProvider:o});const a=it.Assets.get(t),h=it.Assets.get(s),c=new Es(h),u=a instanceof Uint8Array?new qs(c):new Gs(c);u.scale=r;const d=u.readSkeletonData(a);return it.Cache.set(n,d),new gs({skeletonData:d,darkTint:i,autoUpdate:l,boundsProvider:o})}},et=pt("pixi.js"),Sr=class{registeredSpines=new Map;drawMeshHull=!0;drawMeshTriangles=!0;drawBones=!0;drawPaths=!0;drawBoundingBoxes=!0;drawClipping=!0;drawRegionAttachments=!0;drawEvents=!0;lineWidth=1;regionAttachmentsColor=30975;meshHullColor=30975;meshTrianglesColor=16763904;clippingPolygonColor=16711935;boundingBoxesRectColor=65280;boundingBoxesPolygonColor=65280;boundingBoxesCircleColor=65280;pathsCurveColor=16711680;pathsLineColor=16711935;skeletonXYColor=16711680;bonesColor=61132;eventFontSize=24;eventFontColor=0;registerSpine(e){if(this.registeredSpines.has(e)){console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",e);return}const t={parentDebugContainer:new et.Container,bones:new et.Container,skeletonXY:new et.Graphics,regionAttachmentsShape:new et.Graphics,meshTrianglesLine:new et.Graphics,meshHullLine:new et.Graphics,clippingPolygon:new et.Graphics,boundingBoxesRect:new et.Graphics,boundingBoxesCircle:new et.Graphics,boundingBoxesPolygon:new et.Graphics,pathsCurve:new et.Graphics,pathsLine:new et.Graphics,eventText:new et.Container,eventCallback:{event:(s,r)=>{if(this.drawEvents){const i=Math.abs(e.scale.x||e.scale.y||1),l=new et.Text({text:r.data.name,style:{fontSize:this.eventFontSize/i,fill:this.eventFontColor,fontFamily:"monospace"}});l.scale.x=Math.sign(e.scale.x),l.anchor.set(.5),t.eventText.addChild(l),setTimeout(()=>{l.destroyed||l.destroy()},250)}}}};t.parentDebugContainer.addChild(t.bones),t.parentDebugContainer.addChild(t.skeletonXY),t.parentDebugContainer.addChild(t.regionAttachmentsShape),t.parentDebugContainer.addChild(t.meshTrianglesLine),t.parentDebugContainer.addChild(t.meshHullLine),t.parentDebugContainer.addChild(t.clippingPolygon),t.parentDebugContainer.addChild(t.boundingBoxesRect),t.parentDebugContainer.addChild(t.boundingBoxesCircle),t.parentDebugContainer.addChild(t.boundingBoxesPolygon),t.parentDebugContainer.addChild(t.pathsCurve),t.parentDebugContainer.addChild(t.pathsLine),t.parentDebugContainer.addChild(t.eventText),t.parentDebugContainer.zIndex=9999999,t.parentDebugContainer.accessibleChildren=!1,t.parentDebugContainer.eventMode="none",t.parentDebugContainer.interactiveChildren=!1,e.addChild(t.parentDebugContainer),e.state.addListener(t.eventCallback),this.registeredSpines.set(e,t)}renderDebug(e){this.registeredSpines.has(e)||this.registerSpine(e);const t=this.registeredSpines.get(e);if(!t)return;e.addChild(t.parentDebugContainer),t.skeletonXY.clear(),t.regionAttachmentsShape.clear(),t.meshTrianglesLine.clear(),t.meshHullLine.clear(),t.clippingPolygon.clear(),t.boundingBoxesRect.clear(),t.boundingBoxesCircle.clear(),t.boundingBoxesPolygon.clear(),t.pathsCurve.clear(),t.pathsLine.clear();for(let i=t.bones.children.length;i>0;i--)t.bones.children[i-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(e.scale.x||e.scale.y||1),r=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(e,t,r,s),this.drawPaths&&this.drawPathsFunc(e,t,r),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(e,t,r),this.drawClipping&&this.drawClippingFunc(e,t,r),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(e,t,r),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(e,t,r),this.drawEvents)for(const i of t.eventText.children)i.alpha-=.05,i.y-=2}drawBonesFunc(e,t,s,r){const i=e.skeleton,l=i.x,o=i.y,n=i.bones;t.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let h=0,c=n.length;h<c;h++){const u=n[h],d=u.data.length,m=l+u.worldX,f=o+u.worldY,p=l+d*u.a+u.worldX,b=o+d*u.b+u.worldY;if(u.data.name==="root"||u.data.parent===null)continue;const w=Math.abs(m-p),g=Math.abs(f-b),x=Math.pow(w,2),y=g,v=Math.pow(g,2),C=Math.sqrt(x+v),S=Math.pow(C,2),k=Math.PI/180,T=Math.acos((S+v-x)/(2*y*C))||0;if(C===0)continue;const Y=new et.Graphics;t.bones.addChild(Y);const M=C/50/r;Y.context.poly([0,0,0-M,C-M*3,0,C-M,0+M,C-M*3]).fill(this.bonesColor),Y.x=m,Y.y=f,Y.pivot.y=C;let X=0;m<p&&f<b?X=-T+180*k:m>p&&f<b?X=180*k+T:m>p&&f>b?X=-T:m<p&&f>b?X=T:f===b&&m<p?X=90*k:f===b&&m>p?X=-90*k:m===p&&f<b?X=180*k:m===p&&f>b&&(X=0),Y.rotation=X,Y.circle(0,C,M*1.2).fill({color:0,alpha:.6}).stroke({width:s+M/2.4,color:this.bonesColor})}const a=s*3;t.skeletonXY.context.moveTo(l-a,o-a).lineTo(l+a,o+a).moveTo(l+a,o-a).lineTo(l-a,o+a).stroke()}drawRegionAttachmentsFunc(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l],a=n.getAttachment();if(a===null||!(a instanceof ot))continue;const h=a,c=new Float32Array(8);h.computeWorldVertices(n,c,0,2),t.regionAttachmentsShape.poly(Array.from(c.slice(0,8)))}t.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l];if(!n.bone.active)continue;const a=n.getAttachment();if(a===null||!(a instanceof ut))continue;const h=a,c=new Float32Array(h.worldVerticesLength),u=h.triangles;let d=h.hullLength;if(h.computeWorldVertices(n,0,h.worldVerticesLength,c,0,2),this.drawMeshTriangles)for(let m=0,f=u.length;m<f;m+=3){const p=u[m]*2,b=u[m+1]*2,w=u[m+2]*2;t.meshTrianglesLine.context.moveTo(c[p],c[p+1]).lineTo(c[b],c[b+1]).lineTo(c[w],c[w+1])}if(this.drawMeshHull&&d>0){d=(d>>1)*2;let m=c[d-2],f=c[d-1];for(let p=0,b=d;p<b;p+=2){const w=c[p],g=c[p+1];t.meshHullLine.context.moveTo(w,g).lineTo(m,f),m=w,f=g}}}t.meshHullLine.stroke({width:s,color:this.meshHullColor}),t.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l];if(!n.bone.active)continue;const a=n.getAttachment();if(a===null||!(a instanceof St))continue;const h=a,c=h.worldVerticesLength,u=new Float32Array(c);h.computeWorldVertices(n,0,c,u,0,2),t.clippingPolygon.poly(Array.from(u))}t.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(e,t,s){const r=new ns;r.update(e.skeleton,!0),r.minX!==1/0&&t.boundingBoxesRect.rect(r.minX,r.minY,r.getWidth(),r.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const i=r.polygons,l=(o,n,a)=>{if(a<3)throw new Error("Polygon must contain at least 3 vertices");const h=[],c=s*2;for(let u=0,d=o.length;u<d;u+=2){const m=o[u],f=o[u+1];t.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),t.boundingBoxesCircle.drawCircle(m,f,c),t.boundingBoxesCircle.fill(0),t.boundingBoxesCircle.circle(m,f,c).fill({color:this.boundingBoxesCircleColor}),h.push(m,f)}t.boundingBoxesPolygon.poly(h).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let o=0,n=i.length;o<n;o++){const a=i[o];l(a,0,a.length)}}drawPathsFunc(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l];if(!n.bone.active)continue;const a=n.getAttachment();if(a===null||!(a instanceof Mt))continue;const h=a;let c=h.worldVerticesLength;const u=new Float32Array(c);h.computeWorldVertices(n,0,c,u,0,2);let d=u[2],m=u[3],f=0,p=0;if(h.closed){const b=u[0],w=u[1],g=u[c-2],x=u[c-1];f=u[c-4],p=u[c-3],t.pathsCurve.moveTo(d,m),t.pathsCurve.bezierCurveTo(b,w,g,x,f,p),t.pathsLine.moveTo(d,m),t.pathsLine.lineTo(b,w),t.pathsLine.moveTo(f,p),t.pathsLine.lineTo(g,x)}c-=4;for(let b=4;b<c;b+=6){const w=u[b],g=u[b+1],x=u[b+2],y=u[b+3];f=u[b+4],p=u[b+5],t.pathsCurve.moveTo(d,m),t.pathsCurve.bezierCurveTo(w,g,x,y,f,p),t.pathsLine.moveTo(d,m),t.pathsLine.lineTo(w,g),t.pathsLine.moveTo(f,p),t.pathsLine.lineTo(x,y),d=f,m=p}}t.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),t.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(e){this.registeredSpines.has(e)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",e);const t=this.registeredSpines.get(e);t&&(e.state.removeListener(t.eventCallback),t.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(e))}};return gi(ps)})();
27
+ `}},gr=class extends gt.Shader{constructor(e){const t=(0,gt.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[gt.colorBitGl,mr,(0,gt.generateTextureBatchBitGl)(e),gt.roundPixelsBitGl]}),s=(0,gt.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[gt.colorBit,fr,(0,gt.generateTextureBatchBit)(e),gt.roundPixelsBit]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:(0,gt.getBatchSamplersUniformGroup)(e)}})}},Hs=null,pr=class hi extends Kt.Batcher{static extension={type:[Kt.ExtensionType.Batcher],name:"darkTint"};geometry=new ur;shader=Hs||(Hs=new gr(this.maxTextures));name=hi.extension.name;vertexSize=7;packAttributes(t,s,r,i,l){const o=l<<16|t.roundPixels&65535,n=t.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,{positions:f,uvs:p}=t,b=t.color,w=(b>>24&255)/255,g=Kt.Color.shared.setValue(t.darkColor).premultiply(w,!0).toPremultiplied(1,!1),x=t.attributeOffset,y=x+t.attributeSize;for(let v=x;v<y;v++){const C=v*2,S=f[C],k=f[C+1];s[i++]=a*S+c*k+d,s[i++]=u*k+h*S+m,s[i++]=p[C],s[i++]=p[C+1],r[i++]=b,r[i++]=g,r[i++]=o}}packQuadAttributes(t,s,r,i,l){const o=t.texture,n=t.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,f=t.bounds,p=f.maxX,b=f.minX,w=f.maxY,g=f.minY,x=o.uvs,y=t.color,v=t.darkColor,C=l<<16|t.roundPixels&65535;s[i+0]=a*b+c*g+d,s[i+1]=u*g+h*b+m,s[i+2]=x.x0,s[i+3]=x.y0,r[i+4]=y,r[i+5]=v,r[i+6]=C,s[i+7]=a*p+c*g+d,s[i+8]=u*g+h*p+m,s[i+9]=x.x1,s[i+10]=x.y1,r[i+11]=y,r[i+12]=v,r[i+13]=C,s[i+14]=a*p+c*w+d,s[i+15]=u*w+h*p+m,s[i+16]=x.x2,s[i+17]=x.y2,r[i+18]=y,r[i+19]=v,r[i+20]=C,s[i+21]=a*b+c*w+d,s[i+22]=u*w+h*b+m,s[i+23]=x.x3,s[i+24]=x.y3,r[i+25]=y,r[i+26]=v,r[i+27]=C}};Kt.extensions.add(pr);var Nt=pt("pixi.js"),xr=class{indexOffset=0;attributeOffset=0;indexSize;attributeSize;batcherName="darkTint";topology="triangle-list";packAsQuad=!1;renderable;positions;indices;uvs;roundPixels;data;blendMode;darkTint;texture;transform;_textureId;_attributeStart;_indexStart;_batcher;_batch;get color(){const e=this.data.color,t=this.renderable.groupColor,s=this.renderable.groupAlpha;let r;const i=e.a*s*255;if(t!==16777215){const l=t>>16&255,o=t>>8&255,n=t&255,a=e.r*n,h=e.g*o,c=e.b*l;r=i<<24|c<<16|h<<8|a}else r=i<<24|e.b*255<<16|e.g*255<<8|e.r*255;return r}get darkColor(){const e=this.data.darkColor;return e.b*255<<16|e.g*255<<8|e.r*255}get groupTransform(){return this.renderable.groupTransform}setData(e,t,s,r){if(this.renderable=e,this.transform=e.groupTransform,this.data=t,t.clipped){const i=t.clippedData;this.indexSize=i.indicesCount,this.attributeSize=i.vertexCount,this.positions=i.vertices,this.indices=i.indices,this.uvs=i.uvs}else this.indexSize=t.indices.length,this.attributeSize=t.vertices.length/2,this.positions=t.vertices,this.indices=t.indices,this.uvs=t.uvs;this.texture=t.texture,this.roundPixels=r,this.blendMode=s,this.batcherName=t.darkTint?"darkTint":"default"}},br={0:"normal",1:"add",2:"multiply",3:"screen"},$s=class{static extension={type:[Nt.ExtensionType.WebGLPipes,Nt.ExtensionType.WebGPUPipes,Nt.ExtensionType.CanvasPipes],name:"spine"};renderer;gpuSpineData={};_destroyRenderableBound=this.destroyRenderable.bind(this);constructor(e){this.renderer=e}validateRenderable(e){if(e._validateAndTransformAttachments(),e.spineAttachmentsDirty)return!0;if(e.spineTexturesDirty){const t=e.skeleton.drawOrder,s=this.gpuSpineData[e.uid];for(let r=0,i=t.length;r<i;r++){const l=t[r],o=l.getAttachment();if(o instanceof ot||o instanceof ut){const n=e._getCachedData(l,o),a=s.slotBatches[n.id],h=n.texture;if(h!==a.texture&&!a._batcher.checkAndUpdateTexture(a,h))return!0}}}return!1}addRenderable(e,t){const s=this._getSpineData(e),r=this.renderer.renderPipes.batch,i=e.skeleton.drawOrder,l=this.renderer._roundPixels|e._roundPixels;e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;for(let o=0,n=i.length;o<n;o++){const a=i[o],h=a.getAttachment(),c=br[a.data.blendMode];if(h instanceof ot||h instanceof ut){const d=e._getCachedData(a,h),m=s.slotBatches[d.id]||=new xr;m.setData(e,d,c,l),d.skipRender||r.addToBatch(m,t)}const u=e._slotsObject[a.data.name];if(u){const d=u.container;d.includeInBuild=!0,(0,Nt.collectAllRenderables)(d,t,this.renderer),d.includeInBuild=!1}}}updateRenderable(e){const t=this.gpuSpineData[e.uid];e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;const s=e.skeleton.drawOrder;for(let r=0,i=s.length;r<i;r++){const l=s[r],o=l.getAttachment();if((o instanceof ot||o instanceof ut)&&!e._getCachedData(l,o).skipRender){const a=t.slotBatches[e._getCachedData(l,o).id];a._batcher?.updateElement(a)}}}destroyRenderable(e){this.gpuSpineData[e.uid]=null,e.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(e){return this.gpuSpineData[e.uid]||this._initMeshData(e)}_initMeshData(e){return this.gpuSpineData[e.uid]={slotBatches:{}},e.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[e.uid]}};Nt.extensions.add($s);var it=pt("pixi.js"),Qt=new Et;Yt.yDown=!0;var Pt=new Jt,wr=class{constructor(e,t,s,r){this.x=e,this.y=t,this.width=s,this.height=r}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},yr=class{constructor(e=!1){this.clipping=e}calculateBounds(e){if(!e.skeleton)return{x:0,y:0,width:0,height:0};const t=new Yt(e.skeleton.data);t.setToSetupPose(),t.updateWorldTransform(2);const s=t.getBoundsRect(this.clipping?new Jt:void 0);return s.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},vr=class{constructor(e,t=[],s=.05,r=!1){this.animation=e,this.skins=t,this.timeStep=s,this.clipping=r}calculateBounds(e){if(!e.skeleton||!e.state)return{x:0,y:0,width:0,height:0};const t=new Ve(e.state.data),s=new Yt(e.skeleton.data),r=this.clipping?new Jt:void 0,i=s.data;if(this.skins.length>0){let o=new Vt("custom-skin");for(const n of this.skins){const a=i.findSkin(n);a!=null&&o.addSkin(a)}s.setSkin(o)}s.setToSetupPose();const l=this.animation!=null?i.findAnimation(this.animation):null;if(l==null){s.updateWorldTransform(2);const o=s.getBoundsRect(r);return o.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:o}else{let o=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;t.clearTracks(),t.setAnimationWith(0,l,!1);const c=Math.max(l.duration/this.timeStep,1);for(let d=0;d<c;d++){const m=d>0?this.timeStep:0;t.update(m),t.apply(s),s.update(m),s.updateWorldTransform(2);const f=s.getBoundsRect(r);o=Math.min(o,f.x),n=Math.min(n,f.y),a=Math.max(a,f.x+f.width),h=Math.max(h,f.y+f.height)}const u={x:o,y:n,width:a-o,height:h-n};return u.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:u}}},js=new Tt(()=>new it.Graphics),Cr=class gs extends it.ViewContainer{batched=!0;buildId=0;renderPipeId="spine";_didSpineUpdate=!1;beforeUpdateWorldTransforms=()=>{};afterUpdateWorldTransforms=()=>{};skeleton;state;skeletonBounds;darkTint=!1;_debug=void 0;_slotsObject=Object.create(null);clippingSlotToPixiMasks=Object.create(null);getSlotFromRef(t){let s;if(typeof t=="number"?s=this.skeleton.slots[t]:typeof t=="string"?s=this.skeleton.findSlot(t):s=t,!s)throw new Error(`No slot found with the given slot reference: ${t}`);return s}spineAttachmentsDirty=!0;spineTexturesDirty=!0;_lastAttachments=[];_stateChanged=!0;attachmentCacheData=[];get debug(){return this._debug}set debug(t){this._debug&&this._debug.unregisterSpine(this),t&&t.registerSpine(this),this._debug=t}_autoUpdate=!1;get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t&&!this._autoUpdate?it.Ticker.shared.add(this.internalUpdate,this):!t&&this._autoUpdate&&it.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=t}_boundsProvider;get boundsProvider(){return this._boundsProvider}set boundsProvider(t){this._boundsProvider=t,t&&(this._boundsDirty=!1),this.updateBounds()}hasNeverUpdated=!0;constructor(t){t instanceof Lt&&(t={skeletonData:t}),super({}),this.allowChildren=!0;const s=t instanceof Lt?t:t.skeletonData;this.skeleton=new Yt(s),this.state=new Ve(new Ys(s)),this.autoUpdate=t?.autoUpdate??!0,this.darkTint=t?.darkTint===void 0?this.skeleton.slots.some(i=>!!i.data.darkColor):t?.darkTint;const r=this.skeleton.slots;for(let i=0;i<r.length;i++)this.attachmentCacheData[i]=Object.create(null);this._boundsProvider=t.boundsProvider}update(t){this.internalUpdate(0,t)}internalUpdate(t,s){this._updateAndApplyState(s??it.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(t,s){const r=t;if(typeof t=="string"&&(t=this.skeleton.findBone(t)),!t)throw Error(`Cant set bone position, bone ${String(r)} not found`);if(Qt.set(s.x,s.y),t.parent){const i=t.parent.worldToLocal(Qt);t.x=i.x,t.y=-i.y}else t.x=Qt.x,t.y=Qt.y}getBonePosition(t,s){const r=t;return typeof t=="string"&&(t=this.skeleton.findBone(t)),t?(s||(s={x:0,y:0}),s.x=t.worldX,s.y=t.worldY,s):(console.error(`Cant set bone position! Bone ${String(r)} not found`),s)}_updateAndApplyState(t){this.hasNeverUpdated=!1,this.state.update(t),this.skeleton.update(t);const{skeleton:s}=this;this.state.apply(s),this.beforeUpdateWorldTransforms(this),s.updateWorldTransform(2),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const t=this.skeleton.drawOrder,s=this._lastAttachments;let r=0,i=!1;for(let l=0;l<t.length;l++){const n=t[l].getAttachment();n&&(n!==s[r]&&(i=!0,s[r]=n),r++)}r!==s.length&&(i=!0,s.length=r),this.spineAttachmentsDirty||=i}currentClippingSlot;updateAndSetPixiMask(t,s){const r=t.attachment;if(r&&r instanceof St){const o=this.clippingSlotToPixiMasks[t.data.name]||={slot:t,vertices:new Array};o.maskComputed=!1,this.currentClippingSlot=o;return}let i=this.currentClippingSlot,l=this._slotsObject[t.data.name];if(i&&l){let o=i.mask;if(o||(o=js.obtain(),i.mask=o,this.addChild(o)),!i.maskComputed){let n=i.slot,a=n.attachment;i.maskComputed=!0;const h=a.worldVerticesLength,c=i.vertices;a.computeWorldVertices(n,0,h,c,0,2),o.clear().poly(c).stroke({width:0}).fill({alpha:.25})}l.container.mask=o}else l?.container.mask&&(l.container.mask=null);if(i&&i.slot.attachment.endSlot==t.data&&(this.currentClippingSlot=void 0),s){for(const o in this.clippingSlotToPixiMasks){const n=this.clippingSlotToPixiMasks[o];(!(n.slot.attachment instanceof St)||!n.maskComputed)&&n.mask&&(this.removeChild(n.mask),js.free(n.mask),n.mask=void 0)}this.currentClippingSlot=void 0}}transformAttachments(){const t=this.skeleton.drawOrder;for(let s=0;s<t.length;s++){const r=t[s];this.updateAndSetPixiMask(r,s===t.length-1);const i=r.getAttachment();if(i){if(i instanceof ut||i instanceof ot){const l=this._getCachedData(r,i);i instanceof ot?i.computeWorldVertices(r,l.vertices,0,2):i.computeWorldVertices(r,0,i.worldVerticesLength,l.vertices,0,2),l.uvs.length<i.uvs.length&&(l.uvs=new Float32Array(i.uvs.length)),(0,it.fastCopy)(i.uvs.buffer,l.uvs.buffer);const n=r.bone.skeleton.color,a=r.color,h=i.color;l.color.set(n.r*a.r*h.r,n.g*a.g*h.g,n.b*a.b*h.b,n.a*a.a*h.a),r.darkColor&&l.darkColor.setFromColor(r.darkColor),l.skipRender=l.clipped=!1;const c=i.region?.texture.texture||it.Texture.EMPTY;l.texture!==c&&(l.texture=c,this.spineTexturesDirty=!0),Pt.isClipping()&&this.updateClippingData(l)}else if(i instanceof St){Pt.clipStart(r,i);continue}}Pt.clipEndWithSlot(r)}Pt.clipEnd()}updateClippingData(t){t.clipped=!0,Pt.clipTrianglesUnpacked(t.vertices,t.indices,t.indices.length,t.uvs);const{clippedVertices:s,clippedUVs:r,clippedTriangles:i}=Pt,l=s.length/2,o=i.length;t.clippedData||(t.clippedData={vertices:new Float32Array(l*2),uvs:new Float32Array(l*2),vertexCount:l,indices:new Uint16Array(o),indicesCount:o},this.spineAttachmentsDirty=!0);const n=t.clippedData,a=n.vertexCount!==l||o!==n.indicesCount;t.skipRender=l===0,a&&(this.spineAttachmentsDirty=!0,n.vertexCount<l&&(n.vertices=new Float32Array(l*2),n.uvs=new Float32Array(l*2)),n.indices.length<o&&(n.indices=new Uint16Array(o)));const{vertices:h,uvs:c,indices:u}=n;for(let d=0;d<l;d++)h[d*2]=s[d*2],h[d*2+1]=s[d*2+1],c[d*2]=r[d*2],c[d*2+1]=r[d*2+1];n.vertexCount=l;for(let d=0;d<o;d++)u[d]!==i[d]&&(this.spineAttachmentsDirty=!0,u[d]=i[d]);n.indicesCount=o}updateSlotObjects(){for(const t in this._slotsObject){const s=this._slotsObject[t];s&&this.updateSlotObject(s)}}updateSlotObject(t){const{slot:s,container:r}=t,i=t.followAttachmentTimeline?!!s.attachment:!0;if(r.visible=this.skeleton.drawOrder.includes(s)&&i,r.visible){let l=s.bone;r.position.set(l.worldX,l.worldY),r.angle=l.getWorldRotationX();let o=1,n=1;for(;l;)o*=l.scaleX,n*=l.scaleY,l=l.parent;o<0&&(r.angle-=180),r.scale.set(s.bone.getWorldScaleX()*Math.sign(o),s.bone.getWorldScaleY()*Math.sign(n)),r.alpha=this.skeleton.color.a*s.color.a}}_getCachedData(t,s){return this.attachmentCacheData[t.data.index][s.name]||this.initCachedData(t,s)}initCachedData(t,s){let r;return s instanceof ot?(r=new Float32Array(8),this.attachmentCacheData[t.data.index][s.name]={id:`${t.data.index}-${s.name}`,vertices:r,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(s.uvs.length),color:new V(1,1,1,1),darkColor:new V(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:s.region?.texture.texture}):(r=new Float32Array(s.worldVerticesLength),this.attachmentCacheData[t.data.index][s.name]={id:`${t.data.index}-${s.name}`,vertices:r,clipped:!1,indices:s.triangles,uvs:new Float32Array(s.uvs.length),color:new V(1,1,1,1),darkColor:new V(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:s.region?.texture.texture}),this.attachmentCacheData[t.data.index][s.name]}onViewUpdate(){if(this._didViewChangeTick++,this._boundsProvider||(this._boundsDirty=!0),this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this),this.debug?.renderDebug(this)}addSlotObject(t,s,r){t=this.getSlotFromRef(t);for(const l in this._slotsObject)this._slotsObject[l]?.container===s&&this.removeSlotObject(this._slotsObject[l].slot);this.removeSlotObject(t),s.includeInBuild=!1,this.addChild(s);const i={container:s,slot:t,followAttachmentTimeline:r?.followAttachmentTimeline||!1};this._slotsObject[t.data.name]=i,this.updateSlotObject(i)}removeSlotObject(t){let s;if(t instanceof it.Container){for(const r in this._slotsObject)if(this._slotsObject[r]?.container===t){this._slotsObject[r]=null,s=t;break}}else{const r=this.getSlotFromRef(t);s=this._slotsObject[r.data.name]?.container,this._slotsObject[r.data.name]=null}s&&(this.removeChild(s),s.includeInBuild=!0)}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([t,s])=>{s&&s.container.removeFromParent(),delete this._slotsObject[t]})}getSlotObject(t){return t=this.getSlotFromRef(t),this._slotsObject[t.data.name]?.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||=new ns;const t=this.skeletonBounds;if(t.update(this.skeleton,!0),this._boundsProvider){const s=this._boundsProvider.calculateBounds(this),r=this._bounds;r.clear(),r.x=s.x,r.y=s.y,r.width=s.width,r.height=s.height}else if(t.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const s=this.skeleton.drawOrder,r=this._bounds;r.clear();for(let i=0;i<s.length;i++){const l=s[i],o=l.getAttachment();if(o&&(o instanceof ot||o instanceof ut)){const n=this._getCachedData(l,o);r.addVertexData(n.vertices,0,n.vertices.length)}}}else this._bounds.minX=t.minX,this._bounds.minY=t.minY,this._bounds.maxX=t.maxX,this._bounds.maxY=t.maxY}addBounds(t){t.addBounds(this.bounds)}destroy(t=!1){super.destroy(t),it.Ticker.shared.remove(this.internalUpdate,this),this.state.clearListeners(),this.debug=void 0,this.skeleton=null,this.state=null,this._slotsObject=null,this._lastAttachments.length=0,this.attachmentCacheData=null}skeletonToPixiWorldCoordinates(t){this.worldTransform.apply(t,t)}pixiWorldCoordinatesToSkeleton(t){this.worldTransform.applyInverse(t,t)}pixiWorldCoordinatesToBone(t,s){this.pixiWorldCoordinatesToSkeleton(t),s.parent?s.parent.worldToLocal(t):s.worldToLocal(t)}static from({skeleton:t,atlas:s,scale:r=1,darkTint:i,autoUpdate:l=!0,boundsProvider:o}){const n=`${t}-${s}-${r}`;if(it.Cache.has(n))return new gs({skeletonData:it.Cache.get(n),darkTint:i,autoUpdate:l,boundsProvider:o});const a=it.Assets.get(t),h=it.Assets.get(s),c=new Es(h),u=a instanceof Uint8Array?new qs(c):new Gs(c);u.scale=r;const d=u.readSkeletonData(a);return it.Cache.set(n,d),new gs({skeletonData:d,darkTint:i,autoUpdate:l,boundsProvider:o})}},et=pt("pixi.js"),Sr=class{registeredSpines=new Map;drawMeshHull=!0;drawMeshTriangles=!0;drawBones=!0;drawPaths=!0;drawBoundingBoxes=!0;drawClipping=!0;drawRegionAttachments=!0;drawEvents=!0;lineWidth=1;regionAttachmentsColor=30975;meshHullColor=30975;meshTrianglesColor=16763904;clippingPolygonColor=16711935;boundingBoxesRectColor=65280;boundingBoxesPolygonColor=65280;boundingBoxesCircleColor=65280;pathsCurveColor=16711680;pathsLineColor=16711935;skeletonXYColor=16711680;bonesColor=61132;eventFontSize=24;eventFontColor=0;registerSpine(e){if(this.registeredSpines.has(e)){console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",e);return}const t={parentDebugContainer:new et.Container,bones:new et.Container,skeletonXY:new et.Graphics,regionAttachmentsShape:new et.Graphics,meshTrianglesLine:new et.Graphics,meshHullLine:new et.Graphics,clippingPolygon:new et.Graphics,boundingBoxesRect:new et.Graphics,boundingBoxesCircle:new et.Graphics,boundingBoxesPolygon:new et.Graphics,pathsCurve:new et.Graphics,pathsLine:new et.Graphics,eventText:new et.Container,eventCallback:{event:(s,r)=>{if(this.drawEvents){const i=Math.abs(e.scale.x||e.scale.y||1),l=new et.Text({text:r.data.name,style:{fontSize:this.eventFontSize/i,fill:this.eventFontColor,fontFamily:"monospace"}});l.scale.x=Math.sign(e.scale.x),l.anchor.set(.5),t.eventText.addChild(l),setTimeout(()=>{l.destroyed||l.destroy()},250)}}}};t.parentDebugContainer.addChild(t.bones),t.parentDebugContainer.addChild(t.skeletonXY),t.parentDebugContainer.addChild(t.regionAttachmentsShape),t.parentDebugContainer.addChild(t.meshTrianglesLine),t.parentDebugContainer.addChild(t.meshHullLine),t.parentDebugContainer.addChild(t.clippingPolygon),t.parentDebugContainer.addChild(t.boundingBoxesRect),t.parentDebugContainer.addChild(t.boundingBoxesCircle),t.parentDebugContainer.addChild(t.boundingBoxesPolygon),t.parentDebugContainer.addChild(t.pathsCurve),t.parentDebugContainer.addChild(t.pathsLine),t.parentDebugContainer.addChild(t.eventText),t.parentDebugContainer.zIndex=9999999,t.parentDebugContainer.accessibleChildren=!1,t.parentDebugContainer.eventMode="none",t.parentDebugContainer.interactiveChildren=!1,e.addChild(t.parentDebugContainer),e.state.addListener(t.eventCallback),this.registeredSpines.set(e,t)}renderDebug(e){this.registeredSpines.has(e)||this.registerSpine(e);const t=this.registeredSpines.get(e);if(!t)return;e.addChild(t.parentDebugContainer),t.skeletonXY.clear(),t.regionAttachmentsShape.clear(),t.meshTrianglesLine.clear(),t.meshHullLine.clear(),t.clippingPolygon.clear(),t.boundingBoxesRect.clear(),t.boundingBoxesCircle.clear(),t.boundingBoxesPolygon.clear(),t.pathsCurve.clear(),t.pathsLine.clear();for(let i=t.bones.children.length;i>0;i--)t.bones.children[i-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(e.scale.x||e.scale.y||1),r=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(e,t,r,s),this.drawPaths&&this.drawPathsFunc(e,t,r),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(e,t,r),this.drawClipping&&this.drawClippingFunc(e,t,r),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(e,t,r),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(e,t,r),this.drawEvents)for(const i of t.eventText.children)i.alpha-=.05,i.y-=2}drawBonesFunc(e,t,s,r){const i=e.skeleton,l=i.x,o=i.y,n=i.bones;t.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let h=0,c=n.length;h<c;h++){const u=n[h],d=u.data.length,m=l+u.worldX,f=o+u.worldY,p=l+d*u.a+u.worldX,b=o+d*u.b+u.worldY;if(u.data.name==="root"||u.data.parent===null)continue;const w=Math.abs(m-p),g=Math.abs(f-b),x=Math.pow(w,2),y=g,v=Math.pow(g,2),C=Math.sqrt(x+v),S=Math.pow(C,2),k=Math.PI/180,T=Math.acos((S+v-x)/(2*y*C))||0;if(C===0)continue;const Y=new et.Graphics;t.bones.addChild(Y);const M=C/50/r;Y.context.poly([0,0,0-M,C-M*3,0,C-M,0+M,C-M*3]).fill(this.bonesColor),Y.x=m,Y.y=f,Y.pivot.y=C;let X=0;m<p&&f<b?X=-T+180*k:m>p&&f<b?X=180*k+T:m>p&&f>b?X=-T:m<p&&f>b?X=T:f===b&&m<p?X=90*k:f===b&&m>p?X=-90*k:m===p&&f<b?X=180*k:m===p&&f>b&&(X=0),Y.rotation=X,Y.circle(0,C,M*1.2).fill({color:0,alpha:.6}).stroke({width:s+M/2.4,color:this.bonesColor})}const a=s*3;t.skeletonXY.context.moveTo(l-a,o-a).lineTo(l+a,o+a).moveTo(l+a,o-a).lineTo(l-a,o+a).stroke()}drawRegionAttachmentsFunc(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l],a=n.getAttachment();if(a===null||!(a instanceof ot))continue;const h=a,c=new Float32Array(8);h.computeWorldVertices(n,c,0,2),t.regionAttachmentsShape.poly(Array.from(c.slice(0,8)))}t.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l];if(!n.bone.active)continue;const a=n.getAttachment();if(a===null||!(a instanceof ut))continue;const h=a,c=new Float32Array(h.worldVerticesLength),u=h.triangles;let d=h.hullLength;if(h.computeWorldVertices(n,0,h.worldVerticesLength,c,0,2),this.drawMeshTriangles)for(let m=0,f=u.length;m<f;m+=3){const p=u[m]*2,b=u[m+1]*2,w=u[m+2]*2;t.meshTrianglesLine.context.moveTo(c[p],c[p+1]).lineTo(c[b],c[b+1]).lineTo(c[w],c[w+1])}if(this.drawMeshHull&&d>0){d=(d>>1)*2;let m=c[d-2],f=c[d-1];for(let p=0,b=d;p<b;p+=2){const w=c[p],g=c[p+1];t.meshHullLine.context.moveTo(w,g).lineTo(m,f),m=w,f=g}}}t.meshHullLine.stroke({width:s,color:this.meshHullColor}),t.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l];if(!n.bone.active)continue;const a=n.getAttachment();if(a===null||!(a instanceof St))continue;const h=a,c=h.worldVerticesLength,u=new Float32Array(c);h.computeWorldVertices(n,0,c,u,0,2),t.clippingPolygon.poly(Array.from(u))}t.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(e,t,s){const r=new ns;r.update(e.skeleton,!0),r.minX!==1/0&&t.boundingBoxesRect.rect(r.minX,r.minY,r.getWidth(),r.getHeight()).stroke({width:s,color:this.boundingBoxesRectColor});const i=r.polygons,l=(o,n,a)=>{if(a<3)throw new Error("Polygon must contain at least 3 vertices");const h=[],c=s*2;for(let u=0,d=o.length;u<d;u+=2){const m=o[u],f=o[u+1];t.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),t.boundingBoxesCircle.drawCircle(m,f,c),t.boundingBoxesCircle.fill(0),t.boundingBoxesCircle.circle(m,f,c).fill({color:this.boundingBoxesCircleColor}),h.push(m,f)}t.boundingBoxesPolygon.poly(h).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let o=0,n=i.length;o<n;o++){const a=i[o];l(a,0,a.length)}}drawPathsFunc(e,t,s){const i=e.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l];if(!n.bone.active)continue;const a=n.getAttachment();if(a===null||!(a instanceof Mt))continue;const h=a;let c=h.worldVerticesLength;const u=new Float32Array(c);h.computeWorldVertices(n,0,c,u,0,2);let d=u[2],m=u[3],f=0,p=0;if(h.closed){const b=u[0],w=u[1],g=u[c-2],x=u[c-1];f=u[c-4],p=u[c-3],t.pathsCurve.moveTo(d,m),t.pathsCurve.bezierCurveTo(b,w,g,x,f,p),t.pathsLine.moveTo(d,m),t.pathsLine.lineTo(b,w),t.pathsLine.moveTo(f,p),t.pathsLine.lineTo(g,x)}c-=4;for(let b=4;b<c;b+=6){const w=u[b],g=u[b+1],x=u[b+2],y=u[b+3];f=u[b+4],p=u[b+5],t.pathsCurve.moveTo(d,m),t.pathsCurve.bezierCurveTo(w,g,x,y,f,p),t.pathsLine.moveTo(d,m),t.pathsLine.lineTo(w,g),t.pathsLine.moveTo(f,p),t.pathsLine.lineTo(x,y),d=f,m=p}}t.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),t.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(e){this.registeredSpines.has(e)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",e);const t=this.registeredSpines.get(e);t&&(e.state.removeListener(t.eventCallback),t.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(e))}};return gi(ps)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@esotericsoftware/spine-pixi-v8",
3
- "version": "4.2.87",
3
+ "version": "4.2.88",
4
4
  "description": "The official Spine Runtimes for PixiJS v8.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "homepage": "https://github.com/esotericsoftware/spine-runtimes#readme",
33
33
  "dependencies": {
34
- "@esotericsoftware/spine-core": "4.2.87"
34
+ "@esotericsoftware/spine-core": "4.2.88"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "pixi.js": "^8.4.0"