1097 lines
651 KiB
JavaScript
1097 lines
651 KiB
JavaScript
|
|
(function(){var Zt='<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg>',xt='<svg aria-hidden="true" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true"><path fill-rule="evenodd" fill="rgb(63, 185, 80)" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg>';document.addEventListener("nav",()=>{let Bt=document.getElementsByTagName("pre");for(let Et=0;Et<Bt.length;Et++){let Ct=Bt[Et].getElementsByTagName("code")[0];if(Ct){let _=function(){navigator.clipboard.writeText(nr).then(()=>{Ft.blur(),Ft.innerHTML=xt,setTimeout(()=>{Ft.innerHTML=Zt,Ft.style.borderColor=""},2e3)},Lr=>console.error(Lr))};var bt=_;let nr=(Ct.dataset.clipboard?JSON.parse(Ct.dataset.clipboard):Ct.innerText).replace(/\n\n/g,`
|
||
|
|
`),Ft=document.createElement("button");Ft.className="clipboard-button",Ft.type="button",Ft.innerHTML=Zt,Ft.ariaLabel="Copy source",Ft.addEventListener("click",_),window.addCleanup(()=>Ft.removeEventListener("click",_)),Bt[Et].prepend(Ft)}}})})(),function(){var Zt=Object.create,xt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyNames,Et=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,_=(g,b)=>()=>(b||g((b={exports:{}}).exports,b),b.exports),nr=(g,b,S,p)=>{if(b&&typeof b=="object"||typeof b=="function")for(let m of bt(b))!Ct.call(g,m)&&m!==S&&xt(g,m,{get:()=>b[m],enumerable:!(p=Bt(b,m))||p.enumerable});return g},Ft=(g,b,S)=>(S=g!=null?Zt(Et(g)):{},nr(b||!g||!g.__esModule?xt(S,"default",{value:g,enumerable:!0}):S,g)),Lr=_(()=>{}),Qt=_((g,b)=>{"use strict";b.exports=p;function S(T){return T instanceof Buffer?Buffer.from(T):new T.constructor(T.buffer.slice(),T.byteOffset,T.length)}function p(T){if(T=T||{},T.circles)return m(T);let E=new Map;if(E.set(Date,W=>new Date(W)),E.set(Map,(W,q)=>new Map(M(Array.from(W),q))),E.set(Set,(W,q)=>new Set(M(Array.from(W),q))),T.constructorHandlers)for(let W of T.constructorHandlers)E.set(W[0],W[1]);let C=null;return T.proto?j:F;function M(W,q){let z=Object.keys(W),I=new Array(z.length);for(let Q=0;Q<z.length;Q++){let V=z[Q],re=W[V];typeof re!="object"||re===null?I[V]=re:re.constructor!==Object&&(C=E.get(re.constructor))?I[V]=C(re,q):ArrayBuffer.isView(re)?I[V]=S(re):I[V]=q(re)}return I}function F(W){if(typeof W!="object"||W===null)return W;if(Array.isArray(W))return M(W,F);if(W.constructor!==Object&&(C=E.get(W.constructor)))return C(W,F);let q={};for(let z in W){if(Object.hasOwnProperty.call(W,z)===!1)continue;let I=W[z];typeof I!="object"||I===null?q[z]=I:I.constructor!==Object&&(C=E.get(I.constructor))?q[z]=C(I,F):ArrayBuffer.isView(I)?q[z]=S(I):q[z]=F(I)}return q}function j(W){if(typeof W!="object"||W===null)return W;if(Array.isArray(W))return M(W,j);if(W.constructor!==Object&&(C=E.get(W.constructor)))return C(W,j);let q={};for(let z in W){let I=W[z];typeof I!="object"||I===null?q[z]=I:I.constructor!==Object&&(C=E.get(I.constructor))?q[z]=C(I,j):ArrayBuffer.isView(I)?q[z]=S(I):q[z]=j(I)}return q}}function m(T){let E=[],C=[],M=new Map;if(M.set(Date,z=>new Date(z)),M.set(Map,(z,I)=>new Map(j(Array.from(z),I))),M.set(Set,(z,I)=>new Set(j(Array.from(z),I))),T.constructorHandlers)for(let z of T.constructorHandlers)M.set(z[0],z[1]);let F=null;return T.proto?q:W;function j(z,I){let Q=Object.keys(z),V=new Array(Q.length);for(let re=0;re<Q.length;re++){let he=Q[re],oe=z[he];if(typeof oe!="object"||oe===null)V[he]=oe;else if(oe.constructor!==Object&&(F=M.get(oe.constructor)))V[he]=F(oe,I);else if(ArrayBuffer.isView(oe))V[he]=S(oe);else{let Re=E.indexOf(oe);Re!==-1?V[he]=C[Re]:V[he]=I(oe)}}return V}function W(z){if(typeof z!="object"||z===null)return z;if(Array.isArray(z))return j(z,W);if(z.constructor!==Object&&(F=M.get(z.constructor)))return F(z,W);let I={};E.push(z),C.push(I);for(let Q in z){if(Object.hasOwnProperty.call(z,Q)===!1)continue;let V=z[Q];if(typeof V!="object"||V===null)I[Q]=V;else if(V.constructor!==Object&&(F=M.get(V.constructor)))I[Q]=F(V,W);else if(ArrayBuffer.isView(V))I[Q]=S(V);else{let re=E.indexOf(V);re!==-1?I[Q]=C[re]:I[Q]=W(V)}}return E.pop(),C.pop(),I}function q(z){if(typeof z!="object"||z===null)return z;if(Array.isArray(z))return j(z,q);if(z.constructor!==Object&&(F=M.get(z.constructor)))return F(z,q);let I={};E.push(z),C.push(I);for(let Q in z){let V=z[Q];if(typeof V!="object"||V===null)I[Q]=V;else if(V.constructor!==Object&&(F=M.get(V.constructor)))I[Q]=F(V,q);else if(ArrayBuffer.isView(V))I[Q]=S(V);else{let re=E.indexOf(V);re!==-1?I[Q]=C[re]:I[Q]=q(V)}}return E.pop(),C.pop(),I}}}),O;function sr(g){return typeof g<"u"?g:!0}function Nt(g){let b=Array(g);for(let S=0;S<g;S++)b[S]=xe();return b}function xe(){return Object.create(null)}function J(g,b){return b.length-g.length}function At(g){return typeof g=="string"}function Yt(g){return typeof g=="object"}function at(g){return typeof g=="function"}function It(g,b){var S=Mr;if(g&&(b
|
||
|
|
<h3 class="card-title">${Se}</h3>
|
||
|
|
${Ot}
|
||
|
|
<p class="card-description">${et}</p>
|
||
|
|
`,Ht.addEventListener("click",Gt=>{Gt.altKey||Gt.ctrlKey||Gt.metaKey||Gt.shiftKey||I()});let hr=Gt=>{Gt.altKey||Gt.ctrlKey||Gt.metaKey||Gt.shiftKey||I()};async function vr(Gt){if(!Gt.target)return;let qr=Gt.target;await Be(qr)}return Ht.addEventListener("mouseenter",vr),window.addCleanup(()=>Ht.removeEventListener("mouseenter",vr)),Ht.addEventListener("click",hr),window.addCleanup(()=>Ht.removeEventListener("click",hr)),Ht};async function Xe(Ge){if(jt(z),Ge.length===0?z.innerHTML=`<a class="result-card no-match">
|
||
|
|
<h3>No results.</h3>
|
||
|
|
<p>Try another search term?</p>
|
||
|
|
</a>`:z.append(...Ge.map(Je)),Ge.length===0&&W)jt(W);else{let Se=z.firstElementChild;Se.classList.add("focus"),V=Se,await Be(Se)}}async function Rt(Ge){if(Ni.has(Ge))return Ni.get(Ge);let Se=Re(Ge).toString(),et=await fetch(Se).then(pt=>pt.text()).then(pt=>{if(pt===void 0)throw new Error(`Could not fetch ${Se}`);let Ot=cn.parseFromString(pt??"","text/html");return Ti(Ot,Se),[...Ot.getElementsByClassName("popover-hint")]});return Ni.set(Ge,et),et}async function Be(Ge){if(!C||!j||!Ge||!W)return;let Se=Ge.id,et=await Rt(Se).then(pt=>pt.flatMap(Ot=>[...fn(ir,Ot).children]));q=document.createElement("div"),q.classList.add("preview-inner"),q.append(...et),W.replaceChildren(q),[...W.getElementsByClassName("highlight")].sort((pt,Ot)=>Ot.innerHTML.length-pt.innerHTML.length)[0]?.scrollIntoView({block:"start"})}async function _r(Ge){if(!C||!di)return;ir=Ge.target.value,C.classList.toggle("display-results",ir!==""),Sr=ir.startsWith("#")?"tags":"basic";let Se;if(Sr==="tags"){ir=ir.substring(1).trim();let Ot=ir.indexOf(" ");if(Ot!=-1){let Ht=ir.substring(0,Ot),hr=ir.substring(Ot+1).trim();Se=await di.searchAsync({query:hr,limit:Math.max(fi,1e4),index:["title","content"],tag:Ht});for(let vr of Se)vr.result=vr.result.slice(0,fi);Sr="basic",ir=hr}else Se=await di.searchAsync({query:ir,limit:fi,index:["tags"]})}else Sr==="basic"&&(Se=await di.searchAsync({query:ir,limit:fi,index:["title","content"]}));let et=Ot=>{let Ht=Se.filter(hr=>hr.field===Ot);return Ht.length===0?[]:[...Ht[0].result]},pt=[...new Set([...et("title"),...et("content"),...et("tags")])].map(Ot=>he(ir,Ot));await Xe(pt)}document.addEventListener("keydown",re),window.addCleanup(()=>document.removeEventListener("keydown",re)),T.addEventListener("click",()=>Q("basic")),window.addCleanup(()=>T.removeEventListener("click",()=>Q("basic"))),E.addEventListener("input",_r),window.addCleanup(()=>E.removeEventListener("input",_r)),wi(p,I),await jn(S)}var zi=!1;async function jn(g){if(zi)return;let b=0,S=[];for(let[p,m]of Object.entries(g))S.push(di.addAsync(b++,{id:b,slug:p,title:m.title,content:m.content,tags:m.tags}));await Promise.all(S),zi=!0}document.addEventListener("nav",async g=>{let b=g.detail.url,S=await fetchData,p=document.getElementsByClassName("search");for(let m of p)await Vn(m,b,S)})}(),function(){var Zt=Object.create,xt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyNames,Et=Object.getPrototypeOf,Ct=Object.prototype.hasOwnProperty,_=(ge,Z)=>()=>(Z||ge((Z={exports:{}}).exports,Z),Z.exports),nr=(ge,Z,pe,Ne)=>{if(Z&&typeof Z=="object"||typeof Z=="function")for(let Ve of bt(Z))!Ct.call(ge,Ve)&&Ve!==pe&&xt(ge,Ve,{get:()=>Z[Ve],enumerable:!(Ne=Bt(Z,Ve))||Ne.enumerable});return ge},Ft=(ge,Z,pe)=>(pe=ge!=null?Zt(Et(ge)):{},nr(Z||!ge||!ge.__esModule?xt(pe,"default",{value:ge,enumerable:!0}):pe,ge)),Lr=_((ge,Z)=>{"use strict";Z.exports=Ne;function pe(rt){return rt instanceof Buffer?Buffer.from(rt):new rt.constructor(rt.buffer.slice(),rt.byteOffset,rt.length)}function Ne(rt){if(rt=rt||{},rt.circles)return Ve(rt);let $e=new Map;if($e.set(Date,Ae=>new Date(Ae)),$e.set(Map,(Ae,Le)=>new Map(Tt(Array.from(Ae),Le))),$e.set(Set,(Ae,Le)=>new Set(Tt(Array.from(Ae),Le))),rt.constructorHandlers)for(let Ae of rt.constructorHandlers)$e.set(Ae[0],Ae[1]);let ht=null;return rt.proto?ut:St;function Tt(Ae,Le){let be=Object.keys(Ae),Te=new Array(be.length);for(let je=0;je<be.length;je++){let ve=be[je],Ke=Ae[ve];typeof Ke!="object"||Ke===null?Te[ve]=Ke:Ke.constructor!==Object&&(ht=$e.get(Ke.constructor))?Te[ve]=ht(Ke,Le):ArrayBuffer.isView(Ke)?Te[ve]=pe(Ke):Te[ve]=Le(Ke)}return Te}function St(Ae){if(typeof Ae!="object"||Ae===null)return Ae;if(Array.isArray(Ae))return Tt(Ae,St);if(Ae.constructor!==Object&&(ht=$e.get(Ae.constructor)))return ht(Ae,St);let Le={};for(let be in Ae){if(Object.hasOwnProperty.call(Ae,be)===!1)continue;let Te=Ae[be];typeof Te!="object"||Te===null?Le[be]=Te:Te.constructor!==Object&&(ht=$e.get(Te.constructor))?Le[be]=ht(Te,St):ArrayBuffer.isView(Te)?Le[be]=pe(Te):Le[be]=St(Te)}return Le}function ut(Ae){if(typeof Ae!="object"||Ae===nul
|
||
|
|
Deprecated since v${t}`):(i=i.split(`
|
||
|
|
`).splice(r).join(`
|
||
|
|
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${e}
|
||
|
|
Deprecated since v${t}`),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${e}
|
||
|
|
Deprecated since v${t}`),console.warn(i))),Fi[e]=!0}var Fi,ot,Di,kt=_(()=>{"use strict";Fi={},ot="8.0.0",Di="8.3.4"}),Ti,ln=_(()=>{"use strict";Ti=class{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e<t;e++)this._pool[this._index++]=new this._classType;this._count+=t}get(t){let e;return this._index>0?e=this._pool[--this._index]:e=new this._classType,e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){this._pool.length=0,this._index=0}}}),hn,it,Kt=_(()=>{ln(),hn=class{constructor(){this._poolsByClass=new Map}prepopulate(t,e){this.getPool(t).prepopulate(e)}get(t,e){return this.getPool(t).get(e)}return(t){this.getPool(t.constructor).return(t)}getPool(t){return this._poolsByClass.has(t)||this._poolsByClass.set(t,new Ti(t)),this._poolsByClass.get(t)}stats(){let t={};return this._poolsByClass.forEach(e=>{let r=t[e._classType.name]?e._classType.name+e._classType.ID:e._classType.name;t[r]={free:e.totalFree,used:e.totalUsed,size:e.totalSize}}),t}},it=new hn}),Ui,Li=_(()=>{kt(),Ui={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){typeof t=="boolean"&&t===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(t===!0?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){Qe("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}}});function Sr(t,e,r){let i=t.length,n;if(e>=i||r===0)return;r=e+r>i?i-e:r;let s=i-r;for(n=e;n<s;++n)t[n]=t[n+r];t.length=s}var ir=_(()=>{"use strict"}),un,di=_(()=>{ir(),kt(),un={allowChildren:!0,removeChildren(t=0,e){let r=e??this.children.length,i=r-t,n=[];if(i>0&&i<=r){for(let a=r-1;a>=t;a--){let o=this.children[a];o&&(n.push(o),o.parent=null)}Sr(this.children,t,r);let s=this.renderGroup||this.parentRenderGroup;s&&s.removeChildren(n);for(let a=0;a<n.length;++a){let o=n[a];o.parentRenderLayer?.detach(o),this.emit("childRemoved",o,this,a),n[a].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}else if(i===0&&this.children.length===0)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){let e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){let e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||Qe(ot,"addChildAt: Only Containers will be allowed to add children in v8.0.0");let{children:r}=this;if(e<0||e>r.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${r.length}`);if(t.parent){let n=t.parent.children.indexOf(t);if(t.parent===this&&n===e)return t;n!==-1&&t.parent.children.splice(n,1)}e===r.length?r.push(t):r.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;let i=this.renderGroup||this.parentRenderGroup;return i&&i.addChild(t),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",t,this,e),t.emit("added",this),t},swapChildren(t,e){if(t===e)return;let r=this.getChildIndex(t),i=this.getChildIndex(e);this.children[r]=e,this.children[i]=t;let n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...t){return t.length===1?this.reparentChildAt(t[0],this.children.length):(t.forEach(e=>this.reparentChildAt(e,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;let r=t.worldTransform.clone()
|
||
|
|
color: transparent;
|
||
|
|
pointer-events: none;
|
||
|
|
padding: 0;
|
||
|
|
margin: 0;
|
||
|
|
border: 0;
|
||
|
|
outline: 0;
|
||
|
|
background: transparent;
|
||
|
|
box-sizing: border-box;
|
||
|
|
user-select: none;
|
||
|
|
-webkit-user-select: none;
|
||
|
|
-moz-user-select: none;
|
||
|
|
-ms-user-select: none;
|
||
|
|
`,e.accessibleText&&(r.innerText=e.accessibleText)),r.style.width=`${Yn}px`,r.style.height=`${Yn}px`,r.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",r.style.position="absolute",r.style.zIndex=dl.toString(),r.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?r.setAttribute("aria-live","off"):r.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?r.setAttribute("aria-relevant","additions"):r.setAttribute("aria-relevant","text"),r.addEventListener("click",this._onClick.bind(this)),r.addEventListener("focus",this._onFocus.bind(this)),r.addEventListener("focusout",this._onFocusOut.bind(this))),r.style.pointerEvents=e.accessiblePointerEvents,r.type=e.accessibleType,e.accessibleTitle&&e.accessibleTitle!==null?r.title=e.accessibleTitle:(!e.accessibleHint||e.accessibleHint===null)&&(r.title=`container ${e.tabIndex}`),e.accessibleHint&&e.accessibleHint!==null&&r.setAttribute("aria-label",e.accessibleHint),this.debug&&this._updateDebugHTML(r),e._accessibleActive=!0,e._accessibleDiv=r,r.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv),e.interactive&&(e._accessibleDiv.tabIndex=e.tabIndex)}_dispatchEvent(e,r){let{container:i}=e.target,n=this._renderer.events.rootBoundary,s=Object.assign(new Js(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,r.forEach(a=>n.dispatchEvent(s,a))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){e.keyCode!==ud||!this._activateOnTab||this._activate()}_onMouseMove(e){e.movementX===0&&e.movementY===0||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._div=null,this._pool=null,this._children=null,this._renderer=null,this._activateOnTab&&globalThis.removeEventListener("keydown",this._onKeyDown)}setAccessibilityEnabled(e){e?this._activate():this._deactivate()}},ra.extension={type:[O.WebGLSystem,O.WebGPUSystem],name:"accessibility"},ra.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0},md=ra}),_d,Uy=_(()=>{"use strict";_d={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,_accessibleActive:!1,_accessibleDiv:null,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_renderId:-1}}),Ly=_(()=>{J(),Zr(),Dy(),Uy(),xe.add(md),xe.mixin(dr,_d)}),pl,Ny=_(()=>{J(),pl=class{static init(t){Object.defineProperty(this,"resizeTo",{set(e){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,r;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,r=globalThis.innerHeight;else{let{clientWidth:i,clientHeight:n}=this._resizeTo;e=i,r=n}this.renderer.resize(e,r),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}},pl.extension=O.Application}),mn,gl=_(()=>{"use strict";mn=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(mn||{})}),ia,Hy=_(()=>{"use strict";ia=class{constructor(t,e=null,r=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=r,this._once=i}match(t,e=null){return this._fn===t&&this._context===e}emit(t){this._fn&&(this._context
|
||
|
|
else `),r<t-1&&(e+=`if(test == ${r}.0){}`);return e}function mx(t,e){if(t===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");let r=e.createShader(e.FRAGMENT_SHADER);try{for(;;){let i=Qd.replace(/%forloop%/gi,gx(t));if(e.shaderSource(r,i),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))t=t/2|0;else break}}finally{e.deleteShader(r)}return t}var Qd,_x=_(()=>{"use strict";Qd=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
||
|
|
`)});function xn(){if(Yi)return Yi;let t=Kd();return Yi=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),Yi=mx(Yi,t),t.getExtension("WEBGL_lose_context")?.loseContext(),Yi}var Yi,bn=_(()=>{Zd(),_x(),Yi=null});function Fl(t,e){let r=2166136261;for(let i=0;i<e;i++)r^=t[i].uid,r=Math.imul(r,16777619),r>>>=0;return Dl[r]||vx(t,e,r)}function vx(t,e,r){let i={},n=0;ca||(ca=xn());for(let a=0;a<ca;a++){let o=a<e?t[a]:Fe.EMPTY.source;i[n++]=o.source,i[n++]=o.style}let s=new ei(i);return Dl[r]=s,s}var Dl,ca,Ul=_(()=>{Xi(),Dt(),bn(),Dl={},ca=0}),qi,Jd=_(()=>{"use strict";qi=class{constructor(t){typeof t=="number"?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||(this._int8View=new Int8Array(this.rawBinaryData)),this._int8View}get uint8View(){return this._uint8View||(this._uint8View=new Uint8Array(this.rawBinaryData)),this._uint8View}get int16View(){return this._int16View||(this._int16View=new Int16Array(this.rawBinaryData)),this._int16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}get float64View(){return this._float64Array||(this._float64Array=new Float64Array(this.rawBinaryData)),this._float64Array}get bigUint64View(){return this._bigUint64Array||(this._bigUint64Array=new BigUint64Array(this.rawBinaryData)),this._bigUint64Array}view(t){return this[`${t}View`]}destroy(){this.rawBinaryData=null,this._int8View=null,this._uint8View=null,this._int16View=null,this.uint16View=null,this._int32View=null,this.uint32View=null,this.float32View=null}static sizeOf(t){switch(t){case"int8":case"uint8":return 1;case"int16":case"uint16":return 2;case"int32":case"uint32":case"float32":return 4;default:throw new Error(`${t} isn't a valid view type`)}}}});function Ll(t,e){let r=t.byteLength/8|0,i=new Float64Array(t,0,r);new Float64Array(e,0,r).set(i);let n=t.byteLength-r*8;if(n>0){let s=new Uint8Array(t,r*8,n);new Uint8Array(e,r*8,n).set(s)}}var ef=_(()=>{"use strict"}),tf,Wt,wn=_(()=>{"use strict";tf={normal:"normal-npm",add:"add-npm",screen:"screen-npm"},Wt=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(Wt||{})});function Jn(t,e){return e.alphaMode==="no-premultiply-alpha"&&tf[t]||t}var da=_(()=>{wn()}),rf,yx=_(()=>{"use strict";rf=class{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let t=0;t<this.count;t++){let e=this.textures[t];this.textures[t]=null,this.ids[e.uid]=null}this.count=0}}});function nf(){return fa>0?Nl[--fa]:new af}function sf(t){Nl[fa++]=t}var af,Nl,fa,Tn,Hl,of,xx=_(()=>{jt(),Jd(),ef(),da(),bn(),yx(),af=class{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new rf,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}},Nl=[],fa=0,Tn=0,Hl=class Vo{constructor(e={}){this.uid=Mt("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],Vo.defaultOptions.maxTextures=Vo.defaultOptions.maxTextures??xn(),e={...Vo.defaultOptions,...e};let{maxTextures:r,attributesInitialSize:i,indicesInitialSize:n}=e;this.attributeBuffer=new qi(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=r}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)sf(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,r){let i=
|
||
|
|
|
||
|
|
#ifdef GL_ES // This checks if it is WebGL1
|
||
|
|
#define in varying
|
||
|
|
#define finalColor gl_FragColor
|
||
|
|
#define texture texture2D
|
||
|
|
#endif
|
||
|
|
${t}
|
||
|
|
`):`
|
||
|
|
|
||
|
|
#ifdef GL_ES // This checks if it is WebGL1
|
||
|
|
#define in attribute
|
||
|
|
#define out varying
|
||
|
|
#endif
|
||
|
|
${t}
|
||
|
|
`}var Mx=_(()=>{"use strict"});function Rx(t,e,r){let i=r?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if(t.substring(0,9)!=="precision"){let n=r?e.requestedFragmentPrecision:e.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float;
|
||
|
|
${t}`}else if(i!=="highp"&&t.substring(0,15)==="precision highp")return t.replace("precision highp","precision mediump");return t}var kx=_(()=>{"use strict"});function Bx(t,e){return e?`#version 300 es
|
||
|
|
${t}`:t}var Ix=_(()=>{"use strict"});function Ox(t,{name:e="pixi-program"},r=!0){e=e.replace(/\s+/g,"-"),e+=r?"-fragment":"-vertex";let i=r?df:ff;return i[e]?(i[e]++,e+=`-${i[e]}`):i[e]=1,t.indexOf("#define SHADER_NAME")!==-1?t:`${`#define SHADER_NAME ${e}`}
|
||
|
|
${t}`}var df,ff,Gx=_(()=>{"use strict";df={},ff={}});function Fx(t,e){return e?t.replace("#version 300 es",""):t}var Dx=_(()=>{"use strict"}),_a,va,Vl,Zi,En=_(()=>{ga(),Ax(),Mx(),kx(),Ix(),Gx(),Dx(),_a={stripVersion:Fx,ensurePrecision:Rx,addProgramDefines:Px,setProgramName:Ox,insertVersion:Bx},va=Object.create(null),Vl=class zc{constructor(e){e={...zc.defaultOptions,...e};let r=e.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:r,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Cx()},setProgramName:{name:e.name},addProgramDefines:r,insertVersion:r},n=e.fragment,s=e.vertex;Object.keys(_a).forEach(a=>{let o=i[a];n=_a[a](n,o,!0),s=_a[a](s,o,!1)}),this.fragment=n,this.vertex=s,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=ts(`${this.vertex}:${this.fragment}`,"gl-program")}destroy(){this.fragment=null,this.vertex=null,this._attributeData=null,this._uniformData=null,this._uniformBlockData=null,this.transformFeedbackVaryings=null}static from(e){let r=`${e.vertex}:${e.fragment}`;return va[r]||(va[r]=new zc(e)),va[r]}},Vl.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"},Zi=Vl});function Ri(t){return jl[t]??jl.float32}var jl,Cn=_(()=>{"use strict";jl={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}}});function Ux({source:t,entryPoint:e}){let r={},i=t.indexOf(`fn ${e}`);if(i!==-1){let n=t.indexOf("->",i);if(n!==-1){let s=t.substring(i,n),a=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g,o;for(;(o=a.exec(s))!==null;){let l=pf[o[3]]??"float32";r[o[2]]={location:parseInt(o[1],10),format:l,stride:Ri(l).stride,offset:0,instance:!1,start:0}}}}return r}var pf,Lx=_(()=>{Cn(),pf={f32:"float32","vec2<f32>":"float32x2","vec3<f32>":"float32x3","vec4<f32>":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2<i32>":"sint32x2","vec3<i32>":"sint32x3","vec4<i32>":"sint32x4",u32:"uint32","vec2<u32>":"uint32x2","vec3<u32>":"uint32x3","vec4<u32>":"uint32x4",bool:"uint32","vec2<bool>":"uint32x2","vec3<bool>":"uint32x3","vec4<bool>":"uint32x4"}});function Wl(t){let e=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,r=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,n=/var(<[^>]+>)? (\w+)/,s=/:\s*(\w+)/,a=/struct\s+(\w+)\s*{([^}]+)}/g,o=/(\w+)\s*:\s*([\w\<\>]+)/g,l=/struct\s+(\w+)/,h=t.match(e)?.map(c=>({group:parseInt(c.match(r)[1],10),binding:parseInt(c.match(i)[1],10),name:c.match(n)[2],isUniform:c.match(n)[1]==="<uniform>",type:c.match(s)[1]}));if(!h)return{groups:[],structs:[]};let u=t.match(a)?.map(c=>{let f=c.match(l)[1],d=c.match(o).reduce((y,x)=>{let[v,w]=x.split(":");return y[v.trim()]=w.trim(),y},{});return d?{name:f,members:d}:null}).filter(({name:c})=>h.some(f=>f.type===c))??[];return{groups:h,structs:u}}var Nx=_(()=>{"use stric
|
||
|
|
`),a=e.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",`
|
||
|
|
${s}
|
||
|
|
`),a}var Kx=_(()=>{"use strict"});function xf(t,e){let r,i=/@out\s+([^;]+);/g;for(;(r=i.exec(t))!==null;)e.push(r[1])}function Zx(t){let e=/\b(\w+)\s*:/g.exec(t);return e?e[1]:""}function Qx(t){let e=/@.*?\s+/g;return t.replace(e,"")}function Jx(t,e){let r=[];xf(e,r),t.forEach(l=>{l.header&&xf(l.header,r)});let i=0,n=r.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`,
|
||
|
|
`),s=r.sort().map(l=>` var ${Qx(l)};`).join(`
|
||
|
|
`),a=`return VSOutput(
|
||
|
|
${r.sort().map(l=>` ${Zx(l)}`).join(`,
|
||
|
|
`)});`,o=e.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",`
|
||
|
|
${n}
|
||
|
|
`),o=o.replace("{{start}}",`
|
||
|
|
${s}
|
||
|
|
`),o=o.replace("{{return}}",`
|
||
|
|
${a}
|
||
|
|
`),o}var eb=_(()=>{"use strict"});function bf(t,e){let r=t;for(let i in e){let n=e[i];n.join(`
|
||
|
|
`).length?r=r.replace(`{{${i}}}`,`//-----${i} START-----//
|
||
|
|
${n.join(`
|
||
|
|
`)}
|
||
|
|
//----${i} FINISH----//`):r=r.replace(`{{${i}}}`,"")}return r}var tb=_(()=>{"use strict"});function rb({template:t,bits:e}){let r=wf(t,e);if(ki[r])return ki[r];let{vertex:i,fragment:n}=nb(t,e);return ki[r]=Tf(i,n,e),ki[r]}function ib({template:t,bits:e}){let r=wf(t,e);return ki[r]||(ki[r]=Tf(t.vertex,t.fragment,e)),ki[r]}function nb(t,e){let r=e.map(a=>a.vertex).filter(a=>!!a),i=e.map(a=>a.fragment).filter(a=>!!a),n=yf(r,t.vertex,!0);n=Jx(r,n);let s=yf(i,t.fragment,!0);return{vertex:n,fragment:s}}function wf(t,e){return e.map(r=>(xa.has(r)||xa.set(r,Sf++),xa.get(r))).sort((r,i)=>r-i).join("-")+t.vertex+t.fragment}function Tf(t,e,r){let i=mf(t),n=mf(e);return r.forEach(s=>{gf(s.vertex,i,s.name),gf(s.fragment,n,s.name)}),{vertex:bf(t,i),fragment:bf(e,n)}}var ki,xa,Sf,sb=_(()=>{Yx(),qx(),Kx(),eb(),tb(),ki=Object.create(null),xa=new Map,Sf=0}),Ef,Cf,Af,Pf,ab=_(()=>{"use strict";Ef=`
|
||
|
|
@in aPosition: vec2<f32>;
|
||
|
|
@in aUV: vec2<f32>;
|
||
|
|
|
||
|
|
@out @builtin(position) vPosition: vec4<f32>;
|
||
|
|
@out vUV : vec2<f32>;
|
||
|
|
@out vColor : vec4<f32>;
|
||
|
|
|
||
|
|
{{header}}
|
||
|
|
|
||
|
|
struct VSOutput {
|
||
|
|
{{struct}}
|
||
|
|
};
|
||
|
|
|
||
|
|
@vertex
|
||
|
|
fn main( {{in}} ) -> VSOutput {
|
||
|
|
|
||
|
|
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
||
|
|
var modelMatrix = mat3x3<f32>(
|
||
|
|
1.0, 0.0, 0.0,
|
||
|
|
0.0, 1.0, 0.0,
|
||
|
|
0.0, 0.0, 1.0
|
||
|
|
);
|
||
|
|
var position = aPosition;
|
||
|
|
var uv = aUV;
|
||
|
|
|
||
|
|
{{start}}
|
||
|
|
|
||
|
|
vColor = vec4<f32>(1., 1., 1., 1.);
|
||
|
|
|
||
|
|
{{main}}
|
||
|
|
|
||
|
|
vUV = uv;
|
||
|
|
|
||
|
|
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
||
|
|
|
||
|
|
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
||
|
|
|
||
|
|
vColor *= globalUniforms.uWorldColorAlpha;
|
||
|
|
|
||
|
|
{{end}}
|
||
|
|
|
||
|
|
{{return}}
|
||
|
|
};
|
||
|
|
`,Cf=`
|
||
|
|
@in vUV : vec2<f32>;
|
||
|
|
@in vColor : vec4<f32>;
|
||
|
|
|
||
|
|
{{header}}
|
||
|
|
|
||
|
|
@fragment
|
||
|
|
fn main(
|
||
|
|
{{in}}
|
||
|
|
) -> @location(0) vec4<f32> {
|
||
|
|
|
||
|
|
{{start}}
|
||
|
|
|
||
|
|
var outColor:vec4<f32>;
|
||
|
|
|
||
|
|
{{main}}
|
||
|
|
|
||
|
|
var finalColor:vec4<f32> = outColor * vColor;
|
||
|
|
|
||
|
|
{{end}}
|
||
|
|
|
||
|
|
return finalColor;
|
||
|
|
};
|
||
|
|
`,Af=`
|
||
|
|
in vec2 aPosition;
|
||
|
|
in vec2 aUV;
|
||
|
|
|
||
|
|
out vec4 vColor;
|
||
|
|
out vec2 vUV;
|
||
|
|
|
||
|
|
{{header}}
|
||
|
|
|
||
|
|
void main(void){
|
||
|
|
|
||
|
|
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
||
|
|
mat3 modelMatrix = mat3(
|
||
|
|
1.0, 0.0, 0.0,
|
||
|
|
0.0, 1.0, 0.0,
|
||
|
|
0.0, 0.0, 1.0
|
||
|
|
);
|
||
|
|
vec2 position = aPosition;
|
||
|
|
vec2 uv = aUV;
|
||
|
|
|
||
|
|
{{start}}
|
||
|
|
|
||
|
|
vColor = vec4(1.);
|
||
|
|
|
||
|
|
{{main}}
|
||
|
|
|
||
|
|
vUV = uv;
|
||
|
|
|
||
|
|
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
||
|
|
|
||
|
|
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
||
|
|
|
||
|
|
vColor *= uWorldColorAlpha;
|
||
|
|
|
||
|
|
{{end}}
|
||
|
|
}
|
||
|
|
`,Pf=`
|
||
|
|
|
||
|
|
in vec4 vColor;
|
||
|
|
in vec2 vUV;
|
||
|
|
|
||
|
|
out vec4 finalColor;
|
||
|
|
|
||
|
|
{{header}}
|
||
|
|
|
||
|
|
void main(void) {
|
||
|
|
|
||
|
|
{{start}}
|
||
|
|
|
||
|
|
vec4 outColor;
|
||
|
|
|
||
|
|
{{main}}
|
||
|
|
|
||
|
|
finalColor = outColor * vColor;
|
||
|
|
|
||
|
|
{{end}}
|
||
|
|
}
|
||
|
|
`}),Mf,Rf,ob=_(()=>{"use strict";Mf={name:"global-uniforms-bit",vertex:{header:`
|
||
|
|
struct GlobalUniforms {
|
||
|
|
uProjectionMatrix:mat3x3<f32>,
|
||
|
|
uWorldTransformMatrix:mat3x3<f32>,
|
||
|
|
uWorldColorAlpha: vec4<f32>,
|
||
|
|
uResolution: vec2<f32>,
|
||
|
|
}
|
||
|
|
|
||
|
|
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
||
|
|
`}},Rf={name:"global-uniforms-bit",vertex:{header:`
|
||
|
|
uniform mat3 uProjectionMatrix;
|
||
|
|
uniform mat3 uWorldTransformMatrix;
|
||
|
|
uniform vec4 uWorldColorAlpha;
|
||
|
|
uniform vec2 uResolution;
|
||
|
|
`}}});function is({bits:t,name:e}){let r=rb({template:{fragment:Cf,vertex:Ef},bits:[Mf,...t]});return Pn.from({name:e,vertex:{source:r.vertex,entryPoint:"main"},fragment:{source:r.fragment,entryPoint:"main"}})}function ns({bits:t,name:e}){return new Zi({name:e,...ib({template:{vertex:Af,fragment:Pf},bits:[Rf,...t]})})}var Qi=_(()=>{En(),rs(),sb(),ab(),ob()}),ba,wa,Ta=_(()=>{"use strict";ba={name:"color-bit",vertex:{header:`
|
||
|
|
@in aColor: vec4<f32>;
|
||
|
|
`,main:`
|
||
|
|
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
||
|
|
`}},wa={name:"color-bit",vertex:{header:`
|
||
|
|
in vec4 aColor;
|
||
|
|
`,main:`
|
||
|
|
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
||
|
|
`}}});function lb(t){let e=[];if(t===1)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let r=0;for(let i=0;i<t;i++)e.push(`@group(1) @binding(${r++}) var textureSource${i+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${r++}) var textureSampler${i+1}: sampler;`)}return e.join(`
|
||
|
|
`)}function hb(t){let e=[];if(t===1)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let r=0;r<t;r++)r===t-1?e.push(" default:{"):e.push(` case ${r}:{`),e.push(` outColor = textureSampleGrad(textureSource${r+1}, textureSampler${r+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join(`
|
||
|
|
`)}function $l(t){return Sa[t]||(Sa[t]={name:"texture-batch-bit",vertex:{header:`
|
||
|
|
@in aTextureIdAndRound: vec2<u32>;
|
||
|
|
@out @interpolate(flat) vTextureId : u32;
|
||
|
|
`,main:`
|
||
|
|
vTextureId = aTextureIdAndRound.y;
|
||
|
|
`,end:`
|
||
|
|
if(aTextureIdAndRound.x == 1)
|
||
|
|
{
|
||
|
|
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
||
|
|
}
|
||
|
|
`},fragment:{header:`
|
||
|
|
@in @interpolate(flat) vTextureId: u32;
|
||
|
|
|
||
|
|
${lb(t)}
|
||
|
|
`,main:`
|
||
|
|
var uvDx = dpdx(vUV);
|
||
|
|
var uvDy = dpdy(vUV);
|
||
|
|
|
||
|
|
${hb(t)}
|
||
|
|
`}}),Sa[t]}function ub(t){let e=[];for(let r=0;r<t;r++)r>0&&e.push("else"),r<t-1&&e.push(`if(vTextureId < ${r}.5)`),e.push("{"),e.push(` outColor = texture(uTextures[${r}], vUV);`),e.push("}");return e.join(`
|
||
|
|
`)}function Xl(t){return Ea[t]||(Ea[t]={name:"texture-batch-bit",vertex:{header:`
|
||
|
|
in vec2 aTextureIdAndRound;
|
||
|
|
out float vTextureId;
|
||
|
|
|
||
|
|
`,main:`
|
||
|
|
vTextureId = aTextureIdAndRound.y;
|
||
|
|
`,end:`
|
||
|
|
if(aTextureIdAndRound.x == 1.)
|
||
|
|
{
|
||
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
||
|
|
}
|
||
|
|
`},fragment:{header:`
|
||
|
|
in float vTextureId;
|
||
|
|
|
||
|
|
uniform sampler2D uTextures[${t}];
|
||
|
|
|
||
|
|
`,main:`
|
||
|
|
|
||
|
|
${ub(t)}
|
||
|
|
`}}),Ea[t]}var Sa,Ea,Ca=_(()=>{"use strict";Sa={},Ea={}}),Mn,Rn,Ji=_(()=>{"use strict";Mn={name:"round-pixels-bit",vertex:{header:`
|
||
|
|
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
||
|
|
{
|
||
|
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
||
|
|
}
|
||
|
|
`}},Rn={name:"round-pixels-bit",vertex:{header:`
|
||
|
|
vec2 roundPixels(vec2 position, vec2 targetSize)
|
||
|
|
{
|
||
|
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
||
|
|
}
|
||
|
|
`}}}),Yl,kf,cb=_(()=>{"use strict";Yl=["f32","i32","vec2<f32>","vec3<f32>","vec4<f32>","mat2x2<f32>","mat3x3<f32>","mat4x4<f32>","mat3x2<f32>","mat4x2<f32>","mat2x3<f32>","mat4x3<f32>","mat2x4<f32>","mat3x4<f32>","vec2<i32>","vec3<i32>","vec4<i32>"],kf=Yl.reduce((t,e)=>(t[e]=!0,t),{})});function db(t,e){switch(t){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);case"mat2x2<f32>":return new Float32Array([1,0,0,1]);case"mat3x3<f32>":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4<f32>":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var fb=_(()=>{"use strict"}),ql,ur,xr=_(()=>{jt(),ga(),cb(),fb(),ql=class ty{constructor(e,r){this._touched=0,this.uid=Mt("uniform"),this._resourceType="uniformGroup",this._resourceId=Mt("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,r={...ty.defaultOptions,...r},this.uniformStructures=e;let i={};for(let n in e){let s=e[n];if(s.name=n,s.size=s.size??1,!kf[s.type])throw new Error(`Uniform type ${s.type} is not supported. Supported uniform types are: ${Yl.join(", ")}`);s.value??(s.value=db(s.type,s.size)),i[n]=s.value}this.uniforms=i,this._dirtyId=1,this.ubo=r.ubo,this.isStatic=r.isStatic,this._signature=ts(Object.keys(i).map(n=>`${n}-${e[n].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}},ql.defaultOptions={ubo:!1,isStatic:!1},ur=ql});function Kl(t){let e=Zl[t];if(e)return e;let r=new Int32Array(t);for(let i=0;i<t;i++)r[i]=i;return e=Zl[t]=new ur({uTextures:{value:r,type:"i32",size:t}},{isStatic:!0}),e}var Zl,Ql=_(()=>{xr(),Zl={}}),Gr,gi=_(()=>{"use strict";Gr=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(Gr||{})}),Vr,ti=_(()=>{It(),jt(),En(),Xi(),rs(),gi(),xr(),Vr=class ry extends at{constructor(e){super(),this.uid=Mt("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:r,glProgram:i,groups:n,resources:s,compatibleRenderers:a,groupMap:o}=e;this.gpuProgram=r,this.glProgram=i,a===void 0&&(a=0,r&&(a|=Gr.WEBGPU),i&&(a|=Gr.WEBGL)),this.compatibleRenderers=a;let l={};if(!s&&!n&&(s={}),s&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!r&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!r&&n&&o)for(let h in o)for(let u in o[h]){let c=o[h][u];l[c]={group:h,binding:u,name:c}}else if(r&&n&&!o){let h=r.structsAndGroups.groups;o={},h.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,l[u.name]=u})}else if(s){n={},o={},r&&r.structsAndGroups.groups.forEach(u=>{o[u.group]=o[u.group]||{},o[u.group][u.binding]=u.name,l[u.name]=u});let h=0;for(let u in s)l[u]||(n[99]||(n[99]=new ei,this._ownedBindGroups.push(n[99])),l[u]={group:99,binding:h,name:u},o[99]=o[99]||{},o[99][h]=u,h++);for(let u in s){let c=u,f=s[u];!f.source&&!f._resourceType&&(f=new ur(f));let d=l[c];d&&(n[d.group]||(n[d.group]=new ei,this._ownedBindGroups.push(n[d.group])),n[d.group].setResource(f,d.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,l)}addResource(e,r,i){var n,s;(n=this._uniformBindMap)[r]||(n[r]={}),(s=this._uniformBindMap[r])[i]||(s[i]=e),this.groups[r]||(this.groups[r]=new ei,this._ownedBindGroups.push(this.groups[r]))}_buildResourceAccessor(e,r){let i={};for(let n in r){let s=r[n];Object.defineProperty(i,s.name,{get(){return e[s.group].getResource(s.binding)},set(a){e[s.group].setResource(a,s.binding)}})}return i}destroy(e=!1){this.emit("destroy",this),e&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(r=>{r.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(e){let{gpu:r,gl:i,...n}=e,s,a;return r&&(s=Pn.from(r)),i&&(a=Zi.from(i)),new ry({gpuProgram:s,glProgram:a,...n})}}}),Bf,pb=_(()=>{Qi(),Ta(),Ca(),Ji(),Ql(),ti(),Bf=class extends Vr{constructor(t){let e=ns({name:"batch",bits:[wa
|
||
|
|
|
||
|
|
var index = 0;
|
||
|
|
|
||
|
|
for (let i = 0; i < ps.length; ++i)
|
||
|
|
{
|
||
|
|
const p = ps[i];
|
||
|
|
|
||
|
|
`);let i=0;for(let s in t){let a=t[s];if(e!==a.dynamic)continue;r.push(`offset = index + ${i}`),r.push(a.code);let o=Ri(a.format);i+=o.stride/4}r.push(`
|
||
|
|
index += stride * 4;
|
||
|
|
}
|
||
|
|
`),r.unshift(`
|
||
|
|
var stride = ${i};
|
||
|
|
`);let n=r.join(`
|
||
|
|
`);return new Function("ps","f32v","u32v",n)}var Hb=_(()=>{Cn()});function zb(t){let e=[];for(let r in t){let i=t[r];e.push(r,i.code,i.dynamic?"d":"s")}return e.join("_")}var hp,Vb=_(()=>{Ki(),Mi(),es(),Cn(),Jd(),Lb(),Hb(),hp=class{constructor(t){this._size=0,this._generateParticleUpdateCache={};let e=this._size=t.size??1e3,r=t.properties,i=0,n=0;for(let h in r){let u=r[h],c=Ri(u.format);u.dynamic?n+=c.stride:i+=c.stride}this._dynamicStride=n/4,this._staticStride=i/4,this.staticAttributeBuffer=new qi(e*4*i),this.dynamicAttributeBuffer=new qi(e*4*n),this.indexBuffer=op(e);let s=new Sn,a=0,o=0;this._staticBuffer=new yr({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:dt.VERTEX|dt.COPY_DST}),this._dynamicBuffer=new yr({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:dt.VERTEX|dt.COPY_DST});for(let h in r){let u=r[h],c=Ri(u.format);u.dynamic?(s.addAttribute(u.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:u.format}),a+=c.size):(s.addAttribute(u.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:o*4,format:u.format}),o+=c.size)}s.addIndex(this.indexBuffer);let l=this.getParticleUpdate(r);this._dynamicUpload=l.dynamicUpdate,this._staticUpload=l.staticUpdate,this.geometry=s}getParticleUpdate(t){let e=zb(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return Nb(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new qi(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new qi(this._size*this._dynamicStride*4*4),this.indexBuffer=op(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));let r=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,r.float32View,r.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){let i=this.staticAttributeBuffer;this._staticUpload(t,i.float32View,i.uint32View),this._staticBuffer.setDataWithSize(i.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}}),up,jb=_(()=>{up=`varying vec2 vUV;
|
||
|
|
varying vec4 vColor;
|
||
|
|
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
|
||
|
|
void main(void){
|
||
|
|
vec4 color = texture2D(uTexture, vUV) * vColor;
|
||
|
|
gl_FragColor = color;
|
||
|
|
}`}),cp,Wb=_(()=>{cp=`attribute vec2 aVertex;
|
||
|
|
attribute vec2 aUV;
|
||
|
|
attribute vec4 aColor;
|
||
|
|
|
||
|
|
attribute vec2 aPosition;
|
||
|
|
attribute float aRotation;
|
||
|
|
|
||
|
|
uniform mat3 uTranslationMatrix;
|
||
|
|
uniform float uRound;
|
||
|
|
uniform vec2 uResolution;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
|
||
|
|
varying vec2 vUV;
|
||
|
|
varying vec4 vColor;
|
||
|
|
|
||
|
|
vec2 roundPixels(vec2 position, vec2 targetSize)
|
||
|
|
{
|
||
|
|
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
void main(void){
|
||
|
|
float cosRotation = cos(aRotation);
|
||
|
|
float sinRotation = sin(aRotation);
|
||
|
|
float x = aVertex.x * cosRotation - aVertex.y * sinRotation;
|
||
|
|
float y = aVertex.x * sinRotation + aVertex.y * cosRotation;
|
||
|
|
|
||
|
|
vec2 v = vec2(x, y);
|
||
|
|
v = v + aPosition;
|
||
|
|
|
||
|
|
gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
||
|
|
|
||
|
|
if(uRound == 1.0)
|
||
|
|
{
|
||
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
||
|
|
}
|
||
|
|
|
||
|
|
vUV = aUV;
|
||
|
|
vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;
|
||
|
|
}
|
||
|
|
`}),ah,$b=_(()=>{ah=`
|
||
|
|
struct ParticleUniforms {
|
||
|
|
uProjectionMatrix:mat3x3<f32>,
|
||
|
|
uColor:vec4<f32>,
|
||
|
|
uResolution:vec2<f32>,
|
||
|
|
uRoundPixels:f32,
|
||
|
|
};
|
||
|
|
|
||
|
|
@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;
|
||
|
|
|
||
|
|
@group(1) @binding(0) var uTexture: texture_2d<f32>;
|
||
|
|
@group(1) @binding(1) var uSampler : sampler;
|
||
|
|
|
||
|
|
struct VSOutput {
|
||
|
|
@builtin(position) position: vec4<f32>,
|
||
|
|
@location(0) uv : vec2<f32>,
|
||
|
|
@location(1) color : vec4<f32>,
|
||
|
|
};
|
||
|
|
@vertex
|
||
|
|
fn mainVertex(
|
||
|
|
@location(0) aVertex: vec2<f32>,
|
||
|
|
@location(1) aPosition: vec2<f32>,
|
||
|
|
@location(2) aUV: vec2<f32>,
|
||
|
|
@location(3) aColor: vec4<f32>,
|
||
|
|
@location(4) aRotation: f32,
|
||
|
|
) -> VSOutput {
|
||
|
|
|
||
|
|
let v = vec2(
|
||
|
|
aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),
|
||
|
|
aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)
|
||
|
|
) + aPosition;
|
||
|
|
|
||
|
|
let position = vec4((uniforms.uProjectionMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
||
|
|
|
||
|
|
let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;
|
||
|
|
|
||
|
|
return VSOutput(
|
||
|
|
position,
|
||
|
|
aUV,
|
||
|
|
vColor,
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@fragment
|
||
|
|
fn mainFragment(
|
||
|
|
@location(0) uv: vec2<f32>,
|
||
|
|
@location(1) color: vec4<f32>,
|
||
|
|
@builtin(position) position: vec4<f32>,
|
||
|
|
) -> @location(0) vec4<f32> {
|
||
|
|
|
||
|
|
var sample = textureSample(uTexture, uSampler, uv) * color;
|
||
|
|
|
||
|
|
return sample;
|
||
|
|
}`}),dp,Xb=_(()=>{De(),Ze(),En(),rs(),ti(),Dt(),ed(),jb(),Wb(),$b(),dp=class extends Vr{constructor(){let t=Zi.from({vertex:cp,fragment:up}),e=Pn.from({fragment:{source:ah,entryPoint:"mainFragment"},vertex:{source:ah,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:Fe.WHITE.source,uSampler:new Yo({}),uniforms:{uTranslationMatrix:{value:new me,type:"mat3x3<f32>"},uColor:{value:new ce(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}}),oh,fp=_(()=>{Ze(),xr(),da(),ii(),ls(),Vb(),Xb(),oh=class{constructor(t,e){this.state=Fr.for2d(),this._gpuBufferHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this.localUniforms=new ur({uTranslationMatrix:{value:new me,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new dp,this.state=Fr.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return this._gpuBufferHash[t.uid]||this._initBuffer(t)}_initBuffer(t){return this._gpuBufferHash[t.uid]=new hp({size:t.particleChildren.length,properties:t._properties}),t.on("destroyed",this._destroyRenderableBound),this._gpuBufferHash[t.uid]}updateRenderable(t){}destroyRenderable(t){this._gpuBufferHash[t.uid].destroy(),this._gpuBufferHash[t.uid]=null,t.off("destroyed",this._destroyRenderableBound)}execute(t){let e=t.particleChildren;if(e.length===0)return;let r=this.renderer,i=this.getBuffers(t);t.texture||(t.texture=e[0].texture);let n=this.state;i.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=Jn(t.blendMode,t.texture._source);let s=this.localUniforms.uniforms,a=s.uTranslationMatrix;t.worldTransform.copyTo(a),a.prepend(r.globalUniforms.globalUniformData.projectionMatrix),s.uResolution=r.globalUniforms.globalUniformData.resolution,s.uRound=r._roundPixels|t._roundPixels,os(t.groupColorAlpha,s.uColor,0),this.adaptor.execute(this,t)}destroy(){this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}}),lh,Yb=_(()=>{J(),Ub(),fp(),lh=class extends oh{constructor(t){super(t,new ap)}},lh.extension={type:[O.WebGLPipes],name:"particle"}}),pp,qb=_(()=>{"use strict";pp=class{execute(t,e){let r=t.renderer,i=e.shader||t.defaultShader;i.groups[0]=r.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),i.groups[1]=r.texture.getTextureBindGroup(e.texture);let n=t.state,s=t.getBuffers(e);r.encoder.draw({geometry:s.geometry,shader:e.shader||t.defaultShader,state:n,size:e.particleChildren.length*6})}}}),hh,Kb=_(()=>{J(),qb(),fp(),hh=class extends oh{constructor(t){super(t,new pp)}},hh.extension={type:[O.WebGPUPipes],name:"particle"}}),gp=_(()=>{J(),Yb(),Kb(),xe.add(lh),xe.add(hh)}),hs,Na=_(()=>{"use strict";hs=class{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}}});function uh(t,e){let{texture:r,bounds:i}=t;Dd(i,e._anchor,r);let n=e._style.padding;i.minX-=n,i.minY-=n,i.maxX-=n,i.maxY-=n}var mp=_(()=>{Ud()}),ch,Zb=_(()=>{J(),Kt(),Na(),mp(),ch=class{constructor(t){this._gpuText=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.runners.resolutionChange.add(this),this._renderer.renderableGC.addManagedHash(this,"_gpuText")}resolutionChange(){for(let t in this._gpuText){let e=this._gpuText[t];if(!e)continue;let r=e.batchableSprite.renderable;r._autoResolution&&(r._resolution=this._renderer.resolution,r.onViewUpdate())}}validateRenderable(t){let e=this._getGpuText(t),r=t._getKey();return e.currentKey!==r}addRenderable(t,e){let r=this._getGpuText(t).batchableSprite;t._didTextUpdate&&
|
||
|
|
`:e,e}static _getFromCache(e,r,i,n){let s=i[e];return typeof s!="number"&&(s=Oe._measureText(e,r,n)+r,i[e]=s),s}static _collapseSpaces(e){return e==="normal"||e==="pre-line"}static _collapseNewlines(e){return e==="normal"}static _trimRight(e){if(typeof e!="string")return"";for(let r=e.length-1;r>=0;r--){let i=e[r];if(!Oe.isBreakingSpace(i))break;e=e.slice(0,-1)}return e}static _isNewline(e){return typeof e!="string"?!1:Oe._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,r){return typeof e!="string"?!1:Oe._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){let r=[],i="";if(typeof e!="string")return r;for(let n=0;n<e.length;n++){let s=e[n],a=e[n+1];if(Oe.isBreakingSpace(s,a)||Oe._isNewline(s)){i!==""&&(r.push(i),i=""),r.push(s);continue}i+=s}return i!==""&&r.push(i),r}static canBreakWords(e,r){return r}static canBreakChars(e,r,i,n,s){return!0}static wordWrapSplit(e){return Oe.graphemeSegmenter(e)}static measureFont(e){if(Oe._fonts[e])return Oe._fonts[e];let r=Oe._context;r.font=e;let i=r.measureText(Oe.METRICS_STRING+Oe.BASELINE_SYMBOL),n={ascent:i.actualBoundingBoxAscent,descent:i.actualBoundingBoxDescent,fontSize:i.actualBoundingBoxAscent+i.actualBoundingBoxDescent};return Oe._fonts[e]=n,n}static clearMetrics(e=""){e?delete Oe._fonts[e]:Oe._fonts={}}static get _canvas(){if(!Oe.__canvas){let e;try{let r=new OffscreenCanvas(0,0);if(r.getContext("2d",qa)?.measureText)return Oe.__canvas=r,r;e=Lt.get().createCanvas()}catch{e=Lt.get().createCanvas()}e.width=e.height=10,Oe.__canvas=e}return Oe.__canvas}static get _context(){return Oe.__context||(Oe.__context=Oe._canvas.getContext("2d",qa)),Oe.__context}},Ur.METRICS_STRING="|\xC9q\xC5",Ur.BASELINE_SYMBOL="M",Ur.BASELINE_MULTIPLIER=1.4,Ur.HEIGHT_MULTIPLIER=2,Ur.graphemeSegmenter=(()=>{if(typeof Intl?.Segmenter=="function"){let t=new Intl.Segmenter;return e=>[...t.segment(e)].map(r=>r.segment)}return t=>[...t]})(),Ur.experimentalLetterSpacing=!1,Ur._fonts={},Ur._newlines=[10,13],Ur._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],Ur._measurementCache={},ai=Ur});function Ka(t,e,r,i=0){if(t.texture===Fe.WHITE&&!t.fill)return ce.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(t.fill){if(t.fill instanceof cs){let n=t.fill,s=e.createPattern(n.texture.source.resource,"repeat"),a=n.transform.copyTo(me.shared);return a.scale(n.texture.frame.width,n.texture.frame.height),s.setTransform(a),s}else if(t.fill instanceof ri){let n=t.fill,s=n.type==="linear",a=n.textureSpace==="local",o=1,l=1;a&&r&&(o=r.width+i,l=r.height+i);let h,u=!1;if(s){let{start:c,end:f}=n;h=e.createLinearGradient(c.x*o,c.y*l,f.x*o,f.y*l),u=Math.abs(f.x-c.x)<Math.abs((f.y-c.y)*.1)}else{let{center:c,innerRadius:f,outerCenter:d,outerRadius:y}=n;h=e.createRadialGradient(c.x*o,c.y*l,f*o,d.x*o,d.y*l,y*o)}if(u&&a&&r){let c=r.lineHeight/l;for(let f=0;f<r.lines.length;f++){let d=(f*r.lineHeight+i/2)/l;n.colorStops.forEach(y=>{let x=d+y.offset*c;h.addColorStop(Math.floor(x*Sh)/Sh,ce.shared.setValue(y.color).toHex())})}}else n.colorStops.forEach(c=>{h.addColorStop(c.offset,ce.shared.setValue(c.color).toHex())});return h}}else{let n=e.createPattern(t.texture.source.resource,"repeat"),s=t.matrix.copyTo(me.shared);return s.scale(t.texture.frame.width,t.texture.frame.height),n.setTransform(s),n}return Be("FillStyle not recognised",t),"red"}var Sh,ig=_(()=>{De(),Ze(),Dt(),Se(),ss(),fh(),Sh=1e5}),Eh,L0=_(()=>{De(),J(),$s(),us(),Vi(),Jb(),kt(),ms(),tg(),Th(),wh(),ig(),Eh=class{constructor(t){this._activeTextures={},this._renderer=t}getTextureSize(t,e,r){let i=ai.measureText(t||" ",r),n=Math.ceil(Math.ceil(Math.max(1,i.width)+r.padding*2)*e),s=Math.ceil(Math.ceil(Math.max(1,i.height)+r.padding*2)*e);return n=Math.ceil(n-1e-6),s=Math.ceil(s-1e-6),n=pn(n),s=pn(s),{width:n,height:s}}getTexture(t,e,r,i){typeof t=="string"&&(Qe("8.0.0","CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:r,resolution:e}),t.style instanceof si||(t.style=new si(t.style));let{texture:n,canvasAndContext:s}=this.createTextureAndCanvas(t);return this._re
|
||
|
|
struct LocalUniforms {
|
||
|
|
uColor:vec4<f32>,
|
||
|
|
uTransformMatrix:mat3x3<f32>,
|
||
|
|
uDistance: f32,
|
||
|
|
uRound:f32,
|
||
|
|
}
|
||
|
|
|
||
|
|
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
||
|
|
`,main:`
|
||
|
|
vColor *= localUniforms.uColor;
|
||
|
|
modelMatrix *= localUniforms.uTransformMatrix;
|
||
|
|
`,end:`
|
||
|
|
if(localUniforms.uRound == 1)
|
||
|
|
{
|
||
|
|
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
||
|
|
}
|
||
|
|
`},fragment:{header:`
|
||
|
|
struct LocalUniforms {
|
||
|
|
uColor:vec4<f32>,
|
||
|
|
uTransformMatrix:mat3x3<f32>,
|
||
|
|
uDistance: f32
|
||
|
|
}
|
||
|
|
|
||
|
|
@group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
||
|
|
`,main:`
|
||
|
|
outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));
|
||
|
|
`}},og={name:"local-uniform-msdf-bit",vertex:{header:`
|
||
|
|
uniform mat3 uTransformMatrix;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
uniform float uRound;
|
||
|
|
`,main:`
|
||
|
|
vColor *= uColor;
|
||
|
|
modelMatrix *= uTransformMatrix;
|
||
|
|
`,end:`
|
||
|
|
if(uRound == 1.)
|
||
|
|
{
|
||
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
||
|
|
}
|
||
|
|
`},fragment:{header:`
|
||
|
|
uniform float uDistance;
|
||
|
|
`,main:`
|
||
|
|
outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));
|
||
|
|
`}}}),lg,hg,H0=_(()=>{"use strict";lg={name:"msdf-bit",fragment:{header:`
|
||
|
|
fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {
|
||
|
|
|
||
|
|
// MSDF
|
||
|
|
var median = msdfColor.r + msdfColor.g + msdfColor.b -
|
||
|
|
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
||
|
|
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
||
|
|
|
||
|
|
// SDF
|
||
|
|
median = min(median, msdfColor.a);
|
||
|
|
|
||
|
|
var screenPxDistance = distance * (median - 0.5);
|
||
|
|
var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||
|
|
if (median < 0.01) {
|
||
|
|
alpha = 0.0;
|
||
|
|
} else if (median > 0.99) {
|
||
|
|
alpha = 1.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Gamma correction for coverage-like alpha
|
||
|
|
var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));
|
||
|
|
var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);
|
||
|
|
var coverage: f32 = pow(shapeColor.a * alpha, gamma);
|
||
|
|
|
||
|
|
return coverage;
|
||
|
|
|
||
|
|
}
|
||
|
|
`}},hg={name:"msdf-bit",fragment:{header:`
|
||
|
|
float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {
|
||
|
|
|
||
|
|
// MSDF
|
||
|
|
float median = msdfColor.r + msdfColor.g + msdfColor.b -
|
||
|
|
min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -
|
||
|
|
max(msdfColor.r, max(msdfColor.g, msdfColor.b));
|
||
|
|
|
||
|
|
// SDF
|
||
|
|
median = min(median, msdfColor.a);
|
||
|
|
|
||
|
|
float screenPxDistance = distance * (median - 0.5);
|
||
|
|
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);
|
||
|
|
|
||
|
|
if (median < 0.01) {
|
||
|
|
alpha = 0.0;
|
||
|
|
} else if (median > 0.99) {
|
||
|
|
alpha = 1.0;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Gamma correction for coverage-like alpha
|
||
|
|
float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));
|
||
|
|
float gamma = mix(1.0, 1.0 / 2.2, luma);
|
||
|
|
float coverage = pow(shapeColor.a * alpha, gamma);
|
||
|
|
|
||
|
|
return coverage;
|
||
|
|
}
|
||
|
|
`}}}),Ch,Ah,ug,z0=_(()=>{Ze(),bn(),Qi(),Ta(),Ca(),Ji(),Ql(),ti(),xr(),N0(),H0(),ug=class extends Vr{constructor(){let t=new ur({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new me,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}}),e=xn();Ch??(Ch=is({name:"sdf-shader",bits:[ba,$l(e),ag,lg,Mn]})),Ah??(Ah=ns({name:"sdf-shader",bits:[wa,Xl(e),og,hg,Rn]})),super({glProgram:Ah,gpuProgram:Ch,resources:{localUniforms:t,batchSamplers:Kl(e)}})}}}),cg,V0=_(()=>{It(),kt(),cg=class extends at{constructor(){super(...arguments),this.chars=Object.create(null),this.lineHeight=0,this.fontFamily="",this.fontMetrics={fontSize:0,ascent:0,descent:0},this.baseLineOffset=0,this.distanceField={type:"none",range:0},this.pages=[],this.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return Qe(ot,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return Qe(ot,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return Qe(ot,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return Qe(ot,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return Qe(ot,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(let e in this.chars)this.chars[e].texture?.destroy();this.chars=null,t&&(this.pages.forEach(e=>e.texture.destroy(!0)),this.pages=null)}}});function dg(t){if(t==="")return[];typeof t=="string"&&(t=[t]);let e=[];for(let r=0,i=t.length;r<i;r++){let n=t[r];if(Array.isArray(n)){if(n.length!==2)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${n.length}.`);if(n[0].length===0||n[1].length===0)throw new Error("[BitmapFont]: Invalid character delimiter.");let s=n[0].charCodeAt(0),a=n[1].charCodeAt(0);if(a<s)throw new Error("[BitmapFont]: Invalid character range.");for(let o=s,l=a;o<=l;o++)e.push(String.fromCharCode(o))}else e.push(...Array.from(n))}if(e.length===0)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}var fg=_(()=>{"use strict"}),Ph,Mh,j0=_(()=>{De(),S(),us(),Il(),Dt(),kt(),Th(),wh(),ig(),ms(),V0(),fg(),Ph=class uy extends cg{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentPageIndex=-1,this._skipKerning=!1;let r={...uy.defaultOptions,...e};this._textureSize=r.textureSize,this._mipmap=r.mipmap;let i=r.style.clone();r.overrideFill&&(i._fill.color=16777215,i._fill.alpha=1,i._fill.texture=Fe.WHITE,i._fill.fill=null),this.applyFillAsTint=r.overrideFill;let n=i.fontSize;i.fontSize=this.baseMeasurementFontSize;let s=Ya(i);r.overrideSize?i._stroke&&(i._stroke.width*=this.baseRenderedFontSize/n):i.fontSize=this.baseRenderedFontSize=n,this._style=i,this._skipKerning=r.skipKerning??!1,this.resolution=r.resolution??1,this._padding=r.padding??4,this.fontMetrics=ai.measureFont(s),this.lineHeight=i.lineHeight||this.fontMetrics.fontSize||i.fontSize}ensureCharacters(e){let r=dg(e).filter(v=>!this._currentChars.includes(v)).filter((v,w,P)=>P.indexOf(v)===w);if(!r.length)return;this._currentChars=[...this._currentChars,...r];let i;this._currentPageIndex===-1?i=this._nextPage():i=this.pages[this._currentPageIndex];let{canvas:n,context:s}=i.canvasAndContext,a=i.texture.source,o=this._style,l=this._currentX,h=this._currentY,u=this.baseRenderedFontSize/this.baseMeasurementFontSize,c=this._padding*u,f=0,d=!1,y=n.width/this.resolution,x=n.height/this.resolution;for(let v=0;v<r.length;v++){let w=r[v],P=ai.measureText(w,o,n,!1);P.lineHeight=P.height;let G=P.width*u,k=Math.ceil((o.fontStyle==="italic"?2:1)*G),L=P.height*u,N=k+c*2,H=L+c*2;if(d=!1,w!
|
||
|
|
`&&w!=="\r"&&w!==" "&&w!==" "&&(d=!0,f=Math.ceil(Math.max(H,f))),l+N>y&&(h+=f,f=H,l=0,h+f>x)){a.update();let ue=this._nextPage();n=ue.canvasAndContext.canvas,s=ue.canvasAndContext.context,a=ue.texture.source,h=0}let fe=G/u-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[w]={id:w.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:fe,kerning:{}},d){this._drawGlyph(s,P,l+c,h+c,u,o);let ue=a.width*u,ae=a.height*u,le=new b(l/ue*a.width,h/ae*a.height,N/ue*a.width,H/ae*a.height);this.chars[w].texture=new Fe({source:a,frame:le}),l+=Math.ceil(N)}}a.update(),this._currentX=l,this._currentY=h,this._skipKerning&&this._applyKerning(r,s)}get pageTextures(){return Qe(ot,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(e,r){let i=this._measureCache;for(let n=0;n<e.length;n++){let s=e[n];for(let a=0;a<this._currentChars.length;a++){let o=this._currentChars[a],l=i[s];l||(l=i[s]=r.measureText(s).width);let h=i[o];h||(h=i[o]=r.measureText(o).width);let u=r.measureText(s+o).width,c=u-(l+h);c&&(this.chars[s].kerning[o]=c),u=r.measureText(s+o).width,c=u-(l+h),c&&(this.chars[o].kerning[s]=c)}}}_nextPage(){this._currentPageIndex++;let e=this.resolution,r=ni.getOptimalCanvasAndContext(this._textureSize,this._textureSize,e);this._setupContext(r.context,this._style,e);let i=e*(this.baseRenderedFontSize/this.baseMeasurementFontSize),n=new Fe({source:new yn({resource:r.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})}),s={canvasAndContext:r,texture:n};return this.pages[this._currentPageIndex]=s,s}_setupContext(e,r,i){r.fontSize=this.baseRenderedFontSize,e.scale(i,i),e.font=Ya(r),r.fontSize=this.baseMeasurementFontSize,e.textBaseline=r.textBaseline;let n=r._stroke,s=n?.width??0;if(n&&(e.lineWidth=s,e.lineJoin=n.join,e.miterLimit=n.miterLimit,e.strokeStyle=Ka(n,e)),r._fill&&(e.fillStyle=Ka(r._fill,e)),r.dropShadow){let a=r.dropShadow,o=ce.shared.setValue(a.color).toArray(),l=a.blur*i,h=a.distance*i;e.shadowColor=`rgba(${o[0]*255},${o[1]*255},${o[2]*255},${a.alpha})`,e.shadowBlur=l,e.shadowOffsetX=Math.cos(a.angle)*h,e.shadowOffsetY=Math.sin(a.angle)*h}else e.shadowColor="black",e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0}_drawGlyph(e,r,i,n,s,a){let o=r.text,l=r.fontProperties,h=(a._stroke?.width??0)*s,u=i+h/2,c=n-h/2,f=l.descent*s,d=r.lineHeight*s;a.stroke&&h&&e.strokeText(o,u,c+d-f),a._fill&&e.fillText(o,u,c+d-f)}destroy(){super.destroy();for(let e=0;e<this.pages.length;e++){let{canvasAndContext:r,texture:i}=this.pages[e];ni.returnCanvasAndContext(r),i.destroy(!0)}this.pages=null}},Ph.defaultOptions={textureSize:512,style:new si,mipmap:!0},Mh=Ph});function pg(t,e,r,i){let n={width:0,height:0,offsetY:0,scale:e.fontSize/r.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};n.offsetY=r.baseLineOffset;let s=n.lines[0],a=null,o=!0,l={spaceWord:!1,width:0,start:0,index:0,positions:[],chars:[]},h=y=>{let x=s.width;for(let v=0;v<l.index;v++){let w=y.positions[v];s.chars.push(y.chars[v]),s.charPositions.push(w+x)}s.width+=y.width,o=!1,l.width=0,l.index=0,l.chars.length=0},u=()=>{let y=s.chars.length-1;if(i){let x=s.chars[y];for(;x===" ";)s.width-=r.chars[x].xAdvance,x=s.chars[--y]}n.width=Math.max(n.width,s.width),s={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},o=!0,n.lines.push(s),n.height+=r.lineHeight},c=r.baseMeasurementFontSize/e.fontSize,f=e.letterSpacing*c,d=e.wordWrapWidth*c;for(let y=0;y<t.length+1;y++){let x,v=y===t.length;v||(x=t[y]);let w=r.chars[x]||r.chars[" "];if(/(?:\s)/.test(x)||x==="\r"||x===`
|
||
|
|
`||v){if(!o&&e.wordWrap&&s.width+l.width-f>d?(u(),h(l),v||s.charPositions.push(0)):(l.start=s.width,h(l),v||s.charPositions.push(0)),x==="\r"||x===`
|
||
|
|
`)s.width!==0&&u();else if(!v){let P=w.xAdvance+(w.kerning[a]||0)+f;s.width+=P,s.spaceWidth=P,s.spacesIndex.push(s.charPositions.length),s.chars.push(x)}}else{let P=w.kerning[a]||0,G=w.xAdvance+P+f;l.positions[l.index++]=l.width+P,l.chars.push(x),l.width+=G}a=x}return u(),e.align==="center"?W0(n):e.align==="right"?$0(n):e.align==="justify"&&X0(n),n}function W0(t){for(let e=0;e<t.lines.length;e++){let r=t.lines[e],i=t.width/2-r.width/2;for(let n=0;n<r.charPositions.length;n++)r.charPositions[n]+=i}}function $0(t){for(let e=0;e<t.lines.length;e++){let r=t.lines[e],i=t.width-r.width;for(let n=0;n<r.charPositions.length;n++)r.charPositions[n]+=i}}function X0(t){let e=t.width;for(let r=0;r<t.lines.length;r++){let i=t.lines[r],n=0,s=i.spacesIndex[n++],a=0,o=i.spacesIndex.length,l=(e-i.width)/o;for(let h=0;h<i.charPositions.length;h++)h===s&&(s=i.spacesIndex[n++],a+=l),i.charPositions[h]+=a}}var gg=_(()=>{"use strict"}),_s,mg,_g,Y0=_(()=>{la(),kt(),Se(),ms(),j0(),gg(),fg(),_s=0,mg=class{constructor(){this.ALPHA=[["a","z"],["A","Z"]," "],this.NUMERIC=[["0","9"]],this.ALPHANUMERIC=[["a","z"],["A","Z"],["0","9"]," "],this.ASCII=[[" ","~"]],this.defaultOptions={chars:this.ALPHANUMERIC,resolution:1,padding:4,skipKerning:!1}}getFont(t,e){let r=`${e.fontFamily}-bitmap`,i=!0;if(e._fill.fill&&!e._stroke)r+=e._fill.fill.styleKey,i=!1;else if(e._stroke||e.dropShadow){let s=e.styleKey;s=s.substring(0,s.lastIndexOf("-")),r=`${s}-bitmap`,i=!1}if(!or.has(r)){let s=new Mh({style:e,overrideFill:i,overrideSize:!0,...this.defaultOptions});_s++,_s>50&&Be("BitmapText",`You have dynamically created ${_s} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),s.once("destroy",()=>{_s--,or.remove(r)}),or.set(r,s)}let n=or.get(r);return n.ensureCharacters?.(t),n}getLayout(t,e,r=!0){let i=this.getFont(t,e);return pg([...t],e,i,r)}measureText(t,e,r=!0){return this.getLayout(t,e,r)}install(...t){let e=t[0];typeof e=="string"&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},Qe(ot,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));let r=e?.name;if(!r)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};let i=e.style,n=i instanceof si?i:new si(i),s=n._fill.fill!==null&&n._fill.fill!==void 0,a=new Mh({style:n,overrideFill:s,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1}),o=dg(e.chars);return a.ensureCharacters(o.join("")),or.set(`${r}-bitmap`,a),a.once("destroy",()=>or.remove(`${r}-bitmap`)),a}uninstall(t){let e=`${t}-bitmap`,r=or.get(e);r&&r.destroy()}},_g=new mg});function vg(t,e){e.groupTransform=t.groupTransform,e.groupColorAlpha=t.groupColorAlpha,e.groupColor=t.groupColor,e.groupBlendMode=t.groupBlendMode,e.globalDisplayStatus=t.globalDisplayStatus,e.groupTransform=t.groupTransform,e.localDisplayStatus=t.localDisplayStatus,e.groupAlpha=t.groupAlpha,e._roundPixels=t._roundPixels}var Rh,q0=_(()=>{la(),J(),Kt(),sg(),z0(),Y0(),gg(),Rh=class{constructor(t){this._gpuBitmapText={},this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBitmapText")}validateRenderable(t){let e=this._getGpuBitmapText(t);return t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,e)),this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){let r=this._getGpuBitmapText(t);vg(t,r),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,r)),this._renderer.renderPipes.graphics.addRenderable(r,e),r.context.customShader&&this._updateDistanceField(t)}destroyRenderable(t){t.off("destroyed",this._destroyRenderableBound),this._destroyRenderableByUid(t.uid)}_destroyRenderableByUid(t){let e=this._gpuBitmapText[t].context;e.customShader&&(it.return(e.customShader),e.customShader=null),it.return(this._gpuBitmapText[t]),this._gpuBitmapText[t]=null}updateRenderable(t){let e=this._getGpuB
|
||
|
|
font-family: "${t.fontFamily}";
|
||
|
|
src: url('${r}');
|
||
|
|
font-weight: ${t.fontWeight};
|
||
|
|
font-style: ${t.fontStyle};
|
||
|
|
}`}var o1=_(()=>{a1()});async function l1(t,e,r){let i=t.filter(n=>or.has(`${n}-and-url`)).map((n,s)=>{if(!vs.has(n)){let{url:a}=or.get(`${n}-and-url`);s===0?vs.set(n,Sg({fontWeight:e.fontWeight,fontStyle:e.fontStyle,fontFamily:n},a)):vs.set(n,Sg({fontWeight:r.fontWeight,fontStyle:r.fontStyle,fontFamily:n},a))}return vs.get(n)});return(await Promise.all(i)).join(`
|
||
|
|
`)}var vs,h1=_(()=>{la(),o1(),vs=new Map});function u1(t,e,r,i,n){let{domElement:s,styleElement:a,svgRoot:o}=n;s.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,s.setAttribute("style",`transform: scale(${r});transform-origin: top left; display: inline-block`),a.textContent=i;let{width:l,height:h}=n.image;return o.setAttribute("width",l.toString()),o.setAttribute("height",h.toString()),new XMLSerializer().serializeToString(o)}var c1=_(()=>{"use strict"});function d1(t,e){let r=ni.getOptimalCanvasAndContext(t.width,t.height,e),{context:i}=r;return i.clearRect(0,0,t.width,t.height),i.drawImage(t,0,0),r}var f1=_(()=>{us()});function p1(t,e,r){return new Promise(async i=>{r&&await new Promise(n=>setTimeout(n,100)),t.onload=()=>{i()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"})}var g1=_(()=>{"use strict"});function m1(t,e,r,i){i||(i=Eg||(Eg=new Oh));let{domElement:n,styleElement:s,svgRoot:a}=i;n.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,n.setAttribute("style","transform-origin: top left; display: inline-block"),r&&(s.textContent=r),document.body.appendChild(a);let o=n.getBoundingClientRect();a.remove();let l=e.padding*2;return{width:o.width-l,height:o.height-l}}var Eg,_1=_(()=>{xg()}),Qa,v1=_(()=>{J(),us(),Vi(),gi(),Q0(),Se(),Kt(),tg(),xg(),r1(),n1(),h1(),c1(),f1(),g1(),_1(),Qa=class{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===Gr.WEBGPU}getTexture(t){return this._buildTexturePromise(t.text,t.resolution,t.style)}getManagedTexture(t,e,r,i){if(this._activeTextures[i])return this._increaseReferenceCount(i),this._activeTextures[i].promise;let n=this._buildTexturePromise(t,e,r).then(s=>(this._activeTextures[i].texture=s,s));return this._activeTextures[i]={texture:null,promise:n,usageCount:1},n}async _buildTexturePromise(t,e,r){let i=it.get(Oh),n=i1(t,r),s=await l1(n,r,Tg.defaultTextStyle),a=m1(t,r,s,i),o=Math.ceil(Math.ceil(Math.max(1,a.width)+r.padding*2)*e),l=Math.ceil(Math.ceil(Math.max(1,a.height)+r.padding*2)*e),h=i.image,u=2;h.width=(o|0)+u,h.height=(l|0)+u;let c=u1(t,r,e,s,i);await p1(h,c,Z0()&&n.length>0);let f=h,d;this._createCanvas&&(d=d1(h,e));let y=Jp(d?d.canvas:f,h.width-u,h.height-u,e);return this._createCanvas&&(this._renderer.texture.initSource(y.source),ni.returnCanvasAndContext(d)),it.return(i),y}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){let e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e):e.promise.then(r=>{e.texture=r,this._cleanUp(e)}).catch(()=>{Be("HTMLTextSystem: Failed to clean texture")}),this._activeTextures[t]=null))}_cleanUp(t){ar.returnTexture(t.texture),t.texture.source.resource=null,t.texture.source.uploadMethodId="unknown"}getReferenceCount(t){return this._activeTextures[t].usageCount}destroy(){this._activeTextures=null}},Qa.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"htmlText"},Qa.defaultFontOptions={fontFamily:"Arial",fontStyle:"normal",fontWeight:"normal"}}),Cg=_(()=>{J(),K0(),v1(),xe.add(Qa),xe.add(kh)}),Dh,Ja,Uh=_(()=>{Ki(),Mi(),es(),kt(),Dh=class dy extends Sn{constructor(...e){let r=e[0]??{};r instanceof Float32Array&&(Qe(ot,"use new MeshGeometry({ positions, uvs, indices }) instead"),r={positions:r,uvs:e[1],indices:e[2]}),r={...dy.defaultOptions,...r};let i=r.positions||new Float32Array([0,0,1,0,1,1,0,1]),n=r.uvs;n||(r.positions?n=new Float32Array(i.length):n=new Float32Array([0,0,1,0,1,1,0,1]));let s=r.indices||new Uint32Array([0,1,2,0,2,3]),a=r.shrinkBuffersToFit,o=new yr({data:i,label:"attribute-mesh-positions",shrinkToFit:a,usage:dt.VERTEX|dt.COPY_DST}),l=new yr({data:n,label:"attribute-mesh-uvs",shrinkToFit:a,usage:dt.VERTEX|dt.COPY_DST}),h=new yr({data:s,label:"index-mesh-buffer",shrinkToFit:a,usage:dt.INDEX|dt.COPY_DST});super({attributes:{aPosition:{buffer:o,format:"float32x2",stride:2*4,offset:0},aUV:{buffer:l,format:"float32x2",stride:2*4,offset:0}},indexBuffer:h,topology:r.topology}),this.batchMode="auto"}get positions(){re
|
||
|
|
|
||
|
|
struct LocalUniforms {
|
||
|
|
uTransformMatrix:mat3x3<f32>,
|
||
|
|
uColor:vec4<f32>,
|
||
|
|
uRound:f32,
|
||
|
|
}
|
||
|
|
|
||
|
|
@group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;
|
||
|
|
`,main:`
|
||
|
|
vColor *= localUniforms.uColor;
|
||
|
|
modelMatrix *= localUniforms.uTransformMatrix;
|
||
|
|
`,end:`
|
||
|
|
if(localUniforms.uRound == 1)
|
||
|
|
{
|
||
|
|
vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
||
|
|
}
|
||
|
|
`}},Ag={...In,vertex:{...In.vertex,header:In.vertex.header.replace("group(1)","group(2)")}},eo={name:"local-uniform-bit",vertex:{header:`
|
||
|
|
|
||
|
|
uniform mat3 uTransformMatrix;
|
||
|
|
uniform vec4 uColor;
|
||
|
|
uniform float uRound;
|
||
|
|
`,main:`
|
||
|
|
vColor *= uColor;
|
||
|
|
modelMatrix = uTransformMatrix;
|
||
|
|
`,end:`
|
||
|
|
if(uRound == 1.)
|
||
|
|
{
|
||
|
|
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
||
|
|
}
|
||
|
|
`}}}),Pg,Mg,y1=_(()=>{"use strict";Pg={name:"tiling-bit",vertex:{header:`
|
||
|
|
struct TilingUniforms {
|
||
|
|
uMapCoord:mat3x3<f32>,
|
||
|
|
uClampFrame:vec4<f32>,
|
||
|
|
uClampOffset:vec2<f32>,
|
||
|
|
uTextureTransform:mat3x3<f32>,
|
||
|
|
uSizeAnchor:vec4<f32>
|
||
|
|
};
|
||
|
|
|
||
|
|
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
||
|
|
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
||
|
|
@group(2) @binding(2) var uSampler: sampler;
|
||
|
|
`,main:`
|
||
|
|
uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;
|
||
|
|
|
||
|
|
position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;
|
||
|
|
`},fragment:{header:`
|
||
|
|
struct TilingUniforms {
|
||
|
|
uMapCoord:mat3x3<f32>,
|
||
|
|
uClampFrame:vec4<f32>,
|
||
|
|
uClampOffset:vec2<f32>,
|
||
|
|
uTextureTransform:mat3x3<f32>,
|
||
|
|
uSizeAnchor:vec4<f32>
|
||
|
|
};
|
||
|
|
|
||
|
|
@group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;
|
||
|
|
@group(2) @binding(1) var uTexture: texture_2d<f32>;
|
||
|
|
@group(2) @binding(2) var uSampler: sampler;
|
||
|
|
`,main:`
|
||
|
|
|
||
|
|
var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);
|
||
|
|
coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;
|
||
|
|
var unclamped = coord;
|
||
|
|
coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);
|
||
|
|
|
||
|
|
var bias = 0.;
|
||
|
|
|
||
|
|
if(unclamped.x == coord.x && unclamped.y == coord.y)
|
||
|
|
{
|
||
|
|
bias = -32.;
|
||
|
|
}
|
||
|
|
|
||
|
|
outColor = textureSampleBias(uTexture, uSampler, coord, bias);
|
||
|
|
`}},Mg={name:"tiling-bit",vertex:{header:`
|
||
|
|
uniform mat3 uTextureTransform;
|
||
|
|
uniform vec4 uSizeAnchor;
|
||
|
|
|
||
|
|
`,main:`
|
||
|
|
uv = (uTextureTransform * vec3(aUV, 1.0)).xy;
|
||
|
|
|
||
|
|
position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;
|
||
|
|
`},fragment:{header:`
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform mat3 uMapCoord;
|
||
|
|
uniform vec4 uClampFrame;
|
||
|
|
uniform vec2 uClampOffset;
|
||
|
|
`,main:`
|
||
|
|
|
||
|
|
vec2 coord = vUV + ceil(uClampOffset - vUV);
|
||
|
|
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
||
|
|
vec2 unclamped = coord;
|
||
|
|
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
||
|
|
|
||
|
|
outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0
|
||
|
|
|
||
|
|
`}}}),Lh,Nh,Rg,x1=_(()=>{Ze(),Qi(),ys(),Ji(),ti(),xr(),Dt(),y1(),Rg=class extends Vr{constructor(){Lh??(Lh=is({name:"tiling-sprite-shader",bits:[In,Pg,Mn]})),Nh??(Nh=ns({name:"tiling-sprite-shader",bits:[eo,Mg,Rn]}));let t=new ur({uMapCoord:{value:new me,type:"mat3x3<f32>"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4<f32>"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2<f32>"},uTextureTransform:{value:new me,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:Nh,gpuProgram:Lh,resources:{localUniforms:new ur({uTransformMatrix:{value:new me,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:Fe.EMPTY.source,uSampler:Fe.EMPTY.source.style}})}updateUniforms(t,e,r,i,n,s){let a=this.resources.tilingUniforms,o=s.width,l=s.height,h=s.textureMatrix,u=a.uniforms.uTextureTransform;u.set(r.a*o/t,r.b*o/e,r.c*l/t,r.d*l/e,r.tx/t,r.ty/e),u.invert(),a.uniforms.uMapCoord=h.mapCoord,a.uniforms.uClampFrame=h.uClampFrame,a.uniforms.uClampOffset=h.uClampOffset,a.uniforms.uTextureTransform=u,a.uniforms.uSizeAnchor[0]=t,a.uniforms.uSizeAnchor[1]=e,a.uniforms.uSizeAnchor[2]=i,a.uniforms.uSizeAnchor[3]=n,s&&(this.resources.uTexture=s.source,this.resources.uSampler=s.source.style)}}}),kg,b1=_(()=>{Uh(),kg=class extends Ja{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}});function w1(t,e){let r=t.anchor.x,i=t.anchor.y;e[0]=-r*t.width,e[1]=-i*t.height,e[2]=(1-r)*t.width,e[3]=-i*t.height,e[4]=(1-r)*t.width,e[5]=(1-i)*t.height,e[6]=-r*t.width,e[7]=(1-i)*t.height}var T1=_(()=>{"use strict"});function S1(t,e,r,i){let n=0,s=t.length/(e||2),a=i.a,o=i.b,l=i.c,h=i.d,u=i.tx,c=i.ty;for(r*=e;n<s;){let f=t[r],d=t[r+1];t[r]=a*f+l*d+u,t[r+1]=o*f+h*d+c,r+=e,n++}}var E1=_(()=>{"use strict"});function C1(t,e){let r=t.texture,i=r.frame.width,n=r.frame.height,s=0,a=0;t.applyAnchorToTexture&&(s=t.anchor.x,a=t.anchor.y),e[0]=e[6]=-s,e[2]=e[4]=1-s,e[1]=e[3]=-a,e[5]=e[7]=1-a;let o=me.shared;o.copyFrom(t._tileTransform.matrix),o.tx/=t.width,o.ty/=t.height,o.invert(),o.scale(t.width/i,t.height/n),S1(e,2,0,o)}var A1=_(()=>{Ze(),E1()}),xs,Hh,P1=_(()=>{J(),da(),ii(),gi(),ls(),nh(),Uh(),x1(),b1(),T1(),A1(),xs=new kg,Hh=class{constructor(t){this._state=Fr.default2d,this._tilingSpriteDataHash=Object.create(null),this._destroyRenderableBound=this.destroyRenderable.bind(this),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_tilingSpriteDataHash")}validateRenderable(t){let e=this._getTilingSpriteData(t),r=e.canBatch;this._updateCanBatch(t);let i=e.canBatch;if(i&&i===r){let{batchableMesh:n}=e;return!n._batcher.checkAndUpdateTexture(n,t.texture)}return r!==i}addRenderable(t,e){let r=this._renderer.renderPipes.batch;this._updateCanBatch(t);let i=this._getTilingSpriteData(t),{geometry:n,canBatch:s}=i;if(s){i.batchableMesh||(i.batchableMesh=new La);let a=i.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),a.geometry=n,a.renderable=t,a.transform=t.groupTransform,a.setTexture(t._texture)),a.roundPixels=this._renderer._roundPixels|t._roundPixels,r.addToBatch(a,e)}else r.break(e),i.shader||(i.shader=new Rg),this.updateRenderable(t),e.add(t)}execute(t){let{shader:e}=this._tilingSpriteDataHash[t.uid];e.groups[0]=this._renderer.globalUniforms.bindGroup;let r=e.resources.localUniforms.uniforms;r.uTransformMatrix=t.groupTransform,r.uRound=this._renderer._roundPixels|t._roundPixels,os(t.groupColorAlpha,r.uColor,0),this._state.blendMode=Jn(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:xs,shader:e,state:this._state})}updateRenderable(t){let e=this._getTilingSpriteData(t),{canBatch:r}=e;if(r){let{batchableMesh:i}=e;t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)}else if(t.didViewUpdate){let{shader:i}=e;i.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}destroyRenderable(t){let e=this._getTilingSpriteData(t);e
|
||
|
|
|
||
|
|
struct TextureUniforms {
|
||
|
|
uTextureMatrix:mat3x3<f32>,
|
||
|
|
}
|
||
|
|
|
||
|
|
@group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
|
||
|
|
`,main:`
|
||
|
|
uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
|
||
|
|
`},fragment:{header:`
|
||
|
|
@group(2) @binding(0) var uTexture: texture_2d<f32>;
|
||
|
|
@group(2) @binding(1) var uSampler: sampler;
|
||
|
|
|
||
|
|
|
||
|
|
`,main:`
|
||
|
|
outColor = textureSample(uTexture, uSampler, vUV);
|
||
|
|
`}},jg={name:"texture-bit",vertex:{header:`
|
||
|
|
uniform mat3 uTextureMatrix;
|
||
|
|
`,main:`
|
||
|
|
uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
|
||
|
|
`},fragment:{header:`
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
|
||
|
|
|
||
|
|
`,main:`
|
||
|
|
outColor = texture(uTexture, vUV);
|
||
|
|
`}}}),Zh,j1=_(()=>{J(),Ze(),Qi(),ys(),Ji(),Wg(),ti(),Dt(),Se(),Zh=class{init(){let t=is({name:"mesh",bits:[In,Vg,Mn]});this._shader=new Vr({gpuProgram:t,resources:{uTexture:Fe.EMPTY._source,uSampler:Fe.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new me}}}})}execute(t,e){let r=t.renderer,i=e._shader;if(!i)i=this._shader,i.groups[2]=r.texture.getTextureBindGroup(e.texture);else if(!i.gpuProgram){Be("Mesh shader has no gpuProgram",e.shader);return}let n=i.gpuProgram;if(n.autoAssignGlobalUniforms&&(i.groups[0]=r.globalUniforms.bindGroup),n.autoAssignLocalUniforms){let s=t.localUniforms;i.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(s,!0)}r.encoder.draw({geometry:e._geometry,shader:i,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}},Zh.extension={type:[O.WebGPUPipesAdaptor],name:"mesh"}}),Ss,Qh,W1=_(()=>{J(),ii(),Ul(),Ss=Fr.for2d(),Qh=class{start(t,e,r){let i=t.renderer,n=i.encoder,s=r.gpuProgram;this._shader=r,this._geometry=e,n.setGeometry(e,s),Ss.blendMode="normal",i.pipeline.getPipeline(e,s,Ss);let a=i.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,a,s)}execute(t,e){let r=this._shader.gpuProgram,i=t.renderer,n=i.encoder;if(!e.bindGroup){let o=e.textures;e.bindGroup=Fl(o.textures,o.count)}Ss.blendMode=e.blendMode;let s=i.bindGroup.getBindGroup(e.bindGroup,r,1),a=i.pipeline.getPipeline(this._geometry,r,Ss,e.topology);e.bindGroup._touch(i.textureGC.count),n.setPipeline(a),n.renderPassEncoder.setBindGroup(1,s),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}},Qh.extension={type:[O.WebGPUPipesAdaptor],name:"batch"}}),Jh,$1=_(()=>{J(),Jh=class{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}},Jh.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"customRender"}});function eu(t,e){let r=t.instructionSet,i=r.instructions;for(let n=0;n<r.instructionSize;n++){let s=i[n];e[s.renderPipeId].execute(s)}}var $g=_(()=>{"use strict"}),Xg,tu,X1=_(()=>{J(),Ze(),Kt(),Na(),$g(),Xg=new me,tu=class{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(it.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){let r=t._batchableRenderGroup??(t._batchableRenderGroup=it.get(hs));r.renderable=t.root,r.transform=t.root.relativeGroupTransform,r.texture=t.texture,r.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.batch.addToBatch(r,e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;let e=Xg.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295}),eu(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),eu(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}},tu.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"renderGroup"}});function ru(t,e){e||(e=0);for(let r=e;r<t.length&&t[r];r++)t[r]=null}var Yg=_(()=>{"use strict"});function qg(t,e=!1){Y1(t);let r=t.childrenToUpdate,i=t.updateTick++;for(let n in r){let s=Number(n),a=r[n],o=a.list,l=a.index;for(let h=0;h<l;h++){let u=o[h];u.parentRenderGroup===t&&u.relativ
|
||
|
|
in vec2 vTextureCoord;
|
||
|
|
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
uniform sampler2D uMaskTexture;
|
||
|
|
|
||
|
|
uniform float uAlpha;
|
||
|
|
uniform vec4 uMaskClamp;
|
||
|
|
uniform float uInverse;
|
||
|
|
|
||
|
|
out vec4 finalColor;
|
||
|
|
|
||
|
|
void main(void)
|
||
|
|
{
|
||
|
|
float clip = step(3.5,
|
||
|
|
step(uMaskClamp.x, vMaskCoord.x) +
|
||
|
|
step(uMaskClamp.y, vMaskCoord.y) +
|
||
|
|
step(vMaskCoord.x, uMaskClamp.z) +
|
||
|
|
step(vMaskCoord.y, uMaskClamp.w));
|
||
|
|
|
||
|
|
// TODO look into why this is needed
|
||
|
|
float npmAlpha = uAlpha;
|
||
|
|
vec4 original = texture(uTexture, vTextureCoord);
|
||
|
|
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
||
|
|
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
||
|
|
|
||
|
|
float a = alphaMul * masky.r * npmAlpha * clip;
|
||
|
|
|
||
|
|
if (uInverse == 1.0) {
|
||
|
|
a = 1.0 - a;
|
||
|
|
}
|
||
|
|
|
||
|
|
finalColor = original * a;
|
||
|
|
}
|
||
|
|
`}),im,rw=_(()=>{im=`in vec2 aPosition;
|
||
|
|
|
||
|
|
out vec2 vTextureCoord;
|
||
|
|
out vec2 vMaskCoord;
|
||
|
|
|
||
|
|
|
||
|
|
uniform vec4 uInputSize;
|
||
|
|
uniform vec4 uOutputFrame;
|
||
|
|
uniform vec4 uOutputTexture;
|
||
|
|
uniform mat3 uFilterMatrix;
|
||
|
|
|
||
|
|
vec4 filterVertexPosition( vec2 aPosition )
|
||
|
|
{
|
||
|
|
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
||
|
|
|
||
|
|
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
||
|
|
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
||
|
|
|
||
|
|
return vec4(position, 0.0, 1.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
vec2 filterTextureCoord( vec2 aPosition )
|
||
|
|
{
|
||
|
|
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
||
|
|
}
|
||
|
|
|
||
|
|
vec2 getFilterCoord( vec2 aPosition )
|
||
|
|
{
|
||
|
|
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
||
|
|
}
|
||
|
|
|
||
|
|
void main(void)
|
||
|
|
{
|
||
|
|
gl_Position = filterVertexPosition(aPosition);
|
||
|
|
vTextureCoord = filterTextureCoord(aPosition);
|
||
|
|
vMaskCoord = getFilterCoord(aPosition);
|
||
|
|
}
|
||
|
|
`}),hu,iw=_(()=>{hu=`struct GlobalFilterUniforms {
|
||
|
|
uInputSize:vec4<f32>,
|
||
|
|
uInputPixel:vec4<f32>,
|
||
|
|
uInputClamp:vec4<f32>,
|
||
|
|
uOutputFrame:vec4<f32>,
|
||
|
|
uGlobalFrame:vec4<f32>,
|
||
|
|
uOutputTexture:vec4<f32>,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct MaskUniforms {
|
||
|
|
uFilterMatrix:mat3x3<f32>,
|
||
|
|
uMaskClamp:vec4<f32>,
|
||
|
|
uAlpha:f32,
|
||
|
|
uInverse:f32,
|
||
|
|
};
|
||
|
|
|
||
|
|
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
||
|
|
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
||
|
|
@group(0) @binding(2) var uSampler : sampler;
|
||
|
|
|
||
|
|
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
||
|
|
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
||
|
|
|
||
|
|
struct VSOutput {
|
||
|
|
@builtin(position) position: vec4<f32>,
|
||
|
|
@location(0) uv : vec2<f32>,
|
||
|
|
@location(1) filterUv : vec2<f32>,
|
||
|
|
};
|
||
|
|
|
||
|
|
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
||
|
|
{
|
||
|
|
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
||
|
|
|
||
|
|
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
||
|
|
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
||
|
|
|
||
|
|
return vec4(position, 0.0, 1.0);
|
||
|
|
}
|
||
|
|
|
||
|
|
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
||
|
|
{
|
||
|
|
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
||
|
|
}
|
||
|
|
|
||
|
|
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
||
|
|
{
|
||
|
|
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
||
|
|
}
|
||
|
|
|
||
|
|
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
||
|
|
{
|
||
|
|
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
||
|
|
}
|
||
|
|
|
||
|
|
fn getSize() -> vec2<f32>
|
||
|
|
{
|
||
|
|
return gfu.uGlobalFrame.zw;
|
||
|
|
}
|
||
|
|
|
||
|
|
@vertex
|
||
|
|
fn mainVertex(
|
||
|
|
@location(0) aPosition : vec2<f32>,
|
||
|
|
) -> VSOutput {
|
||
|
|
return VSOutput(
|
||
|
|
filterVertexPosition(aPosition),
|
||
|
|
filterTextureCoord(aPosition),
|
||
|
|
getFilterCoord(aPosition)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
@fragment
|
||
|
|
fn mainFragment(
|
||
|
|
@location(0) uv: vec2<f32>,
|
||
|
|
@location(1) filterUv: vec2<f32>,
|
||
|
|
@builtin(position) position: vec4<f32>
|
||
|
|
) -> @location(0) vec4<f32> {
|
||
|
|
|
||
|
|
var maskClamp = filterUniforms.uMaskClamp;
|
||
|
|
var uAlpha = filterUniforms.uAlpha;
|
||
|
|
|
||
|
|
var clip = step(3.5,
|
||
|
|
step(maskClamp.x, filterUv.x) +
|
||
|
|
step(maskClamp.y, filterUv.y) +
|
||
|
|
step(filterUv.x, maskClamp.z) +
|
||
|
|
step(filterUv.y, maskClamp.w));
|
||
|
|
|
||
|
|
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
||
|
|
var source = textureSample(uTexture, uSampler, uv);
|
||
|
|
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
|
||
|
|
|
||
|
|
var a: f32 = alphaMul * mask.r * uAlpha * clip;
|
||
|
|
|
||
|
|
if (filterUniforms.uInverse == 1.0) {
|
||
|
|
a = 1.0 - a;
|
||
|
|
}
|
||
|
|
|
||
|
|
return source * a;
|
||
|
|
}
|
||
|
|
`}),nm,nw=_(()=>{Ze(),En(),rs(),xr(),rd(),N1(),tw(),rw(),iw(),nm=class extends Ug{constructor(t){let{sprite:e,...r}=t,i=new Jo(e.texture),n=new ur({uFilterMatrix:{value:new me,type:"mat3x3<f32>"},uMaskClamp:{value:i.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}}),s=Pn.from({vertex:{source:hu,entryPoint:"mainVertex"},fragment:{source:hu,entryPoint:"mainFragment"}}),a=Zi.from({vertex:im,fragment:rm,name:"mask-filter"});super({...r,gpuProgram:s,glProgram:a,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=i}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}apply(t,e,r,i){this._textureMatrix.texture=this.sprite.texture,t.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,t.applyFilter(this,e,r,i)}}}),sm,am,uu,sw=_(()=>{J(),fi(),nw(),T(),Q(),Ld(),Kt(),Dt(),Vi(),gi(),sm=new m,am=class extends kr{constructor(){super(),this.filters=[new nm({sprite:new oa(Fe.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}},uu=class{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,r){let i=this._renderer;if(i.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){let n=t.mask;n.includeInBuild=!0,n.collectRenderables(r,i,null),n.includeInBuild=!1}i.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){let e=this._renderer,r=t.mask.renderMaskToTexture;if(t.action==="pushMaskBegin"){let i=it.get(am);if(i.inverse=t.inverse,r){t.mask.mask.measurable=!0;let n=q(t.mask.mask,!0,sm);t.mask.mask.measurable=!1,n.ceil();let s=e.renderTarget.renderTarget.colorTexture.source,a=ar.getOptimalTexture(n.width,n.height,s._resolution,s.antialias);e.renderTarget.push(a,!0),e.globalUniforms.push({offset:n,worldColor:4294967295});let o=i.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer,filterTexture:a})}else i.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){let i=this._activeMaskStage[this._activeMaskStage.length-1];r&&(e.type===Gr.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:i.maskedContainer,filterEffect:i.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();let i=this._activeMaskStage.pop();r&&ar.returnTexture(i.filterTexture),it.return(i.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}},uu.extension={type:[O.WebGLPipes,O.WebGPUPipes,O.CanvasPipes],name:"alphaMask"}}),cu,aw=_(()=>{J(),cu=class{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,r){this._renderer.renderPipes.batch.break(r);let i=this._colorStack;i[this._colorStackIndex]=i[this._colorStackIndex-1]&t.mask;let n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,r.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,r){this._renderer.renderPipes.batch.break(r);let i=this._colorStack;this._colorStackIndex--;let n=i[this._colorStackIndex-1];n!==
|
||
|
|
|
||
|
|
`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Es} - ${t} - http://www.pixijs.com/`);_u=!0}}var _u,mw=_(()=>{tr(),em(),_u=!1}),oo,_w=_(()=>{J(),mw(),gi(),oo=class{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===Gr.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),gw(e)}}},oo.extension={type:[O.WebGLSystem,O.WebGPUSystem,O.CanvasSystem],name:"hello",priority:-2},oo.defaultOptions={hello:!1}});function vw(t){let e=!1;for(let i in t)if(t[i]==null){e=!0;break}if(!e)return t;let r=Object.create(null);for(let i in t){let n=t[i];n&&(r[i]=n)}return r}function yw(t){let e=0;for(let r=0;r<t.length;r++)t[r]==null?e++:t[r-e]=t[r];return t.length-=e,t}var xw=_(()=>{"use strict"}),pm,lo,gm,bw=_(()=>{J(),xw(),pm=0,lo=class xy{constructor(e){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=e}init(e){e={...xy.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime,this._frequency=e.renderableGCFrequency,this.enabled=e.renderableGCActive}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(let r of this._managedHashes)r.context[r.hash]=vw(r.context[r.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(let r of this._managedArrays)yw(r.context[r.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(e,r){this._managedHashes.push({context:e,hash:r})}addManagedArray(e,r){this._managedArrays.push({context:e,hash:r})}prerender({container:e}){this._now=performance.now(),e.renderGroup.gcTick=pm++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}addRenderable(e){this.enabled&&(e._lastUsed===-1&&(this._managedRenderables.push(e),e.once("destroyed",this._removeRenderable,this)),e._lastUsed=this._now)}run(){let e=this._now,r=this._managedRenderables,i=this._renderer.renderPipes,n=0;for(let s=0;s<r.length;s++){let a=r[s];if(a===null){n++;continue}let o=a.renderGroup??a.parentRenderGroup,l=o?.instructionSet?.gcTick??-1;if((o?.gcTick??0)===l&&(a._lastUsed=e),e-a._lastUsed>this.maxUnusedTime){if(!a.destroyed){let h=i;o&&(o.structureDidChange=!0),h[a.renderPipeId].destroyRenderable(a)}a._lastUsed=-1,n++,a.off("destroyed",this._removeRenderable,this)}else r[s-n]=a}r.length-=n}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(e){let r=this._managedRenderables.indexOf(e);r>=0&&(e.off("destroyed",this._removeRenderable,this),this._managedRenderables[r]=null)}_updateInstructionGCTick(e,r){e.instructionSet.gcTick=r;for(let i of e.renderGroupChildren)this._updateInstructionGCTick(i,r)}},lo.extension={type:[O.WebGLSystem,O.WebGPUSystem],name:"renderableGC",priority:0},lo.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4},gm=lo}),ho,mm,ww=_(()=>{J(),ho=class by{constructor(e){this._renderer=e,this.count=0,this.checkCount=0}init(e){e={...by.defaultOptions,...e},this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=e.textureGCAMaxIdle??e.textureGCMaxIdle,this.active=e.textureGCActive}postrender(){this._renderer.renderingToScreen&&(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let e=this._renderer.texture.managedTextures;for(let r=0;r<e.length;r++){let i=e[r];i.autoGarbageCollect&&i.resource&&i._touched>-1&&this.count-i._touched>this.maxIdle&&(i._touched=-1,i.unload())}}destroy(){this._renderer=nu
|
||
|
|
var matrix = uv[name].toArray(true);
|
||
|
|
data[offset] = matrix[0];
|
||
|
|
data[offset + 1] = matrix[1];
|
||
|
|
data[offset + 2] = matrix[2];
|
||
|
|
data[offset + 4] = matrix[3];
|
||
|
|
data[offset + 5] = matrix[4];
|
||
|
|
data[offset + 6] = matrix[5];
|
||
|
|
data[offset + 8] = matrix[6];
|
||
|
|
data[offset + 9] = matrix[7];
|
||
|
|
data[offset + 10] = matrix[8];
|
||
|
|
`,uniform:`
|
||
|
|
gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));
|
||
|
|
`},{type:"vec4<f32>",test:t=>t.type==="vec4<f32>"&&t.size===1&&t.value.width!==void 0,ubo:`
|
||
|
|
v = uv[name];
|
||
|
|
data[offset] = v.x;
|
||
|
|
data[offset + 1] = v.y;
|
||
|
|
data[offset + 2] = v.width;
|
||
|
|
data[offset + 3] = v.height;
|
||
|
|
`,uniform:`
|
||
|
|
cv = ud[name].value;
|
||
|
|
v = uv[name];
|
||
|
|
if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {
|
||
|
|
cv[0] = v.x;
|
||
|
|
cv[1] = v.y;
|
||
|
|
cv[2] = v.width;
|
||
|
|
cv[3] = v.height;
|
||
|
|
gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);
|
||
|
|
}
|
||
|
|
`},{type:"vec2<f32>",test:t=>t.type==="vec2<f32>"&&t.size===1&&t.value.x!==void 0,ubo:`
|
||
|
|
v = uv[name];
|
||
|
|
data[offset] = v.x;
|
||
|
|
data[offset + 1] = v.y;
|
||
|
|
`,uniform:`
|
||
|
|
cv = ud[name].value;
|
||
|
|
v = uv[name];
|
||
|
|
if (cv[0] !== v.x || cv[1] !== v.y) {
|
||
|
|
cv[0] = v.x;
|
||
|
|
cv[1] = v.y;
|
||
|
|
gl.uniform2f(ud[name].location, v.x, v.y);
|
||
|
|
}
|
||
|
|
`},{type:"vec4<f32>",test:t=>t.type==="vec4<f32>"&&t.size===1&&t.value.red!==void 0,ubo:`
|
||
|
|
v = uv[name];
|
||
|
|
data[offset] = v.red;
|
||
|
|
data[offset + 1] = v.green;
|
||
|
|
data[offset + 2] = v.blue;
|
||
|
|
data[offset + 3] = v.alpha;
|
||
|
|
`,uniform:`
|
||
|
|
cv = ud[name].value;
|
||
|
|
v = uv[name];
|
||
|
|
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {
|
||
|
|
cv[0] = v.red;
|
||
|
|
cv[1] = v.green;
|
||
|
|
cv[2] = v.blue;
|
||
|
|
cv[3] = v.alpha;
|
||
|
|
gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);
|
||
|
|
}
|
||
|
|
`},{type:"vec3<f32>",test:t=>t.type==="vec3<f32>"&&t.size===1&&t.value.red!==void 0,ubo:`
|
||
|
|
v = uv[name];
|
||
|
|
data[offset] = v.red;
|
||
|
|
data[offset + 1] = v.green;
|
||
|
|
data[offset + 2] = v.blue;
|
||
|
|
`,uniform:`
|
||
|
|
cv = ud[name].value;
|
||
|
|
v = uv[name];
|
||
|
|
if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {
|
||
|
|
cv[0] = v.red;
|
||
|
|
cv[1] = v.green;
|
||
|
|
cv[2] = v.blue;
|
||
|
|
gl.uniform3f(ud[name].location, v.red, v.green, v.blue);
|
||
|
|
}
|
||
|
|
`}]});function Em(t,e,r,i){let n=[`
|
||
|
|
var v = null;
|
||
|
|
var v2 = null;
|
||
|
|
var t = 0;
|
||
|
|
var index = 0;
|
||
|
|
var name = null;
|
||
|
|
var arrayOffset = null;
|
||
|
|
`],s=0;for(let o=0;o<t.length;o++){let l=t[o],h=l.data.name,u=!1,c=0;for(let f=0;f<Ii.length;f++)if(Ii[f].test(l.data)){c=l.offset/4,n.push(`name = "${h}";`,`offset += ${c-s};`,Ii[f][e]||Ii[f].ubo),u=!0;break}if(!u)if(l.data.size>1)c=l.offset/4,n.push(r(l,c-s));else{let f=i[l.data.type];c=l.offset/4,n.push(`
|
||
|
|
v = uv.${h};
|
||
|
|
offset += ${c-s};
|
||
|
|
${f};
|
||
|
|
`)}s=c}let a=n.join(`
|
||
|
|
`);return new Function("uv","data","dataInt32","offset",a)}var Cm=_(()=>{Sm()});function Fn(t,e){return`
|
||
|
|
for (let i = 0; i < ${t*e}; i++) {
|
||
|
|
data[offset + (((i / ${t})|0) * 4) + (i % ${t})] = v[i];
|
||
|
|
}
|
||
|
|
`}var Au,Am,Pm=_(()=>{"use strict";Au={f32:`
|
||
|
|
data[offset] = v;`,i32:`
|
||
|
|
dataInt32[offset] = v;`,"vec2<f32>":`
|
||
|
|
data[offset] = v[0];
|
||
|
|
data[offset + 1] = v[1];`,"vec3<f32>":`
|
||
|
|
data[offset] = v[0];
|
||
|
|
data[offset + 1] = v[1];
|
||
|
|
data[offset + 2] = v[2];`,"vec4<f32>":`
|
||
|
|
data[offset] = v[0];
|
||
|
|
data[offset + 1] = v[1];
|
||
|
|
data[offset + 2] = v[2];
|
||
|
|
data[offset + 3] = v[3];`,"vec2<i32>":`
|
||
|
|
dataInt32[offset] = v[0];
|
||
|
|
dataInt32[offset + 1] = v[1];`,"vec3<i32>":`
|
||
|
|
dataInt32[offset] = v[0];
|
||
|
|
dataInt32[offset + 1] = v[1];
|
||
|
|
dataInt32[offset + 2] = v[2];`,"vec4<i32>":`
|
||
|
|
dataInt32[offset] = v[0];
|
||
|
|
dataInt32[offset + 1] = v[1];
|
||
|
|
dataInt32[offset + 2] = v[2];
|
||
|
|
dataInt32[offset + 3] = v[3];`,"mat2x2<f32>":`
|
||
|
|
data[offset] = v[0];
|
||
|
|
data[offset + 1] = v[1];
|
||
|
|
data[offset + 4] = v[2];
|
||
|
|
data[offset + 5] = v[3];`,"mat3x3<f32>":`
|
||
|
|
data[offset] = v[0];
|
||
|
|
data[offset + 1] = v[1];
|
||
|
|
data[offset + 2] = v[2];
|
||
|
|
data[offset + 4] = v[3];
|
||
|
|
data[offset + 5] = v[4];
|
||
|
|
data[offset + 6] = v[5];
|
||
|
|
data[offset + 8] = v[6];
|
||
|
|
data[offset + 9] = v[7];
|
||
|
|
data[offset + 10] = v[8];`,"mat4x4<f32>":`
|
||
|
|
for (let i = 0; i < 16; i++) {
|
||
|
|
data[offset + i] = v[i];
|
||
|
|
}`,"mat3x2<f32>":Fn(3,2),"mat4x2<f32>":Fn(4,2),"mat2x3<f32>":Fn(2,3),"mat4x3<f32>":Fn(4,3),"mat2x4<f32>":Fn(2,4),"mat3x4<f32>":Fn(3,4)},Am={...Au,"mat2x2<f32>":`
|
||
|
|
data[offset] = v[0];
|
||
|
|
data[offset + 1] = v[1];
|
||
|
|
data[offset + 2] = v[2];
|
||
|
|
data[offset + 3] = v[3];
|
||
|
|
`}});function kw(t,e){let{size:r,align:i}=Cs[t.data.type],n=(i-r)/4,s=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
||
|
|
v = uv.${t.data.name};
|
||
|
|
${e!==0?`offset += ${e};`:""}
|
||
|
|
|
||
|
|
arrayOffset = offset;
|
||
|
|
|
||
|
|
t = 0;
|
||
|
|
|
||
|
|
for(var i=0; i < ${t.data.size*(r/4)}; i++)
|
||
|
|
{
|
||
|
|
for(var j = 0; j < ${r/4}; j++)
|
||
|
|
{
|
||
|
|
${s}[arrayOffset++] = v[t++];
|
||
|
|
}
|
||
|
|
${n!==0?`arrayOffset += ${n};`:""}
|
||
|
|
}
|
||
|
|
`}var Bw=_(()=>{Tm()});function Iw(t){return Em(t,"uboWgsl",kw,Am)}var Ow=_(()=>{Cm(),Pm(),Bw()}),Pu,Gw=_(()=>{J(),wm(),Tm(),Ow(),Pu=class extends Cu{constructor(){super({createUboElements:Rw,generateUboSync:Iw})}},Pu.extension={type:[O.WebGPUSystem],name:"ubo"}}),po,Mu=_(()=>{It(),jt(),po=class extends at{constructor({buffer:t,offset:e,size:r}){super(),this.uid=Mt("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=Mt("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=r,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=Mt("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}}),Mm,Fw=_(()=>{"use strict";Mm=class{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);let e=this.byteIndex,r=e+t*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,e}addGroup(t){let e=this.addEmptyGroup(t.length);for(let r=0;r<t.length;r++)this.data[e/4+r]=t[r];return e}destroy(){this.data=null}}}),mi,Ru,Dw=_(()=>{J(),Ki(),Mu(),Mi(),Fw(),Xi(),mi=128,Ru=class{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new Mm({minUniformOffsetAlignment:mi});let e=256/mi;for(let r=0;r<e;r++){let i=dt.UNIFORM|dt.COPY_DST;r===0&&(i|=dt.COPY_SRC),this._buffers.push(new yr({data:this._batchBuffer.data,usage:i}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(let t in this._bindGroupHash)this._bindGroupHash[t]=null;this._batchBuffer.clear()}getUniformBindGroup(t,e){if(!e&&this._bindGroupHash[t.uid])return this._bindGroupHash[t.uid];this._renderer.ubo.ensureUniformGroup(t);let r=t.buffer.data,i=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,i/4),this._bindGroupHash[t.uid]=this._getBindGroup(i/mi),this._bindGroupHash[t.uid]}getUboResource(t){this._renderer.ubo.updateUniformGroup(t);let e=t.buffer.data,r=this._batchBuffer.addGroup(e);return this._getBufferResource(r/mi)}getArrayBindGroup(t){let e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/mi)}getArrayBufferResource(t){let e=this._batchBuffer.addGroup(t)/mi;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){let e=this._buffers[t%2];this._bufferResources[t]=new po({buffer:e,offset:(t/2|0)*256,size:mi})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){let e=new ei({0:this._getBufferResource(t)});this._bindGroups[t]=e}return this._bindGroups[t]}_uploadBindGroups(){let t=this._renderer.buffer,e=this._buffers[0];e.update(this._batchBuffer.byteIndex),t.updateBuffer(e);let r=this._renderer.gpu.device.createCommandEncoder();for(let i=1;i<this._buffers.length;i++){let n=this._buffers[i];r.copyBufferToBuffer(t.getGPUBuffer(e),mi,t.getGPUBuffer(n),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([r.finish()])}destroy(){for(let t=0;t<this._bindGroups.length;t++)this._bindGroups[t].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let t=0;t<this._buffers.length;t++)this._buffers[t].destroy();this._buffers=null;for(let t=0;t<this._bufferResources.length;t++)this._bufferResources[t].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}},Ru.extension={type:[O.WebGPUPipes],name:"uniformBatch"}});function Rm(t,e){for(let r in t.attributes){let i=t.attributes[r],n=e[r];n?(i.format??(i.format=n.format),i.offset??(i.offset=n.offset),
|
||
|
|
var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||
|
|
vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
|
||
|
|
|
||
|
|
struct VertexOutput {
|
||
|
|
@builtin(position) position : vec4<f32>,
|
||
|
|
@location(0) texCoord : vec2<f32>,
|
||
|
|
};
|
||
|
|
|
||
|
|
@vertex
|
||
|
|
fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
|
||
|
|
var output : VertexOutput;
|
||
|
|
output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
|
||
|
|
output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
|
||
|
|
return output;
|
||
|
|
}
|
||
|
|
|
||
|
|
@group(0) @binding(0) var imgSampler : sampler;
|
||
|
|
@group(0) @binding(1) var img : texture_2d<f32>;
|
||
|
|
|
||
|
|
@fragment
|
||
|
|
fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||
|
|
return textureSample(img, imgSampler, texCoord);
|
||
|
|
}
|
||
|
|
`})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){let e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let r=t,i=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){let o={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};r=this.device.createTexture(o)}let s=this.device.createCommandEncoder({}),a=e.getBindGroupLayout(0);for(let o=0;o<i;++o){let l=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),h=n?1:0;for(let u=1;u<t.mipLevelCount;++u){let c=r.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),f=s.beginRenderPass({colorAttachments:[{view:c,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),d=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:l}]});f.setPipeline(e),f.setBindGroup(0,d),f.draw(3,1,0,0),f.end(),l=c}}if(!n){let o={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:i};for(let l=1;l<t.mipLevelCount;++l)s.copyTextureToTexture({texture:r,mipLevel:l-1},{texture:t,mipLevel:l},o),o.width=Math.ceil(o.width/2),o.height=Math.ceil(o.height/2)}return this.device.queue.submit([s.finish()]),n||r.destroy(),t}}}),Uu,rT=_(()=>{tr(),J(),xr(),us(),Xi(),Qw(),Jw(),Nm(),eT(),tT(),Uu=class{constructor(t){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:Du,buffer:Dm,video:Hm,compressed:Lm},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){if(t.autoGenerateMipmaps){let o=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(o))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);let r=Fu[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},i=Math.ceil(t.pixelWidth/r.blockWidth)*r.blockWidth,n=Math.ceil(t.pixelHeight/r.blockHeight)*r.blockHeight,s={label:t.label,size:{width:i,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},a=this._gpu.device.createTexture(s);return this._gpuSources[t.uid]=a,this.managedTextures.includes(t)||(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("destroy",this.onSourceDestroy,this),t.on("unload",this.onSourceUnload,this),t.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(t)),this.onSourceUpdate(t),a}onSourceUpdate(t){let e=this.getGpuSource(t);e&&(this._uploads[t.uploadMethodId]&&this._uploads[t.uploadMethodId].upload(t,e,this._gpu),t.autoGenerateMipmaps&&t.mipLevelCount>1&&this.onUpdateMipmaps(t))}onSourceUnload(t){let e=this._gpuSources[t.uid];e&&(this._gpuSources[t.uid]=null,e.destroy())}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new zm(this._gpu.device));let e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceDestroy(t){t.off("update",this.onSourceUpdate,this),t.off("unload",this.onSourceUnload,this),t.off("destroy",this.onSourceDestroy,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(t),1),this.onSourceUnload(t)}onSourceResize(t){let e=t
|
||
|
|
attribute vec2 aPosition;
|
||
|
|
out vec2 vUv;
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
||
|
|
|
||
|
|
vUv = (aPosition + 1.0) / 2.0;
|
||
|
|
|
||
|
|
// flip dem UVs
|
||
|
|
vUv.y = 1.0 - vUv.y;
|
||
|
|
}`,fragment:`
|
||
|
|
in vec2 vUv;
|
||
|
|
out vec4 finalColor;
|
||
|
|
|
||
|
|
uniform sampler2D uTexture;
|
||
|
|
|
||
|
|
void main() {
|
||
|
|
finalColor = texture(uTexture, vUv);
|
||
|
|
}`,name:"big-triangle"});this._bigTriangleShader=new Vr({glProgram:n,resources:{uTexture:Fe.WHITE.source}})}renderStart(e){let r=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!r.isRoot,this._useBackBufferThisRender){let i=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=i.colorTexture,e.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){let e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:Qm,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new Fe({source:new er({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}},_o.extension={type:[O.WebGLSystem],name:"backBuffer",priority:1},_o.defaultOptions={useBackBuffer:!1},Jm=_o}),qu,gT=_(()=>{J(),qu=class{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}},qu.extension={type:[O.WebGLSystem],name:"colorMask"}}),Ku,mT=_(()=>{J(),Ku=class{constructor(t){this.commandFinished=Promise.resolve(),this._renderer=t}setGeometry(t,e){this._renderer.geometry.bind(t,e.glProgram)}finishRenderPass(){}draw(t){let e=this._renderer,{geometry:r,shader:i,state:n,skipSync:s,topology:a,size:o,start:l,instanceCount:h}=t;e.shader.bind(i,s),e.geometry.bind(r,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(a,o,l,h??r.instanceCount)}destroy(){this._renderer=null}},Ku.extension={type:[O.WebGLSystem],name:"encoder"}}),Zu,_T=_(()=>{J(),Bm(),wn(),Zu=class{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Wt.NONE},this._renderTargetStencilState=Object.create(null),t.renderTarget.onRenderTargetChange.add(this)}contextChange(t){this._gl=t,this._comparisonFuncMapping={always:t.ALWAYS,never:t.NEVER,equal:t.EQUAL,"not-equal":t.NOTEQUAL,less:t.LESS,"less-equal":t.LEQUAL,greater:t.GREATER,"greater-equal":t.GEQUAL},this._stencilOpsMapping={keep:t.KEEP,zero:t.ZERO,replace:t.REPLACE,invert:t.INVERT,"increment-clamp":t.INCR,"decrement-clamp":t.DECR,"increment-wrap":t.INCR_WRAP,"decrement-wrap":t.DECR_WRAP},this.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:Wt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Wt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){let r=this._renderTargetStencilState[this._activeRenderTarget.uid],i=this._gl,n=_i[t],s=this._stencilCache;if(r.stencilMode=t,r.stencilReference=e,t===Wt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,i.disable(i.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,i.enable(i.STENCIL_TEST)),(t!==s.stencilMode||s.stencilReference!==e)&&(s.stencilMode=t,s.stencilReference=e,i.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),i.stencilOp(i.KEEP,i.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))}},Zu.extension={type:[O.WebGLSystem],name:"stencil"}});function vT(t){let e=t.map(s=>({data:s,offset:0,size:0})),r=16,i=0,n=0;for(let s=0;s<e.length;s++){let a=e[s];if(i=Qu[a.data.type],!i)throw new Error(`Unknown type ${a.data.type}`);a.data.size>1&&(i=Math.max(i,r)*a.data.size);let o=i===12?16:i;a.size=i;let l=n%r;l>0&&r-l<o?n+=(r-l)%16:n+=(i-l%i)%i,a.offset=n,n+=i}return n=Math.ceil(n/16)*16,{uboElements:e,size:n}}var Qu,e_=_(
|
||
|
|
v = uv.${t.data.name};
|
||
|
|
offset += ${e};
|
||
|
|
|
||
|
|
arrayOffset = offset;
|
||
|
|
|
||
|
|
t = 0;
|
||
|
|
|
||
|
|
for(var i=0; i < ${t.data.size*r}; i++)
|
||
|
|
{
|
||
|
|
for(var j = 0; j < ${i}; j++)
|
||
|
|
{
|
||
|
|
${s}[arrayOffset++] = v[t++];
|
||
|
|
}
|
||
|
|
${n!==0?`arrayOffset += ${n};`:""}
|
||
|
|
}
|
||
|
|
`}var xT=_(()=>{e_()});function bT(t){return Em(t,"uboStd40",yT,Au)}var wT=_(()=>{Cm(),Pm(),xT()}),Ju,TT=_(()=>{J(),wm(),e_(),wT(),Ju=class extends Cu{constructor(){super({createUboElements:vT,generateUboSync:bT})}},Ju.extension={type:[O.WebGLSystem],name:"ubo"}}),t_,ST=_(()=>{"use strict";t_=class{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}}),r_,ET=_(()=>{S(),Se(),Zn(),ws(),ST(),r_=class{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new b}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new b}copyToTexture(t,e,r,i,n){let s=this._renderTargetSystem,a=this._renderer,o=s.getGpuRenderTarget(t),l=a.gl;return this.finishRenderPass(t),l.bindFramebuffer(l.FRAMEBUFFER,o.resolveTargetFramebuffer),a.texture.bind(e,0),l.copyTexSubImage2D(l.TEXTURE_2D,0,n.x,n.y,r.x,r.y,i.width,i.height),e}startRenderPass(t,e=!0,r,i){let n=this._renderTargetSystem,s=t.colorTexture,a=n.getGpuRenderTarget(t),o=i.y;t.isRoot&&(o=s.pixelHeight-i.height),t.colorTextures.forEach(u=>{this._renderer.texture.unbind(u)});let l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,a.framebuffer);let h=this._viewPortCache;(h.x!==i.x||h.y!==o||h.width!==i.width||h.height!==i.height)&&(h.x=i.x,h.y=o,h.width=i.width,h.height=i.height,l.viewport(i.x,o,i.width,i.height)),!a.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(a),this.clear(t,e,r)}finishRenderPass(t){let e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;let r=this._renderer.gl;r.bindFramebuffer(r.FRAMEBUFFER,e.resolveTargetFramebuffer),r.bindFramebuffer(r.READ_FRAMEBUFFER,e.framebuffer),r.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,r.COLOR_BUFFER_BIT,r.NEAREST),r.bindFramebuffer(r.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){let e=this._renderer.gl,r=new t_,i=t.colorTexture;return Jr.test(i.resource)?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),r.framebuffer=null,r):(this._initColor(t,r),e.bindFramebuffer(e.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(t){let e=this._renderer.gl;t.framebuffer&&(e.deleteFramebuffer(t.framebuffer),t.framebuffer=null),t.resolveTargetFramebuffer&&(e.deleteFramebuffer(t.resolveTargetFramebuffer),t.resolveTargetFramebuffer=null),t.depthStencilRenderBuffer&&(e.deleteRenderbuffer(t.depthStencilRenderBuffer),t.depthStencilRenderBuffer=null),t.msaaRenderBuffer.forEach(r=>{e.deleteRenderbuffer(r)}),t.msaaRenderBuffer=null}clear(t,e,r){if(!e)return;let i=this._renderTargetSystem;typeof e=="boolean"&&(e=e?br.ALL:br.NONE);let n=this._renderer.gl;if(e&br.COLOR){r??(r=i.defaultClearColor);let s=this._clearColorCache,a=r;(s[0]!==a[0]||s[1]!==a[1]||s[2]!==a[2]||s[3]!==a[3])&&(s[0]=a[0],s[1]=a[1],s[2]=a[2],s[3]=a[3],n.clearColor(a[0],a[1],a[2],a[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;let e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){let r=this._renderer,i=r.gl,n=i.createFramebuffer();if(e.resolveTargetFramebuffer=n,i.bindFramebuffer(i.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((s,a)=>{let o=s.source;o.antialias&&(r.context.supports.msaa?e.msaa=!0:Be("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),r.texture.bindSource(o,0);let l=r.texture.getGlSource(o).texture;i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+a,3553,l,0)}),e.msaa){let s=i.createFramebuffer();e.framebuffer=s,i.bindFramebuffer(i.FRAMEBUFFER,s),t.colorTextures.forEach((a,o)=>{let l=i.createRenderbuffer();e.msaaRenderBuffer[o]=l})}else e.framebuffer=n;this._resizeColor(t,e)}_resizeColor(t,e){let r=t.colorTexture.source;if(e.width=r.pixelWidth,e.height=r.pixelHeight,t.colorTextures.forEach((i,n)=>{n!==0&&i.source.resize(r.width,r.height,r._resolution)}),e.msaa){let i=this._renderer,n=i.gl,s=e.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,s),t.colorTextures.forEach((a,o)=>{let l=a.so
|
||
|
|
var g = s.groups;
|
||
|
|
var sS = r.shader;
|
||
|
|
var p = s.glProgram;
|
||
|
|
var ugS = r.uniformGroup;
|
||
|
|
var resources;
|
||
|
|
`],n=!1,s=0,a=e._getProgramData(t.glProgram);for(let l in t.groups){let h=t.groups[l];r.push(`
|
||
|
|
resources = g[${l}].resources;
|
||
|
|
`);for(let u in h.resources){let c=h.resources[u];if(c instanceof ur)if(c.ubo){let f=t._uniformBindMap[l][Number(u)];r.push(`
|
||
|
|
sS.bindUniformBlock(
|
||
|
|
resources[${u}],
|
||
|
|
'${f}',
|
||
|
|
${t.glProgram._uniformBlockData[f].index}
|
||
|
|
);
|
||
|
|
`)}else r.push(`
|
||
|
|
ugS.updateUniformGroup(resources[${u}], p, sD);
|
||
|
|
`);else if(c instanceof po){let f=t._uniformBindMap[l][Number(u)];r.push(`
|
||
|
|
sS.bindUniformBlock(
|
||
|
|
resources[${u}],
|
||
|
|
'${f}',
|
||
|
|
${t.glProgram._uniformBlockData[f].index}
|
||
|
|
);
|
||
|
|
`)}else if(c instanceof er){let f=t._uniformBindMap[l][u],d=a.uniformData[f];d&&(n||(n=!0,i.push(`
|
||
|
|
var tS = r.texture;
|
||
|
|
`)),e._gl.uniform1i(d.location,s),r.push(`
|
||
|
|
tS.bind(resources[${u}], ${s});
|
||
|
|
`),s++)}}}let o=[...i,...r].join(`
|
||
|
|
`);return new Function("r","s","sD",o)}var PT=_(()=>{Mu(),xr(),Er()}),i_,MT=_(()=>{"use strict";i_=class{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}});function n_(t,e,r){let i=t.createShader(e);return t.shaderSource(i,r),t.compileShader(i),i}var RT=_(()=>{"use strict"});function tc(t){let e=new Array(t);for(let r=0;r<e.length;r++)e[r]=!1;return e}function s_(t,e){switch(t){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return tc(2*e);case"bvec3":return tc(3*e);case"bvec4":return tc(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var a_=_(()=>{"use strict"});function o_(t,e){if(!Ps){let r=Object.keys(rc);Ps={};for(let i=0;i<r.length;++i){let n=r[i];Ps[t[n]]=rc[n]}}return Ps[e]}function kT(t,e){let r=o_(t,e);return l_[r]||"float32"}var Ps,rc,l_,h_=_(()=>{"use strict";Ps=null,rc={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},l_={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"}});function BT(t,e,r=!1){let i={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let a=0;a<n;a++){let o=e.getActiveAttrib(t,a);if(o.name.startsWith("gl_"))continue;let l=kT(e,o.type);i[o.name]={location:0,format:l,stride:Ri(l).stride,offset:0,instance:!1,start:0}}let s=Object.keys(i);if(r){s.sort((a,o)=>a>o?1:-1);for(let a=0;a<s.length;a++)i[s[a]].location=a,e.bindAttribLocation(t,a,s[a]);e.linkProgram(t)}else for(let a=0;a<s.length;a++)i[s[a]].location=e.getAttribLocation(t,s[a]);return i}var IT=_(()=>{Cn(),h_()});function OT(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};let r={},i=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let n=0;n<i;n++){let s=e.getActiveUniformBlockName(t,n),a=e.getUniformBlockIndex(t,s),o=e.getActiveUniformBlockParameter(t,n,e.UNIFORM_BLOCK_DATA_SIZE);r[s]={name:s,index:a,size:o}}return r}var GT=_(()=>{"use strict"});function FT(t,e){let r={},i=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<i;n++){let s=e.getActiveUniform(t,n),a=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),l=o_(e,s.type);r[a]={name:a,index:n,type:l,size:s.size,isArray:o,value:s_(l,s.size)}}return r}var DT=_(()=>{a_(),h_()});function u_(t,e){let r=t.getShaderSource(e).split(`
|
||
|
|
`).map((h,u)=>`${u}: ${h}`),i=t.getShaderInfoLog(e),n=i.split(`
|
||
|
|
`),s={},a=n.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!s[h]?(s[h]=!0,!0):!1),o=[""];a.forEach(h=>{r[h-1]=`%c${r[h-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});let l=r.join(`
|
||
|
|
`);o[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function UT(t,e,r,i){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(r,t.COMPILE_STATUS)||u_(t,r),t.getShaderParameter(i,t.COMPILE_STATUS)||u_(t,i),console.error("PixiJS Error: Could not initialize shader."),t.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",t.getProgramInfoLog(e)))}var LT=_(()=>{"use strict"});function NT(t,e){let r=n_(t,t.VERTEX_SHADER,e.vertex),i=n_(t,t.FRAGMENT_SHADER,e.fragment),n=t.createProgram();t.attachShader(n,r),t.attachShader(n,i);let s=e.transformFeedbackVaryings;s&&(typeof t.transformFeedbackVaryings!="function"?Be("TransformFeedback is not supported but TransformFeedbackVaryings are given."):t.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||UT(t,n,r,i),e._attributeData=BT(n,t,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=FT(n,t),e._uniformBlockData=OT(n,t),t.deleteShader(r),t.deleteShader(i);let a={};for(let o in e._uniformData){let l=e._uniformData[o];a[o]={location:t.getUniformLocation(n,o),value:s_(l.type,l.size)}}return new i_(n,a)}var HT=_(()=>{Se(),MT(),RT(),a_(),IT(),GT(),DT(),LT()}),Ms,ic,zT=_(()=>{J(),bn(),PT(),HT(),Ms={textureCount:0,blockIndex:0},ic=class{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null,this.maxTextures=xn()}bind(t,e){if(this._setProgram(t.glProgram),e)return;Ms.textureCount=0,Ms.blockIndex=0;let r=this._shaderSyncFunctions[t.glProgram._key];r||(r=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),r(this._renderer,t,Ms)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,Ms)}bindUniformBlock(t,e,r=0){let i=this._renderer.buffer,n=this._getProgramData(this._activeProgram),s=t._bufferResource;s||this._renderer.ubo.updateUniformGroup(t);let a=t.buffer,o=i.updateBuffer(a),l=i.freeLocationForBufferBase(o);if(s){let{offset:u,size:c}=t;u===0&&c===a.data.byteLength?i.bindBufferBase(o,l):i.bindBufferRange(o,l,u)}else i.getLastBindBaseLocation(o)!==l&&i.bindBufferBase(o,l);let h=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[r]!==l&&(n.uniformBlockBindings[r]=l,this._renderer.gl.uniformBlockBinding(n.program,h,l))}_setProgram(t){if(this._activeProgram===t)return;this._activeProgram=t;let e=this._getProgramData(t);this._gl.useProgram(e.program)}_getProgramData(t){return this._programDataHash[t._key]||this._createProgramData(t)}_createProgramData(t){let e=t._key;return this._programDataHash[e]=NT(this._gl,t),this._programDataHash[e]}destroy(){for(let t of Object.keys(this._programDataHash))this._programDataHash[t].destroy(),this._programDataHash[t]=null;this._programDataHash=null}_generateShaderSync(t,e){return AT(t,e)}resetState(){this._activeProgram=null}},ic.extension={type:[O.WebGLSystem],name:"shader"}}),c_,d_,VT=_(()=>{"use strict";c_={f32:`if (cv !== v) {
|
||
|
|
cu.value = v;
|
||
|
|
gl.uniform1f(location, v);
|
||
|
|
}`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
gl.uniform2f(location, v[0], v[1]);
|
||
|
|
}`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
gl.uniform3f(location, v[0], v[1], v[2]);
|
||
|
|
}`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
cv[3] = v[3];
|
||
|
|
gl.uniform4f(location, v[0], v[1], v[2], v[3]);
|
||
|
|
}`,i32:`if (cv !== v) {
|
||
|
|
cu.value = v;
|
||
|
|
gl.uniform1i(location, v);
|
||
|
|
}`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
gl.uniform2i(location, v[0], v[1]);
|
||
|
|
}`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
gl.uniform3i(location, v[0], v[1], v[2]);
|
||
|
|
}`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
cv[3] = v[3];
|
||
|
|
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
||
|
|
}`,u32:`if (cv !== v) {
|
||
|
|
cu.value = v;
|
||
|
|
gl.uniform1ui(location, v);
|
||
|
|
}`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
gl.uniform2ui(location, v[0], v[1]);
|
||
|
|
}`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
gl.uniform3ui(location, v[0], v[1], v[2]);
|
||
|
|
}`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
cv[3] = v[3];
|
||
|
|
gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
|
||
|
|
}`,bool:`if (cv !== v) {
|
||
|
|
cu.value = v;
|
||
|
|
gl.uniform1i(location, v);
|
||
|
|
}`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
gl.uniform2i(location, v[0], v[1]);
|
||
|
|
}`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
gl.uniform3i(location, v[0], v[1], v[2]);
|
||
|
|
}`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
|
||
|
|
cv[0] = v[0];
|
||
|
|
cv[1] = v[1];
|
||
|
|
cv[2] = v[2];
|
||
|
|
cv[3] = v[3];
|
||
|
|
gl.uniform4i(location, v[0], v[1], v[2], v[3]);
|
||
|
|
}`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},d_={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"}});function jT(t,e){let r=[`
|
||
|
|
var v = null;
|
||
|
|
var cv = null;
|
||
|
|
var cu = null;
|
||
|
|
var t = 0;
|
||
|
|
var gl = renderer.gl;
|
||
|
|
var name = null;
|
||
|
|
`];for(let i in t.uniforms){if(!e[i]){t.uniforms[i]instanceof ur?t.uniforms[i].ubo?r.push(`
|
||
|
|
renderer.shader.bindUniformBlock(uv.${i}, "${i}");
|
||
|
|
`):r.push(`
|
||
|
|
renderer.shader.updateUniformGroup(uv.${i});
|
||
|
|
`):t.uniforms[i]instanceof po&&r.push(`
|
||
|
|
renderer.shader.bindBufferResource(uv.${i}, "${i}");
|
||
|
|
`);continue}let n=t.uniformStructures[i],s=!1;for(let a=0;a<Ii.length;a++){let o=Ii[a];if(n.type===o.type&&o.test(n)){r.push(`name = "${i}";`,Ii[a].uniform),s=!0;break}}if(!s){let a=(n.size===1?c_:d_)[n.type].replace("location",`ud["${i}"].location`);r.push(`
|
||
|
|
cu = ud["${i}"];
|
||
|
|
cv = cu.value;
|
||
|
|
v = uv["${i}"];
|
||
|
|
${a};`)}}return new Function("ud","uv","renderer","syncData",r.join(`
|
||
|
|
`))}var WT=_(()=>{Mu(),xr(),Sm(),VT()}),nc,$T=_(()=>{J(),WT(),nc=class{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,r){let i=this._renderer.shader._getProgramData(e);(!t.isStatic||t._dirtyId!==i.uniformDirtyGroups[t.uid])&&(i.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(i.uniformData,t.uniforms,this._renderer,r))}_getUniformSyncFunction(t,e){return this._uniformGroupSyncHash[t._signature]?.[e._key]||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){let r=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),i=this._getSignature(t,e._uniformData,"u");return this._cache[i]||(this._cache[i]=this._generateUniformsSync(t,e._uniformData)),r[e._key]=this._cache[i],r[e._key]}_generateUniformsSync(t,e){return jT(t,e)}_getSignature(t,e,r){let i=t.uniforms,n=[`${r}-`];for(let s in i)n.push(s),e[s]&&n.push(e[s].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}},nc.extension={type:[O.WebGLSystem],name:"uniformGroup"}});function XT(t){let e={};if(e.normal=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e.add=[t.ONE,t.ONE],e.multiply=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.screen=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e["screen-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.erase=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],!(t instanceof Lt.get().getWebGLRenderingContext()))e.min=[t.ONE,t.ONE,t.ONE,t.ONE,t.MIN,t.MIN],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,t.MAX,t.MAX];else{let r=t.getExtension("EXT_blend_minmax");r&&(e.min=[t.ONE,t.ONE,t.ONE,t.ONE,r.MIN_EXT,r.MIN_EXT],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,r.MAX_EXT,r.MAX_EXT])}return e}var YT=_(()=>{tr()}),f_,p_,g_,m_,__,v_,sc,y_,qT=_(()=>{J(),ii(),YT(),f_=0,p_=1,g_=2,m_=3,__=4,v_=5,sc=class Xc{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[f_]=this.setBlend,this.map[p_]=this.setOffset,this.map[g_]=this.setCullFace,this.map[m_]=this.setDepthTest,this.map[__]=this.setFrontFace,this.map[v_]=this.setDepthMask,this.checks=[],this.defaultState=Fr.for2d(),e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){this._invertFrontFace=!e.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(e){this.gl=e,this.blendModesMap=XT(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let r=this.stateId^e.data,i=0;for(;r;)r&1&&this.map[i].call(this,!!(e.data&1<<i)),r>>=1,i++;this.stateId=e.data}for(let r=0;r<this.checks.length;r++)this.checks[r](this,e)}forceState(e){e||(e=this.defaultState);for(let r=0;r<this.map.length;r++)this.map[r].call(this,!!(e.data&1<<r));for(let r=0;r<this.checks.length;r++)this.checks[r](this,e);this.stateId=e.data}setBlend(e){this._updateCheck(Xc._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(Xc._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this._cullFace=e,this.gl[e?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(e){this._frontFace=e,this._frontFaceDirty=!1;let r=this._invertFrontFace?!e:e;this._glFrontFace!==r&&(this._glFrontFace=r,this.gl.frontFace(this.gl[r?"CW":"CCW"]))}setBlendMode(e){if(this.blendModesMap[e]||(e="normal"),e===this.blendMode)return;this.blendMode=e;let r=this.blendModesMap[e],i=this.gl;r.length===2?i.blendFunc(r[0],r[1]):i.blendFuncSeparate(r[0],r[1],r[2],r[3]),r.length===6?(this._blendEq=!0,i.blendEquationSeparate(r[4],r[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(e,r){thi
|