@esotericsoftware/spine-pixi-v8 4.2.94 → 4.2.96
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/SpinePipe.js +6 -5
- package/dist/esm/spine-pixi-v8.min.mjs +3 -3
- package/dist/esm/spine-pixi-v8.mjs +4 -4
- package/dist/esm/spine-pixi-v8.mjs.map +2 -2
- package/dist/iife/spine-pixi-v8.js +4 -4
- 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
|
-
`}},gr=class extends ge.Shader{constructor(t){const e=(0,ge.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[ge.colorBitGl,mr,(0,ge.generateTextureBatchBitGl)(t),ge.roundPixelsBitGl]}),s=(0,ge.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[ge.colorBit,fr,(0,ge.generateTextureBatchBit)(t),ge.roundPixelsBit]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:(0,ge.getBatchSamplersUniformGroup)(t)}})}},Hs=null,pr=class hi extends Qe.Batcher{static extension={type:[Qe.ExtensionType.Batcher],name:"darkTint"};geometry=new ur;shader=Hs||(Hs=new gr(this.maxTextures));name=hi.extension.name;vertexSize=7;packAttributes(e,s,r,i,l){const o=l<<16|e.roundPixels&65535,n=e.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,{positions:f,uvs:p}=e,b=e.color,w=(b>>24&255)/255,g=Qe.Color.shared.setValue(e.darkColor).premultiply(w,!0).toPremultiplied(1,!1),x=e.attributeOffset,y=x+e.attributeSize;for(let v=x;v<y;v++){const C=v*2,A=f[C],k=f[C+1];s[i++]=a*A+c*k+d,s[i++]=u*k+h*A+m,s[i++]=p[C],s[i++]=p[C+1],r[i++]=b,r[i++]=g,r[i++]=o}}packQuadAttributes(e,s,r,i,l){const o=e.texture,n=e.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,f=e.bounds,p=f.maxX,b=f.minX,w=f.maxY,g=f.minY,x=o.uvs,y=e.color,v=e.darkColor,C=l<<16|e.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}};Qe.extensions.add(pr);var Ze=pe("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 t=this.data.color,e=this.renderable.groupColor,s=this.renderable.groupAlpha;let r;const i=t.a*s*255;if(e!==16777215){const l=e>>16&255,o=e>>8&255,n=e&255,a=t.r*n,h=t.g*o,c=t.b*l;r=i<<24|c<<16|h<<8|a}else r=i<<24|t.b*255<<16|t.g*255<<8|t.r*255;return r}get darkColor(){const t=this.data.darkColor;return t.b*255<<16|t.g*255<<8|t.r*255}get groupTransform(){return this.renderable.groupTransform}setData(t,e,s,r){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const i=e.clippedData;this.indexSize=i.indicesCount,this.attributeSize=i.vertexCount,this.positions=i.vertices,this.indices=i.indices,this.uvs=i.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=r,this.blendMode=s,this.batcherName=e.darkTint?"darkTint":"default"}},br={0:"normal",1:"add",2:"multiply",3:"screen"},$s=class{static extension={type:[Ze.ExtensionType.WebGLPipes,Ze.ExtensionType.WebGPUPipes,Ze.ExtensionType.CanvasPipes],name:"spine"};renderer;gpuSpineData={};_destroyRenderableBound=this.destroyRenderable.bind(this);constructor(t){this.renderer=t}validateRenderable(t){if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,s=this.gpuSpineData[t.uid];for(let r=0,i=e.length;r<i;r++){const l=e[r],o=l.getAttachment();if(o instanceof oe||o instanceof ue){const n=t._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(t,e){const s=this._getSpineData(t),r=this.renderer.renderPipes.batch,i=t.skeleton.drawOrder,l=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;for(let o=0,n=i.length;o<n;o++){const a=i[o],h=a.getAttachment(),c=br[a.data.blendMode];let u=!1;if(h instanceof oe||h instanceof ue){const m=t._getCachedData(a,h),f=s.slotBatches[m.id]||=new xr;f.setData(t,m,c,l),u=m.skipRender,u||r.addToBatch(f,e)}const d=t._slotsObject[a.data.name];if(d){const m=d.container;u||(m.includeInBuild=!0,m.collectRenderables(e,this.renderer,null)),m.includeInBuild=!1}}}updateRenderable(t){const e=this.gpuSpineData[t.uid];t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;const s=t.skeleton.drawOrder;for(let r=0,i=s.length;r<i;r++){const l=s[r],o=l.getAttachment();if((o instanceof oe||o instanceof ue)&&!t._getCachedData(l,o).skipRender){const a=e.slotBatches[t._getCachedData(l,o).id];a._batcher?.updateElement(a)}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}};Ze.extensions.add($s);var ie=pe("pixi.js"),et=new Ee;Ye.yDown=!0;var Pe=new Ke,wr=class{constructor(t,e,s,r){this.x=t,this.y=e,this.width=s,this.height=r}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},yr=class{constructor(t=!1){this.clipping=t}calculateBounds(t){if(!t.skeleton)return{x:0,y:0,width:0,height:0};const e=new Ye(t.skeleton.data);e.setToSetupPose(),e.updateWorldTransform(2);const s=e.getBoundsRect(this.clipping?new Ke:void 0);return s.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},vr=class{constructor(t,e=[],s=.05,r=!1){this.animation=t,this.skins=e,this.timeStep=s,this.clipping=r}calculateBounds(t){if(!t.skeleton||!t.state)return{x:0,y:0,width:0,height:0};const e=new Ot(t.state.data),s=new Ye(t.skeleton.data),r=this.clipping?new Ke:void 0,i=s.data;if(this.skins.length>0){let o=new Ve("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;e.clearTracks(),e.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;e.update(m),e.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 Te(()=>new ie.Graphics),Cr=class gs extends ie.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 s;if(typeof e=="number"?s=this.skeleton.slots[e]:typeof e=="string"?s=this.skeleton.findSlot(e):s=e,!s)throw new Error(`No slot found with the given slot reference: ${e}`);return s}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=!1;get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e&&!this._autoUpdate?ie.Ticker.shared.add(this.internalUpdate,this):!e&&this._autoUpdate&&ie.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 Le&&(e={skeletonData:e}),super({}),this.allowChildren=!0;const s=e instanceof Le?e:e.skeletonData;this.skeleton=new Ye(s),this.state=new Ot(new Ys(s)),this.autoUpdate=e?.autoUpdate??!0,this.darkTint=e?.darkTint===void 0?this.skeleton.slots.some(i=>!!i.data.darkColor):e?.darkTint;const r=this.skeleton.slots;for(let i=0;i<r.length;i++)this.attachmentCacheData[i]=Object.create(null);this._boundsProvider=e.boundsProvider}update(e){this.internalUpdate(0,e)}internalUpdate(e,s){this._updateAndApplyState(s??ie.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(e,s){const r=e;if(typeof e=="string"&&(e=this.skeleton.findBone(e)),!e)throw Error(`Cant set bone position, bone ${String(r)} not found`);if(et.set(s.x,s.y),e.parent){const i=e.parent.worldToLocal(et);e.x=i.x,e.y=-i.y}else e.x=et.x,e.y=et.y}getBonePosition(e,s){const r=e;return typeof e=="string"&&(e=this.skeleton.findBone(e)),e?(s||(s={x:0,y:0}),s.x=e.worldX,s.y=e.worldY,s):(console.error(`Cant set bone position! Bone ${String(r)} not found`),s)}_updateAndApplyState(e){this.hasNeverUpdated=!1,this.state.update(e),this.skeleton.update(e);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 e=this.skeleton.drawOrder,s=this._lastAttachments;let r=0,i=!1;for(let l=0;l<e.length;l++){const n=e[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(e,s){const r=e.attachment;if(r&&r instanceof Ae){const o=this.clippingSlotToPixiMasks[e.data.name]||={slot:e,vertices:new Array};o.maskComputed=!1,this.currentClippingSlot=o;return}let i=this.currentClippingSlot,l=this._slotsObject[e.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==e.data&&(this.currentClippingSlot=void 0),s){for(const o in this.clippingSlotToPixiMasks){const n=this.clippingSlotToPixiMasks[o];(!(n.slot.attachment instanceof Ae)||!n.maskComputed)&&n.mask&&(this.removeChild(n.mask),js.free(n.mask),n.mask=void 0)}this.currentClippingSlot=void 0}}transformAttachments(){const e=this.skeleton.drawOrder;for(let s=0;s<e.length;s++){const r=e[s];this.updateAndSetPixiMask(r,s===e.length-1);const i=r.getAttachment();if(i){if(i instanceof ue||i instanceof oe){const l=this._getCachedData(r,i);i instanceof oe?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,ie.fastCopy)(i.uvs.buffer,l.uvs.buffer);const n=r.bone.skeleton.color,a=r.color,h=i.color,c=n.a*a.a*h.a;if(l.color.set(n.r*a.r*h.r,n.g*a.g*h.g,n.b*a.b*h.b,c),this.alpha===0||c===0)l.skipRender||(this.spineAttachmentsDirty=!0),l.skipRender=!0;else{l.skipRender&&(this.spineAttachmentsDirty=!0),l.skipRender=l.clipped=!1,r.darkColor&&l.darkColor.setFromColor(r.darkColor);const u=i.region?.texture.texture||ie.Texture.EMPTY;l.texture!==u&&(l.texture=u,this.spineTexturesDirty=!0),Pe.isClipping()&&this.updateClippingData(l)}}else if(i instanceof Ae){Pe.clipStart(r,i);continue}}Pe.clipEndWithSlot(r)}Pe.clipEnd()}updateClippingData(e){e.clipped=!0,Pe.clipTrianglesUnpacked(e.vertices,e.indices,e.indices.length,e.uvs);const{clippedVertices:s,clippedUVs:r,clippedTriangles:i}=Pe,l=s.length/2,o=i.length;e.clippedData||(e.clippedData={vertices:new Float32Array(l*2),uvs:new Float32Array(l*2),vertexCount:l,indices:new Uint16Array(o),indicesCount:o},this.spineAttachmentsDirty=!0);const n=e.clippedData,a=n.vertexCount!==l||o!==n.indicesCount;e.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 e in this._slotsObject){const s=this._slotsObject[e];s&&this.updateSlotObject(s)}}updateSlotObject(e){const{slot:s,container:r}=e,i=e.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(e,s){return this.attachmentCacheData[e.data.index][s.name]||this.initCachedData(e,s)}initCachedData(e,s){let r;return s instanceof oe?(r=new Float32Array(8),this.attachmentCacheData[e.data.index][s.name]={id:`${e.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[e.data.index][s.name]={id:`${e.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[e.data.index][s.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,s,r){e=this.getSlotFromRef(e);for(const l in this._slotsObject)this._slotsObject[l]?.container===s&&this.removeSlotObject(this._slotsObject[l].slot);this.removeSlotObject(e),s.includeInBuild=!1,this.addChild(s);const i={container:s,slot:e,followAttachmentTimeline:r?.followAttachmentTimeline||!1};this._slotsObject[e.data.name]=i,this.updateSlotObject(i)}removeSlotObject(e){let s;if(e instanceof ie.Container){for(const r in this._slotsObject)if(this._slotsObject[r]?.container===e){this._slotsObject[r]=null,s=e;break}}else{const r=this.getSlotFromRef(e);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(([e,s])=>{s&&s.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 os;const e=this.skeletonBounds;if(e.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(e.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 oe||o instanceof ue)){const n=this._getCachedData(l,o);r.addVertexData(n.vertices,0,n.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),ie.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,s){this.pixiWorldCoordinatesToSkeleton(e),s.parent?s.parent.worldToLocal(e):s.worldToLocal(e)}static from({skeleton:e,atlas:s,scale:r=1,darkTint:i,autoUpdate:l=!0,boundsProvider:o}){const n=`${e}-${s}-${r}`;if(ie.Cache.has(n))return new gs({skeletonData:ie.Cache.get(n),darkTint:i,autoUpdate:l,boundsProvider:o});const a=ie.Assets.get(e),h=ie.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 ie.Cache.set(n,d),new gs({skeletonData:d,darkTint:i,autoUpdate:l,boundsProvider:o})}},te=pe("pixi.js"),Ar=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(t){if(this.registeredSpines.has(t)){console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",t);return}const e={parentDebugContainer:new te.Container,bones:new te.Container,skeletonXY:new te.Graphics,regionAttachmentsShape:new te.Graphics,meshTrianglesLine:new te.Graphics,meshHullLine:new te.Graphics,clippingPolygon:new te.Graphics,boundingBoxesRect:new te.Graphics,boundingBoxesCircle:new te.Graphics,boundingBoxesPolygon:new te.Graphics,pathsCurve:new te.Graphics,pathsLine:new te.Graphics,eventText:new te.Container,eventCallback:{event:(s,r)=>{if(this.drawEvents){const i=Math.abs(t.scale.x||t.scale.y||1),l=new te.Text({text:r.data.name,style:{fontSize:this.eventFontSize/i,fill:this.eventFontColor,fontFamily:"monospace"}});l.scale.x=Math.sign(t.scale.x),l.anchor.set(.5),e.eventText.addChild(l),setTimeout(()=>{l.destroyed||l.destroy()},250)}}}};e.parentDebugContainer.addChild(e.bones),e.parentDebugContainer.addChild(e.skeletonXY),e.parentDebugContainer.addChild(e.regionAttachmentsShape),e.parentDebugContainer.addChild(e.meshTrianglesLine),e.parentDebugContainer.addChild(e.meshHullLine),e.parentDebugContainer.addChild(e.clippingPolygon),e.parentDebugContainer.addChild(e.boundingBoxesRect),e.parentDebugContainer.addChild(e.boundingBoxesCircle),e.parentDebugContainer.addChild(e.boundingBoxesPolygon),e.parentDebugContainer.addChild(e.pathsCurve),e.parentDebugContainer.addChild(e.pathsLine),e.parentDebugContainer.addChild(e.eventText),e.parentDebugContainer.zIndex=9999999,e.parentDebugContainer.accessibleChildren=!1,e.parentDebugContainer.eventMode="none",e.parentDebugContainer.interactiveChildren=!1,t.addChild(e.parentDebugContainer),t.state.addListener(e.eventCallback),this.registeredSpines.set(t,e)}renderDebug(t){this.registeredSpines.has(t)||this.registerSpine(t);const e=this.registeredSpines.get(t);if(!e)return;t.addChild(e.parentDebugContainer),e.skeletonXY.clear(),e.regionAttachmentsShape.clear(),e.meshTrianglesLine.clear(),e.meshHullLine.clear(),e.clippingPolygon.clear(),e.boundingBoxesRect.clear(),e.boundingBoxesCircle.clear(),e.boundingBoxesPolygon.clear(),e.pathsCurve.clear(),e.pathsLine.clear();for(let i=e.bones.children.length;i>0;i--)e.bones.children[i-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(t.scale.x||t.scale.y||1),r=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(t,e,r,s),this.drawPaths&&this.drawPathsFunc(t,e,r),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(t,e,r),this.drawClipping&&this.drawClippingFunc(t,e,r),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(t,e,r),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(t,e,r),this.drawEvents)for(const i of e.eventText.children)i.alpha-=.05,i.y-=2}drawBonesFunc(t,e,s,r){const i=t.skeleton,l=i.x,o=i.y,n=i.bones;e.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),A=Math.pow(C,2),k=Math.PI/180,T=Math.acos((A+v-x)/(2*y*C))||0;if(C===0)continue;const Y=new te.Graphics;e.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;e.skeletonXY.context.moveTo(l-a,o-a).lineTo(l+a,o+a).moveTo(l+a,o-a).lineTo(l-a,o+a).stroke()}drawRegionAttachmentsFunc(t,e,s){const i=t.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l],a=n.getAttachment();if(a===null||!(a instanceof oe))continue;const h=a,c=new Float32Array(8);h.computeWorldVertices(n,c,0,2),e.regionAttachmentsShape.poly(Array.from(c.slice(0,8)))}e.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(t,e,s){const i=t.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 ue))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;e.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];e.meshHullLine.context.moveTo(w,g).lineTo(m,f),m=w,f=g}}}e.meshHullLine.stroke({width:s,color:this.meshHullColor}),e.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(t,e,s){const i=t.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 Ae))continue;const h=a,c=h.worldVerticesLength,u=new Float32Array(c);h.computeWorldVertices(n,0,c,u,0,2),e.clippingPolygon.poly(Array.from(u))}e.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(t,e,s){const r=new os;r.update(t.skeleton,!0),r.minX!==1/0&&e.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];e.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),e.boundingBoxesCircle.drawCircle(m,f,c),e.boundingBoxesCircle.fill(0),e.boundingBoxesCircle.circle(m,f,c).fill({color:this.boundingBoxesCircleColor}),h.push(m,f)}e.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(t,e,s){const i=t.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 Me))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],e.pathsCurve.moveTo(d,m),e.pathsCurve.bezierCurveTo(b,w,g,x,f,p),e.pathsLine.moveTo(d,m),e.pathsLine.lineTo(b,w),e.pathsLine.moveTo(f,p),e.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],e.pathsCurve.moveTo(d,m),e.pathsCurve.bezierCurveTo(w,g,x,y,f,p),e.pathsLine.moveTo(d,m),e.pathsLine.lineTo(w,g),e.pathsLine.moveTo(f,p),e.pathsLine.lineTo(x,y),d=f,m=p}}e.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),e.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(t){this.registeredSpines.has(t)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",t);const e=this.registeredSpines.get(t);e&&(t.state.removeListener(e.eventCallback),e.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(t))}};return gi(ps)})();
|
|
27
|
+
`}},gr=class extends ge.Shader{constructor(t){const e=(0,ge.compileHighShaderGlProgram)({name:"dark-tint-batch",bits:[ge.colorBitGl,mr,(0,ge.generateTextureBatchBitGl)(t),ge.roundPixelsBitGl]}),s=(0,ge.compileHighShaderGpuProgram)({name:"dark-tint-batch",bits:[ge.colorBit,fr,(0,ge.generateTextureBatchBit)(t),ge.roundPixelsBit]});super({glProgram:e,gpuProgram:s,resources:{batchSamplers:(0,ge.getBatchSamplersUniformGroup)(t)}})}},Hs=null,pr=class hi extends Qe.Batcher{static extension={type:[Qe.ExtensionType.Batcher],name:"darkTint"};geometry=new ur;shader=Hs||(Hs=new gr(this.maxTextures));name=hi.extension.name;vertexSize=7;packAttributes(e,s,r,i,l){const o=l<<16|e.roundPixels&65535,n=e.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,{positions:f,uvs:p}=e,b=e.color,w=(b>>24&255)/255,g=Qe.Color.shared.setValue(e.darkColor).premultiply(w,!0).toPremultiplied(1,!1),x=e.attributeOffset,y=x+e.attributeSize;for(let v=x;v<y;v++){const C=v*2,A=f[C],k=f[C+1];s[i++]=a*A+c*k+d,s[i++]=u*k+h*A+m,s[i++]=p[C],s[i++]=p[C+1],r[i++]=b,r[i++]=g,r[i++]=o}}packQuadAttributes(e,s,r,i,l){const o=e.texture,n=e.transform,a=n.a,h=n.b,c=n.c,u=n.d,d=n.tx,m=n.ty,f=e.bounds,p=f.maxX,b=f.minX,w=f.maxY,g=f.minY,x=o.uvs,y=e.color,v=e.darkColor,C=l<<16|e.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}};Qe.extensions.add(pr);var Ze=pe("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 t=this.data.color,e=this.renderable.groupColor,s=this.renderable.groupAlpha;let r;const i=t.a*s*255;if(e!==16777215){const l=e>>16&255,o=e>>8&255,n=e&255,a=t.r*n,h=t.g*o,c=t.b*l;r=i<<24|c<<16|h<<8|a}else r=i<<24|t.b*255<<16|t.g*255<<8|t.r*255;return r}get darkColor(){const t=this.data.darkColor;return t.b*255<<16|t.g*255<<8|t.r*255}get groupTransform(){return this.renderable.groupTransform}setData(t,e,s,r){if(this.renderable=t,this.transform=t.groupTransform,this.data=e,e.clipped){const i=e.clippedData;this.indexSize=i.indicesCount,this.attributeSize=i.vertexCount,this.positions=i.vertices,this.indices=i.indices,this.uvs=i.uvs}else this.indexSize=e.indices.length,this.attributeSize=e.vertices.length/2,this.positions=e.vertices,this.indices=e.indices,this.uvs=e.uvs;this.texture=e.texture,this.roundPixels=r,this.blendMode=s,this.batcherName=e.darkTint?"darkTint":"default"}},br={0:"normal",1:"add",2:"multiply",3:"screen"},$s=class{static extension={type:[Ze.ExtensionType.WebGLPipes,Ze.ExtensionType.WebGPUPipes,Ze.ExtensionType.CanvasPipes],name:"spine"};renderer;gpuSpineData={};_destroyRenderableBound=this.destroyRenderable.bind(this);constructor(t){this.renderer=t}validateRenderable(t){if(t._validateAndTransformAttachments(),t.spineAttachmentsDirty)return!0;if(t.spineTexturesDirty){const e=t.skeleton.drawOrder,s=this.gpuSpineData[t.uid];for(let r=0,i=e.length;r<i;r++){const l=e[r],o=l.getAttachment();if(o instanceof oe||o instanceof ue){const n=t._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(t,e){const s=this._getSpineData(t),r=this.renderer.renderPipes.batch,i=t.skeleton.drawOrder,l=this.renderer._roundPixels|t._roundPixels;t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;for(let o=0,n=i.length;o<n;o++){const a=i[o],h=a.getAttachment(),c=br[a.data.blendMode];let u=!1;if(h instanceof oe||h instanceof ue){const m=t._getCachedData(a,h),f=s.slotBatches[m.id]||=new xr;f.setData(t,m,c,l),u=m.skipRender,u||r.addToBatch(f,e)}const d=t._slotsObject[a.data.name];if(d){const m=d.container;u||(m.includeInBuild=!0,m.collectRenderables(e,this.renderer,null)),m.includeInBuild=!1}}}updateRenderable(t){const e=this.gpuSpineData[t.uid];t._validateAndTransformAttachments(),t.spineAttachmentsDirty=!1,t.spineTexturesDirty=!1;const s=t.skeleton.drawOrder;for(let r=0,i=s.length;r<i;r++){const l=s[r],o=l.getAttachment();if(o instanceof oe||o instanceof ue){const n=t._getCachedData(l,o);if(!n.skipRender){const a=e.slotBatches[n.id];a?._batcher?.updateElement(a)}}}}destroyRenderable(t){this.gpuSpineData[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}destroy(){this.gpuSpineData=null,this.renderer=null}_getSpineData(t){return this.gpuSpineData[t.uid]||this._initMeshData(t)}_initMeshData(t){return this.gpuSpineData[t.uid]={slotBatches:{}},t.on("destroyed",this._destroyRenderableBound),this.gpuSpineData[t.uid]}};Ze.extensions.add($s);var ie=pe("pixi.js"),et=new Ee;Ye.yDown=!0;var Pe=new Ke,wr=class{constructor(t,e,s,r){this.x=t,this.y=e,this.width=s,this.height=r}calculateBounds(){return{x:this.x,y:this.y,width:this.width,height:this.height}}},yr=class{constructor(t=!1){this.clipping=t}calculateBounds(t){if(!t.skeleton)return{x:0,y:0,width:0,height:0};const e=new Ye(t.skeleton.data);e.setToSetupPose(),e.updateWorldTransform(2);const s=e.getBoundsRect(this.clipping?new Ke:void 0);return s.width==Number.NEGATIVE_INFINITY?{x:0,y:0,width:0,height:0}:s}},vr=class{constructor(t,e=[],s=.05,r=!1){this.animation=t,this.skins=e,this.timeStep=s,this.clipping=r}calculateBounds(t){if(!t.skeleton||!t.state)return{x:0,y:0,width:0,height:0};const e=new Ot(t.state.data),s=new Ye(t.skeleton.data),r=this.clipping?new Ke:void 0,i=s.data;if(this.skins.length>0){let o=new Ve("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;e.clearTracks(),e.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;e.update(m),e.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 Te(()=>new ie.Graphics),Cr=class gs extends ie.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 s;if(typeof e=="number"?s=this.skeleton.slots[e]:typeof e=="string"?s=this.skeleton.findSlot(e):s=e,!s)throw new Error(`No slot found with the given slot reference: ${e}`);return s}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=!1;get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e&&!this._autoUpdate?ie.Ticker.shared.add(this.internalUpdate,this):!e&&this._autoUpdate&&ie.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 Le&&(e={skeletonData:e}),super({}),this.allowChildren=!0;const s=e instanceof Le?e:e.skeletonData;this.skeleton=new Ye(s),this.state=new Ot(new Ys(s)),this.autoUpdate=e?.autoUpdate??!0,this.darkTint=e?.darkTint===void 0?this.skeleton.slots.some(i=>!!i.data.darkColor):e?.darkTint;const r=this.skeleton.slots;for(let i=0;i<r.length;i++)this.attachmentCacheData[i]=Object.create(null);this._boundsProvider=e.boundsProvider}update(e){this.internalUpdate(0,e)}internalUpdate(e,s){this._updateAndApplyState(s??ie.Ticker.shared.deltaMS/1e3)}get bounds(){return this._boundsDirty&&this.updateBounds(),this._bounds}setBonePosition(e,s){const r=e;if(typeof e=="string"&&(e=this.skeleton.findBone(e)),!e)throw Error(`Cant set bone position, bone ${String(r)} not found`);if(et.set(s.x,s.y),e.parent){const i=e.parent.worldToLocal(et);e.x=i.x,e.y=-i.y}else e.x=et.x,e.y=et.y}getBonePosition(e,s){const r=e;return typeof e=="string"&&(e=this.skeleton.findBone(e)),e?(s||(s={x:0,y:0}),s.x=e.worldX,s.y=e.worldY,s):(console.error(`Cant set bone position! Bone ${String(r)} not found`),s)}_updateAndApplyState(e){this.hasNeverUpdated=!1,this.state.update(e),this.skeleton.update(e);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 e=this.skeleton.drawOrder,s=this._lastAttachments;let r=0,i=!1;for(let l=0;l<e.length;l++){const n=e[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(e,s){const r=e.attachment;if(r&&r instanceof Ae){const o=this.clippingSlotToPixiMasks[e.data.name]||={slot:e,vertices:new Array};o.maskComputed=!1,this.currentClippingSlot=o;return}let i=this.currentClippingSlot,l=this._slotsObject[e.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==e.data&&(this.currentClippingSlot=void 0),s){for(const o in this.clippingSlotToPixiMasks){const n=this.clippingSlotToPixiMasks[o];(!(n.slot.attachment instanceof Ae)||!n.maskComputed)&&n.mask&&(this.removeChild(n.mask),js.free(n.mask),n.mask=void 0)}this.currentClippingSlot=void 0}}transformAttachments(){const e=this.skeleton.drawOrder;for(let s=0;s<e.length;s++){const r=e[s];this.updateAndSetPixiMask(r,s===e.length-1);const i=r.getAttachment();if(i){if(i instanceof ue||i instanceof oe){const l=this._getCachedData(r,i);i instanceof oe?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,ie.fastCopy)(i.uvs.buffer,l.uvs.buffer);const n=r.bone.skeleton.color,a=r.color,h=i.color,c=n.a*a.a*h.a;if(l.color.set(n.r*a.r*h.r,n.g*a.g*h.g,n.b*a.b*h.b,c),this.alpha===0||c===0)l.skipRender||(this.spineAttachmentsDirty=!0),l.skipRender=!0;else{l.skipRender&&(this.spineAttachmentsDirty=!0),l.skipRender=l.clipped=!1,r.darkColor&&l.darkColor.setFromColor(r.darkColor);const u=i.region?.texture.texture||ie.Texture.EMPTY;l.texture!==u&&(l.texture=u,this.spineTexturesDirty=!0),Pe.isClipping()&&this.updateClippingData(l)}}else if(i instanceof Ae){Pe.clipStart(r,i);continue}}Pe.clipEndWithSlot(r)}Pe.clipEnd()}updateClippingData(e){e.clipped=!0,Pe.clipTrianglesUnpacked(e.vertices,e.indices,e.indices.length,e.uvs);const{clippedVertices:s,clippedUVs:r,clippedTriangles:i}=Pe,l=s.length/2,o=i.length;e.clippedData||(e.clippedData={vertices:new Float32Array(l*2),uvs:new Float32Array(l*2),vertexCount:l,indices:new Uint16Array(o),indicesCount:o},this.spineAttachmentsDirty=!0);const n=e.clippedData,a=n.vertexCount!==l||o!==n.indicesCount;e.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 e in this._slotsObject){const s=this._slotsObject[e];s&&this.updateSlotObject(s)}}updateSlotObject(e){const{slot:s,container:r}=e,i=e.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(e,s){return this.attachmentCacheData[e.data.index][s.name]||this.initCachedData(e,s)}initCachedData(e,s){let r;return s instanceof oe?(r=new Float32Array(8),this.attachmentCacheData[e.data.index][s.name]={id:`${e.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[e.data.index][s.name]={id:`${e.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[e.data.index][s.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,s,r){e=this.getSlotFromRef(e);for(const l in this._slotsObject)this._slotsObject[l]?.container===s&&this.removeSlotObject(this._slotsObject[l].slot);this.removeSlotObject(e),s.includeInBuild=!1,this.addChild(s);const i={container:s,slot:e,followAttachmentTimeline:r?.followAttachmentTimeline||!1};this._slotsObject[e.data.name]=i,this.updateSlotObject(i)}removeSlotObject(e){let s;if(e instanceof ie.Container){for(const r in this._slotsObject)if(this._slotsObject[r]?.container===e){this._slotsObject[r]=null,s=e;break}}else{const r=this.getSlotFromRef(e);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(([e,s])=>{s&&s.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 os;const e=this.skeletonBounds;if(e.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(e.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 oe||o instanceof ue)){const n=this._getCachedData(l,o);r.addVertexData(n.vertices,0,n.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),ie.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,s){this.pixiWorldCoordinatesToSkeleton(e),s.parent?s.parent.worldToLocal(e):s.worldToLocal(e)}static from({skeleton:e,atlas:s,scale:r=1,darkTint:i,autoUpdate:l=!0,boundsProvider:o}){const n=`${e}-${s}-${r}`;if(ie.Cache.has(n))return new gs({skeletonData:ie.Cache.get(n),darkTint:i,autoUpdate:l,boundsProvider:o});const a=ie.Assets.get(e),h=ie.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 ie.Cache.set(n,d),new gs({skeletonData:d,darkTint:i,autoUpdate:l,boundsProvider:o})}},te=pe("pixi.js"),Ar=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(t){if(this.registeredSpines.has(t)){console.warn("SpineDebugRenderer.registerSpine() - this spine is already registered!",t);return}const e={parentDebugContainer:new te.Container,bones:new te.Container,skeletonXY:new te.Graphics,regionAttachmentsShape:new te.Graphics,meshTrianglesLine:new te.Graphics,meshHullLine:new te.Graphics,clippingPolygon:new te.Graphics,boundingBoxesRect:new te.Graphics,boundingBoxesCircle:new te.Graphics,boundingBoxesPolygon:new te.Graphics,pathsCurve:new te.Graphics,pathsLine:new te.Graphics,eventText:new te.Container,eventCallback:{event:(s,r)=>{if(this.drawEvents){const i=Math.abs(t.scale.x||t.scale.y||1),l=new te.Text({text:r.data.name,style:{fontSize:this.eventFontSize/i,fill:this.eventFontColor,fontFamily:"monospace"}});l.scale.x=Math.sign(t.scale.x),l.anchor.set(.5),e.eventText.addChild(l),setTimeout(()=>{l.destroyed||l.destroy()},250)}}}};e.parentDebugContainer.addChild(e.bones),e.parentDebugContainer.addChild(e.skeletonXY),e.parentDebugContainer.addChild(e.regionAttachmentsShape),e.parentDebugContainer.addChild(e.meshTrianglesLine),e.parentDebugContainer.addChild(e.meshHullLine),e.parentDebugContainer.addChild(e.clippingPolygon),e.parentDebugContainer.addChild(e.boundingBoxesRect),e.parentDebugContainer.addChild(e.boundingBoxesCircle),e.parentDebugContainer.addChild(e.boundingBoxesPolygon),e.parentDebugContainer.addChild(e.pathsCurve),e.parentDebugContainer.addChild(e.pathsLine),e.parentDebugContainer.addChild(e.eventText),e.parentDebugContainer.zIndex=9999999,e.parentDebugContainer.accessibleChildren=!1,e.parentDebugContainer.eventMode="none",e.parentDebugContainer.interactiveChildren=!1,t.addChild(e.parentDebugContainer),t.state.addListener(e.eventCallback),this.registeredSpines.set(t,e)}renderDebug(t){this.registeredSpines.has(t)||this.registerSpine(t);const e=this.registeredSpines.get(t);if(!e)return;t.addChild(e.parentDebugContainer),e.skeletonXY.clear(),e.regionAttachmentsShape.clear(),e.meshTrianglesLine.clear(),e.meshHullLine.clear(),e.clippingPolygon.clear(),e.boundingBoxesRect.clear(),e.boundingBoxesCircle.clear(),e.boundingBoxesPolygon.clear(),e.pathsCurve.clear(),e.pathsLine.clear();for(let i=e.bones.children.length;i>0;i--)e.bones.children[i-1].destroy({children:!0,texture:!0,textureSource:!0});const s=Math.abs(t.scale.x||t.scale.y||1),r=this.lineWidth/s;if(this.drawBones&&this.drawBonesFunc(t,e,r,s),this.drawPaths&&this.drawPathsFunc(t,e,r),this.drawBoundingBoxes&&this.drawBoundingBoxesFunc(t,e,r),this.drawClipping&&this.drawClippingFunc(t,e,r),(this.drawMeshHull||this.drawMeshTriangles)&&this.drawMeshHullAndMeshTriangles(t,e,r),this.drawRegionAttachments&&this.drawRegionAttachmentsFunc(t,e,r),this.drawEvents)for(const i of e.eventText.children)i.alpha-=.05,i.y-=2}drawBonesFunc(t,e,s,r){const i=t.skeleton,l=i.x,o=i.y,n=i.bones;e.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),A=Math.pow(C,2),k=Math.PI/180,T=Math.acos((A+v-x)/(2*y*C))||0;if(C===0)continue;const Y=new te.Graphics;e.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;e.skeletonXY.context.moveTo(l-a,o-a).lineTo(l+a,o+a).moveTo(l+a,o-a).lineTo(l-a,o+a).stroke()}drawRegionAttachmentsFunc(t,e,s){const i=t.skeleton.slots;for(let l=0,o=i.length;l<o;l++){const n=i[l],a=n.getAttachment();if(a===null||!(a instanceof oe))continue;const h=a,c=new Float32Array(8);h.computeWorldVertices(n,c,0,2),e.regionAttachmentsShape.poly(Array.from(c.slice(0,8)))}e.regionAttachmentsShape.stroke({color:this.regionAttachmentsColor,width:s})}drawMeshHullAndMeshTriangles(t,e,s){const i=t.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 ue))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;e.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];e.meshHullLine.context.moveTo(w,g).lineTo(m,f),m=w,f=g}}}e.meshHullLine.stroke({width:s,color:this.meshHullColor}),e.meshTrianglesLine.stroke({width:s,color:this.meshTrianglesColor})}drawClippingFunc(t,e,s){const i=t.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 Ae))continue;const h=a,c=h.worldVerticesLength,u=new Float32Array(c);h.computeWorldVertices(n,0,c,u,0,2),e.clippingPolygon.poly(Array.from(u))}e.clippingPolygon.stroke({width:s,color:this.clippingPolygonColor,alpha:1})}drawBoundingBoxesFunc(t,e,s){const r=new os;r.update(t.skeleton,!0),r.minX!==1/0&&e.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];e.boundingBoxesCircle.beginFill(this.boundingBoxesCircleColor),e.boundingBoxesCircle.drawCircle(m,f,c),e.boundingBoxesCircle.fill(0),e.boundingBoxesCircle.circle(m,f,c).fill({color:this.boundingBoxesCircleColor}),h.push(m,f)}e.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(t,e,s){const i=t.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 Me))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],e.pathsCurve.moveTo(d,m),e.pathsCurve.bezierCurveTo(b,w,g,x,f,p),e.pathsLine.moveTo(d,m),e.pathsLine.lineTo(b,w),e.pathsLine.moveTo(f,p),e.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],e.pathsCurve.moveTo(d,m),e.pathsCurve.bezierCurveTo(w,g,x,y,f,p),e.pathsLine.moveTo(d,m),e.pathsLine.lineTo(w,g),e.pathsLine.moveTo(f,p),e.pathsLine.lineTo(x,y),d=f,m=p}}e.pathsCurve.stroke({width:s,color:this.pathsCurveColor}),e.pathsLine.stroke({width:s,color:this.pathsLineColor})}unregisterSpine(t){this.registeredSpines.has(t)||console.warn("SpineDebugRenderer.unregisterSpine() - spine is not registered, can't unregister!",t);const e=this.registeredSpines.get(t);e&&(t.state.removeListener(e.eventCallback),e.parentDebugContainer.destroy({textureSource:!0,children:!0,texture:!0}),this.registeredSpines.delete(t))}};return gi(ps)})();
|
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.96",
|
|
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.96"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"pixi.js": "^8.12.0"
|