3 lines
40 KiB
JavaScript
3 lines
40 KiB
JavaScript
var ft=Object.defineProperty;var gt=(W,t,e)=>t in W?ft(W,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):W[t]=e;var T=(W,t,e)=>gt(W,typeof t!="symbol"?t+"":t,e);import{f as ht,R as pt,N as dt,ac as ut,Z as mt,b4 as yt,O as rt,b5 as at,U as D,B as Tt}from"./index-CQJ6qUg9.js";import{$ as Rt,a0 as Yt,a1 as Ft,a2 as Et,y as _t,a3 as Ot,a4 as kt,a5 as Xt,a6 as Bt,a7 as Nt,a8 as Dt,a9 as $t,aa as zt,ab as Wt,ad as qt,H as Gt,ae as Jt,af as Ht,ag as Zt,ah as Kt,ai as Qt,aj as jt,ak as te,al as ee,am as se,an as ne,ao as ie,ap as oe,aq as re,ar as ae,as as le,at as ce,au as he,av as pe,aw as de,ax as ue,ay as fe,az as ge,aA as me,aB as ye,aC as Te,aD as be,aE as we,aF as xe,aG as Ae,aH as Pe,aI as Ie,aJ as Ce,aK as Ve,aL as Le,aM as Se,aN as Me,aO as ve,aP as Ue,aQ as Re,aR as Ye,aS as Fe,aT as Ee,x as _e,aU as Oe,aV as ke,aW as Xe,aX as Be,aY as Ne,aZ as De,a_ as $e,a$ as ze,b0 as We,b1 as qe,b2 as Ge,b3 as Je,b6 as He,b7 as Ze,b8 as Ke,b9 as Qe,ba as je,bb as ts,bc as es,bd as ss,be as ns,bf as is,bg as os,bh as rs,bi as as,bj as ls,bk as cs,bl as hs,bm as ps,bn as ds,bo as us,bp as fs,bq as gs,br as ms,bs as ys,bt as Ts,bu as bs,w as ws,X as xs,J as As,Y as Ps,z as Is,bv as Cs,bw as Vs,bx as Ls,by as Ss,bz as Ms,bA as vs,bB as Us,bC as Rs,bD as Ys,bE as Fs,bF as Es,bG as _s,T as Os,bH as ks,bI as Xs,b as Bs,bJ as Ns,c as Ds,bK as $s,bL as zs,bM as Ws,bN as qs,bO as Gs,bP as Js,bQ as Hs,bR as Zs,bS as Ks,bT as Qs,bU as js,bV as tn,bW as en,bX as sn,bY as nn,bZ as on,b_ as rn,V as an,b$ as ln,c0 as cn,c1 as hn,c2 as pn,c3 as dn}from"./index-CQJ6qUg9.js";class It{constructor(t){T(this,"skeletonData");T(this,"animationToMixTime",{});T(this,"defaultMix",0);if(!t)throw new Error("skeletonData cannot be null.");this.skeletonData=t}setMix(t,e,n){return typeof t=="string"?this.setMix1(t,e,n):this.setMix2(t,e,n)}setMix1(t,e,n){const s=this.skeletonData.findAnimation(t);if(!s)throw new Error(`Animation not found: ${t}`);const i=this.skeletonData.findAnimation(e);if(!i)throw new Error(`Animation not found: ${e}`);this.setMix2(s,i,n)}setMix2(t,e,n){if(!t)throw new Error("from cannot be null.");if(!e)throw new Error("to cannot be null.");const s=`${t.name}.${e.name}`;this.animationToMixTime[s]=n}getMix(t,e){const n=`${t.name}.${e.name}`,s=this.animationToMixTime[n];return s===void 0?this.defaultMix:s}}class Ct{constructor(t,e="",n=new bt,s=new lt){T(this,"textureLoader");T(this,"pathPrefix");T(this,"downloader");T(this,"cache");T(this,"errors",{});T(this,"toLoad",0);T(this,"loaded",0);T(this,"texturePmaInfo",{});this.textureLoader=t,this.pathPrefix=e,this.downloader=n,this.cache=s}start(t){return this.toLoad++,this.pathPrefix+t}success(t,e,n){this.toLoad--,this.loaded++,this.cache.assets[e]=n,this.cache.assetsRefCount[e]=(this.cache.assetsRefCount[e]||0)+1,t&&t(e,n)}error(t,e,n){this.toLoad--,this.loaded++,this.errors[e]=n,t&&t(e,n)}loadAll(){return new Promise((e,n)=>{const s=()=>{if(this.isLoadingComplete()){this.hasErrors()?n(this.errors):e(this);return}requestAnimationFrame(s)};requestAnimationFrame(s)})}setRawDataURI(t,e){this.downloader.rawDataUris[this.pathPrefix+t]=e}loadBinary(t,e=()=>{},n=()=>{}){t=this.start(t),!this.reuseAssets(t,e,n)&&(this.cache.assetsLoaded[t]=new Promise((s,i)=>{this.downloader.downloadBinary(t,o=>{this.success(e,t,o),s(o)},(o,r)=>{const l=`Couldn't load binary ${t}: status ${o}, ${r}`;this.error(n,t,l),i(l)})}))}loadText(t,e=()=>{},n=()=>{}){t=this.start(t),this.downloader.downloadText(t,s=>{this.success(e,t,s)},(s,i)=>{this.error(n,t,`Couldn't load text ${t}: status ${s}, ${i}`)})}loadJson(t,e=()=>{},n=()=>{}){t=this.start(t),!this.reuseAssets(t,e,n)&&(this.cache.assetsLoaded[t]=new Promise((s,i)=>{this.downloader.downloadJson(t,o=>{this.success(e,t,o),s(o)},(o,r)=>{const l=`Couldn't load JSON ${t}: status ${o}, ${r}`;this.error(n,t,l),i(l)})}))}reuseAssets(t,e=()=>{},n=()=>{}){const s=this.cache.getAsset(t),i=s!==void 0;return i&&(this.cache.assetsLoaded[t]=s.then(o=>(o=o instanceof Image||o instanceof ImageBitmap?this.textureLoader(o):o,this.success(e,t,o),o)).catch(o=>{this.error(n,t,o)})),i}loadTexture(t,e=()=>{},n=()=>{}){if(t=this.start(t),this.reuseAssets(t,e,n))return;const s=this.texturePmaInfo[t];this.cache.assetsLoaded[t]=new Promise((i,o)=>{if(!!!(typeof window<"u"&&typeof navigator<"u"&&window.document))fetch(t,{mode:"cors"}).then(c=>{if(c.ok)return c.blob();const a=`Couldn't load image: ${t}`;this.error(n,t,`Couldn't load image: ${t}`),o(a)}).then(c=>c?createImageBitmap(c,{premultiplyAlpha:"none",colorSpaceConversion:"none"}):null).then(c=>{if(c){const a=this.createTexture(t,s,c);this.success(e,t,a),i(a)}});else{const c=new Image;c.crossOrigin="anonymous",c.onload=()=>{const a=this.createTexture(t,s,c);this.success(e,t,a),i(a)},c.onerror=()=>{const a=`Couldn't load image: ${t}`;this.error(n,t,a),o(a)},this.downloader.rawDataUris[t]&&(t=this.downloader.rawDataUris[t]),c.src=t}})}loadTextureAtlas(t,e=()=>{},n=()=>{},s){const i=t.lastIndexOf("/"),o=i>=0?t.substring(0,i+1):"";t=this.start(t),!this.reuseAssets(t,e,n)&&(this.cache.assetsLoaded[t]=new Promise((r,l)=>{this.downloader.downloadText(t,c=>{try{const a=this.createTextureAtlas(c,o,t,s);let h=a.pages.length,m=!1;if(h===0){this.success(e,t,a),r(a);return}for(const y of a.pages)this.loadTexture(this.texturePath(o,y.name,s),(A,u)=>{m||(y.setTexture(u),--h===0&&(this.success(e,t,a),r(a)))},(A,u)=>{if(!m){const g=`Couldn't load texture ${t} page image: ${A}`;this.error(n,t,g),l(g)}m=!0})}catch(a){const h=`Couldn't parse texture atlas ${t}: ${a.message}`;this.error(n,t,h),l(h)}},(c,a)=>{const h=`Couldn't load texture atlas ${t}: status ${c}, ${a}`;this.error(n,t,h),l(h)})}))}loadTextureAtlasButNoTextures(t,e=()=>{},n=()=>{}){const s=t.lastIndexOf("/"),i=s>=0?t.substring(0,s+1):"";t=this.start(t),!this.reuseAssets(t,e,n)&&(this.cache.assetsLoaded[t]=new Promise((o,r)=>{this.downloader.downloadText(t,l=>{try{const c=this.createTextureAtlas(l,i,t);this.success(e,t,c),o(c)}catch(c){const a=`Couldn't parse texture atlas ${t}: ${c.message}`;this.error(n,t,a),r(a)}},(l,c)=>{const a=`Couldn't load texture atlas ${t}: status ${l}, ${c}`;this.error(n,t,a),r(a)})}))}async loadBinaryAsync(t){return new Promise((e,n)=>{this.loadBinary(t,(s,i)=>e(i),(s,i)=>n(i))})}async loadJsonAsync(t){return new Promise((e,n)=>{this.loadJson(t,(s,i)=>e(i),(s,i)=>n(i))})}async loadTextureAsync(t){return new Promise((e,n)=>{this.loadTexture(t,(s,i)=>e(i),(s,i)=>n(i))})}async loadTextureAtlasAsync(t){return new Promise((e,n)=>{this.loadTextureAtlas(t,(s,i)=>e(i),(s,i)=>n(i))})}async loadTextureAtlasButNoTexturesAsync(t){return new Promise((e,n)=>{this.loadTextureAtlasButNoTextures(t,(s,i)=>e(i),(s,i)=>n(i))})}setCache(t){this.cache=t}get(t){return this.cache.assets[this.pathPrefix+t]}require(t){t=this.pathPrefix+t;const e=this.cache.assets[t];if(e)return e;const n=this.errors[t];throw Error(`Asset not found: ${t}${n?`
|
|
${n}`:""}`)}remove(t){t=this.pathPrefix+t;const e=this.cache.assets[t];return e.dispose&&e.dispose(),delete this.cache.assets[t],delete this.cache.assetsRefCount[t],delete this.cache.assetsLoaded[t],e}removeAll(){for(const t in this.cache.assets){const e=this.cache.assets[t];e.dispose&&e.dispose()}this.cache.assets={},this.cache.assetsLoaded={},this.cache.assetsRefCount={}}isLoadingComplete(){return this.toLoad===0}getToLoad(){return this.toLoad}getLoaded(){return this.loaded}dispose(){this.removeAll()}disposeAsset(t){const e=this.cache.assets[t];if(e instanceof ht){e.dispose();return}this.disposeAssetInternal(t)}hasErrors(){return Object.keys(this.errors).length>0}getErrors(){return this.errors}disposeAssetInternal(t){if(this.cache.assetsRefCount[t]>0&&--this.cache.assetsRefCount[t]===0)return this.remove(t)}createTextureAtlas(t,e,n,s){const i=new ht(t);i.dispose=()=>{var o;if(!(this.cache.assetsRefCount[n]<=0)){this.disposeAssetInternal(n);for(const r of i.pages)(o=r.texture)==null||o.dispose()}};for(const o of i.pages){const r=this.texturePath(e,o.name,s);this.texturePmaInfo[this.pathPrefix+r]=o.pma}return i}createTexture(t,e,n){const s=this.textureLoader(n,e),i=s.dispose.bind(s);return s.dispose=()=>{this.disposeAssetInternal(t)&&i()},s}texturePath(t,e,n){return n?n[e]:t+e}}const nt=class nt{constructor(){T(this,"assets",{});T(this,"assetsRefCount",{});T(this,"assetsLoaded",{})}static getCache(t){const e=nt.AVAILABLE_CACHES.get(t);if(e)return e;const n=new nt;return nt.AVAILABLE_CACHES.set(t,n),n}async addAsset(t,e){return this.assetsLoaded[t]=Promise.resolve(e),this.assets[t]=e,e}getAsset(t){return this.assetsLoaded[t]}};T(nt,"AVAILABLE_CACHES",new Map);let lt=nt;class bt{constructor(){T(this,"callbacks",{});T(this,"rawDataUris",{})}dataUriToString(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");return e!==-1?(e+=7,atob(t.substr(e))):t.substr(t.indexOf(",")+1)}base64ToUint8Array(t){var e=window.atob(t),n=e.length,s=new Uint8Array(n);for(let i=0;i<n;i++)s[i]=e.charCodeAt(i);return s}dataUriToUint8Array(t){if(!t.startsWith("data:"))throw new Error("Not a data URI.");let e=t.indexOf("base64,");if(e===-1)throw new Error("Not a binary data URI.");return e+=7,this.base64ToUint8Array(t.substr(e))}downloadText(t,e,n){if(this.start(t,e,n))return;const s=this.rawDataUris[t];if(s&&!s.includes(".")){try{this.finish(t,200,this.dataUriToString(s))}catch(r){this.finish(t,400,JSON.stringify(r))}return}const i=new XMLHttpRequest;i.overrideMimeType("text/html"),i.open("GET",s||t,!0);const o=()=>{this.finish(t,i.status,i.responseText)};i.onload=o,i.onerror=o,i.send()}downloadJson(t,e,n){this.downloadText(t,s=>{e(JSON.parse(s))},n)}downloadBinary(t,e,n){if(this.start(t,e,n))return;const s=this.rawDataUris[t];if(s&&!s.includes(".")){try{this.finish(t,200,this.dataUriToUint8Array(s))}catch(r){this.finish(t,400,JSON.stringify(r))}return}const i=new XMLHttpRequest;i.open("GET",s||t,!0),i.responseType="arraybuffer";const o=()=>{this.finish(t,i.status,i.response)};i.onload=()=>{i.status===200||i.status===0?this.finish(t,200,new Uint8Array(i.response)):o()},i.onerror=o,i.send()}start(t,e,n){let s=this.callbacks[t];try{if(s)return!0;this.callbacks[t]=s=[]}finally{s.push(e,n)}}finish(t,e,n){const s=this.callbacks[t];if(delete this.callbacks[t],e===200||e===0)for(let i=0,o=s.length;i<o;i+=2)s[i](n);else for(let i=1,o=s.length;i<o;i+=2)s[i](e,n)}}class Vt{constructor(t,e=!1){T(this,"atlas");T(this,"allowMissingRegions");this.atlas=t,this.allowMissingRegions=e}findRegions(t,e,n){const s=n.regions;for(let i=0,o=s.length;i<o;i++)s[i]=this.findRegion(t,n.getPath(e,i))}findRegion(t,e){const n=this.atlas.findRegion(e);if(!n&&!this.allowMissingRegions)throw new Error(`Region not found in atlas: ${e} (attachment: ${t})`);return n}newRegionAttachment(t,e,n,s,i){return this.findRegions(n,s,i),new pt(n,i)}newMeshAttachment(t,e,n,s,i){return this.findRegions(n,s,i),new dt(n,i)}newBoundingBoxAttachment(t,e,n){return new ut(n)}newPathAttachment(t,e,n){return new mt(n)}newPointAttachment(t,e,n){return new yt(n)}newClippingAttachment(t,e,n){return new rt(n)}}class Lt{constructor(){T(this,"minX",0);T(this,"minY",0);T(this,"maxX",0);T(this,"maxY",0);T(this,"boundingBoxes",[]);T(this,"polygons",[]);T(this,"polygonPool",new at(()=>D.newFloatArray(16)))}update(t,e){if(!t)throw new Error("skeleton cannot be null.");const n=this.boundingBoxes,s=this.polygons,i=this.polygonPool,o=t.slots,r=o.length;n.length=0,i.freeAll(s),s.length=0;for(let l=0;l<r;l++){const c=o[l];if(!c.bone.active)continue;const a=c.appliedPose.attachment;if(a instanceof ut){n.push(a);let h=i.obtain();h.length!==a.worldVerticesLength&&(h=D.newFloatArray(a.worldVerticesLength)),s.push(h),a.computeWorldVertices(t,c,0,a.worldVerticesLength,h,0,2)}}e?this.aabbCompute():(this.minX=Number.POSITIVE_INFINITY,this.minY=Number.POSITIVE_INFINITY,this.maxX=Number.NEGATIVE_INFINITY,this.maxY=Number.NEGATIVE_INFINITY)}aabbCompute(){let t=Number.POSITIVE_INFINITY,e=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;const i=this.polygons;for(let o=0,r=i.length;o<r;o++){const l=i[o],c=l;for(let a=0,h=l.length;a<h;a+=2){const m=c[a],y=c[a+1];t=Math.min(t,m),e=Math.min(e,y),n=Math.max(n,m),s=Math.max(s,y)}}this.minX=t,this.minY=e,this.maxX=n,this.maxY=s}aabbContainsPoint(t,e){return t>=this.minX&&t<=this.maxX&&e>=this.minY&&e<=this.maxY}aabbIntersectsSegment(t,e,n,s){const i=this.minX,o=this.minY,r=this.maxX,l=this.maxY;if(t<=i&&n<=i||e<=o&&s<=o||t>=r&&n>=r||e>=l&&s>=l)return!1;const c=(s-e)/(n-t);let a=c*(i-t)+e;if(a>o&&a<l||(a=c*(r-t)+e,a>o&&a<l))return!0;let h=(o-e)/c+t;return h>i&&h<r||(h=(l-e)/c+t,h>i&&h<r)}aabbIntersectsSkeleton(t){return this.minX<t.maxX&&this.maxX>t.minX&&this.minY<t.maxY&&this.maxY>t.minY}containsPoint(t,e){const n=this.polygons;for(let s=0,i=n.length;s<i;s++)if(this.containsPointPolygon(n[s],t,e))return this.boundingBoxes[s];return null}containsPointPolygon(t,e,n){const s=t,i=t.length;let o=i-2,r=!1;for(let l=0;l<i;l+=2){const c=s[l+1],a=s[o+1];if(c<n&&a>=n||a<n&&c>=n){const h=s[l];h+(n-c)/(a-c)*(s[o]-h)<e&&(r=!r)}o=l}return r}intersectsSegment(t,e,n,s){const i=this.polygons;for(let o=0,r=i.length;o<r;o++)if(this.intersectsSegmentPolygon(i[o],t,e,n,s))return this.boundingBoxes[o];return null}intersectsSegmentPolygon(t,e,n,s,i){const o=t,r=t.length,l=e-s,c=n-i,a=e*i-n*s;let h=o[r-2],m=o[r-1];for(let y=0;y<r;y+=2){const A=o[y],u=o[y+1],g=h*u-m*A,b=h-A,L=m-u,C=l*L-c*b,f=(a*b-l*g)/C;if((f>=h&&f<=A||f>=A&&f<=h)&&(f>=e&&f<=s||f>=s&&f<=e)){const x=(a*L-c*g)/C;if((x>=m&&x<=u||x>=u&&x<=m)&&(x>=n&&x<=i||x>=i&&x<=n))return!0}h=A,m=u}return!1}getPolygon(t){if(!t)throw new Error("boundingBox cannot be null.");const e=this.boundingBoxes.indexOf(t);return e===-1?null:this.polygons[e]}getWidth(){return this.maxX-this.minX}getHeight(){return this.maxY-this.minY}}class z{constructor(){T(this,"convexPolygons",[]);T(this,"convexPolygonsIndices",[]);T(this,"indicesArray",[]);T(this,"isConcaveArray",[]);T(this,"triangles",[]);T(this,"polygonPool",new at(()=>[]));T(this,"polygonIndicesPool",new at(()=>[]))}triangulate(t){const e=t;let n=t.length>>1;const s=this.indicesArray;s.length=0;for(let r=0;r<n;r++)s[r]=r;const i=this.isConcaveArray;i.length=0;for(let r=0;r<n;r++)i[r]=z.isConcave(r,n,e,s);const o=this.triangles;for(o.length=0;n>3;){let r=n-1,l=0,c=1;for(;;){t:if(!i[l]){const m=s[r]<<1,y=s[l]<<1,A=s[c]<<1,u=e[m],g=e[m+1],b=e[y],L=e[y+1],C=e[A],f=e[A+1];for(let x=c+1<n?c+1:0;x!==r;){if(i[x]){const S=s[x]<<1,P=e[S],M=e[S+1];if(z.positiveArea(C,f,u,g,P,M)&&z.positiveArea(u,g,b,L,P,M)&&z.positiveArea(b,L,C,f,P,M))break t}++x===n&&(x=0)}break}if(c===0){do{if(!i[l])break;l--}while(l>0);r=l>0?l-1:n-1,c=l+1<n?l+1:0;break}r=l,l=c,++c===n&&(c=0)}o.push(s[r],s[l],s[c]),s.splice(l,1),i.splice(l,1),n--;const a=l>0?l-1:n-1,h=l<n?l:0;i[a]=z.isConcave(a,n,e,s),i[h]=z.isConcave(h,n,e,s)}return n===3&&o.push(s[2],s[0],s[1]),o}decompose(t,e){const n=t,s=this.convexPolygons;this.polygonPool.freeAll(s),s.length=0;const i=this.convexPolygonsIndices;this.polygonIndicesPool.freeAll(i),i.length=0;let o=this.polygonIndicesPool.obtain();o.length=0;let r=this.polygonPool.obtain();r.length=0;let l=-1,c=0;for(let a=0,h=e.length;a<h;a+=3){const m=e[a]<<1,y=e[a+1]<<1,A=e[a+2]<<1,u=n[m],g=n[m+1],b=n[y],L=n[y+1],C=n[A],f=n[A+1];if(l===m){const x=r.length-4;if(z.winding(r[x],r[x+1],r[x+2],r[x+3],C,f)===c&&z.winding(C,f,r[0],r[1],r[2],r[3])===c){r.push(C,f),o.push(A);continue}}r.length>0&&(s.push(r),i.push(o),r=this.polygonPool.obtain(),o=this.polygonIndicesPool.obtain()),r.length=0,r.push(u,g,b,L),r.push(C,f),o.length=0,o.push(m,y,A),c=z.winding(u,g,b,L,C,f),l=m}r.length>0&&(s.push(r),i.push(o));for(let a=0,h=s.length;a<h;a++){if(o=i[a],o.length===0)continue;const m=o[0];let y=o[o.length-1];r=s[a];const A=r.length-4;let u=r[A],g=r[A+1],b=r[A+2],L=r[A+3];const C=r[0],f=r[1],x=r[2],S=r[3],P=z.winding(u,g,b,L,C,f);for(let M=0;M<h;M++){if(M===a)continue;const I=i[M];if(I.length!==3)continue;const R=I[0],v=I[1],V=I[2],w=s[M],U=w[w.length-2],O=w[w.length-1];R!==m||v!==y||z.winding(u,g,b,L,U,O)===P&&z.winding(U,O,C,f,x,S)===P&&(w.length=0,I.length=0,r.push(U,O),o.push(V),y=V,u=b,g=L,b=U,L=O,M=-1)}}for(let a=s.length-1;a>=0;a--)r=s[a],r.length===0?(s.splice(a,1),this.polygonPool.free(r),o=i[a],i.splice(a,1),this.polygonIndicesPool.free(o)):r.push(r[0],r[1]);return s}static isConcave(t,e,n,s){const i=s[t>0?t-1:e-1]<<1,o=s[t]<<1,r=s[t+1<e?t+1:0]<<1;return!z.positiveArea(n[i],n[i+1],n[o],n[o+1],n[r],n[r+1])}static positiveArea(t,e,n,s,i,o){return t*(o-s)+n*(e-o)+i*(s-e)>=0}static winding(t,e,n,s,i,o){return t*(o-s)+n*(e-o)+i*(s-e)>=0?1:-1}}class wt{constructor(){T(this,"triangulator",null);T(this,"clippingPolygon",[]);T(this,"clippingPolygons",[]);T(this,"clipOutput",[]);T(this,"clippedVertices",[]);T(this,"clippedUVs",[]);T(this,"clippedTriangles",[]);T(this,"inverseVertices",[]);T(this,"_clippedVerticesTyped",new Float32Array(1024));T(this,"_clippedUVsTyped",new Float32Array(1024));T(this,"_clippedTrianglesTyped",new Uint16Array(1024));T(this,"clippedVerticesTyped",new Float32Array(0));T(this,"clippedUVsTyped",new Float32Array(0));T(this,"clippedTrianglesTyped",new Uint16Array(0));T(this,"clippedVerticesLength",0);T(this,"clippedUVsLength",0);T(this,"clippedTrianglesLength",0);T(this,"scratch",[]);T(this,"inverse",!1);T(this,"clipAttachment",null)}clipStart(t,e,n){if(this.clipAttachment)return;const s=n.worldVerticesLength;this.clipAttachment=n,this.inverse=n.inverse;const i=D.setArraySize(this.clippingPolygon,s);n.computeWorldVertices(t,e,0,s,i,0,2);const o=this.clippingPolygon,r=this.makeClockwise(o);r||this.inverse||n.convex?(r||this.makeConvex(o),this.clippingPolygon.push(o[0],o[1]),this.clippingPolygons.push(o)):(this.triangulator===null&&(this.triangulator=new z),this.clippingPolygons.push(...this.triangulator.decompose(o,this.triangulator.triangulate(o))))}clipEnd(t){this.clipAttachment&&(t&&this.clipAttachment.endSlot!==t.data||(this.clipAttachment=null,this.clippingPolygons.length=0))}isClipping(){return this.clipAttachment!=null}clipTriangles(t,e,n,s,i,o,r,l){return s&&i&&o&&typeof r=="boolean"&&typeof l=="number"?this.clipTrianglesRender(t,e,n,s,i,o,r,l):this.clipTrianglesNoRender(t,e,n)}clipTrianglesNoRender(t,e,n){const s=this.clippedVertices;s.length=0;const i=this.clippedTriangles;i.length=0;let o=0;if(this.inverse){const h=this.clippingPolygons[0];for(let m=0;m<n;m+=3){let y=e[m]<<1;const A=t[y],u=t[y+1];y=e[m+1]<<1;const g=t[y],b=t[y+1];y=e[m+2]<<1;const L=t[y],C=t[y+1];this.clipInverse(A,u,g,b,L,C,h);const f=this.inverseVertices;for(let x=0,S=this.inverseVertices.length;x<S;){const P=f[x++];let M=P>>1,I=s.length;const R=D.setArraySize(s,I+P);D.arrayCopy(f,x,R,I,P),I=i.length;const v=D.setArraySize(i,I+3*(M-2));for(let V=1;V<M-1;V++,I+=3)v[I]=o,v[I+1]=o+V,v[I+2]=o+V+1;o+=M,x+=P}}return!0}const r=this.clipOutput,l=this.clippingPolygons,c=l.length;let a=null;for(let h=0;h<n;h+=3){let m=e[h]<<1;const y=t[m],A=t[m+1];m=e[h+1]<<1;const u=t[m],g=t[m+1];m=e[h+2]<<1;const b=t[m],L=t[m+1];for(let C=0;C<c;C++){let f=s.length;if(this.clip(y,A,u,g,b,L,l[C])){a=this.clipOutput;const x=r.length;if(x===0)continue;let S=x>>1;const P=D.setArraySize(s,f+x);D.arrayCopy(a,0,P,f,x),f=i.length;const M=D.setArraySize(i,f+3*(S-2));S--;for(let I=1;I<S;I++,f+=3)M[f]=o,M[f+1]=o+I,M[f+2]=o+I+1;o+=S}else{const x=D.setArraySize(s,f+6);x[f]=y,x[f+1]=A,x[f+2]=u,x[f+3]=g,x[f+4]=b,x[f+5]=L,f=i.length;const S=D.setArraySize(i,f+3);S[f]=o,S[f+1]=o+1,S[f+2]=o+2,o+=3;break}}}return a!=null}clipTrianglesRender(t,e,n,s,i,o,r,l){const c=this.clippedVertices;c.length=0;const a=this.clippedTriangles;a.length=0;let h=0;if(this.inverse){const g=this.clippingPolygons[0];for(let b=0;b<n;b+=3){let L=e[b],C=e[b+1],f=e[b+2];const x=t[L*l],S=t[L*l+1],P=t[C*l],M=t[C*l+1],I=t[f*l],R=t[f*l+1];this.clipInverse(x,S,P,M,I,R,g);const v=this.inverseVertices.length;if(v===0)continue;const V=s[L<<=1],w=s[L+1],U=s[C<<=1],O=s[C+1],B=s[f<<=1],K=s[f+1],q=M-R,J=I-P,d=x-I,p=R-S,_=1/(q*d+J*(S-R)),E=this.inverseVertices;for(let k=0;k<v;){const Y=E[k++],G=Y>>1;let F=c.length;const N=D.setArraySize(c,F+G*l);for(let X=0;X<Y;X+=2,F+=l){const Z=E[k+X],Q=E[k+X+1];N[F]=Z,N[F+1]=Q,N[F+2]=i.r,N[F+3]=i.g,N[F+4]=i.b,N[F+5]=i.a;const $=Z-I,et=Q-R,j=(q*$+J*et)*_,tt=(p*$+d*et)*_,st=1-j-tt;N[F+6]=V*j+U*tt+B*st,N[F+7]=w*j+O*tt+K*st,r&&(N[F+8]=o.r,N[F+9]=o.g,N[F+10]=o.b,N[F+11]=o.a)}F=a.length;const H=D.setArraySize(a,F+3*(G-2));for(let X=1;X<G-1;X++,F+=3)H[F]=h,H[F+1]=h+X,H[F+2]=h+X+1;h+=G,k+=Y}}return!0}const m=this.clipOutput,y=this.clippingPolygons,A=this.clippingPolygons.length;let u=null;for(let g=0;g<n;g+=3){let b=e[g];const L=t[b*l],C=t[b*l+1],f=s[b<<1],x=s[(b<<1)+1];b=e[g+1];const S=t[b*l],P=t[b*l+1],M=s[b<<1],I=s[(b<<1)+1];b=e[g+2];const R=t[b*l],v=t[b*l+1],V=s[b<<1],w=s[(b<<1)+1];let U=0,O=0,B=0,K=0,q=0;for(let J=0;J<A;J++){let d=c.length;if(this.clip(L,C,S,P,R,v,y[J])){u=this.clipOutput;const p=m.length;if(p===0)continue;let _=p>>1;q===0&&(U=P-v,O=R-S,B=L-R,K=v-C,q=1/(U*B-O*K));const E=D.setArraySize(c,d+_*l);for(let Y=0;Y<p;Y+=2,d+=l){const G=u[Y],F=u[Y+1];E[d]=G,E[d+1]=F,E[d+2]=i.r,E[d+3]=i.g,E[d+4]=i.b,E[d+5]=i.a;const N=G-R,H=F-v,X=(U*N+O*H)*q,Z=(K*N+B*H)*q,Q=1-X-Z;E[d+6]=f*X+M*Z+V*Q,E[d+7]=x*X+I*Z+w*Q,r&&(E[d+8]=o.r,E[d+9]=o.g,E[d+10]=o.b,E[d+11]=o.a)}d=a.length;const k=D.setArraySize(a,d+3*(_-2));_--;for(let Y=1;Y<_;Y++,d+=3)k[d]=h,k[d+1]=h+Y,k[d+2]=h+Y+1;h+=_+1}else{const p=D.setArraySize(c,d+3*l);p[d]=L,p[d+1]=C,p[d+2]=i.r,p[d+3]=i.g,p[d+4]=i.b,p[d+5]=i.a,r?(p[d+6]=f,p[d+7]=x,p[d+8]=o.r,p[d+9]=o.g,p[d+10]=o.b,p[d+11]=o.a,p[d+12]=S,p[d+13]=P,p[d+14]=i.r,p[d+15]=i.g,p[d+16]=i.b,p[d+17]=i.a,p[d+18]=M,p[d+19]=I,p[d+20]=o.r,p[d+21]=o.g,p[d+22]=o.b,p[d+23]=o.a,p[d+24]=R,p[d+25]=v,p[d+26]=i.r,p[d+27]=i.g,p[d+28]=i.b,p[d+29]=i.a,p[d+30]=V,p[d+31]=w,p[d+32]=o.r,p[d+33]=o.g,p[d+34]=o.b,p[d+35]=o.a):(p[d+6]=f,p[d+7]=x,p[d+8]=S,p[d+9]=P,p[d+10]=i.r,p[d+11]=i.g,p[d+12]=i.b,p[d+13]=i.a,p[d+14]=M,p[d+15]=I,p[d+16]=R,p[d+17]=v,p[d+18]=i.r,p[d+19]=i.g,p[d+20]=i.b,p[d+21]=i.a,p[d+22]=V,p[d+23]=w),d=a.length;const _=D.setArraySize(a,d+3);_[d]=h,_[d+1]=h+1,_[d+2]=h+2,h+=3;break}}}return u!=null}clipTrianglesUnpacked(t,e,n,s,i,o=2){let r=this._clippedVerticesTyped,l=this._clippedUVsTyped,c=this._clippedTrianglesTyped,a=0;if(this.clippedVerticesLength=0,this.clippedUVsLength=0,this.clippedTrianglesLength=0,this.inverse){const u=this.clippingPolygons[0];for(let g=0;g<s;g+=3){let b=n[g]*o;const L=t[e+b],C=t[e+b+1];let f=n[g]<<1;const x=i[f],S=i[f+1];b=n[g+1]*o;const P=t[e+b],M=t[e+b+1];f=n[g+1]<<1;const I=i[f],R=i[f+1];b=n[g+2]*o;const v=t[e+b],V=t[e+b+1];f=n[g+2]<<1;const w=i[f],U=i[f+1];this.clipInverse(L,C,P,M,v,V,u);const O=this.inverseVertices.length;if(O===0)continue;const B=M-V,K=v-P,q=L-v,J=V-C,d=1/(B*q+K*(C-V)),p=this.inverseVertices;for(let _=0;_<O;){const E=p[_++],k=E>>1;let Y=this.clippedVerticesLength;const G=Y+k*o,F=this.clippedUVsLength+k*2;r.length<G&&(this._clippedVerticesTyped=new Float32Array(G*2),this._clippedVerticesTyped.set(r.subarray(0,Y)),r=this._clippedVerticesTyped),l.length<F&&(this._clippedUVsTyped=new Float32Array(F*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),l=this._clippedUVsTyped),this.clippedVerticesLength=G,this.clippedUVsLength=F;const N=this._clippedVerticesTyped,H=this._clippedUVsTyped;let X=F-k*2;for(let $=0;$<E;$+=2,Y+=o,X+=2){const et=p[_+$],j=p[_+$+1];N[Y]=et,N[Y+1]=j;const tt=et-v,st=j-V,it=(B*tt+K*st)*d,ot=(J*tt+q*st)*d,ct=1-it-ot;H[X]=x*it+I*ot+w*ct,H[X+1]=S*it+R*ot+U*ct}Y=this.clippedTrianglesLength;const Z=Y+3*(k-2);c.length<Z&&(this._clippedTrianglesTyped=new Uint16Array(Z*2),this._clippedTrianglesTyped.set(c.subarray(0,Y)),c=this._clippedTrianglesTyped),this.clippedTrianglesLength=Z;const Q=c;for(let $=1;$<k-1;$++,Y+=3)Q[Y]=a,Q[Y+1]=a+$,Q[Y+2]=a+$+1;a+=k,_+=E}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),!0}const h=this.clipOutput,m=this.clippingPolygons,y=this.clippingPolygons.length;let A=null;for(let u=0;u<s;u+=3){let g=n[u],b=g*o;const L=t[e+b],C=t[e+b+1];let f=g<<1;const x=i[f],S=i[f+1];g=n[u+1],b=g*o;const P=t[e+b],M=t[e+b+1];f=g<<1;const I=i[f],R=i[f+1];g=n[u+2],b=g*o;const v=t[e+b],V=t[e+b+1];f=g<<1;const w=i[f],U=i[f+1];let O=0,B=0,K=0,q=0,J=0;for(let d=0;d<y;d++){let p=this.clippedVerticesLength;if(this.clip(L,C,P,M,v,V,m[d])){A=h;const _=h.length;if(_===0)continue;let E=_>>1;J===0&&(O=M-V,B=v-P,K=L-v,q=V-C,J=1/(O*K-B*q));const k=p+E*o;r.length<k&&(this._clippedVerticesTyped=new Float32Array(k*2),this._clippedVerticesTyped.set(r.subarray(0,p)),this._clippedUVsTyped=new Float32Array((this.clippedUVsLength+E*2)*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),r=this._clippedVerticesTyped,l=this._clippedUVsTyped);const Y=r,G=l;this.clippedVerticesLength=k;let F=this.clippedUVsLength;this.clippedUVsLength=F+E*2;for(let X=0;X<_;X+=2,p+=o,F+=2){const Z=A[X],Q=A[X+1];Y[p]=Z,Y[p+1]=Q;const $=Z-v,et=Q-V,j=(O*$+B*et)*J,tt=(q*$+K*et)*J,st=1-j-tt;G[F]=x*j+I*tt+w*st,G[F+1]=S*j+R*tt+U*st}p=this.clippedTrianglesLength;const N=p+3*(E-2);c.length<N&&(this._clippedTrianglesTyped=new Uint16Array(N*2),this._clippedTrianglesTyped.set(c.subarray(0,p)),c=this._clippedTrianglesTyped),this.clippedTrianglesLength=N;const H=c;E--;for(let X=1;X<E;X++,p+=3)H[p]=a,H[p+1]=a+X,H[p+2]=a+X+1;a+=E+1}else{let _=p+3*o;r.length<_&&(this._clippedVerticesTyped=new Float32Array(_*2),this._clippedVerticesTyped.set(r.subarray(0,p)),r=this._clippedVerticesTyped),r[p]=L,r[p+1]=C,r[p+o]=P,r[p+o+1]=M,r[p+o*2]=v,r[p+o*2+1]=V;const E=this.clippedUVsLength+6;l.length<E&&(this._clippedUVsTyped=new Float32Array(E*2),this._clippedUVsTyped.set(l.subarray(0,this.clippedUVsLength)),l=this._clippedUVsTyped);const k=this.clippedUVsLength;l[k]=x,l[k+1]=S,l[k+2]=I,l[k+3]=R,l[k+4]=w,l[k+5]=U,this.clippedVerticesLength=_,this.clippedUVsLength=E,p=this.clippedTrianglesLength,_=p+3,c.length<_&&(this._clippedTrianglesTyped=new Uint16Array(_*2),this._clippedTrianglesTyped.set(c.subarray(0,p)),c=this._clippedTrianglesTyped);const Y=c;Y[p]=a,Y[p+1]=a+1,Y[p+2]=a+2,a+=3,this.clippedTrianglesLength=_;break}}}return this.clippedVerticesTyped=this._clippedVerticesTyped.subarray(0,this.clippedVerticesLength),this.clippedUVsTyped=this._clippedUVsTyped.subarray(0,this.clippedUVsLength),this.clippedTrianglesTyped=this._clippedTrianglesTyped.subarray(0,this.clippedTrianglesLength),A!==null}clip(t,e,n,s,i,o,r){const l=this.clipOutput;let c=!1,a,h;r.length%4>=2?(a=this.clipOutput,h=this.scratch):(a=this.scratch,h=this.clipOutput);const m=r;a.length=8;const y=a;y[0]=t,y[1]=e,y[2]=n,y[3]=s,y[4]=i,y[5]=o,y[6]=t,y[7]=e,h.length=0;const A=r.length-4;for(let u=0;;u+=2){const g=m[u],b=m[u+1],L=g-m[u+2],C=b-m[u+3],f=h.length,x=a;t=x[0],e=x[1];let S=C*(g-t)-L*(b-e);for(let M=2,I=a.length-2;M<=I;M+=2){n=x[M],s=x[M+1];const R=C*(g-n)-L*(b-s);if(S>0)if(R>0)h.push(n,s);else{const v=n-t,V=s-e,w=S/(v*C-V*L);w>=0&&w<=1?(h.push(t+v*w,e+V*w),c=!0):h.push(n,s)}else if(R>0){const v=n-t,V=s-e,w=S/(v*C-V*L);w>=0&&w<=1?(h.push(t+v*w,e+V*w,n,s),c=!0):h.push(n,s)}else c=!0;t=n,e=s,S=R}if(f===h.length)return l.length=0,!0;if(h.push(h[0],h[1]),u===A)break;const P=h;h=a,h.length=0,a=P}if(l!==h){l.length=0;for(let u=0,g=h.length-2;u<g;u++)l[u]=h[u]}else l.length=l.length-2;return c}clipInverse(t,e,n,s,i,o,r){this.inverseVertices.length=0;const l=r.length-4;let c,a;r.length%4>=2?(c=this.clipOutput,a=this.scratch):(c=this.scratch,a=this.clipOutput),c.length=8;let h=r,m=c;m[0]=t,m[1]=e,m[2]=n,m[3]=s,m[4]=i,m[5]=o,m[6]=t,m[7]=e,a.length=0;for(let y=0;;y+=2){const A=h[y],u=h[y+1],g=A-h[y+2],b=u-h[y+3],L=a.length,C=this.inverseVertices.length;this.inverseVertices.push(0),m=c,t=m[0],e=m[1];let f=b*(A-t)-g*(u-e);for(let P=2,M=c.length-2;P<=M;P+=2){n=m[P],s=m[P+1];const I=b*(A-n)-g*(u-s);if(f>0)if(I>0)a.push(n,s);else{const R=n-t,v=s-e,V=f/(R*b-v*g);if(V>=0&&V<=1){const w=t+R*V,U=e+v*V;a.push(w,U),this.inverseVertices.push(w,U,n,s)}else a.push(n,s)}else if(I>0){const R=n-t,v=s-e,V=f/(R*b-v*g);if(V>=0&&V<=1){const w=t+R*V,U=e+v*V;this.inverseVertices.push(w,U),a.push(w,U,n,s)}else a.push(n,s)}else this.inverseVertices.push(n,s);t=n,e=s,f=I}const x=this.inverseVertices.length-C-1;if(x>=6?this.inverseVertices[C]=x:this.inverseVertices.length=C,L===a.length||(a.push(a[0],a[1]),y===l))break;const S=a;a=c,a.length=0,c=S}}makeClockwise(t){const e=t,n=t.length;let s=!0,i=!0,o=0,r=e[n-2],l=e[n-1],c=e[0],a=e[1];for(let m=2;m<n;m+=2){const y=e[m],A=e[m+1];o+=c*A-y*a;const u=(c-r)*(A-a)-(a-l)*(y-c);i=i&&u<=0,s=s&&u>=0,r=c,l=a,c=y,a=A}o+=c*e[1]-e[0]*a;const h=(c-r)*(e[1]-a)-(a-l)*(e[0]-c);if(i=i&&h<=0,s=s&&h>=0,o>=0){for(let m=0,y=n-2,A=n>>1;m<A;m+=2){const u=e[m],g=e[m+1],b=y-m;e[m]=e[b],e[m+1]=e[b+1],e[b]=u,e[b+1]=g}return s}return i}makeConvex(t){const e=t.length,n=t;this.clipOutput.length=e;const s=this.clipOutput;s[0]=n[0],s[1]=n[1];for(let r=2;r<e;r+=2){const l=n[r],c=n[r+1];let a=r-2;for(;a>=0&&(s[a]>l||s[a]===l&&s[a+1]>c);a-=2)s[a+2]=s[a],s[a+3]=s[a+1];s[a+2]=l,s[a+3]=c}n[0]=s[0],n[1]=s[1],n[2]=s[2],n[3]=s[3];let i=4;for(let r=4;r<e;r+=2,i+=2){const l=s[r],c=s[r+1];for(;(n[i-2]-n[i-4])*(c-n[i-3])-(n[i-1]-n[i-3])*(l-n[i-4])>=0&&(i-=2,i!==2););n[i]=l,n[i+1]=c}n[i]=s[e-4],n[i+1]=s[e-3];const o=i;i+=2;for(let r=e-6;r>=0;r-=2,i+=2){const l=s[r],c=s[r+1];for(;(n[i-2]-n[i-4])*(c-n[i-3])-(n[i-1]-n[i-3])*(l-n[i-4])>=0&&(i-=2,i!==o););n[i]=l,n[i+1]=c}t.length=i-2}}class St{constructor(t,e,n={}){T(this,"skeleton");T(this,"adapter");T(this,"positionInheritanceFactorX",0);T(this,"positionInheritanceFactorY",0);T(this,"rotationInheritanceFactor",0);T(this,"hasLastTransform",!1);T(this,"lastX",0);T(this,"lastY",0);T(this,"lastZ",0);T(this,"lastRotation",0);T(this,"currentTransform",{x:0,y:0,z:0,rotation:0});T(this,"currentPosition",{x:0,y:0,z:0});T(this,"lastPosition",{x:0,y:0,z:0});this.skeleton=t,this.adapter=e,this.positionInheritanceFactorX=n.positionInheritanceX??0,this.positionInheritanceFactorY=n.positionInheritanceY??0,this.rotationInheritanceFactor=n.rotationInheritance??0}get positionInheritanceX(){return this.positionInheritanceFactorX}get positionInheritanceY(){return this.positionInheritanceFactorY}setPositionInheritance(t,e){const n=this.positionInheritanceFactorX===0&&this.positionInheritanceFactorY===0,s=t!==0||e!==0;this.positionInheritanceFactorX=t,this.positionInheritanceFactorY=e,n&&s&&this.resetPosition()}get rotationInheritance(){return this.rotationInheritanceFactor}set rotationInheritance(t){const e=this.rotationInheritanceFactor===0;this.rotationInheritanceFactor=t,e&&t!==0&&this.resetRotation()}resetPosition(){const t=this.currentTransform,e=!this.hasLastTransform&&this.rotationInheritanceFactor!==0;this.adapter.readTransform(t,e),this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z,e&&(this.lastRotation=t.rotation),this.hasLastTransform=!0}resetRotation(){const t=this.currentTransform;this.adapter.readTransform(t,!0),this.lastRotation=t.rotation,this.hasLastTransform||(this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z),this.hasLastTransform=!0}resetTransform(){const t=this.currentTransform;this.adapter.readTransform(t,!0),this.setLastTransform(t.x,t.y,t.z,t.rotation)}applyTransformMovement(){const t=this.positionInheritanceFactorX!==0||this.positionInheritanceFactorY!==0,e=this.rotationInheritanceFactor!==0;if(!t&&!e)return;const n=this.currentTransform;this.adapter.readTransform(n,e);const{x:s,y:i,z:o}=n,r=e?n.rotation:this.lastRotation,l=s!==this.lastX||i!==this.lastY||o!==this.lastZ;if(this.hasLastTransform){if(!l&&r===this.lastRotation)return;t&&l&&this.applyPositionMovement(s,i,o),e&&r!==this.lastRotation&&this.applyRotationMovement(r)}this.setLastTransform(s,i,o,r)}applyPositionMovement(t,e,n){const s=this.currentPosition;s.x=t,s.y=e,s.z=n,this.adapter.worldToSkeleton(s);const i=this.lastPosition;i.x=this.lastX,i.y=this.lastY,i.z=this.lastZ,this.adapter.worldToSkeleton(i),this.skeleton.physicsTranslate((s.x-i.x)*this.positionInheritanceFactorX,(s.y-i.y)*this.positionInheritanceFactorY)}applyRotationMovement(t){const e=this.rotationInheritanceFactor;e!==0&&this.skeleton.physicsRotate(0,0,this.getRotationDelta(t,this.lastRotation)*e)}setLastTransform(t,e,n,s){this.lastX=t,this.lastY=e,this.lastZ=n,this.lastRotation=s,this.hasLastTransform=!0}getRotationDelta(t,e){let n=t-e;return n=(n+180)%360-180,n<-180?n+360:n}}class Mt{constructor(){T(this,"commandPool",new xt);T(this,"worldVertices",new Float32Array(12*1024));T(this,"quadIndices",new Uint16Array([0,1,2,2,3,0]));T(this,"clipping",new wt);T(this,"renderCommands",[])}render(t,e=!1,n,s=2,i=0){var c,a;this.commandPool.reset(),this.renderCommands.length=0;const o=this.clipping;let r=0;const l=t.drawOrder.appliedPose;for(let h=0,m=l.length;h<m;h++){const y=l[h];if(!y.bone.active){o.clipEnd(y);continue}const A=y.appliedPose,u=A.attachment;if(!u){o.clipEnd(y);continue}const g=A.color;if(g.a===0&&!(u instanceof rt)){o.clipEnd(y);continue}let L,C,f,x,S,P,M;if(u instanceof pt){if(P=u.color,P.a===0){o.clipEnd(y);continue}const w=u.sequence,U=w.resolveIndex(A);u.computeWorldVertices(y,u.getOffsets(A),this.worldVertices,0,s),L=this.worldVertices,C=4,f=w.getUVs(U),x=this.quadIndices,S=6,M=(c=w.regions[U])==null?void 0:c.texture}else if(u instanceof dt){if(P=u.color,P.a===0){o.clipEnd(y);continue}this.worldVertices.length<u.worldVerticesLength&&(this.worldVertices=new Float32Array(u.worldVerticesLength)),u.computeWorldVertices(t,y,0,u.worldVerticesLength,this.worldVertices,0,s),L=this.worldVertices,C=u.worldVerticesLength>>1;const w=u.sequence,U=w.resolveIndex(A);f=w.getUVs(U),x=u.triangles,S=x.length,M=(a=w.regions[U])==null?void 0:a.texture}else if(u instanceof rt){o.clipEnd(y),o.clipStart(t,y,u);continue}else{o.clipEnd(y);continue}if(!M){o.clipEnd(y);continue}const I=t.color;let R,v;if(e){let w;if(n){w=Math.floor(n[3]*I.a*g.a*P.a*255);const U=Math.floor(w*n[0]*I.r*g.r*P.r),O=Math.floor(w*n[1]*I.g*g.g*P.g),B=Math.floor(w*n[2]*I.b*g.b*P.b);R=w<<24|U<<16|O<<8|B}else{w=Math.floor(I.a*g.a*P.a*255);const U=Math.floor(w*I.r*g.r*P.r),O=Math.floor(w*I.g*g.g*P.g),B=Math.floor(w*I.b*g.b*P.b);R=w<<24|U<<16|O<<8|B}if(v=4278190080,A.darkColor){const{r:U,g:O,b:B}=A.darkColor;v=4278190080|Math.floor(U*w)<<16|Math.floor(O*w)<<8|Math.floor(B*w)}}else{if(n){const w=Math.floor(n[3]*I.a*g.a*P.a*255),U=Math.floor(n[0]*I.r*g.r*P.r*255),O=Math.floor(n[1]*I.g*g.g*P.g*255),B=Math.floor(n[2]*I.b*g.b*P.b*255);R=w<<24|U<<16|O<<8|B}else{const w=Math.floor(I.a*g.a*P.a*255),U=Math.floor(I.r*g.r*P.r*255),O=Math.floor(I.g*g.g*P.g*255),B=Math.floor(I.b*g.b*P.b*255);R=w<<24|U<<16|O<<8|B}if(v=0,A.darkColor){const{r:w,g:U,b:O}=A.darkColor;v=Math.floor(w*255)<<16|Math.floor(U*255)<<8|Math.floor(O*255)}}o.isClipping()&&(o.clipTrianglesUnpacked(L,0,x,S,f,s),L=o.clippedVerticesTyped,C=o.clippedVerticesLength/s,f=o.clippedUVsTyped,x=o.clippedTrianglesTyped,S=o.clippedTrianglesLength);const V=this.commandPool.getCommand(C,S,s);if(V.blendMode=y.data.blendMode,V.texture=M,V.positions.set(L.subarray(0,C*s)),s>=3)for(let w=2,U=C*s;w<U;w+=s)V.positions[w]=r;V.uvs.set(f.subarray(0,C<<1));for(let w=0;w<C;w++)V.colors[w]=R,V.darkColors[w]=v;x instanceof Uint16Array?V.indices.set(x.subarray(0,S)):V.indices.set(x.slice(0,S)),this.renderCommands.push(V),r+=i,o.clipEnd(y)}return o.clipEnd(),this.batchCommands(s)}batchSubCommands(t,e,n,s,i,o){const r=t[e],l=this.commandPool.getCommand(s,i,o);l.blendMode=r.blendMode,l.texture=r.texture;let c=0,a=0,h=0,m=0,y=0;for(let A=e;A<=n;A++){const u=t[A];l.positions.set(u.positions,c),c+=u.numVertices*o,l.uvs.set(u.uvs,a),a+=u.numVertices<<1,l.colors.set(u.colors,h),l.darkColors.set(u.darkColors,h),h+=u.numVertices;for(let g=0;g<u.numIndices;g++)l.indices[m+g]=u.indices[g]+y;m+=u.numIndices,y+=u.numVertices}return l}batchCommands(t){if(this.renderCommands.length===0)return;let e,n,s=this.renderCommands[0],i=0,o=1,r=s.numVertices,l=s.numIndices;for(;o<=this.renderCommands.length;){const c=o<this.renderCommands.length?this.renderCommands[o]:null;if(c&&c.numVertices===0&&c.numIndices===0){o++;continue}if(c!==null&&c.texture===s.texture&&c.blendMode===s.blendMode&&c.colors[0]===s.colors[0]&&c.darkColors[0]===s.darkColors[0]&&l+c.numIndices<65535)r+=c.numVertices,l+=c.numIndices;else{const h=this.batchSubCommands(this.renderCommands,i,o-1,r,l,t);if(n?(n.next=h,n=h):e=n=h,o===this.renderCommands.length)break;s=this.renderCommands[o],i=o,r=s.numVertices,l=s.numIndices}o++}return e}}class xt{constructor(){T(this,"pool",[]);T(this,"inUse",[])}getCommand(t,e,n){let s;for(const i of this.pool)if(i._positions.length>=t*n&&i._indices.length>=e){s=i;break}if(s)this.pool.splice(this.pool.indexOf(s),1),s.next=void 0,s.numVertices=t,s.numIndices=e,s.positions=s._positions.subarray(0,t*n),s.uvs=s._uvs.subarray(0,t<<1),s.colors=s._colors.subarray(0,t),s.darkColors=s._darkColors.subarray(0,t),s.indices=s._indices.subarray(0,e);else{const i=new Float32Array(t*n),o=new Float32Array(t<<1),r=new Uint32Array(t),l=new Uint32Array(t),c=new Uint16Array(e);s={positions:i,uvs:o,colors:r,darkColors:l,indices:c,_positions:i,_uvs:o,_colors:r,_darkColors:l,_indices:c,numVertices:t,numIndices:e,blendMode:Tt.Normal,texture:null}}return this.inUse.push(s),s}reset(){this.pool.push(...this.inUse),this.inUse.length=0}}export{Rt as ATTACH_RETAIN,Yt as ATTACH_SETUP,Ft as AlphaTimeline,Et as Animation,_t as AnimationState,Ot as AnimationStateAdapter,It as AnimationStateData,lt as AssetCache,Ct as AssetManagerBase,Vt as AtlasAttachmentLoader,kt as Attachment,Xt as AttachmentTimeline,Bt as BinaryInput,Tt as BlendMode,Nt as Bone,Dt as BoneData,$t as BonePose,zt as BoneTimeline1,Wt as BoneTimeline2,ut as BoundingBoxAttachment,qt as CURRENT,rt as ClippingAttachment,Gt as Color,Jt as Constraint,Ht as ConstraintData,Zt as ConstraintTimeline1,Kt as CurveTimeline,Qt as CurveTimeline1,jt as DebugUtils,te as DeformTimeline,bt as Downloader,ee as DrawOrder,se as DrawOrderFolderTimeline,ne as DrawOrderTimeline,ie as Event,oe as EventData,re as EventQueue,ae as EventTimeline,le as EventType,ce as FIRST,he as FakeTexture,pe as FromProperty,de as FromRotate,ue as FromScaleX,fe as FromScaleY,ge as FromShearY,me as FromX,ye as FromY,Te as HOLD,be as IkConstraint,we as IkConstraintData,xe as IkConstraintPose,Ae as IkConstraintTimeline,Pe as Inherit,Ie as InheritTimeline,Ce as IntSet,Ve as Interpolation,Le as MODE,Se as MathUtils,dt as MeshAttachment,Me as MixFrom,mt as PathAttachment,ve as PathConstraint,Ue as PathConstraintData,Re as PathConstraintMixTimeline,Ye as PathConstraintPose,Fe as PathConstraintPositionTimeline,Ee as PathConstraintSpacingTimeline,_e as Physics,Oe as PhysicsConstraint,ke as PhysicsConstraintDampingTimeline,Xe as PhysicsConstraintData,Be as PhysicsConstraintGravityTimeline,Ne as PhysicsConstraintInertiaTimeline,De as PhysicsConstraintMassTimeline,$e as PhysicsConstraintMixTimeline,ze as PhysicsConstraintPose,We as PhysicsConstraintResetTimeline,qe as PhysicsConstraintStrengthTimeline,Ge as PhysicsConstraintTimeline,Je as PhysicsConstraintWindTimeline,yt as PointAttachment,at as Pool,He as Posed,Ze as PosedActive,Ke as PosedData,Qe as PositionMode,je as Pow,ts as PowOut,es as Property,ss as RGB2Timeline,ns as RGBA2Timeline,is as RGBATimeline,os as RGBTimeline,pt as RegionAttachment,rs as RotateMode,as as RotateTimeline,ls as SETUP,cs as ScaleTimeline,hs as ScaleXTimeline,ps as ScaleYMode,ds as ScaleYTimeline,us as Sequence,fs as SequenceMode,gs as SequenceModeValues,ms as SequenceTimeline,ys as ShearTimeline,Ts as ShearXTimeline,bs as ShearYTimeline,ws as Skeleton,xs as SkeletonBinary,Lt as SkeletonBounds,wt as SkeletonClipping,As as SkeletonData,Ps as SkeletonJson,St as SkeletonPhysicsMovement,Mt as SkeletonRendererCore,Is as Skin,Cs as SkinEntry,Vs as Slider,Ls as SliderData,Ss as SliderMixTimeline,Ms as SliderPose,vs as SliderTimeline,Us as Slot,Rs as SlotCurveTimeline,Ys as SlotData,Fs as SlotPose,Es as SpacingMode,_s as StringSet,Os as Texture,ht as TextureAtlas,ks as TextureAtlasPage,Xs as TextureAtlasRegion,Bs as TextureFilter,Ns as TextureRegion,Ds as TextureWrap,$s as TimeKeeper,zs as Timeline,Ws as ToProperty,qs as ToRotate,Gs as ToScaleX,Js as ToScaleY,Hs as ToShearY,Zs as ToX,Ks as ToY,Qs as TrackEntry,js as TransformConstraint,tn as TransformConstraintData,en as TransformConstraintPose,sn as TransformConstraintTimeline,nn as TranslateTimeline,on as TranslateXTimeline,rn as TranslateYTimeline,z as Triangulator,D as Utils,an as Vector2,ln as VertexAttachment,cn as WindowedMean,hn as isBoneTimeline,pn as isConstraintTimeline,dn as isSlotTimeline};
|