@esotericsoftware/spine-pixi-v8 4.2.73 → 4.2.75
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.
- package/dist/Spine.d.ts +1 -1
- package/dist/Spine.js +3 -2
- package/dist/esm/spine-pixi-v8.min.mjs +1 -1
- package/dist/esm/spine-pixi-v8.mjs +2 -1
- package/dist/esm/spine-pixi-v8.mjs.map +2 -2
- package/dist/iife/spine-pixi-v8.js +2 -1
- package/dist/iife/spine-pixi-v8.js.map +2 -2
- package/dist/iife/spine-pixi-v8.min.js +1 -1
- package/package.json +2 -2
|
@@ -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
|
-
`}},li=class extends pe.Shader{constructor(e){const t=(0,pe.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[pe.colorBitGl,oi,(0,pe.generateTextureBatchBitGl)(e),pe.roundPixelsBitGl]}),s=(0,pe.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[pe.colorBit,ai,(0,pe.generateTextureBatchBit)(e),pe.roundPixelsBit]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:(0,pe.getBatchSamplersUniformGroup)(e)}})}},Hs=null,$s=class extends dt.Batcher{geometry=new ni;shader=Hs||(Hs=new li(this.maxTextures));name=$s.extension.name;vertexSize=7;packAttributes(e,t,s,r,n){const h=n<<16|e.roundPixels&65535,a=e.transform,i=a.a,l=a.b,o=a.c,c=a.d,d=a.tx,f=a.ty,{positions:u,uvs:m}=e,p=e.color,w=(p>>24&255)/255,b=dt.Color.shared.setValue(e.darkColor).premultiply(w,!0).toPremultiplied(1,!1),g=e.attributeOffset,x=g+e.attributeSize;for(let v=g;v<x;v++){const y=v*2,C=u[y],S=u[y+1];t[r++]=i*C+o*S+d,t[r++]=c*S+l*C+f,t[r++]=m[y],t[r++]=m[y+1],s[r++]=p,s[r++]=b,s[r++]=h}}packQuadAttributes(e,t,s,r,n){const h=e.texture,a=e.transform,i=a.a,l=a.b,o=a.c,c=a.d,d=a.tx,f=a.ty,u=e.bounds,m=u.maxX,p=u.minX,w=u.maxY,b=u.minY,g=h.uvs,x=e.color,v=e.darkColor,y=n<<16|e.roundPixels&65535;t[r+0]=i*p+o*b+d,t[r+1]=c*b+l*p+f,t[r+2]=g.x0,t[r+3]=g.y0,s[r+4]=x,s[r+5]=v,s[r+6]=y,t[r+7]=i*m+o*b+d,t[r+8]=c*b+l*m+f,t[r+9]=g.x1,t[r+10]=g.y1,s[r+11]=x,s[r+12]=v,s[r+13]=y,t[r+14]=i*m+o*w+d,t[r+15]=c*w+l*m+f,t[r+16]=g.x2,t[r+17]=g.y2,s[r+18]=x,s[r+19]=v,s[r+20]=y,t[r+21]=i*p+o*w+d,t[r+22]=c*w+l*p+f,t[r+23]=g.x3,t[r+24]=g.y3,s[r+25]=x,s[r+26]=v,s[r+27]=y}},js=$s;R(js,"extension",{type:[dt.ExtensionType.Batcher],name:"darkTint"}),dt.extensions.add(js);var Ge=xe("pixi.js"),hi=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 n=e.a*s*255;if(t!==16777215){const h=t>>16&255,a=t>>8&255,i=t&255,l=e.r*i,o=e.g*a,c=e.b*h;r=n<<24|c<<16|o<<8|l}else r=n<<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 n=t.clippedData;this.indexSize=n.indicesCount,this.attributeSize=n.vertexCount,this.positions=n.vertices,this.indices=n.indices,this.uvs=n.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"}},ci={0:"normal",1:"add",2:"multiply",3:"screen"},us=class{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,n=t.length;r<n;r++){const h=t[r],a=h.getAttachment();if(a instanceof N||a instanceof le){const i=e._getCachedData(h,a),l=s.slotBatches[i.id],o=i.texture;if(o!==l.texture&&!l._batcher.checkAndUpdateTexture(l,o))return!0}}}return!1}addRenderable(e,t){const s=this._getSpineData(e),r=this.renderer.renderPipes.batch,n=e.skeleton.drawOrder,h=this.renderer._roundPixels|e._roundPixels;e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;for(let a=0,i=n.length;a<i;a++){const l=n[a],o=l.getAttachment(),c=ci[l.data.blendMode];if(o instanceof N||o instanceof le){const f=e._getCachedData(l,o),u=s.slotBatches[f.id]||=new hi;u.setData(e,f,c,h),f.skipRender||r.addToBatch(u,t)}const d=e._slotsObject[l.data.name];if(d){const f=d.container;f.includeInBuild=!0,(0,Ge.collectAllRenderables)(f,t,this.renderer),f.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,n=s.length;r<n;r++){const h=s[r],a=h.getAttachment();if((a instanceof N||a instanceof le)&&!e._getCachedData(h,a).skipRender){const l=t.slotBatches[e._getCachedData(h,a).id];l._batcher?.updateElement(l)}}}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]}};R(us,"extension",{type:[Ge.ExtensionType.WebGLPipes,Ge.ExtensionType.WebGPUPipes,Ge.ExtensionType.CanvasPipes],name:"spine"}),Ge.extensions.add(us);var se=xe("pixi.js"),ft=new Ve;Se.yDown=!0;var _e=new De,di=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}}},fi=class{constructor(e=!1){this.clipping=e}calculateBounds(e){if(!e.skeleton)return{x:0,y:0,width:0,height:0};const t=new Se(e.skeleton.data);t.setToSetupPose(),t.updateWorldTransform(2);const s=t.getBoundsRect(this.clipping?new De:void 0);return s.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},ui=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 tt(e.state.data),s=new Se(e.skeleton.data),r=this.clipping?new De:void 0,n=s.data;if(this.skins.length>0){let a=new ze("custom-skin");for(const i of this.skins){const l=n.findSkin(i);l!=null&&a.addSkin(l)}s.setSkin(a)}s.setToSetupPose();const h=this.animation!=null?n.findAnimation(this.animation):null;if(h==null){s.updateWorldTransform(2);const a=s.getBoundsRect(r);return a.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:a}else{let a=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;t.clearTracks(),t.setAnimationWith(0,h,!1);const c=Math.max(h.duration/this.timeStep,1);for(let f=0;f<c;f++){const u=f>0?this.timeStep:0;t.update(u),t.apply(s),s.update(u),s.updateWorldTransform(2);const m=s.getBoundsRect(r);a=Math.min(a,m.x),i=Math.min(i,m.y),l=Math.max(l,m.x+m.width),o=Math.max(o,m.y+m.height)}const d={x:a,y:i,width:l-a,height:o-i};return d.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:d}}},Js=new Be(()=>new se.Graphics),ms=class extends se.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(e){let t;if(typeof e=="number"?t=this.skeleton.slots[e]:typeof e=="string"?t=this.skeleton.findSlot(e):t=e,!t)throw new Error(`No slot found with the given slot reference: ${e}`);return t}spineAttachmentsDirty=!0;spineTexturesDirty=!0;_lastAttachments=[];_stateChanged=!0;attachmentCacheData=[];get debug(){return this._debug}set debug(e){this._debug&&this._debug.unregisterSpine(this),e&&e.registerSpine(this),this._debug=e}_autoUpdate=!0;get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e?se.Ticker.shared.add(this.internalUpdate,this):se.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=e}_boundsProvider;get boundsProvider(){return this._boundsProvider}set boundsProvider(e){this._boundsProvider=e,e&&(this._boundsDirty=!1),this.updateBounds()}hasNeverUpdated=!0;constructor(e){e instanceof We&&(e={skeletonData:e}),super();const t=e instanceof We?e:e.skeletonData;this.skeleton=new Se(t),this.state=new tt(new Xs(t)),this.autoUpdate=e?.autoUpdate??!0,this.darkTint=e?.darkTint===void 0?this.skeleton.slots.some(r=>!!r.data.darkColor):e?.darkTint;const s=this.skeleton.slots;for(let r=0;r<s.length;r++)this.attachmentCacheData[r]=Object.create(null);this._boundsProvider=e.boundsProvider}update(e){this.internalUpdate(0,e)}internalUpdate(e,t){this._updateAndApplyState(t??se.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(e,t){const s=e;if(typeof e=="string"&&(e=this.skeleton.findBone(e)),!e)throw Error(`Cant set bone position, bone ${String(s)} not found`);if(ft.set(t.x,t.y),e.parent){const r=e.parent.worldToLocal(ft);e.x=r.x,e.y=-r.y}else e.x=ft.x,e.y=ft.y}getBonePosition(e,t){const s=e;return typeof e=="string"&&(e=this.skeleton.findBone(e)),e?(t||(t={x:0,y:0}),t.x=e.worldX,t.y=e.worldY,t):(console.error(`Cant set bone position! Bone ${String(s)} not found`),t)}_updateAndApplyState(e){this.hasNeverUpdated=!1,this.state.update(e),this.skeleton.update(e);const{skeleton:t}=this;this.state.apply(t),this.beforeUpdateWorldTransforms(this),t.updateWorldTransform(2),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const e=this.skeleton.drawOrder,t=this._lastAttachments;let s=0,r=!1;for(let n=0;n<e.length;n++){const a=e[n].getAttachment();a&&(a!==t[s]&&(r=!0,t[s]=a),s++)}s!==t.length&&(r=!0,t.length=s),this.spineAttachmentsDirty||=r}updateAndSetPixiMask(e,t){const s=e.attachment;if(s&&s instanceof ve){const h=this.clippingSlotToPixiMasks[e.data.name]||={slot:e,vertices:new Array};h.maskComputed=!1,this.currentClippingSlot=this.clippingSlotToPixiMasks[e.data.name];return}let r=this.currentClippingSlot,n=this._slotsObject[e.data.name];if(r&&n){let h=r.slot,a=h.attachment,i=r.mask;if(i||(i=Js.obtain(),r.mask=i,this.addChild(i)),!r.maskComputed){r.maskComputed=!0;const l=a.worldVerticesLength,o=r.vertices;a.computeWorldVertices(h,0,l,o,0,2),i.clear().poly(o).stroke({width:0}).fill({alpha:.25})}n.container.mask=i}else n?.container.mask&&(n.container.mask=null);if(r&&r.slot.attachment.endSlot==e.data&&(this.currentClippingSlot=void 0),t)for(const h in this.clippingSlotToPixiMasks){const a=this.clippingSlotToPixiMasks[h];(!(a.slot.attachment instanceof ve)||!a.maskComputed)&&a.mask&&(this.removeChild(a.mask),Js.free(a.mask),a.mask=void 0)}}currentClippingSlot;transformAttachments(){const e=this.skeleton.drawOrder;for(let t=0;t<e.length;t++){const s=e[t];this.updateAndSetPixiMask(s,t===e.length-1);const r=s.getAttachment();if(r){if(r instanceof le||r instanceof N){const n=this._getCachedData(s,r);r instanceof N?r.computeWorldVertices(s,n.vertices,0,2):r.computeWorldVertices(s,0,r.worldVerticesLength,n.vertices,0,2),n.uvs.length<r.uvs.length&&(n.uvs=new Float32Array(r.uvs.length)),(0,se.fastCopy)(r.uvs.buffer,n.uvs.buffer);const a=s.bone.skeleton.color,i=s.color,l=r.color;n.color.set(a.r*i.r*l.r,a.g*i.g*l.g,a.b*i.b*l.b,a.a*i.a*l.a),s.darkColor&&n.darkColor.setFromColor(s.darkColor),n.skipRender=n.clipped=!1;const o=r.region?.texture.texture||se.Texture.EMPTY;n.texture!==o&&(n.texture=o,this.spineTexturesDirty=!0),_e.isClipping()&&this.updateClippingData(n)}else if(r instanceof ve){_e.clipStart(s,r);continue}}_e.clipEndWithSlot(s)}_e.clipEnd()}updateClippingData(e){e.clipped=!0,_e.clipTrianglesUnpacked(e.vertices,e.indices,e.indices.length,e.uvs);const{clippedVertices:t,clippedUVs:s,clippedTriangles:r}=_e,n=t.length/2,h=r.length;e.clippedData||(e.clippedData={vertices:new Float32Array(n*2),uvs:new Float32Array(n*2),vertexCount:n,indices:new Uint16Array(h),indicesCount:h},this.spineAttachmentsDirty=!0);const a=e.clippedData,i=a.vertexCount!==n||h!==a.indicesCount;e.skipRender=n===0,i&&(this.spineAttachmentsDirty=!0,a.vertexCount<n&&(a.vertices=new Float32Array(n*2),a.uvs=new Float32Array(n*2)),a.indices.length<h&&(a.indices=new Uint16Array(h)));const{vertices:l,uvs:o,indices:c}=a;for(let d=0;d<n;d++)l[d*2]=t[d*2],l[d*2+1]=t[d*2+1],o[d*2]=s[d*2],o[d*2+1]=s[d*2+1];a.vertexCount=n;for(let d=0;d<h;d++)c[d]!==r[d]&&(this.spineAttachmentsDirty=!0,c[d]=r[d]);a.indicesCount=h}updateSlotObjects(){for(const e in this._slotsObject){const t=this._slotsObject[e];t&&this.updateSlotObject(t)}}updateSlotObject(e){const{slot:t,container:s}=e,r=e.followAttachmentTimeline?Boolean(t.attachment):!0;if(s.visible=this.skeleton.drawOrder.includes(t)&&r,s.visible){const n=t.bone;s.position.set(n.worldX,n.worldY),s.scale.x=n.getWorldScaleX(),s.scale.y=n.getWorldScaleY(),s.rotation=n.getWorldRotationX()*se.DEG_TO_RAD,s.alpha=this.skeleton.color.a*t.color.a}}_getCachedData(e,t){return this.attachmentCacheData[e.data.index][t.name]||this.initCachedData(e,t)}initCachedData(e,t){let s;return t instanceof N?(s=new Float32Array(8),this.attachmentCacheData[e.data.index][t.name]={id:`${e.data.index}-${t.name}`,vertices:s,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(t.uvs.length),color:new L(1,1,1,1),darkColor:new L(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:t.region?.texture.texture}):(s=new Float32Array(t.worldVerticesLength),this.attachmentCacheData[e.data.index][t.name]={id:`${e.data.index}-${t.name}`,vertices:s,clipped:!1,indices:t.triangles,uvs:new Float32Array(t.uvs.length),color:new L(1,1,1,1),darkColor:new L(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:t.region?.texture.texture}),this.attachmentCacheData[e.data.index][t.name]}onViewUpdate(){if(this._didViewChangeTick++,this._boundsProvider||(this._boundsDirty=!0),this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this),this.debug?.renderDebug(this)}addSlotObject(e,t,s){e=this.getSlotFromRef(e);for(const n in this._slotsObject)this._slotsObject[n]?.container===t&&this.removeSlotObject(this._slotsObject[n].slot);this.removeSlotObject(e),t.includeInBuild=!1,this.addChild(t);const r={container:t,slot:e,followAttachmentTimeline:s?.followAttachmentTimeline||!1};this._slotsObject[e.data.name]=r,this.updateSlotObject(r)}removeSlotObject(e){let t;if(e instanceof se.Container){for(const s in this._slotsObject)if(this._slotsObject[s]?.container===e){this._slotsObject[s]=null,t=e;break}}else{const s=this.getSlotFromRef(e);t=this._slotsObject[s.data.name]?.container,this._slotsObject[s.data.name]=null}t&&(this.removeChild(t),t.includeInBuild=!0)}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([e,t])=>{t&&t.container.removeFromParent(),delete this._slotsObject[e]})}getSlotObject(e){return e=this.getSlotFromRef(e),this._slotsObject[e.data.name]?.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||=new ds;const e=this.skeletonBounds;if(e.update(this.skeleton,!0),this._boundsProvider){const t=this._boundsProvider.calculateBounds(this),s=this._bounds;s.clear(),s.x=t.x,s.y=t.y,s.width=t.width,s.height=t.height}else if(e.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const t=this.skeleton.drawOrder,s=this._bounds;s.clear();for(let r=0;r<t.length;r++){const n=t[r],h=n.getAttachment();if(h&&(h instanceof N||h instanceof le)){const a=this._getCachedData(n,h);s.addVertexData(a.vertices,0,a.vertices.length)}}}else this._bounds.minX=e.minX,this._bounds.minY=e.minY,this._bounds.maxX=e.maxX,this._bounds.maxY=e.maxY}addBounds(e){e.addBounds(this.bounds)}destroy(e=!1){super.destroy(e),se.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(e){this.worldTransform.apply(e,e)}pixiWorldCoordinatesToSkeleton(e){this.worldTransform.applyInverse(e,e)}pixiWorldCoordinatesToBone(e,t){this.pixiWorldCoordinatesToSkeleton(e),t.parent?t.parent.worldToLocal(e):t.worldToLocal(e)}static from({skeleton:e,atlas:t,scale:s=1,darkTint:r,autoUpdate:n=!0,boundsProvider:h}){const a=`${e}-${t}-${s}`;if(se.Cache.has(a))return new ms({skeletonData:se.Cache.get(a),darkTint:r,autoUpdate:n,boundsProvider:h});const i=se.Assets.get(e),l=se.Assets.get(t),o=new _s(l),c=i instanceof Uint8Array?new Ws(o):new Gs(o);c.scale=s;const d=c.readSkeletonData(i);return se.Cache.set(a,d),new ms({skeletonData:d,darkTint:r,autoUpdate:n,boundsProvider:h})}},re=xe("pixi.js"),mi=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 re.Container,bones:new re.Container,skeletonXY:new re.Graphics,regionAttachmentsShape:new re.Graphics,meshTrianglesLine:new re.Graphics,meshHullLine:new re.Graphics,clippingPolygon:new re.Graphics,boundingBoxesRect:new re.Graphics,boundingBoxesCircle:new re.Graphics,boundingBoxesPolygon:new re.Graphics,pathsCurve:new re.Graphics,pathsLine:new re.Graphics,eventText:new re.Container,eventCallback:{event:(s,r)=>{if(this.drawEvents){const n=Math.abs(e.scale.x||e.scale.y||1),h=new re.Text({text:r.data.name,style:{fontSize:this.eventFontSize/n,fill:this.eventFontColor,fontFamily:"monospace"}});h.scale.x=Math.sign(e.scale.x),h.anchor.set(.5),t.eventText.addChild(h),setTimeout(()=>{h.destroyed||h.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 n=t.bones.children.length;n>0;n--)t.bones.children[n-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 n of t.eventText.children)n.alpha-=.05,n.y-=2}drawBonesFunc(e,t,s,r){const n=e.skeleton,h=n.x,a=n.y,i=n.bones;t.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let o=0,c=i.length;o<c;o++){const d=i[o],f=d.data.length,u=h+d.worldX,m=a+d.worldY,p=h+f*d.a+d.worldX,w=a+f*d.b+d.worldY;if(d.data.name==="root"||d.data.parent===null)continue;const b=Math.abs(u-p),g=Math.abs(m-w),x=Math.pow(b,2),v=g,y=Math.pow(g,2),C=Math.sqrt(x+y),S=Math.pow(C,2),A=Math.PI/180,M=Math.acos((S+y-x)/(2*v*C))||0;if(C===0)continue;const T=new re.Graphics;t.bones.addChild(T);const F=C/50/r;T.context.poly([0,0,0-F,C-F*3,0,C-F,0+F,C-F*3]).fill(this.bonesColor),T.x=u,T.y=m,T.pivot.y=C;let P=0;u<p&&m<w?P=-M+180*A:u>p&&m<w?P=180*A+M:u>p&&m>w?P=-M:u<p&&m>w?P=M:m===w&&u<p?P=90*A:m===w&&u>p?P=-90*A:u===p&&m<w?P=180*A:u===p&&m>w&&(P=0),T.rotation=P,T.circle(0,C,F*1.2).fill({color:0,alpha:.6}).stroke({width:s+F/2.4,color:this.bonesColor})}const l=s*3;t.skeletonXY.context.moveTo(h-l,a-l).lineTo(h+l,a+l).moveTo(h+l,a-l).lineTo(h-l,a+l).stroke()}drawRegionAttachmentsFunc(e,t,s){const n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h],l=i.getAttachment();if(l===null||!(l instanceof N))continue;const o=l,c=new Float32Array(8);o.computeWorldVertices(i,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 n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h];if(!i.bone.active)continue;const l=i.getAttachment();if(l===null||!(l instanceof le))continue;const o=l,c=new Float32Array(o.worldVerticesLength),d=o.triangles;let f=o.hullLength;if(o.computeWorldVertices(i,0,o.worldVerticesLength,c,0,2),this.drawMeshTriangles)for(let u=0,m=d.length;u<m;u+=3){const p=d[u]*2,w=d[u+1]*2,b=d[u+2]*2;t.meshTrianglesLine.context.moveTo(c[p],c[p+1]).lineTo(c[w],c[w+1]).lineTo(c[b],c[b+1])}if(this.drawMeshHull&&f>0){f=(f>>1)*2;let u=c[f-2],m=c[f-1];for(let p=0,w=f;p<w;p+=2){const b=c[p],g=c[p+1];t.meshHullLine.context.moveTo(b,g).lineTo(u,m),u=b,m=g}}}t.meshHullLine.stroke({width:s,color:this.meshHullColor}),t.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(e,t,s){const n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h];if(!i.bone.active)continue;const l=i.getAttachment();if(l===null||!(l instanceof ve))continue;const o=l,c=o.worldVerticesLength,d=new Float32Array(c);o.computeWorldVertices(i,0,c,d,0,2),t.clippingPolygon.poly(Array.from(d))}t.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(e,t,s){const r=new ds;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 n=r.polygons,h=(a,i,l)=>{if(l<3)throw new Error("Polygon must contain at least 3 vertices");const o=[],c=s*2;for(let d=0,f=a.length;d<f;d+=2){const u=a[d],m=a[d+1];t.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),t.boundingBoxesCircle.drawCircle(u,m,c),t.boundingBoxesCircle.fill(0),t.boundingBoxesCircle.circle(u,m,c).fill({color:this.boundingBoxesCircleColor}),o.push(u,m)}t.boundingBoxesPolygon.poly(o).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let a=0,i=n.length;a<i;a++){const l=n[a];h(l,0,l.length)}}drawPathsFunc(e,t,s){const n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h];if(!i.bone.active)continue;const l=i.getAttachment();if(l===null||!(l instanceof Pe))continue;const o=l;let c=o.worldVerticesLength;const d=new Float32Array(c);o.computeWorldVertices(i,0,c,d,0,2);let f=d[2],u=d[3],m=0,p=0;if(o.closed){const w=d[0],b=d[1],g=d[c-2],x=d[c-1];m=d[c-4],p=d[c-3],t.pathsCurve.moveTo(f,u),t.pathsCurve.bezierCurveTo(w,b,g,x,m,p),t.pathsLine.moveTo(f,u),t.pathsLine.lineTo(w,b),t.pathsLine.moveTo(m,p),t.pathsLine.lineTo(g,x)}c-=4;for(let w=4;w<c;w+=6){const b=d[w],g=d[w+1],x=d[w+2],v=d[w+3];m=d[w+4],p=d[w+5],t.pathsCurve.moveTo(f,u),t.pathsCurve.bezierCurveTo(b,g,x,v,m,p),t.pathsLine.moveTo(f,u),t.pathsLine.lineTo(b,g),t.pathsLine.moveTo(m,p),t.pathsLine.lineTo(x,v),f=m,u=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 lr(xs)})();
|
|
27
|
+
`}},li=class extends pe.Shader{constructor(e){const t=(0,pe.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[pe.colorBitGl,oi,(0,pe.generateTextureBatchBitGl)(e),pe.roundPixelsBitGl]}),s=(0,pe.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[pe.colorBit,ai,(0,pe.generateTextureBatchBit)(e),pe.roundPixelsBit]});super({glProgram:t,gpuProgram:s,resources:{batchSamplers:(0,pe.getBatchSamplersUniformGroup)(e)}})}},Hs=null,$s=class extends dt.Batcher{geometry=new ni;shader=Hs||(Hs=new li(this.maxTextures));name=$s.extension.name;vertexSize=7;packAttributes(e,t,s,r,n){const h=n<<16|e.roundPixels&65535,a=e.transform,i=a.a,l=a.b,o=a.c,c=a.d,d=a.tx,f=a.ty,{positions:u,uvs:m}=e,p=e.color,w=(p>>24&255)/255,b=dt.Color.shared.setValue(e.darkColor).premultiply(w,!0).toPremultiplied(1,!1),g=e.attributeOffset,x=g+e.attributeSize;for(let v=g;v<x;v++){const y=v*2,C=u[y],S=u[y+1];t[r++]=i*C+o*S+d,t[r++]=c*S+l*C+f,t[r++]=m[y],t[r++]=m[y+1],s[r++]=p,s[r++]=b,s[r++]=h}}packQuadAttributes(e,t,s,r,n){const h=e.texture,a=e.transform,i=a.a,l=a.b,o=a.c,c=a.d,d=a.tx,f=a.ty,u=e.bounds,m=u.maxX,p=u.minX,w=u.maxY,b=u.minY,g=h.uvs,x=e.color,v=e.darkColor,y=n<<16|e.roundPixels&65535;t[r+0]=i*p+o*b+d,t[r+1]=c*b+l*p+f,t[r+2]=g.x0,t[r+3]=g.y0,s[r+4]=x,s[r+5]=v,s[r+6]=y,t[r+7]=i*m+o*b+d,t[r+8]=c*b+l*m+f,t[r+9]=g.x1,t[r+10]=g.y1,s[r+11]=x,s[r+12]=v,s[r+13]=y,t[r+14]=i*m+o*w+d,t[r+15]=c*w+l*m+f,t[r+16]=g.x2,t[r+17]=g.y2,s[r+18]=x,s[r+19]=v,s[r+20]=y,t[r+21]=i*p+o*w+d,t[r+22]=c*w+l*p+f,t[r+23]=g.x3,t[r+24]=g.y3,s[r+25]=x,s[r+26]=v,s[r+27]=y}},js=$s;R(js,"extension",{type:[dt.ExtensionType.Batcher],name:"darkTint"}),dt.extensions.add(js);var Ge=xe("pixi.js"),hi=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 n=e.a*s*255;if(t!==16777215){const h=t>>16&255,a=t>>8&255,i=t&255,l=e.r*i,o=e.g*a,c=e.b*h;r=n<<24|c<<16|o<<8|l}else r=n<<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 n=t.clippedData;this.indexSize=n.indicesCount,this.attributeSize=n.vertexCount,this.positions=n.vertices,this.indices=n.indices,this.uvs=n.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"}},ci={0:"normal",1:"add",2:"multiply",3:"screen"},us=class{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,n=t.length;r<n;r++){const h=t[r],a=h.getAttachment();if(a instanceof N||a instanceof le){const i=e._getCachedData(h,a),l=s.slotBatches[i.id],o=i.texture;if(o!==l.texture&&!l._batcher.checkAndUpdateTexture(l,o))return!0}}}return!1}addRenderable(e,t){const s=this._getSpineData(e),r=this.renderer.renderPipes.batch,n=e.skeleton.drawOrder,h=this.renderer._roundPixels|e._roundPixels;e._validateAndTransformAttachments(),e.spineAttachmentsDirty=!1,e.spineTexturesDirty=!1;for(let a=0,i=n.length;a<i;a++){const l=n[a],o=l.getAttachment(),c=ci[l.data.blendMode];if(o instanceof N||o instanceof le){const f=e._getCachedData(l,o),u=s.slotBatches[f.id]||=new hi;u.setData(e,f,c,h),f.skipRender||r.addToBatch(u,t)}const d=e._slotsObject[l.data.name];if(d){const f=d.container;f.includeInBuild=!0,(0,Ge.collectAllRenderables)(f,t,this.renderer),f.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,n=s.length;r<n;r++){const h=s[r],a=h.getAttachment();if((a instanceof N||a instanceof le)&&!e._getCachedData(h,a).skipRender){const l=t.slotBatches[e._getCachedData(h,a).id];l._batcher?.updateElement(l)}}}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]}};R(us,"extension",{type:[Ge.ExtensionType.WebGLPipes,Ge.ExtensionType.WebGPUPipes,Ge.ExtensionType.CanvasPipes],name:"spine"}),Ge.extensions.add(us);var se=xe("pixi.js"),ft=new Ve;Se.yDown=!0;var _e=new De,di=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}}},fi=class{constructor(e=!1){this.clipping=e}calculateBounds(e){if(!e.skeleton)return{x:0,y:0,width:0,height:0};const t=new Se(e.skeleton.data);t.setToSetupPose(),t.updateWorldTransform(2);const s=t.getBoundsRect(this.clipping?new De:void 0);return s.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},ui=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 tt(e.state.data),s=new Se(e.skeleton.data),r=this.clipping?new De:void 0,n=s.data;if(this.skins.length>0){let a=new ze("custom-skin");for(const i of this.skins){const l=n.findSkin(i);l!=null&&a.addSkin(l)}s.setSkin(a)}s.setToSetupPose();const h=this.animation!=null?n.findAnimation(this.animation):null;if(h==null){s.updateWorldTransform(2);const a=s.getBoundsRect(r);return a.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:a}else{let a=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,l=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY;t.clearTracks(),t.setAnimationWith(0,h,!1);const c=Math.max(h.duration/this.timeStep,1);for(let f=0;f<c;f++){const u=f>0?this.timeStep:0;t.update(u),t.apply(s),s.update(u),s.updateWorldTransform(2);const m=s.getBoundsRect(r);a=Math.min(a,m.x),i=Math.min(i,m.y),l=Math.max(l,m.x+m.width),o=Math.max(o,m.y+m.height)}const d={x:a,y:i,width:l-a,height:o-i};return d.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:d}}},Js=new Be(()=>new se.Graphics),ms=class extends se.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(e){let t;if(typeof e=="number"?t=this.skeleton.slots[e]:typeof e=="string"?t=this.skeleton.findSlot(e):t=e,!t)throw new Error(`No slot found with the given slot reference: ${e}`);return t}spineAttachmentsDirty=!0;spineTexturesDirty=!0;_lastAttachments=[];_stateChanged=!0;attachmentCacheData=[];get debug(){return this._debug}set debug(e){this._debug&&this._debug.unregisterSpine(this),e&&e.registerSpine(this),this._debug=e}_autoUpdate=!0;get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e?se.Ticker.shared.add(this.internalUpdate,this):se.Ticker.shared.remove(this.internalUpdate,this),this._autoUpdate=e}_boundsProvider;get boundsProvider(){return this._boundsProvider}set boundsProvider(e){this._boundsProvider=e,e&&(this._boundsDirty=!1),this.updateBounds()}hasNeverUpdated=!0;constructor(e){e instanceof We&&(e={skeletonData:e}),super();const t=e instanceof We?e:e.skeletonData;this.skeleton=new Se(t),this.state=new tt(new Xs(t)),this.autoUpdate=e?.autoUpdate??!0,this.darkTint=e?.darkTint===void 0?this.skeleton.slots.some(r=>!!r.data.darkColor):e?.darkTint;const s=this.skeleton.slots;for(let r=0;r<s.length;r++)this.attachmentCacheData[r]=Object.create(null);this._boundsProvider=e.boundsProvider}update(e){this.internalUpdate(0,e)}internalUpdate(e,t){this._updateAndApplyState(t??se.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(e,t){const s=e;if(typeof e=="string"&&(e=this.skeleton.findBone(e)),!e)throw Error(`Cant set bone position, bone ${String(s)} not found`);if(ft.set(t.x,t.y),e.parent){const r=e.parent.worldToLocal(ft);e.x=r.x,e.y=-r.y}else e.x=ft.x,e.y=ft.y}getBonePosition(e,t){const s=e;return typeof e=="string"&&(e=this.skeleton.findBone(e)),e?(t||(t={x:0,y:0}),t.x=e.worldX,t.y=e.worldY,t):(console.error(`Cant set bone position! Bone ${String(s)} not found`),t)}_updateAndApplyState(e){this.hasNeverUpdated=!1,this.state.update(e),this.skeleton.update(e);const{skeleton:t}=this;this.state.apply(t),this.beforeUpdateWorldTransforms(this),t.updateWorldTransform(2),this.afterUpdateWorldTransforms(this),this.updateSlotObjects(),this._stateChanged=!0,this.onViewUpdate()}_validateAndTransformAttachments(){this._stateChanged&&(this._stateChanged=!1,this.validateAttachments(),this.transformAttachments())}validateAttachments(){const e=this.skeleton.drawOrder,t=this._lastAttachments;let s=0,r=!1;for(let n=0;n<e.length;n++){const a=e[n].getAttachment();a&&(a!==t[s]&&(r=!0,t[s]=a),s++)}s!==t.length&&(r=!0,t.length=s),this.spineAttachmentsDirty||=r}currentClippingSlot;updateAndSetPixiMask(e,t){const s=e.attachment;if(s&&s instanceof ve){const h=this.clippingSlotToPixiMasks[e.data.name]||={slot:e,vertices:new Array};h.maskComputed=!1,this.currentClippingSlot=this.clippingSlotToPixiMasks[e.data.name];return}let r=this.currentClippingSlot,n=this._slotsObject[e.data.name];if(r&&n){let h=r.slot,a=h.attachment,i=r.mask;if(i||(i=Js.obtain(),r.mask=i,this.addChild(i)),!r.maskComputed){r.maskComputed=!0;const l=a.worldVerticesLength,o=r.vertices;a.computeWorldVertices(h,0,l,o,0,2),i.clear().poly(o).stroke({width:0}).fill({alpha:.25})}n.container.mask=i}else n?.container.mask&&(n.container.mask=null);if(r&&r.slot.attachment.endSlot==e.data&&(this.currentClippingSlot=void 0),t){for(const h in this.clippingSlotToPixiMasks){const a=this.clippingSlotToPixiMasks[h];(!(a.slot.attachment instanceof ve)||!a.maskComputed)&&a.mask&&(this.removeChild(a.mask),Js.free(a.mask),a.mask=void 0)}this.currentClippingSlot=void 0}}transformAttachments(){const e=this.skeleton.drawOrder;for(let t=0;t<e.length;t++){const s=e[t];this.updateAndSetPixiMask(s,t===e.length-1);const r=s.getAttachment();if(r){if(r instanceof le||r instanceof N){const n=this._getCachedData(s,r);r instanceof N?r.computeWorldVertices(s,n.vertices,0,2):r.computeWorldVertices(s,0,r.worldVerticesLength,n.vertices,0,2),n.uvs.length<r.uvs.length&&(n.uvs=new Float32Array(r.uvs.length)),(0,se.fastCopy)(r.uvs.buffer,n.uvs.buffer);const a=s.bone.skeleton.color,i=s.color,l=r.color;n.color.set(a.r*i.r*l.r,a.g*i.g*l.g,a.b*i.b*l.b,a.a*i.a*l.a),s.darkColor&&n.darkColor.setFromColor(s.darkColor),n.skipRender=n.clipped=!1;const o=r.region?.texture.texture||se.Texture.EMPTY;n.texture!==o&&(n.texture=o,this.spineTexturesDirty=!0),_e.isClipping()&&this.updateClippingData(n)}else if(r instanceof ve){_e.clipStart(s,r);continue}}_e.clipEndWithSlot(s)}_e.clipEnd()}updateClippingData(e){e.clipped=!0,_e.clipTrianglesUnpacked(e.vertices,e.indices,e.indices.length,e.uvs);const{clippedVertices:t,clippedUVs:s,clippedTriangles:r}=_e,n=t.length/2,h=r.length;e.clippedData||(e.clippedData={vertices:new Float32Array(n*2),uvs:new Float32Array(n*2),vertexCount:n,indices:new Uint16Array(h),indicesCount:h},this.spineAttachmentsDirty=!0);const a=e.clippedData,i=a.vertexCount!==n||h!==a.indicesCount;e.skipRender=n===0,i&&(this.spineAttachmentsDirty=!0,a.vertexCount<n&&(a.vertices=new Float32Array(n*2),a.uvs=new Float32Array(n*2)),a.indices.length<h&&(a.indices=new Uint16Array(h)));const{vertices:l,uvs:o,indices:c}=a;for(let d=0;d<n;d++)l[d*2]=t[d*2],l[d*2+1]=t[d*2+1],o[d*2]=s[d*2],o[d*2+1]=s[d*2+1];a.vertexCount=n;for(let d=0;d<h;d++)c[d]!==r[d]&&(this.spineAttachmentsDirty=!0,c[d]=r[d]);a.indicesCount=h}updateSlotObjects(){for(const e in this._slotsObject){const t=this._slotsObject[e];t&&this.updateSlotObject(t)}}updateSlotObject(e){const{slot:t,container:s}=e,r=e.followAttachmentTimeline?Boolean(t.attachment):!0;if(s.visible=this.skeleton.drawOrder.includes(t)&&r,s.visible){const n=t.bone;s.position.set(n.worldX,n.worldY),s.scale.x=n.getWorldScaleX(),s.scale.y=n.getWorldScaleY(),s.rotation=n.getWorldRotationX()*se.DEG_TO_RAD,s.alpha=this.skeleton.color.a*t.color.a}}_getCachedData(e,t){return this.attachmentCacheData[e.data.index][t.name]||this.initCachedData(e,t)}initCachedData(e,t){let s;return t instanceof N?(s=new Float32Array(8),this.attachmentCacheData[e.data.index][t.name]={id:`${e.data.index}-${t.name}`,vertices:s,clipped:!1,indices:[0,1,2,0,2,3],uvs:new Float32Array(t.uvs.length),color:new L(1,1,1,1),darkColor:new L(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:t.region?.texture.texture}):(s=new Float32Array(t.worldVerticesLength),this.attachmentCacheData[e.data.index][t.name]={id:`${e.data.index}-${t.name}`,vertices:s,clipped:!1,indices:t.triangles,uvs:new Float32Array(t.uvs.length),color:new L(1,1,1,1),darkColor:new L(0,0,0,0),darkTint:this.darkTint,skipRender:!1,texture:t.region?.texture.texture}),this.attachmentCacheData[e.data.index][t.name]}onViewUpdate(){if(this._didViewChangeTick++,this._boundsProvider||(this._boundsDirty=!0),this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this),this.debug?.renderDebug(this)}addSlotObject(e,t,s){e=this.getSlotFromRef(e);for(const n in this._slotsObject)this._slotsObject[n]?.container===t&&this.removeSlotObject(this._slotsObject[n].slot);this.removeSlotObject(e),t.includeInBuild=!1,this.addChild(t);const r={container:t,slot:e,followAttachmentTimeline:s?.followAttachmentTimeline||!1};this._slotsObject[e.data.name]=r,this.updateSlotObject(r)}removeSlotObject(e){let t;if(e instanceof se.Container){for(const s in this._slotsObject)if(this._slotsObject[s]?.container===e){this._slotsObject[s]=null,t=e;break}}else{const s=this.getSlotFromRef(e);t=this._slotsObject[s.data.name]?.container,this._slotsObject[s.data.name]=null}t&&(this.removeChild(t),t.includeInBuild=!0)}removeSlotObjects(){Object.entries(this._slotsObject).forEach(([e,t])=>{t&&t.container.removeFromParent(),delete this._slotsObject[e]})}getSlotObject(e){return e=this.getSlotFromRef(e),this._slotsObject[e.data.name]?.container}updateBounds(){this._boundsDirty=!1,this.skeletonBounds||=new ds;const e=this.skeletonBounds;if(e.update(this.skeleton,!0),this._boundsProvider){const t=this._boundsProvider.calculateBounds(this),s=this._bounds;s.clear(),s.x=t.x,s.y=t.y,s.width=t.width,s.height=t.height}else if(e.minX===1/0){this.hasNeverUpdated&&(this._updateAndApplyState(0),this._boundsDirty=!1),this._validateAndTransformAttachments();const t=this.skeleton.drawOrder,s=this._bounds;s.clear();for(let r=0;r<t.length;r++){const n=t[r],h=n.getAttachment();if(h&&(h instanceof N||h instanceof le)){const a=this._getCachedData(n,h);s.addVertexData(a.vertices,0,a.vertices.length)}}}else this._bounds.minX=e.minX,this._bounds.minY=e.minY,this._bounds.maxX=e.maxX,this._bounds.maxY=e.maxY}addBounds(e){e.addBounds(this.bounds)}destroy(e=!1){super.destroy(e),se.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(e){this.worldTransform.apply(e,e)}pixiWorldCoordinatesToSkeleton(e){this.worldTransform.applyInverse(e,e)}pixiWorldCoordinatesToBone(e,t){this.pixiWorldCoordinatesToSkeleton(e),t.parent?t.parent.worldToLocal(e):t.worldToLocal(e)}static from({skeleton:e,atlas:t,scale:s=1,darkTint:r,autoUpdate:n=!0,boundsProvider:h}){const a=`${e}-${t}-${s}`;if(se.Cache.has(a))return new ms({skeletonData:se.Cache.get(a),darkTint:r,autoUpdate:n,boundsProvider:h});const i=se.Assets.get(e),l=se.Assets.get(t),o=new _s(l),c=i instanceof Uint8Array?new Ws(o):new Gs(o);c.scale=s;const d=c.readSkeletonData(i);return se.Cache.set(a,d),new ms({skeletonData:d,darkTint:r,autoUpdate:n,boundsProvider:h})}},re=xe("pixi.js"),mi=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 re.Container,bones:new re.Container,skeletonXY:new re.Graphics,regionAttachmentsShape:new re.Graphics,meshTrianglesLine:new re.Graphics,meshHullLine:new re.Graphics,clippingPolygon:new re.Graphics,boundingBoxesRect:new re.Graphics,boundingBoxesCircle:new re.Graphics,boundingBoxesPolygon:new re.Graphics,pathsCurve:new re.Graphics,pathsLine:new re.Graphics,eventText:new re.Container,eventCallback:{event:(s,r)=>{if(this.drawEvents){const n=Math.abs(e.scale.x||e.scale.y||1),h=new re.Text({text:r.data.name,style:{fontSize:this.eventFontSize/n,fill:this.eventFontColor,fontFamily:"monospace"}});h.scale.x=Math.sign(e.scale.x),h.anchor.set(.5),t.eventText.addChild(h),setTimeout(()=>{h.destroyed||h.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 n=t.bones.children.length;n>0;n--)t.bones.children[n-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 n of t.eventText.children)n.alpha-=.05,n.y-=2}drawBonesFunc(e,t,s,r){const n=e.skeleton,h=n.x,a=n.y,i=n.bones;t.skeletonXY.strokeStyle={width:s,color:this.skeletonXYColor};for(let o=0,c=i.length;o<c;o++){const d=i[o],f=d.data.length,u=h+d.worldX,m=a+d.worldY,p=h+f*d.a+d.worldX,w=a+f*d.b+d.worldY;if(d.data.name==="root"||d.data.parent===null)continue;const b=Math.abs(u-p),g=Math.abs(m-w),x=Math.pow(b,2),v=g,y=Math.pow(g,2),C=Math.sqrt(x+y),S=Math.pow(C,2),A=Math.PI/180,M=Math.acos((S+y-x)/(2*v*C))||0;if(C===0)continue;const T=new re.Graphics;t.bones.addChild(T);const F=C/50/r;T.context.poly([0,0,0-F,C-F*3,0,C-F,0+F,C-F*3]).fill(this.bonesColor),T.x=u,T.y=m,T.pivot.y=C;let P=0;u<p&&m<w?P=-M+180*A:u>p&&m<w?P=180*A+M:u>p&&m>w?P=-M:u<p&&m>w?P=M:m===w&&u<p?P=90*A:m===w&&u>p?P=-90*A:u===p&&m<w?P=180*A:u===p&&m>w&&(P=0),T.rotation=P,T.circle(0,C,F*1.2).fill({color:0,alpha:.6}).stroke({width:s+F/2.4,color:this.bonesColor})}const l=s*3;t.skeletonXY.context.moveTo(h-l,a-l).lineTo(h+l,a+l).moveTo(h+l,a-l).lineTo(h-l,a+l).stroke()}drawRegionAttachmentsFunc(e,t,s){const n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h],l=i.getAttachment();if(l===null||!(l instanceof N))continue;const o=l,c=new Float32Array(8);o.computeWorldVertices(i,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 n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h];if(!i.bone.active)continue;const l=i.getAttachment();if(l===null||!(l instanceof le))continue;const o=l,c=new Float32Array(o.worldVerticesLength),d=o.triangles;let f=o.hullLength;if(o.computeWorldVertices(i,0,o.worldVerticesLength,c,0,2),this.drawMeshTriangles)for(let u=0,m=d.length;u<m;u+=3){const p=d[u]*2,w=d[u+1]*2,b=d[u+2]*2;t.meshTrianglesLine.context.moveTo(c[p],c[p+1]).lineTo(c[w],c[w+1]).lineTo(c[b],c[b+1])}if(this.drawMeshHull&&f>0){f=(f>>1)*2;let u=c[f-2],m=c[f-1];for(let p=0,w=f;p<w;p+=2){const b=c[p],g=c[p+1];t.meshHullLine.context.moveTo(b,g).lineTo(u,m),u=b,m=g}}}t.meshHullLine.stroke({width:s,color:this.meshHullColor}),t.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(e,t,s){const n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h];if(!i.bone.active)continue;const l=i.getAttachment();if(l===null||!(l instanceof ve))continue;const o=l,c=o.worldVerticesLength,d=new Float32Array(c);o.computeWorldVertices(i,0,c,d,0,2),t.clippingPolygon.poly(Array.from(d))}t.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(e,t,s){const r=new ds;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 n=r.polygons,h=(a,i,l)=>{if(l<3)throw new Error("Polygon must contain at least 3 vertices");const o=[],c=s*2;for(let d=0,f=a.length;d<f;d+=2){const u=a[d],m=a[d+1];t.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),t.boundingBoxesCircle.drawCircle(u,m,c),t.boundingBoxesCircle.fill(0),t.boundingBoxesCircle.circle(u,m,c).fill({color:this.boundingBoxesCircleColor}),o.push(u,m)}t.boundingBoxesPolygon.poly(o).fill({color:this.boundingBoxesPolygonColor,alpha:.1}).stroke({width:s,color:this.boundingBoxesPolygonColor})};for(let a=0,i=n.length;a<i;a++){const l=n[a];h(l,0,l.length)}}drawPathsFunc(e,t,s){const n=e.skeleton.slots;for(let h=0,a=n.length;h<a;h++){const i=n[h];if(!i.bone.active)continue;const l=i.getAttachment();if(l===null||!(l instanceof Pe))continue;const o=l;let c=o.worldVerticesLength;const d=new Float32Array(c);o.computeWorldVertices(i,0,c,d,0,2);let f=d[2],u=d[3],m=0,p=0;if(o.closed){const w=d[0],b=d[1],g=d[c-2],x=d[c-1];m=d[c-4],p=d[c-3],t.pathsCurve.moveTo(f,u),t.pathsCurve.bezierCurveTo(w,b,g,x,m,p),t.pathsLine.moveTo(f,u),t.pathsLine.lineTo(w,b),t.pathsLine.moveTo(m,p),t.pathsLine.lineTo(g,x)}c-=4;for(let w=4;w<c;w+=6){const b=d[w],g=d[w+1],x=d[w+2],v=d[w+3];m=d[w+4],p=d[w+5],t.pathsCurve.moveTo(f,u),t.pathsCurve.bezierCurveTo(b,g,x,v,m,p),t.pathsLine.moveTo(f,u),t.pathsLine.lineTo(b,g),t.pathsLine.moveTo(m,p),t.pathsLine.lineTo(x,v),f=m,u=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 lr(xs)})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esotericsoftware/spine-pixi-v8",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.75",
|
|
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.
|
|
34
|
+
"@esotericsoftware/spine-core": "4.2.75"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"pixi.js": "^8.4.0"
|