1117 lines
400 KiB
JavaScript
1117 lines
400 KiB
JavaScript
|
var wp=Object.defineProperty,Sp=Object.defineProperties;var Ap=Object.getOwnPropertyDescriptors;var Es=Object.getOwnPropertySymbols;var Ka=Object.prototype.hasOwnProperty,Za=Object.prototype.propertyIsEnumerable;var qa=(m,J,_t)=>J in m?wp(m,J,{enumerable:!0,configurable:!0,writable:!0,value:_t}):m[J]=_t,Zt=(m,J)=>{for(var _t in J||(J={}))Ka.call(J,_t)&&qa(m,_t,J[_t]);if(Es)for(var _t of Es(J))Za.call(J,_t)&&qa(m,_t,J[_t]);return m},mn=(m,J)=>Sp(m,Ap(J));var _n=(m,J)=>{var _t={};for(var xt in m)Ka.call(m,xt)&&J.indexOf(xt)<0&&(_t[xt]=m[xt]);if(m!=null&&Es)for(var xt of Es(m))J.indexOf(xt)<0&&Za.call(m,xt)&&(_t[xt]=m[xt]);return _t};/*!
|
||
|
* pixi.js - v7.0.2
|
||
|
* Compiled Mon, 31 Oct 2022 15:20:53 UTC
|
||
|
*
|
||
|
* pixi.js is licensed under the MIT License.
|
||
|
* http://www.opensource.org/licenses/mit-license
|
||
|
*/var PIXI=function(m){"use strict";var J=(i=>(i[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",i))(J||{}),_t=(i=>(i[i.UNKNOWN=0]="UNKNOWN",i[i.WEBGL=1]="WEBGL",i[i.CANVAS=2]="CANVAS",i))(_t||{}),xt=(i=>(i[i.COLOR=16384]="COLOR",i[i.DEPTH=256]="DEPTH",i[i.STENCIL=1024]="STENCIL",i))(xt||{}),k=(i=>(i[i.NORMAL=0]="NORMAL",i[i.ADD=1]="ADD",i[i.MULTIPLY=2]="MULTIPLY",i[i.SCREEN=3]="SCREEN",i[i.OVERLAY=4]="OVERLAY",i[i.DARKEN=5]="DARKEN",i[i.LIGHTEN=6]="LIGHTEN",i[i.COLOR_DODGE=7]="COLOR_DODGE",i[i.COLOR_BURN=8]="COLOR_BURN",i[i.HARD_LIGHT=9]="HARD_LIGHT",i[i.SOFT_LIGHT=10]="SOFT_LIGHT",i[i.DIFFERENCE=11]="DIFFERENCE",i[i.EXCLUSION=12]="EXCLUSION",i[i.HUE=13]="HUE",i[i.SATURATION=14]="SATURATION",i[i.COLOR=15]="COLOR",i[i.LUMINOSITY=16]="LUMINOSITY",i[i.NORMAL_NPM=17]="NORMAL_NPM",i[i.ADD_NPM=18]="ADD_NPM",i[i.SCREEN_NPM=19]="SCREEN_NPM",i[i.NONE=20]="NONE",i[i.SRC_OVER=0]="SRC_OVER",i[i.SRC_IN=21]="SRC_IN",i[i.SRC_OUT=22]="SRC_OUT",i[i.SRC_ATOP=23]="SRC_ATOP",i[i.DST_OVER=24]="DST_OVER",i[i.DST_IN=25]="DST_IN",i[i.DST_OUT=26]="DST_OUT",i[i.DST_ATOP=27]="DST_ATOP",i[i.ERASE=26]="ERASE",i[i.SUBTRACT=28]="SUBTRACT",i[i.XOR=29]="XOR",i))(k||{}),Dt=(i=>(i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i))(Dt||{}),I=(i=>(i[i.RGBA=6408]="RGBA",i[i.RGB=6407]="RGB",i[i.RG=33319]="RG",i[i.RED=6403]="RED",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.ALPHA=6406]="ALPHA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i))(I||{}),de=(i=>(i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i))(de||{}),G=(i=>(i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.BYTE=5120]="BYTE",i[i.SHORT=5122]="SHORT",i[i.INT=5124]="INT",i[i.FLOAT=5126]="FLOAT",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.HALF_FLOAT=36193]="HALF_FLOAT",i))(G||{}),Ei=(i=>(i[i.FLOAT=0]="FLOAT",i[i.INT=1]="INT",i[i.UINT=2]="UINT",i))(Ei||{}),Vt=(i=>(i[i.NEAREST=0]="NEAREST",i[i.LINEAR=1]="LINEAR",i))(Vt||{}),zt=(i=>(i[i.CLAMP=33071]="CLAMP",i[i.REPEAT=10497]="REPEAT",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i))(zt||{}),Ft=(i=>(i[i.OFF=0]="OFF",i[i.POW2=1]="POW2",i[i.ON=2]="ON",i[i.ON_MANUAL=3]="ON_MANUAL",i))(Ft||{}),Rt=(i=>(i[i.NPM=0]="NPM",i[i.UNPACK=1]="UNPACK",i[i.PMA=2]="PMA",i[i.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",i[i.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",i[i.PREMULTIPLIED_ALPHA=2]="PREMULTIPLIED_ALPHA",i))(Rt||{}),Nt=(i=>(i[i.NO=0]="NO",i[i.YES=1]="YES",i[i.AUTO=2]="AUTO",i[i.BLEND=0]="BLEND",i[i.CLEAR=1]="CLEAR",i[i.BLIT=2]="BLIT",i))(Nt||{}),bi=(i=>(i[i.AUTO=0]="AUTO",i[i.MANUAL=1]="MANUAL",i))(bi||{}),wt=(i=>(i.LOW="lowp",i.MEDIUM="mediump",i.HIGH="highp",i))(wt||{}),ht=(i=>(i[i.NONE=0]="NONE",i[i.SCISSOR=1]="SCISSOR",i[i.STENCIL=2]="
|
||
|
`," "],Ph=["{","}","|","\\","^","`"].concat(Ih),Ns=["'"].concat(Ph),Xn=["%","/","?",";","#"].concat(Ns),Vn=["/","?","#"],Mh=255,zn=/^[+a-z0-9A-Z_-]{0,63}$/,Bh=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,Dh={javascript:!0,"javascript:":!0},Ls={javascript:!0,"javascript:":!0},Be={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function qe(i,t,e){if(i&&Wt.isObject(i)&&i instanceof Ct)return i;var s=new Ct;return s.parse(i,t,e),s}Ct.prototype.parse=function(i,t,e){if(!Wt.isString(i))throw new TypeError("Parameter 'url' must be a string, not "+typeof i);var s=i.indexOf("?"),r=s!==-1&&s<i.indexOf("#")?"?":"#",n=i.split(r),o=/\\/g;n[0]=n[0].replace(o,"/"),i=n.join(r);var a=i;if(a=a.trim(),!e&&i.split("#").length===1){var h=Ch.exec(a);if(h)return this.path=a,this.href=a,this.pathname=h[1],h[2]?(this.search=h[2],t?this.query=Fs.parse(this.search.substr(1)):this.query=this.search.substr(1)):t&&(this.search="",this.query={}),this}var l=Ah.exec(a);if(l){l=l[0];var c=l.toLowerCase();this.protocol=c,a=a.substr(l.length)}if(e||l||a.match(/^\/\/[^@\/]+@[^@\/]+/)){var u=a.substr(0,2)==="//";u&&!(l&&Ls[l])&&(a=a.substr(2),this.slashes=!0)}if(!Ls[l]&&(u||l&&!Be[l])){for(var d=-1,f=0;f<Vn.length;f++){var p=a.indexOf(Vn[f]);p!==-1&&(d===-1||p<d)&&(d=p)}var _,g;d===-1?g=a.lastIndexOf("@"):g=a.lastIndexOf("@",d),g!==-1&&(_=a.slice(0,g),a=a.slice(g+1),this.auth=decodeURIComponent(_)),d=-1;for(var f=0;f<Xn.length;f++){var p=a.indexOf(Xn[f]);p!==-1&&(d===-1||p<d)&&(d=p)}d===-1&&(d=a.length),this.host=a.slice(0,d),a=a.slice(d),this.parseHost(),this.hostname=this.hostname||"";var v=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!v)for(var T=this.hostname.split(/\./),f=0,y=T.length;f<y;f++){var x=T[f];if(!!x&&!x.match(zn)){for(var b="",D=0,C=x.length;D<C;D++)x.charCodeAt(D)>127?b+="x":b+=x[D];if(!b.match(zn)){var S=T.slice(0,f),O=T.slice(f+1),H=x.match(Bh);H&&(S.push(H[1]),O.unshift(H[2])),O.length&&(a="/"+O.join(".")+a),this.hostname=S.join(".");break}}}this.hostname.length>Mh?this.hostname="":this.hostname=this.hostname.toLowerCase(),v||(this.hostname=xh.toASCII(this.hostname));var P=this.port?":"+this.port:"",N=this.hostname||"";this.host=N+P,this.href+=this.host,v&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),a[0]!=="/"&&(a="/"+a))}if(!Dh[c])for(var f=0,y=Ns.length;f<y;f++){var w=Ns[f];if(a.indexOf(w)!==-1){var E=encodeURIComponent(w);E===w&&(E=escape(w)),a=a.split(w).join(E)}}var V=a.indexOf("#");V!==-1&&(this.hash=a.substr(V),a=a.slice(0,V));var Y=a.indexOf("?");if(Y!==-1?(this.search=a.substr(Y),this.query=a.substr(Y+1),t&&(this.query=Fs.parse(this.query)),a=a.slice(0,Y)):t&&(this.search="",this.query={}),a&&(this.pathname=a),Be[c]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){var P=this.pathname||"",F=this.search||"";this.path=P+F}return this.href=this.format(),this};function Fh(i){return Wt.isString(i)&&(i=qe(i)),i instanceof Ct?i.format():Ct.prototype.format.call(i)}Ct.prototype.format=function(){var i=this.auth||"";i&&(i=encodeURIComponent(i),i=i.replace(/%3A/i,":"),i+="@");var t=this.protocol||"",e=this.pathname||"",s=this.hash||"",r=!1,n="";this.host?r=i+this.host:this.hostname&&(r=i+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(r+=":"+this.port)),this.query&&Wt.isObject(this.query)&&Object.keys(this.query).length&&(n=Fs.stringify(this.query));var o=this.search||n&&"?"+n||"";return t&&t.substr(-1)!==":"&&(t+=":"),this.slashes||(!t||Be[t])&&r!==!1?(r="//"+(r||""),e&&e.charAt(0)!=="/"&&(e="/"+e)):r||(r=""),s&&s.charAt(0)!=="#"&&(s="#"+s),o&&o.charAt(0)!=="?"&&(o="?"+o),e=e.replace(/[?#]/g,function(a){return encodeURIComponent(a)}),o=o.replace("#","%23"),t+r+e+o+s};function Nh(i,t){return qe(i,!1,!0).resolve(t)}Ct.prototype.resolve=function(i){return this.resolveObject(qe(i,!1,!0)).format()};function Lh(i,t){return i?qe(i,!1,!0).resolveObject(t):t}Ct.prototype.resolveObject=function(i){if(Wt.isString(i)){var t=new Ct;t.parse(i,!1,!0),i=t}for(var e=new Ct,s=Object.keys(this),r=0;r<s.length;r+
|
||
|
Deprecated since v${i}`):(s=s.split(`
|
||
|
`).splice(e).join(`
|
||
|
`),console.groupCollapsed?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",`${t}
|
||
|
Deprecated since v${i}`),console.warn(s),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",`${t}
|
||
|
Deprecated since v${i}`),console.warn(s))),Kn[t]=!0}const zs={},Tt=Object.create(null),It=Object.create(null);function Nu(){let i;for(i in Tt)Tt[i].destroy();for(i in It)It[i].destroy()}function Lu(){let i;for(i in Tt)delete Tt[i];for(i in It)delete It[i]}class Ws{constructor(t,e,s){this.canvas=R.ADAPTER.createCanvas(),this.context=this.canvas.getContext("2d"),this.resolution=s||R.RESOLUTION,this.resize(t,e)}clear(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.canvas.width,this.canvas.height)}resize(t,e){this.canvas.width=Math.round(t*this.resolution),this.canvas.height=Math.round(e*this.resolution)}destroy(){this.context=null,this.canvas=null}get width(){return this.canvas.width}set width(t){this.canvas.width=Math.round(t)}get height(){return this.canvas.height}set height(t){this.canvas.height=Math.round(t)}}function Zn(i){let t=i.width,e=i.height;const s=i.getContext("2d",{willReadFrequently:!0}),n=s.getImageData(0,0,t,e).data,o=n.length,a={top:null,left:null,right:null,bottom:null};let h=null,l,c,u;for(l=0;l<o;l+=4)n[l+3]!==0&&(c=l/4%t,u=~~(l/4/t),a.top===null&&(a.top=u),(a.left===null||c<a.left)&&(a.left=c),(a.right===null||a.right<c)&&(a.right=c+1),(a.bottom===null||a.bottom<u)&&(a.bottom=u));return a.top!==null&&(t=a.right-a.left,e=a.bottom-a.top+1,h=s.getImageData(a.left,a.top,t,e)),{height:e,width:t,data:h}}const Qn=/^\s*data:(?:([\w-]+)\/([\w+.-]+))?(?:;charset=([\w-]+))?(?:;(base64))?,(.*)/i;function Ou(i){const t=Qn.exec(i);if(t)return{mediaType:t[1]?t[1].toLowerCase():void 0,subType:t[2]?t[2].toLowerCase():void 0,charset:t[3]?t[3].toLowerCase():void 0,encoding:t[4]?t[4].toLowerCase():void 0,data:t[5]}}let Oi;function Jn(i,t=globalThis.location){if(i.startsWith("data:"))return"";t=t||globalThis.location,Oi||(Oi=document.createElement("a")),Oi.href=i;const e=Wn.parse(Oi.href),s=!e.port&&t.port===""||e.port===t.port;return e.hostname!==t.hostname||!s||e.protocol!==t.protocol?"anonymous":""}function te(i,t=1){const e=R.RETINA_PREFIX.exec(i);return e?parseFloat(e[1]):t}var Uu={__proto__:null,isMobile:Ot,EventEmitter:Pe,earcut:Ps,url:Wn,path:ft,sayHello:Hh,skipHello:kh,isWebGLSupported:Yn,hex2rgb:ve,hex2string:Us,rgb2hex:Iu,string2hex:Fi,correctBlendMode:ks,premultiplyBlendMode:Gs,premultiplyRgba:$n,premultiplyTint:Ni,premultiplyTintToRgba:Hs,createIndicesForQuads:qn,getBufferType:Li,interleaveTypedArrays:Bu,isPow2:Xs,log2:Vs,nextPow2:Ke,removeItems:xe,sign:Te,uid:he,deprecation:Fu,BaseTextureCache:It,ProgramCache:zs,TextureCache:Tt,clearTextureCache:Lu,destroyTextureCache:Nu,CanvasRenderTarget:Ws,trimCanvas:Zn,decomposeDataUri:Ou,determineCrossOrigin:Jn,getResolutionOfUrl:te,DATA_URI:Qn};const Ui=[];function js(i,t){if(!i)return null;let e="";if(typeof i=="string"){const s=/\.(\w{3,4})(?:$|\?|#)/i.exec(i);s&&(e=s[1].toLowerCase())}for(let s=Ui.length-1;s>=0;--s){const r=Ui[s];if(r.test&&r.test(i,e))return new r(i,t)}throw new Error("Unrecognized source type to auto-detect Resource")}class De{constructor(t=0,e=0){this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new St("setRealSize"),this.onUpdate=new St("update"),this.onError=new St("onError")}bind(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)}unbind(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)}resize(t,e){(t!==this._width||e!==this._height)&&(this._width=t,this._height=e,this.onResize.emit(t,e))}get valid(){return!!this._width&&!!this._height}update(){this.destroyed||this.onUpdate.emit()}load(){return Promise.resolve(this)}get width(){return this._width}get height(){return this._height}style(t,e,s){return!1}dispose(){}destroy(){this.destroyed||(this.destroyed=!0,this.dispose(),this.onError.removeAll(),this.onError=null,this.onResize.removeAll(),this.onResize=null,this.onUpdate.removeAll(),this.onUpdate=null)}static test(t,e){return!1}}class Fe extends De{constructor(t,e){const{width:s,height:r}=e||{};if(!s||!r)throw new Error("BufferResource width or height invalid");super(s,r),this.data=t
|
||
|
`).map((l,c)=>`${c}: ${l}`),s=i.getShaderInfoLog(t),r=s.split(`
|
||
|
`),n={},o=r.map(l=>parseFloat(l.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(l=>l&&!n[l]?(n[l]=!0,!0):!1),a=[""];o.forEach(l=>{e[l-1]=`%c${e[l-1]}%c`,a.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const h=e.join(`
|
||
|
`);a[0]=h,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...a),console.groupEnd()}function $u(i,t,e,s){i.getProgramParameter(t,i.LINK_STATUS)||(i.getShaderParameter(e,i.COMPILE_STATUS)||co(i,e),i.getShaderParameter(s,i.COMPILE_STATUS)||co(i,s),console.error("PixiJS Error: Could not initialize shader."),i.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",i.getProgramInfoLog(t)))}function hr(i){const t=new Array(i);for(let e=0;e<t.length;e++)t[e]=!1;return t}function uo(i,t){switch(i){case"float":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return hr(2*t);case"bvec3":return hr(3*t);case"bvec4":return hr(4*t);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}const fo={};let Le=fo;function po(){if(Le===fo||(Le==null?void 0:Le.isContextLost())){const i=R.ADAPTER.createCanvas();let t;R.PREFER_ENV>=J.WEBGL2&&(t=i.getContext("webgl2",{})),t||(t=i.getContext("webgl",{})||i.getContext("experimental-webgl",{}),t?t.getExtension("WEBGL_draw_buffers"):t=null),Le=t}return Le}let zi;function qu(){if(!zi){zi=wt.MEDIUM;const i=po();i&&i.getShaderPrecisionFormat&&(zi=i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision?wt.HIGH:wt.MEDIUM)}return zi}function mo(i,t,e){if(i.substring(0,9)!=="precision"){let s=t;return t===wt.HIGH&&e!==wt.HIGH&&(s=wt.MEDIUM),`precision ${s} float;
|
||
|
${i}`}else if(e!==wt.HIGH&&i.substring(0,15)==="precision highp")return i.replace("precision highp","precision mediump");return i}const Ku={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function _o(i){return Ku[i]}let Wi=null;const go={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"};function yo(i,t){if(!Wi){const e=Object.keys(go);Wi={};for(let s=0;s<e.length;++s){const r=e[s];Wi[i[r]]=go[r]}}return Wi[t]}const be=[{test:i=>i.type==="float"&&i.size===1&&!i.isArray,code:i=>`
|
||
|
if(uv["${i}"] !== ud["${i}"].value)
|
||
|
{
|
||
|
ud["${i}"].value = uv["${i}"]
|
||
|
gl.uniform1f(ud["${i}"].location, uv["${i}"])
|
||
|
}
|
||
|
`},{test:(i,t)=>(i.type==="sampler2D"||i.type==="samplerCube"||i.type==="sampler2DArray")&&i.size===1&&!i.isArray&&(t==null||t.castToBaseTexture!==void 0),code:i=>`t = syncData.textureCount++;
|
||
|
|
||
|
renderer.texture.bind(uv["${i}"], t);
|
||
|
|
||
|
if(ud["${i}"].value !== t)
|
||
|
{
|
||
|
ud["${i}"].value = t;
|
||
|
gl.uniform1i(ud["${i}"].location, t);
|
||
|
; // eslint-disable-line max-len
|
||
|
}`},{test:(i,t)=>i.type==="mat3"&&i.size===1&&!i.isArray&&t.a!==void 0,code:i=>`
|
||
|
gl.uniformMatrix3fv(ud["${i}"].location, false, uv["${i}"].toArray(true));
|
||
|
`,codeUbo:i=>`
|
||
|
var ${i}_matrix = uv.${i}.toArray(true);
|
||
|
|
||
|
data[offset] = ${i}_matrix[0];
|
||
|
data[offset+1] = ${i}_matrix[1];
|
||
|
data[offset+2] = ${i}_matrix[2];
|
||
|
|
||
|
data[offset + 4] = ${i}_matrix[3];
|
||
|
data[offset + 5] = ${i}_matrix[4];
|
||
|
data[offset + 6] = ${i}_matrix[5];
|
||
|
|
||
|
data[offset + 8] = ${i}_matrix[6];
|
||
|
data[offset + 9] = ${i}_matrix[7];
|
||
|
data[offset + 10] = ${i}_matrix[8];
|
||
|
`},{test:(i,t)=>i.type==="vec2"&&i.size===1&&!i.isArray&&t.x!==void 0,code:i=>`
|
||
|
cv = ud["${i}"].value;
|
||
|
v = uv["${i}"];
|
||
|
|
||
|
if(cv[0] !== v.x || cv[1] !== v.y)
|
||
|
{
|
||
|
cv[0] = v.x;
|
||
|
cv[1] = v.y;
|
||
|
gl.uniform2f(ud["${i}"].location, v.x, v.y);
|
||
|
}`,codeUbo:i=>`
|
||
|
v = uv.${i};
|
||
|
|
||
|
data[offset] = v.x;
|
||
|
data[offset+1] = v.y;
|
||
|
`},{test:i=>i.type==="vec2"&&i.size===1&&!i.isArray,code:i=>`
|
||
|
cv = ud["${i}"].value;
|
||
|
v = uv["${i}"];
|
||
|
|
||
|
if(cv[0] !== v[0] || cv[1] !== v[1])
|
||
|
{
|
||
|
cv[0] = v[0];
|
||
|
cv[1] = v[1];
|
||
|
gl.uniform2f(ud["${i}"].location, v[0], v[1]);
|
||
|
}
|
||
|
`},{test:(i,t)=>i.type==="vec4"&&i.size===1&&!i.isArray&&t.width!==void 0,code:i=>`
|
||
|
cv = ud["${i}"].value;
|
||
|
v = uv["${i}"];
|
||
|
|
||
|
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["${i}"].location, v.x, v.y, v.width, v.height)
|
||
|
}`,codeUbo:i=>`
|
||
|
v = uv.${i};
|
||
|
|
||
|
data[offset] = v.x;
|
||
|
data[offset+1] = v.y;
|
||
|
data[offset+2] = v.width;
|
||
|
data[offset+3] = v.height;
|
||
|
`},{test:i=>i.type==="vec4"&&i.size===1&&!i.isArray,code:i=>`
|
||
|
cv = ud["${i}"].value;
|
||
|
v = uv["${i}"];
|
||
|
|
||
|
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(ud["${i}"].location, v[0], v[1], v[2], v[3])
|
||
|
}`}],Zu={float:`
|
||
|
if (cv !== v)
|
||
|
{
|
||
|
cu.value = v;
|
||
|
gl.uniform1f(location, v);
|
||
|
}`,vec2:`
|
||
|
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:`
|
||
|
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:`
|
||
|
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]);
|
||
|
}`,int:`
|
||
|
if (cv !== v)
|
||
|
{
|
||
|
cu.value = v;
|
||
|
|
||
|
gl.uniform1i(location, v);
|
||
|
}`,ivec2:`
|
||
|
if (cv[0] !== v[0] || cv[1] !== v[1])
|
||
|
{
|
||
|
cv[0] = v[0];
|
||
|
cv[1] = v[1];
|
||
|
|
||
|
gl.uniform2i(location, v[0], v[1]);
|
||
|
}`,ivec3:`
|
||
|
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]);
|
||
|
}`,ivec4:`
|
||
|
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]);
|
||
|
}`,uint:`
|
||
|
if (cv !== v)
|
||
|
{
|
||
|
cu.value = v;
|
||
|
|
||
|
gl.uniform1ui(location, v);
|
||
|
}`,uvec2:`
|
||
|
if (cv[0] !== v[0] || cv[1] !== v[1])
|
||
|
{
|
||
|
cv[0] = v[0];
|
||
|
cv[1] = v[1];
|
||
|
|
||
|
gl.uniform2ui(location, v[0], v[1]);
|
||
|
}`,uvec3:`
|
||
|
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]);
|
||
|
}`,uvec4:`
|
||
|
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);
|
||
|
}`,bvec2:`
|
||
|
if (cv[0] != v[0] || cv[1] != v[1])
|
||
|
{
|
||
|
cv[0] = v[0];
|
||
|
cv[1] = v[1];
|
||
|
|
||
|
gl.uniform2i(location, v[0], v[1]);
|
||
|
}`,bvec3:`
|
||
|
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]);
|
||
|
}`,bvec4:`
|
||
|
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]);
|
||
|
}`,mat2:"gl.uniformMatrix2fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",sampler2D:`
|
||
|
if (cv !== v)
|
||
|
{
|
||
|
cu.value = v;
|
||
|
|
||
|
gl.uniform1i(location, v);
|
||
|
}`,samplerCube:`
|
||
|
if (cv !== v)
|
||
|
{
|
||
|
cu.value = v;
|
||
|
|
||
|
gl.uniform1i(location, v);
|
||
|
}`,sampler2DArray:`
|
||
|
if (cv !== v)
|
||
|
{
|
||
|
cu.value = v;
|
||
|
|
||
|
gl.uniform1i(location, v);
|
||
|
}`},Qu={float:"gl.uniform1fv(location, v)",vec2:"gl.uniform2fv(location, v)",vec3:"gl.uniform3fv(location, v)",vec4:"gl.uniform4fv(location, v)",mat4:"gl.uniformMatrix4fv(location, false, v)",mat3:"gl.uniformMatrix3fv(location, false, v)",mat2:"gl.uniformMatrix2fv(location, false, v)",int:"gl.uniform1iv(location, v)",ivec2:"gl.uniform2iv(location, v)",ivec3:"gl.uniform3iv(location, v)",ivec4:"gl.uniform4iv(location, v)",uint:"gl.uniform1uiv(location, v)",uvec2:"gl.uniform2uiv(location, v)",uvec3:"gl.uniform3uiv(location, v)",uvec4:"gl.uniform4uiv(location, v)",bool:"gl.uniform1iv(location, v)",bvec2:"gl.uniform2iv(location, v)",bvec3:"gl.uniform3iv(location, v)",bvec4:"gl.uniform4iv(location, v)",sampler2D:"gl.uniform1iv(location, v)",samplerCube:"gl.uniform1iv(location, v)",sampler2DArray:"gl.uniform1iv(location, v)"};function Ju(i,t){var s;const e=[`
|
||
|
var v = null;
|
||
|
var cv = null;
|
||
|
var cu = null;
|
||
|
var t = 0;
|
||
|
var gl = renderer.gl;
|
||
|
`];for(const r in i.uniforms){const n=t[r];if(!n){(s=i.uniforms[r])!=null&&s.group&&(i.uniforms[r].ubo?e.push(`
|
||
|
renderer.shader.syncUniformBufferGroup(uv.${r}, '${r}');
|
||
|
`):e.push(`
|
||
|
renderer.shader.syncUniformGroup(uv.${r}, syncData);
|
||
|
`));continue}const o=i.uniforms[r];let a=!1;for(let h=0;h<be.length;h++)if(be[h].test(n,o)){e.push(be[h].code(r,o)),a=!0;break}if(!a){const l=(n.size===1&&!n.isArray?Zu:Qu)[n.type].replace("location",`ud["${r}"].location`);e.push(`
|
||
|
cu = ud["${r}"];
|
||
|
cv = cu.value;
|
||
|
v = uv["${r}"];
|
||
|
${l};`)}}return new Function("ud","uv","renderer","syncData",e.join(`
|
||
|
`))}const td=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(`
|
||
|
`);function ed(i){let t="";for(let e=0;e<i;++e)e>0&&(t+=`
|
||
|
else `),e<i-1&&(t+=`if(test == ${e}.0){}`);return t}function vo(i,t){if(i===0)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const e=t.createShader(t.FRAGMENT_SHADER);for(;;){const s=td.replace(/%forloop%/gi,ed(i));if(t.shaderSource(e,s),t.compileShader(e),!t.getShaderParameter(e,t.COMPILE_STATUS))i=i/2|0;else break}return i}let ei;function id(){if(typeof ei=="boolean")return ei;try{ei=new Function("param1","param2","param3","return param1[param2] === param3;")({a:"b"},"a","b")===!0}catch(i){ei=!1}return ei}var sd=`varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
|
||
|
void main(void){
|
||
|
gl_FragColor *= texture2D(uSampler, vTextureCoord);
|
||
|
}`,rd=`attribute vec2 aVertexPosition;
|
||
|
attribute vec2 aTextureCoord;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
void main(void){
|
||
|
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
vTextureCoord = aTextureCoord;
|
||
|
}
|
||
|
`;let nd=0;const ji={};class jt{constructor(t,e,s="pixi-shader",r={}){this.extra={},this.id=nd++,this.vertexSrc=t||jt.defaultVertexSrc,this.fragmentSrc=e||jt.defaultFragmentSrc,this.vertexSrc=this.vertexSrc.trim(),this.fragmentSrc=this.fragmentSrc.trim(),this.extra=r,this.vertexSrc.substring(0,8)!=="#version"&&(s=s.replace(/\s+/g,"-"),ji[s]?(ji[s]++,s+=`-${ji[s]}`):ji[s]=1,this.vertexSrc=`#define SHADER_NAME ${s}
|
||
|
${this.vertexSrc}`,this.fragmentSrc=`#define SHADER_NAME ${s}
|
||
|
${this.fragmentSrc}`,this.vertexSrc=mo(this.vertexSrc,R.PRECISION_VERTEX,wt.HIGH),this.fragmentSrc=mo(this.fragmentSrc,R.PRECISION_FRAGMENT,qu())),this.glPrograms={},this.syncUniforms=null}static get defaultVertexSrc(){return rd}static get defaultFragmentSrc(){return sd}static from(t,e,s){const r=t+e;let n=zs[r];return n||(zs[r]=n=new jt(t,e,s)),n}}class Gt{constructor(t,e){this.uniformBindCount=0,this.program=t,e?e instanceof Pt?this.uniformGroup=e:this.uniformGroup=new Pt(e):this.uniformGroup=new Pt({}),this.disposeRunner=new St("disposeShader")}checkUniformExists(t,e){if(e.uniforms[t])return!0;for(const s in e.uniforms){const r=e.uniforms[s];if(r.group&&this.checkUniformExists(t,r))return!0}return!1}destroy(){this.uniformGroup=null,this.disposeRunner.emit(this),this.disposeRunner.destroy()}get uniforms(){return this.uniformGroup.uniforms}static from(t,e,s){const r=jt.from(t,e);return new Gt(r,s)}}const lr=0,cr=1,ur=2,dr=3,fr=4,pr=5;class Yt{constructor(){this.data=0,this.blendMode=k.NORMAL,this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<lr)}set blend(t){!!(this.data&1<<lr)!==t&&(this.data^=1<<lr)}get offsets(){return!!(this.data&1<<cr)}set offsets(t){!!(this.data&1<<cr)!==t&&(this.data^=1<<cr)}get culling(){return!!(this.data&1<<ur)}set culling(t){!!(this.data&1<<ur)!==t&&(this.data^=1<<ur)}get depthTest(){return!!(this.data&1<<dr)}set depthTest(t){!!(this.data&1<<dr)!==t&&(this.data^=1<<dr)}get depthMask(){return!!(this.data&1<<pr)}set depthMask(t){!!(this.data&1<<pr)!==t&&(this.data^=1<<pr)}get clockwiseFrontFace(){return!!(this.data&1<<fr)}set clockwiseFrontFace(t){!!(this.data&1<<fr)!==t&&(this.data^=1<<fr)}get blendMode(){return this._blendMode}set blendMode(t){this.blend=t!==k.NONE,this._blendMode=t}get polygonOffset(){return this._polygonOffset}set polygonOffset(t){this.offsets=!!t,this._polygonOffset=t}static for2d(){const t=new Yt;return t.depthTest=!1,t.blend=!0,t}}var od=`varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
|
||
|
void main(void){
|
||
|
gl_FragColor = texture2D(uSampler, vTextureCoord);
|
||
|
}
|
||
|
`,ad=`attribute vec2 aVertexPosition;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform vec4 inputSize;
|
||
|
uniform vec4 outputFrame;
|
||
|
|
||
|
vec4 filterVertexPosition( void )
|
||
|
{
|
||
|
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
||
|
|
||
|
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
||
|
}
|
||
|
|
||
|
vec2 filterTextureCoord( void )
|
||
|
{
|
||
|
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
||
|
}
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = filterVertexPosition();
|
||
|
vTextureCoord = filterTextureCoord();
|
||
|
}
|
||
|
`;class Mt extends Gt{constructor(t,e,s){const r=jt.from(t||Mt.defaultVertexSrc,e||Mt.defaultFragmentSrc);super(r,s),this.padding=0,this.resolution=R.FILTER_RESOLUTION,this.multisample=R.FILTER_MULTISAMPLE,this.enabled=!0,this.autoFit=!0,this.state=new Yt}apply(t,e,s,r,n){t.applyFilter(this,e,s,r)}get blendMode(){return this.state.blendMode}set blendMode(t){this.state.blendMode=t}get resolution(){return this._resolution}set resolution(t){this._resolution=t}static get defaultVertexSrc(){return ad}static get defaultFragmentSrc(){return od}}var hd=`attribute vec2 aVertexPosition;
|
||
|
attribute vec2 aTextureCoord;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
uniform mat3 otherMatrix;
|
||
|
|
||
|
varying vec2 vMaskCoord;
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
|
||
|
vTextureCoord = aTextureCoord;
|
||
|
vMaskCoord = ( otherMatrix * vec3( aTextureCoord, 1.0) ).xy;
|
||
|
}
|
||
|
`,ld=`varying vec2 vMaskCoord;
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform sampler2D mask;
|
||
|
uniform float alpha;
|
||
|
uniform float npmAlpha;
|
||
|
uniform vec4 maskClamp;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
float clip = step(3.5,
|
||
|
step(maskClamp.x, vMaskCoord.x) +
|
||
|
step(maskClamp.y, vMaskCoord.y) +
|
||
|
step(vMaskCoord.x, maskClamp.z) +
|
||
|
step(vMaskCoord.y, maskClamp.w));
|
||
|
|
||
|
vec4 original = texture2D(uSampler, vTextureCoord);
|
||
|
vec4 masky = texture2D(mask, vMaskCoord);
|
||
|
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
||
|
|
||
|
original *= (alphaMul * masky.r * alpha * clip);
|
||
|
|
||
|
gl_FragColor = original;
|
||
|
}
|
||
|
`;const xo=new tt;class Yi{constructor(t,e){this._texture=t,this.mapCoord=new tt,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=typeof e=="undefined"?.5:e,this.isSimple=!1}get texture(){return this._texture}set texture(t){this._texture=t,this._textureID=-1}multiplyUvs(t,e){e===void 0&&(e=t);const s=this.mapCoord;for(let r=0;r<t.length;r+=2){const n=t[r],o=t[r+1];e[r]=n*s.a+o*s.c+s.tx,e[r+1]=n*s.b+o*s.d+s.ty}return e}update(t){const e=this._texture;if(!e||!e.valid||!t&&this._textureID===e._updateID)return!1;this._textureID=e._updateID,this._updateID++;const s=e._uvs;this.mapCoord.set(s.x1-s.x0,s.y1-s.y0,s.x3-s.x0,s.y3-s.y0,s.x0,s.y0);const r=e.orig,n=e.trim;n&&(xo.set(r.width/n.width,0,0,r.height/n.height,-n.x/n.width,-n.y/n.height),this.mapCoord.append(xo));const o=e.baseTexture,a=this.uClampFrame,h=this.clampMargin/o.resolution,l=this.clampOffset;return a[0]=(e._frame.x+h+l)/o.width,a[1]=(e._frame.y+h+l)/o.height,a[2]=(e._frame.x+e._frame.width-h+l)/o.width,a[3]=(e._frame.y+e._frame.height-h+l)/o.height,this.uClampOffset[0]=l/o.realWidth,this.uClampOffset[1]=l/o.realHeight,this.isSimple=e._frame.width===o.width&&e._frame.height===o.height&&e.rotate===0,!0}}class To extends Mt{constructor(t,e,s){let r=null;typeof t!="string"&&e===void 0&&s===void 0&&(r=t,t=void 0,e=void 0,s=void 0),super(t||hd,e||ld,s),this.maskSprite=r,this.maskMatrix=new tt}get maskSprite(){return this._maskSprite}set maskSprite(t){this._maskSprite=t,this._maskSprite&&(this._maskSprite.renderable=!1)}apply(t,e,s,r){const n=this._maskSprite,o=n._texture;!o.valid||(o.uvMatrix||(o.uvMatrix=new Yi(o,0)),o.uvMatrix.update(),this.uniforms.npmAlpha=o.baseTexture.alphaMode?0:1,this.uniforms.mask=o,this.uniforms.otherMatrix=t.calculateSpriteMatrix(this.maskMatrix,n).prepend(o.uvMatrix.mapCoord),this.uniforms.alpha=n.worldAlpha,this.uniforms.maskClamp=o.uvMatrix.uClampFrame,t.applyFilter(this,e,s,r))}}class mr{constructor(t){this.renderer=t,this.enableScissor=!0,this.alphaMaskPool=[],this.maskDataPool=[],this.maskStack=[],this.alphaMaskIndex=0}setMaskStack(t){this.maskStack=t,this.renderer.scissor.setMaskStack(t),this.renderer.stencil.setMaskStack(t)}push(t,e){let s=e;if(!s.isMaskData){const n=this.maskDataPool.pop()||new ho;n.pooled=!0,n.maskObject=e,s=n}const r=this.maskStack.length!==0?this.maskStack[this.maskStack.length-1]:null;if(s.copyCountersOrReset(r),s._colorMask=r?r._colorMask:15,s.autoDetect&&this.detect(s),s._target=t,s.type!==ht.SPRITE&&this.maskStack.push(s),s.enabled)switch(s.type){case ht.SCISSOR:this.renderer.scissor.push(s);break;case ht.STENCIL:this.renderer.stencil.push(s);break;case ht.SPRITE:s.copyCountersOrReset(null),this.pushSpriteMask(s);break;case ht.COLOR:this.pushColorMask(s);break;default:break}s.type===ht.SPRITE&&this.maskStack.push(s)}pop(t){const e=this.maskStack.pop();if(!(!e||e._target!==t)){if(e.enabled)switch(e.type){case ht.SCISSOR:this.renderer.scissor.pop(e);break;case ht.STENCIL:this.renderer.stencil.pop(e.maskObject);break;case ht.SPRITE:this.popSpriteMask(e);break;case ht.COLOR:this.popColorMask(e);break;default:break}if(e.reset(),e.pooled&&this.maskDataPool.push(e),this.maskStack.length!==0){const s=this.maskStack[this.maskStack.length-1];s.type===ht.SPRITE&&s._filters&&(s._filters[0].maskSprite=s.maskObject)}}}detect(t){const e=t.maskObject;e?e.isSprite?t.type=ht.SPRITE:this.enableScissor&&this.renderer.scissor.testScissor(t)?t.type=ht.SCISSOR:t.type=ht.STENCIL:t.type=ht.COLOR}pushSpriteMask(t){var c,u;const{maskObject:e}=t,s=t._target;let r=t._filters;r||(r=this.alphaMaskPool[this.alphaMaskIndex],r||(r=this.alphaMaskPool[this.alphaMaskIndex]=[new To]));const n=this.renderer,o=n.renderTexture;let a,h;if(o.current){const d=o.current;a=t.resolution||d.resolution,h=(c=t.multisample)!=null?c:d.multisample}else a=t.resolution||n.resolution,h=(u=t.multisample)!=null?u:n.multisample;r[0].resolution=a,r[0].multisample=h,r[0].maskSprite=e;const l=s.filterArea;s.filterArea=e.getBounds(!0),n.filter.push(s,r),s.filterArea=l,t._fi
|
||
|
data[offset] = v;
|
||
|
`,vec2:`
|
||
|
data[offset] = v[0];
|
||
|
data[offset+1] = v[1];
|
||
|
`,vec3:`
|
||
|
data[offset] = v[0];
|
||
|
data[offset+1] = v[1];
|
||
|
data[offset+2] = v[2];
|
||
|
|
||
|
`,vec4:`
|
||
|
data[offset] = v[0];
|
||
|
data[offset+1] = v[1];
|
||
|
data[offset+2] = v[2];
|
||
|
data[offset+3] = v[3];
|
||
|
`,mat2:`
|
||
|
data[offset] = v[0];
|
||
|
data[offset+1] = v[1];
|
||
|
|
||
|
data[offset+4] = v[2];
|
||
|
data[offset+5] = v[3];
|
||
|
`,mat3:`
|
||
|
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];
|
||
|
`,mat4:`
|
||
|
for(var i = 0; i < 16; i++)
|
||
|
{
|
||
|
data[offset + i] = v[i];
|
||
|
}
|
||
|
`},So={float:4,vec2:8,vec3:12,vec4:16,int:4,ivec2:8,ivec3:12,ivec4:16,uint:4,uvec2:8,uvec3:12,uvec4:16,bool:4,bvec2:8,bvec3:12,bvec4:16,mat2:16*2,mat3:16*3,mat4:16*4};function Ao(i){const t=i.map(n=>({data:n,offset:0,dataLen:0,dirty:0}));let e=0,s=0,r=0;for(let n=0;n<t.length;n++){const o=t[n];if(e=So[o.data.type],o.data.size>1&&(e=Math.max(e,16)*o.data.size),o.dataLen=e,s%e!==0&&s<16){const a=s%e%16;s+=a,r+=a}s+e>16?(r=Math.ceil(r/16)*16,o.offset=r,r+=e,s=e):(o.offset=r,s+=e,r+=e)}return r=Math.ceil(r/16)*16,{uboElements:t,size:r}}function Ro(i,t){const e=[];for(const s in i)t[s]&&e.push(t[s]);return e.sort((s,r)=>s.index-r.index),e}function Co(i,t){if(!i.autoManage)return{size:0,syncFunc:cd};const e=Ro(i.uniforms,t),{uboElements:s,size:r}=Ao(e),n=[`
|
||
|
var v = null;
|
||
|
var v2 = null;
|
||
|
var cv = null;
|
||
|
var t = 0;
|
||
|
var gl = renderer.gl
|
||
|
var index = 0;
|
||
|
var data = buffer.data;
|
||
|
`];for(let o=0;o<s.length;o++){const a=s[o],h=i.uniforms[a.data.name],l=a.data.name;let c=!1;for(let u=0;u<be.length;u++){const d=be[u];if(d.codeUbo&&d.test(a.data,h)){n.push(`offset = ${a.offset/4};`,be[u].codeUbo(a.data.name,h)),c=!0;break}}if(!c)if(a.data.size>1){const u=_o(a.data.type),d=Math.max(So[a.data.type]/16,1),f=u/d,p=(4-f%4)%4;n.push(`
|
||
|
cv = ud.${l}.value;
|
||
|
v = uv.${l};
|
||
|
offset = ${a.offset/4};
|
||
|
|
||
|
t = 0;
|
||
|
|
||
|
for(var i=0; i < ${a.data.size*d}; i++)
|
||
|
{
|
||
|
for(var j = 0; j < ${f}; j++)
|
||
|
{
|
||
|
data[offset++] = v[t++];
|
||
|
}
|
||
|
offset += ${p};
|
||
|
}
|
||
|
|
||
|
`)}else{const u=ud[a.data.type];n.push(`
|
||
|
cv = ud.${l}.value;
|
||
|
v = uv.${l};
|
||
|
offset = ${a.offset/4};
|
||
|
${u};
|
||
|
`)}}return n.push(`
|
||
|
renderer.buffer.update(buffer);
|
||
|
`),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
|
||
|
`))}}class dd{}class Io{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBufferBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBufferBindings=null,this.program=null}}function fd(i,t){const e={},s=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES);for(let r=0;r<s;r++){const n=t.getActiveAttrib(i,r);if(n.name.startsWith("gl_"))continue;const o=yo(t,n.type),a={type:o,name:n.name,size:_o(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function pd(i,t){const e={},s=t.getProgramParameter(i,t.ACTIVE_UNIFORMS);for(let r=0;r<s;r++){const n=t.getActiveUniform(i,r),o=n.name.replace(/\[.*?\]$/,""),a=!!n.name.match(/\[.*?\]$/),h=yo(t,n.type);e[o]={name:o,index:r,type:h,size:n.size,isArray:a,value:uo(h,n.size)}}return e}function Po(i,t){var h;const e=lo(i,i.VERTEX_SHADER,t.vertexSrc),s=lo(i,i.FRAGMENT_SHADER,t.fragmentSrc),r=i.createProgram();i.attachShader(r,e),i.attachShader(r,s);const n=(h=t.extra)==null?void 0:h.transformFeedbackVaryings;if(n&&(typeof i.transformFeedbackVaryings!="function"||i.transformFeedbackVaryings(r,n.names,n.bufferMode==="separate"?i.SEPARATE_ATTRIBS:i.INTERLEAVED_ATTRIBS)),i.linkProgram(r),i.getProgramParameter(r,i.LINK_STATUS)||$u(i,r,e,s),t.attributeData=fd(r,i),t.uniformData=pd(r,i),!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertexSrc)){const l=Object.keys(t.attributeData);l.sort((c,u)=>c>u?1:-1);for(let c=0;c<l.length;c++)t.attributeData[l[c]].location=c,i.bindAttribLocation(r,c,l[c]);i.linkProgram(r)}i.deleteShader(e),i.deleteShader(s);const o={};for(const l in t.uniformData){const c=t.uniformData[l];o[l]={location:i.getUniformLocation(r,l),value:uo(c.type,c.size)}}return new Io(r,o)}let md=0;const qi={textureCount:0,uboCount:0};class xr{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=md++}systemCheck(){if(!id())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;const s=t.program,r=s.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==s&&(this.program=s,this.gl.useProgram(r.program)),e||(qi.textureCount=0,qi.uboCount=0,this.syncUniformGroup(t.uniformGroup,qi)),r}setUniforms(t){const e=this.shader.program,s=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(s.uniformData,t,this.renderer)}syncUniformGroup(t,e){const s=this.getGlProgram();(!t.static||t.dirtyId!==s.uniformDirtyGroups[t.id])&&(s.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,s,e))}syncUniforms(t,e,s){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,s)}createSyncGroups(t){const e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Ju(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){const s=this.getGlProgram();if(!t.static||t.dirtyId!==0||!s.uniformGroups[t.id]){t.dirtyId=0;const r=s.uniformGroups[t.id]||this.createSyncBufferGroup(t,s,e);t.buffer.update(),r(s.uniformData,t.uniforms,this.renderer,qi,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,s.uniformBufferBindings[e])}createSyncBufferGroup(t,e,s){const{gl:r}=this.renderer;this.renderer.buffer.bind(t.buffer);const n=this.gl.getUniformBlockIndex(e.program,s);e.uniformBufferBindings[s]=this.shader.uniformBindCount,r.uniformBlockBinding(e.program,n,this.shader.uniformBindCount),this.shader.uniformBindCount++;const o=this.getSignature(t,this.shader.program.uniformData,"ubo");let a=this._uboCache[o];if(a||(a=this._uboCache[o]=Co(t,this.shader.program.uniformData)),t.autoManage){const h=new Float32Array(a.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGrou
|
||
|
attribute vec2 aTextureCoord;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
vTextureCoord = aTextureCoord;
|
||
|
}`,Ad=`attribute vec2 aVertexPosition;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform vec4 inputSize;
|
||
|
uniform vec4 outputFrame;
|
||
|
|
||
|
vec4 filterVertexPosition( void )
|
||
|
{
|
||
|
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
||
|
|
||
|
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
||
|
}
|
||
|
|
||
|
vec2 filterTextureCoord( void )
|
||
|
{
|
||
|
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
||
|
}
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = filterVertexPosition();
|
||
|
vTextureCoord = filterTextureCoord();
|
||
|
}
|
||
|
`;const Fo=Sd,Mr=Ad,Br=class extends Mo{constructor(i){var s,r;super(),i=Object.assign({},R.RENDER_OPTIONS,i),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new Pt({projectionMatrix:new tt},!0);const t={runners:["init","destroy","contextChange","reset","update","postrender","prerender","resize"],systems:Br.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(t);const e={hello:i.hello,_plugin:Br.__plugins,background:{alpha:i.backgroundAlpha,color:(s=i.background)!=null?s:i.backgroundColor,clearBeforeRender:i.clearBeforeRender},_view:{height:i.height,width:i.width,autoDensity:i.autoDensity,resolution:i.resolution,view:i.view},context:{antialias:i.antialias,context:i.context,powerPreference:i.powerPreference,premultipliedAlpha:(r=i.premultipliedAlpha)!=null?r:i.useContextAlpha&&i.useContextAlpha!=="notMultiplied",preserveDrawingBuffer:i.preserveDrawingBuffer}};this.startup.run(e)}static test(i){return i!=null&&i.forceCanvas?!1:Yn()}render(i,t){this.objectRenderer.render(i,t)}resize(i,t){this._view.resizeView(i,t)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(i=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:i}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return this.background.clearBeforeRender}get useContextAlpha(){return this.context.useContextAlpha}get preserveDrawingBuffer(){return this.context.preserveDrawingBuffer}get backgroundColor(){return this.background.color}set backgroundColor(i){this.background.color=i}get backgroundAlpha(){return this.background.color}set backgroundAlpha(i){this.background.alpha=i}get powerPreference(){return this.context.powerPreference}generateTexture(i,t){return this.textureGenerator.generateTexture(i,t)}};let Se=Br;Se.extension={type:M.Renderer,priority:1},Se.__plugins={},Se.__systems={},U.handleByMap(M.RendererPlugin,Se.__plugins),U.handleByMap(M.RendererSystem,Se.__systems),U.add(Se);class Zi{constructor(){this.texArray=null,this.blend=0,this.type=Dt.TRIANGLES,this.start=0,this.size=0,this.data=null}}class Qi{constructor(){this.elements=[],this.ids=[],this.count=0}clear(){for(let t=0;t<this.count;t++)this.elements[t]=null;this.count=0}}class Ji{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)}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 uint16View(){return this._uint16View||(this._uint16View=new Uint16Array(this.rawBinaryData)),this._uint16View}get int32View(){return this._int32View||(this._int32View=new Int32Array(this.rawBinaryData)),this._int32View}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":ret
|
||
|
`,e+=`
|
||
|
`;for(let s=0;s<t;s++)s>0&&(e+=`
|
||
|
else `),s<t-1&&(e+=`if(vTextureId < ${s}.5)`),e+=`
|
||
|
{`,e+=`
|
||
|
color = texture2D(uSamplers[${s}], vTextureCoord);`,e+=`
|
||
|
}`;return e+=`
|
||
|
`,e+=`
|
||
|
`,e}}class Dr extends se{constructor(t=!1){super(),this._buffer=new nt(null,t,!1),this._indexBuffer=new nt(null,t,!0),this.addAttribute("aVertexPosition",this._buffer,2,!1,G.FLOAT).addAttribute("aTextureCoord",this._buffer,2,!1,G.FLOAT).addAttribute("aColor",this._buffer,4,!0,G.UNSIGNED_BYTE).addAttribute("aTextureId",this._buffer,1,!0,G.FLOAT).addIndex(this._indexBuffer)}}var Rd=`precision highp float;
|
||
|
attribute vec2 aVertexPosition;
|
||
|
attribute vec2 aTextureCoord;
|
||
|
attribute vec4 aColor;
|
||
|
attribute float aTextureId;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
uniform mat3 translationMatrix;
|
||
|
uniform vec4 tint;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
varying vec4 vColor;
|
||
|
varying float vTextureId;
|
||
|
|
||
|
void main(void){
|
||
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
|
||
|
vTextureCoord = aTextureCoord;
|
||
|
vTextureId = aTextureId;
|
||
|
vColor = aColor * tint;
|
||
|
}
|
||
|
`,Cd=`varying vec2 vTextureCoord;
|
||
|
varying vec4 vColor;
|
||
|
varying float vTextureId;
|
||
|
uniform sampler2D uSamplers[%count%];
|
||
|
|
||
|
void main(void){
|
||
|
vec4 color;
|
||
|
%forloop%
|
||
|
gl_FragColor = color * vColor;
|
||
|
}
|
||
|
`;const Ae=class extends ti{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=Yt.for2d(),this.size=R.SPRITE_BATCH_SIZE*4,this._vertexCount=0,this._indexCount=0,this._bufferedElements=[],this._bufferedTextures=[],this._bufferSize=0,this._shader=null,this._packedGeometries=[],this._packedGeometryPoolSize=2,this._flushId=0,this._aBuffers={},this._iBuffers={},this.MAX_TEXTURES=1,this.renderer.on("prerender",this.onPrerender,this),i.runners.contextChange.add(this),this._dcIndex=0,this._aIndex=0,this._iIndex=0,this._attributeBuffer=null,this._indexBuffer=null,this._tempBoundTextures=[]}static get defaultVertexSrc(){return Rd}static get defaultFragmentTemplate(){return Cd}setShaderGenerator({vertex:i=Ae.defaultVertexSrc,fragment:t=Ae.defaultFragmentTemplate}={}){this.shaderGenerator=new No(i,t)}contextChange(){const i=this.renderer.gl;R.PREFER_ENV===J.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),R.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=vo(this.MAX_TEXTURES,i)),this._shader=this.shaderGenerator.generateShader(this.MAX_TEXTURES);for(let t=0;t<this._packedGeometryPoolSize;t++)this._packedGeometries[t]=new this.geometryClass;this.initFlushBuffers()}initFlushBuffers(){const{_drawCallPool:i,_textureArrayPool:t}=Ae,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Zi);for(;t.length<s;)t.push(new Qi);for(let r=0;r<this.MAX_TEXTURES;r++)this._tempBoundTextures[r]=null}onPrerender(){this._flushId=0}render(i){!i._texture.valid||(this._vertexCount+i.vertexData.length/2>this.size&&this.flush(),this._vertexCount+=i.vertexData.length/2,this._indexCount+=i.indices.length,this._bufferedTextures[this._bufferSize]=i._texture.baseTexture,this._bufferedElements[this._bufferSize++]=i)}buildTexturesAndDrawCalls(){const{_bufferedTextures:i,MAX_TEXTURES:t}=this,e=Ae._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++j._globalBatch,a=0,h=e[0],l=0;s.copyBoundTextures(r,t);for(let c=0;c<this._bufferSize;++c){const u=i[c];i[c]=null,u._batchEnabled!==o&&(h.count>=t&&(s.boundArray(h,r,o,t),this.buildDrawCalls(h,l,c),l=c,h=e[++a],++o),u._batchEnabled=o,u.touched=n,h.elements[h.count++]=u)}h.count>0&&(s.boundArray(h,r,o,t),this.buildDrawCalls(h,l,this._bufferSize),++a,++o);for(let c=0;c<r.length;c++)r[c]=null;j._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Ae._drawCallPool;let h=this._dcIndex,l=this._aIndex,c=this._iIndex,u=a[h];u.start=this._iIndex,u.texArray=i;for(let d=t;d<e;++d){const f=s[d],p=f._texture.baseTexture,_=Gs[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==_&&(u.size=c-u.start,t=d,u=a[++h],u.texArray=i,u.start=c),this.packInterleavedGeometry(f,r,n,l,c),l+=f.vertexData.length/2*o,c+=f.indices.length,u.blend=_}t<e&&(u.size=c-u.start,++h),this._dcIndex=h,this._aIndex=l,this._iIndex=c}bindAndClearTexArray(i){const t=this.renderer.texture;for(let e=0;e<i.count;e++)t.bind(i.elements[e],i.ids[e]),i.elements[e]=null;i.count=0}updateGeometry(){const{_packedGeometries:i,_attributeBuffer:t,_indexBuffer:e}=this;R.CAN_UPLOAD_SAME_BUFFER?(i[this._flushId]._buffer.update(t.rawBinaryData),i[this._flushId]._indexBuffer.update(e),this.renderer.geometry.updateBuffers()):(this._packedGeometryPoolSize<=this._flushId&&(this._packedGeometryPoolSize++,i[this._flushId]=new this.geometryClass),i[this._flushId]._buffer.update(t.rawBinaryData),i[this._flushId]._indexBuffer.update(e),this.renderer.geometry.bind(i[this._flushId]),this.renderer.geometry.updateBuffers(),this._flushId++)}drawBatches(){const i=this._dcIndex,{gl:t,state:e}=this.renderer,s=Ae._drawCallPool;let r=null;for(let n=0;n<i;n++){const{texArray:o,type:a,size:h,start:l,blend:c}=s[n];r!==o&&(r=o,this.bindAndClearTexArray(o)),this.state.blendMode=c,e.set(this.state),t.drawElements(a,h,t.UNSIGNED_SHORT,l*2)}}flush(){this._vertexCount!==0&&(this._attributeBuffer=this.getAttributeBuffer(this._vertexCount),this._indexBuffer=this.getIndexBuffer(t
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform float uAlpha;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_FragColor = texture2D(uSampler, vTextureCoord) * uAlpha;
|
||
|
}
|
||
|
`;class Dd extends Mt{constructor(t=1){super(Fo,Bd,{uAlpha:1}),this.alpha=t}get alpha(){return this.uniforms.uAlpha}set alpha(t){this.uniforms.uAlpha=t}}const Fd=`
|
||
|
attribute vec2 aVertexPosition;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
|
||
|
uniform float strength;
|
||
|
|
||
|
varying vec2 vBlurTexCoords[%size%];
|
||
|
|
||
|
uniform vec4 inputSize;
|
||
|
uniform vec4 outputFrame;
|
||
|
|
||
|
vec4 filterVertexPosition( void )
|
||
|
{
|
||
|
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
||
|
|
||
|
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
||
|
}
|
||
|
|
||
|
vec2 filterTextureCoord( void )
|
||
|
{
|
||
|
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
||
|
}
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = filterVertexPosition();
|
||
|
|
||
|
vec2 textureCoord = filterTextureCoord();
|
||
|
%blur%
|
||
|
}`;function Nd(i,t){const e=Math.ceil(i/2);let s=Fd,r="",n;t?n="vBlurTexCoords[%index%] = textureCoord + vec2(%sampleIndex% * strength, 0.0);":n="vBlurTexCoords[%index%] = textureCoord + vec2(0.0, %sampleIndex% * strength);";for(let o=0;o<i;o++){let a=n.replace("%index%",o.toString());a=a.replace("%sampleIndex%",`${o-(e-1)}.0`),r+=a,r+=`
|
||
|
`}return s=s.replace("%blur%",r),s=s.replace("%size%",i.toString()),s}const Ld={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},Od=["varying vec2 vBlurTexCoords[%size%];","uniform sampler2D uSampler;","void main(void)","{"," gl_FragColor = vec4(0.0);"," %blur%","}"].join(`
|
||
|
`);function Ud(i){const t=Ld[i],e=t.length;let s=Od,r="";const n="gl_FragColor += texture2D(uSampler, vBlurTexCoords[%index%]) * %value%;";let o;for(let a=0;a<i;a++){let h=n.replace("%index%",a.toString());o=a,a>=e&&(o=i-a-1),h=h.replace("%value%",t[o].toString()),r+=h,r+=`
|
||
|
`}return s=s.replace("%blur%",r),s=s.replace("%size%",i.toString()),s}class Or extends Mt{constructor(t,e=8,s=4,r=R.FILTER_RESOLUTION,n=5){const o=Nd(n,t),a=Ud(n);super(o,a),this.horizontal=t,this.resolution=r,this._quality=0,this.quality=s,this.blur=e}apply(t,e,s,r){if(s?this.horizontal?this.uniforms.strength=1/s.width*(s.width/e.width):this.uniforms.strength=1/s.height*(s.height/e.height):this.horizontal?this.uniforms.strength=1/t.renderer.width*(t.renderer.width/e.width):this.uniforms.strength=1/t.renderer.height*(t.renderer.height/e.height),this.uniforms.strength*=this.strength,this.uniforms.strength/=this.passes,this.passes===1)t.applyFilter(this,e,s,r);else{const n=t.getFilterTexture(),o=t.renderer;let a=e,h=n;this.state.blend=!1,t.applyFilter(this,a,h,Nt.CLEAR);for(let l=1;l<this.passes-1;l++){t.bindAndClear(a,Nt.BLIT),this.uniforms.uSampler=h;const c=h;h=a,a=c,o.shader.bind(this),o.geometry.draw(5)}this.state.blend=!0,t.applyFilter(this,h,s,r),t.returnFilterTexture(n)}}get blur(){return this.strength}set blur(t){this.padding=1+Math.abs(t)*2,this.strength=t}get quality(){return this._quality}set quality(t){this._quality=t,this.passes=t}}class Gd extends Mt{constructor(t=8,e=4,s=R.FILTER_RESOLUTION,r=5){super(),this.blurXFilter=new Or(!0,t,e,s,r),this.blurYFilter=new Or(!1,t,e,s,r),this.resolution=s,this.quality=e,this.blur=t,this.repeatEdgePixels=!1}apply(t,e,s,r){const n=Math.abs(this.blurXFilter.strength),o=Math.abs(this.blurYFilter.strength);if(n&&o){const a=t.getFilterTexture();this.blurXFilter.apply(t,e,a,Nt.CLEAR),this.blurYFilter.apply(t,a,s,r),t.returnFilterTexture(a)}else o?this.blurYFilter.apply(t,e,s,r):this.blurXFilter.apply(t,e,s,r)}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.strength),Math.abs(this.blurYFilter.strength))*2}get blur(){return this.blurXFilter.blur}set blur(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get blurX(){return this.blurXFilter.blur}set blurX(t){this.blurXFilter.blur=t,this.updatePadding()}get blurY(){return this.blurYFilter.blur}set blurY(t){this.blurYFilter.blur=t,this.updatePadding()}get blendMode(){return this.blurYFilter.blendMode}set blendMode(t){this.blurYFilter.blendMode=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}var kd=`varying vec2 vTextureCoord;
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform float m[20];
|
||
|
uniform float uAlpha;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
vec4 c = texture2D(uSampler, vTextureCoord);
|
||
|
|
||
|
if (uAlpha == 0.0) {
|
||
|
gl_FragColor = c;
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
||
|
if (c.a > 0.0) {
|
||
|
c.rgb /= c.a;
|
||
|
}
|
||
|
|
||
|
vec4 result;
|
||
|
|
||
|
result.r = (m[0] * c.r);
|
||
|
result.r += (m[1] * c.g);
|
||
|
result.r += (m[2] * c.b);
|
||
|
result.r += (m[3] * c.a);
|
||
|
result.r += m[4];
|
||
|
|
||
|
result.g = (m[5] * c.r);
|
||
|
result.g += (m[6] * c.g);
|
||
|
result.g += (m[7] * c.b);
|
||
|
result.g += (m[8] * c.a);
|
||
|
result.g += m[9];
|
||
|
|
||
|
result.b = (m[10] * c.r);
|
||
|
result.b += (m[11] * c.g);
|
||
|
result.b += (m[12] * c.b);
|
||
|
result.b += (m[13] * c.a);
|
||
|
result.b += m[14];
|
||
|
|
||
|
result.a = (m[15] * c.r);
|
||
|
result.a += (m[16] * c.g);
|
||
|
result.a += (m[17] * c.b);
|
||
|
result.a += (m[18] * c.a);
|
||
|
result.a += m[19];
|
||
|
|
||
|
vec3 rgb = mix(c.rgb, result.rgb, uAlpha);
|
||
|
|
||
|
// Premultiply alpha again.
|
||
|
rgb *= result.a;
|
||
|
|
||
|
gl_FragColor = vec4(rgb, result.a);
|
||
|
}
|
||
|
`;class Ur extends Mt{constructor(){const t={m:new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),uAlpha:1};super(Mr,kd,t),this.alpha=1}_loadMatrix(t,e=!1){let s=t;e&&(this._multiply(s,this.uniforms.m,t),s=this._colorMatrix(s)),this.uniforms.m=s}_multiply(t,e,s){return t[0]=e[0]*s[0]+e[1]*s[5]+e[2]*s[10]+e[3]*s[15],t[1]=e[0]*s[1]+e[1]*s[6]+e[2]*s[11]+e[3]*s[16],t[2]=e[0]*s[2]+e[1]*s[7]+e[2]*s[12]+e[3]*s[17],t[3]=e[0]*s[3]+e[1]*s[8]+e[2]*s[13]+e[3]*s[18],t[4]=e[0]*s[4]+e[1]*s[9]+e[2]*s[14]+e[3]*s[19]+e[4],t[5]=e[5]*s[0]+e[6]*s[5]+e[7]*s[10]+e[8]*s[15],t[6]=e[5]*s[1]+e[6]*s[6]+e[7]*s[11]+e[8]*s[16],t[7]=e[5]*s[2]+e[6]*s[7]+e[7]*s[12]+e[8]*s[17],t[8]=e[5]*s[3]+e[6]*s[8]+e[7]*s[13]+e[8]*s[18],t[9]=e[5]*s[4]+e[6]*s[9]+e[7]*s[14]+e[8]*s[19]+e[9],t[10]=e[10]*s[0]+e[11]*s[5]+e[12]*s[10]+e[13]*s[15],t[11]=e[10]*s[1]+e[11]*s[6]+e[12]*s[11]+e[13]*s[16],t[12]=e[10]*s[2]+e[11]*s[7]+e[12]*s[12]+e[13]*s[17],t[13]=e[10]*s[3]+e[11]*s[8]+e[12]*s[13]+e[13]*s[18],t[14]=e[10]*s[4]+e[11]*s[9]+e[12]*s[14]+e[13]*s[19]+e[14],t[15]=e[15]*s[0]+e[16]*s[5]+e[17]*s[10]+e[18]*s[15],t[16]=e[15]*s[1]+e[16]*s[6]+e[17]*s[11]+e[18]*s[16],t[17]=e[15]*s[2]+e[16]*s[7]+e[17]*s[12]+e[18]*s[17],t[18]=e[15]*s[3]+e[16]*s[8]+e[17]*s[13]+e[18]*s[18],t[19]=e[15]*s[4]+e[16]*s[9]+e[17]*s[14]+e[18]*s[19]+e[19],t}_colorMatrix(t){const e=new Float32Array(t);return e[4]/=255,e[9]/=255,e[14]/=255,e[19]/=255,e}brightness(t,e){const s=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}tint(t,e){const s=t>>16&255,r=t>>8&255,n=t&255,o=[s/255,0,0,0,0,0,r/255,0,0,0,0,0,n/255,0,0,0,0,0,1,0];this._loadMatrix(o,e)}greyscale(t,e){const s=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(s,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const s=Math.cos(t),r=Math.sin(t),n=Math.sqrt,o=1/3,a=n(o),h=s+(1-s)*o,l=o*(1-s)-a*r,c=o*(1-s)+a*r,u=o*(1-s)+a*r,d=s+o*(1-s),f=o*(1-s)-a*r,p=o*(1-s)-a*r,_=o*(1-s)+a*r,g=s+o*(1-s),v=[h,l,c,0,0,u,d,f,0,0,p,_,g,0,0,0,0,0,1,0];this._loadMatrix(v,e)}contrast(t,e){const s=(t||0)+1,r=-.5*(s-1),n=[s,0,0,0,r,0,s,0,0,r,0,0,s,0,r,0,0,0,1,0];this._loadMatrix(n,e)}saturate(t=0,e){const s=t*2/3+1,r=(s-1)*-.5,n=[s,r,r,0,0,r,s,r,0,0,r,r,s,0,0,0,0,0,1,0];this._loadMatrix(n,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,11.793603434377337,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-70.35205161461398,-.231103377548616,-.7501899197440212,1.847597816108189,0,30.950940869491138,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,63.72958762196502,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,24.732407896706203,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,35.62982807460946,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,47.43192855600873,-.037703249837783157,.8609577587992641,.15059552388459913,0,-36.96841498319127,.24113635128153335,-.07441037908422492,.44972182064877153,0,-7.562075277591283,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,9.651285835294123,.02578397704808868,.6441188644374771,.03259127616149294,0,7.462829176470591,.0466055556782719,-.0851232987247891,.5241648018700465,0,5.159190588235296,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,s,r,n){t=t||.2,e=e||.15,s=s||16770432,r=r||3375104;const o=(s>>16&255)/255,a=(s>>8&255)/255,h=(s&255)/255,l=(r>>16&255)/255,c=(r>>8&255)/255,u=(r&255)/255,d=[.3,.59,.11,0,0,o,a,h,t,0,l,c,u,e,0,o-l,a
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform vec2 scale;
|
||
|
uniform mat2 rotation;
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform sampler2D mapSampler;
|
||
|
|
||
|
uniform highp vec4 inputSize;
|
||
|
uniform vec4 inputClamp;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
vec4 map = texture2D(mapSampler, vFilterCoord);
|
||
|
|
||
|
map -= 0.5;
|
||
|
map.xy = scale * inputSize.zw * (rotation * map.xy);
|
||
|
|
||
|
gl_FragColor = texture2D(uSampler, clamp(vec2(vTextureCoord.x + map.x, vTextureCoord.y + map.y), inputClamp.xy, inputClamp.zw));
|
||
|
}
|
||
|
`,Xd=`attribute vec2 aVertexPosition;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
uniform mat3 filterMatrix;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
varying vec2 vFilterCoord;
|
||
|
|
||
|
uniform vec4 inputSize;
|
||
|
uniform vec4 outputFrame;
|
||
|
|
||
|
vec4 filterVertexPosition( void )
|
||
|
{
|
||
|
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
||
|
|
||
|
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
||
|
}
|
||
|
|
||
|
vec2 filterTextureCoord( void )
|
||
|
{
|
||
|
return aVertexPosition * (outputFrame.zw * inputSize.zw);
|
||
|
}
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = filterVertexPosition();
|
||
|
vTextureCoord = filterTextureCoord();
|
||
|
vFilterCoord = ( filterMatrix * vec3( vTextureCoord, 1.0) ).xy;
|
||
|
}
|
||
|
`;class Vd extends Mt{constructor(t,e){const s=new tt;t.renderable=!1,super(Xd,Hd,{mapSampler:t._texture,filterMatrix:s,scale:{x:1,y:1},rotation:new Float32Array([1,0,0,1])}),this.maskSprite=t,this.maskMatrix=s,e==null&&(e=20),this.scale=new W(e,e)}apply(t,e,s,r){this.uniforms.filterMatrix=t.calculateSpriteMatrix(this.maskMatrix,this.maskSprite),this.uniforms.scale.x=this.scale.x,this.uniforms.scale.y=this.scale.y;const n=this.maskSprite.worldTransform,o=Math.sqrt(n.a*n.a+n.b*n.b),a=Math.sqrt(n.c*n.c+n.d*n.d);o!==0&&a!==0&&(this.uniforms.rotation[0]=n.a/o,this.uniforms.rotation[1]=n.b/o,this.uniforms.rotation[2]=n.c/a,this.uniforms.rotation[3]=n.d/a),t.applyFilter(this,e,s,r)}get map(){return this.uniforms.mapSampler}set map(t){this.uniforms.mapSampler=t}}var zd=`
|
||
|
attribute vec2 aVertexPosition;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
|
||
|
varying vec2 v_rgbNW;
|
||
|
varying vec2 v_rgbNE;
|
||
|
varying vec2 v_rgbSW;
|
||
|
varying vec2 v_rgbSE;
|
||
|
varying vec2 v_rgbM;
|
||
|
|
||
|
varying vec2 vFragCoord;
|
||
|
|
||
|
uniform vec4 inputSize;
|
||
|
uniform vec4 outputFrame;
|
||
|
|
||
|
vec4 filterVertexPosition( void )
|
||
|
{
|
||
|
vec2 position = aVertexPosition * max(outputFrame.zw, vec2(0.)) + outputFrame.xy;
|
||
|
|
||
|
return vec4((projectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
||
|
}
|
||
|
|
||
|
void texcoords(vec2 fragCoord, vec2 inverseVP,
|
||
|
out vec2 v_rgbNW, out vec2 v_rgbNE,
|
||
|
out vec2 v_rgbSW, out vec2 v_rgbSE,
|
||
|
out vec2 v_rgbM) {
|
||
|
v_rgbNW = (fragCoord + vec2(-1.0, -1.0)) * inverseVP;
|
||
|
v_rgbNE = (fragCoord + vec2(1.0, -1.0)) * inverseVP;
|
||
|
v_rgbSW = (fragCoord + vec2(-1.0, 1.0)) * inverseVP;
|
||
|
v_rgbSE = (fragCoord + vec2(1.0, 1.0)) * inverseVP;
|
||
|
v_rgbM = vec2(fragCoord * inverseVP);
|
||
|
}
|
||
|
|
||
|
void main(void) {
|
||
|
|
||
|
gl_Position = filterVertexPosition();
|
||
|
|
||
|
vFragCoord = aVertexPosition * outputFrame.zw;
|
||
|
|
||
|
texcoords(vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
||
|
}
|
||
|
`,Wd=`varying vec2 v_rgbNW;
|
||
|
varying vec2 v_rgbNE;
|
||
|
varying vec2 v_rgbSW;
|
||
|
varying vec2 v_rgbSE;
|
||
|
varying vec2 v_rgbM;
|
||
|
|
||
|
varying vec2 vFragCoord;
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform highp vec4 inputSize;
|
||
|
|
||
|
|
||
|
/**
|
||
|
Basic FXAA implementation based on the code on geeks3d.com with the
|
||
|
modification that the texture2DLod stuff was removed since it's
|
||
|
unsupported by WebGL.
|
||
|
|
||
|
--
|
||
|
|
||
|
From:
|
||
|
https://github.com/mitsuhiko/webgl-meincraft
|
||
|
|
||
|
Copyright (c) 2011 by Armin Ronacher.
|
||
|
|
||
|
Some rights reserved.
|
||
|
|
||
|
Redistribution and use in source and binary forms, with or without
|
||
|
modification, are permitted provided that the following conditions are
|
||
|
met:
|
||
|
|
||
|
* Redistributions of source code must retain the above copyright
|
||
|
notice, this list of conditions and the following disclaimer.
|
||
|
|
||
|
* Redistributions in binary form must reproduce the above
|
||
|
copyright notice, this list of conditions and the following
|
||
|
disclaimer in the documentation and/or other materials provided
|
||
|
with the distribution.
|
||
|
|
||
|
* The names of the contributors may not be used to endorse or
|
||
|
promote products derived from this software without specific
|
||
|
prior written permission.
|
||
|
|
||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
*/
|
||
|
|
||
|
#ifndef FXAA_REDUCE_MIN
|
||
|
#define FXAA_REDUCE_MIN (1.0/ 128.0)
|
||
|
#endif
|
||
|
#ifndef FXAA_REDUCE_MUL
|
||
|
#define FXAA_REDUCE_MUL (1.0 / 8.0)
|
||
|
#endif
|
||
|
#ifndef FXAA_SPAN_MAX
|
||
|
#define FXAA_SPAN_MAX 8.0
|
||
|
#endif
|
||
|
|
||
|
//optimized version for mobile, where dependent
|
||
|
//texture reads can be a bottleneck
|
||
|
vec4 fxaa(sampler2D tex, vec2 fragCoord, vec2 inverseVP,
|
||
|
vec2 v_rgbNW, vec2 v_rgbNE,
|
||
|
vec2 v_rgbSW, vec2 v_rgbSE,
|
||
|
vec2 v_rgbM) {
|
||
|
vec4 color;
|
||
|
vec3 rgbNW = texture2D(tex, v_rgbNW).xyz;
|
||
|
vec3 rgbNE = texture2D(tex, v_rgbNE).xyz;
|
||
|
vec3 rgbSW = texture2D(tex, v_rgbSW).xyz;
|
||
|
vec3 rgbSE = texture2D(tex, v_rgbSE).xyz;
|
||
|
vec4 texColor = texture2D(tex, v_rgbM);
|
||
|
vec3 rgbM = texColor.xyz;
|
||
|
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||
|
float lumaNW = dot(rgbNW, luma);
|
||
|
float lumaNE = dot(rgbNE, luma);
|
||
|
float lumaSW = dot(rgbSW, luma);
|
||
|
float lumaSE = dot(rgbSE, luma);
|
||
|
float lumaM = dot(rgbM, luma);
|
||
|
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||
|
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||
|
|
||
|
mediump vec2 dir;
|
||
|
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||
|
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||
|
|
||
|
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) *
|
||
|
(0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||
|
|
||
|
float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||
|
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
||
|
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
|
||
|
dir * rcpDirMin)) * inverseVP;
|
||
|
|
||
|
vec3 rgbA = 0.5 * (
|
||
|
texture2D(tex, fragCoord * inverseVP + dir * (1.0 / 3.0 - 0.5)).xyz +
|
||
|
texture2D(tex, fragCoord * inverseVP + dir * (2.0 / 3.0 - 0.5)).xyz);
|
||
|
vec3 rgbB = rgbA * 0.5 + 0.25 * (
|
||
|
texture2D(tex, fragCoord * inverseVP + dir * -0.5).xyz +
|
||
|
texture2D(tex, fragCoord * inverseVP + dir * 0.5).xyz);
|
||
|
|
||
|
float lumaB = dot(rgbB, luma);
|
||
|
if ((lumaB < lumaMin) || (lumaB > lumaMax))
|
||
|
color = vec4(rgbA, texColor.a);
|
||
|
else
|
||
|
color = vec4(rgbB, texColor.a);
|
||
|
return color;
|
||
|
}
|
||
|
|
||
|
void main() {
|
||
|
|
||
|
vec4 color;
|
||
|
|
||
|
color = fxaa(uSampler, vFragCoord, inputSize.zw, v_rgbNW, v_rgbNE, v_rgbSW, v_rgbSE, v_rgbM);
|
||
|
|
||
|
gl_FragColor = color;
|
||
|
}
|
||
|
`;class jd extends Mt{constructor(){super(zd,Wd)}}var Yd=`precision highp float;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
varying vec4 vColor;
|
||
|
|
||
|
uniform float uNoise;
|
||
|
uniform float uSeed;
|
||
|
uniform sampler2D uSampler;
|
||
|
|
||
|
float rand(vec2 co)
|
||
|
{
|
||
|
return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);
|
||
|
}
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
vec4 color = texture2D(uSampler, vTextureCoord);
|
||
|
float randomValue = rand(gl_FragCoord.xy * uSeed);
|
||
|
float diff = (randomValue - 0.5) * uNoise;
|
||
|
|
||
|
// Un-premultiply alpha before applying the color matrix. See issue #3539.
|
||
|
if (color.a > 0.0) {
|
||
|
color.rgb /= color.a;
|
||
|
}
|
||
|
|
||
|
color.r += diff;
|
||
|
color.g += diff;
|
||
|
color.b += diff;
|
||
|
|
||
|
// Premultiply alpha again.
|
||
|
color.rgb *= color.a;
|
||
|
|
||
|
gl_FragColor = color;
|
||
|
}
|
||
|
`;class $d extends Mt{constructor(t=.5,e=Math.random()){super(Mr,Yd,{uNoise:0,uSeed:0}),this.noise=t,this.seed=e}get noise(){return this.uniforms.uNoise}set noise(t){this.uniforms.uNoise=t}get seed(){return this.uniforms.uSeed}set seed(t){this.uniforms.uSeed=t}}R.SORTABLE_CHILDREN=!1;class ri{constructor(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.rect=null,this.updateID=-1}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}getRectangle(t){return this.minX>this.maxX||this.minY>this.maxY?z.EMPTY:(t=t||new z(0,0,1,1),t.x=this.minX,t.y=this.minY,t.width=this.maxX-this.minX,t.height=this.maxY-this.minY,t)}addPoint(t){this.minX=Math.min(this.minX,t.x),this.maxX=Math.max(this.maxX,t.x),this.minY=Math.min(this.minY,t.y),this.maxY=Math.max(this.maxY,t.y)}addPointMatrix(t,e){const{a:s,b:r,c:n,d:o,tx:a,ty:h}=t,l=s*e.x+n*e.y+a,c=r*e.x+o*e.y+h;this.minX=Math.min(this.minX,l),this.maxX=Math.max(this.maxX,l),this.minY=Math.min(this.minY,c),this.maxY=Math.max(this.maxY,c)}addQuad(t){let e=this.minX,s=this.minY,r=this.maxX,n=this.maxY,o=t[0],a=t[1];e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[2],a=t[3],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[4],a=t[5],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,o=t[6],a=t[7],e=o<e?o:e,s=a<s?a:s,r=o>r?o:r,n=a>n?a:n,this.minX=e,this.minY=s,this.maxX=r,this.maxY=n}addFrame(t,e,s,r,n){this.addFrameMatrix(t.worldTransform,e,s,r,n)}addFrameMatrix(t,e,s,r,n){const o=t.a,a=t.b,h=t.c,l=t.d,c=t.tx,u=t.ty;let d=this.minX,f=this.minY,p=this.maxX,_=this.maxY,g=o*e+h*s+c,v=a*e+l*s+u;d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*r+h*s+c,v=a*r+l*s+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*e+h*n+c,v=a*e+l*n+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,g=o*r+h*n+c,v=a*r+l*n+u,d=g<d?g:d,f=v<f?v:f,p=g>p?g:p,_=v>_?v:_,this.minX=d,this.minY=f,this.maxX=p,this.maxY=_}addVertexData(t,e,s){let r=this.minX,n=this.minY,o=this.maxX,a=this.maxY;for(let h=e;h<s;h+=2){const l=t[h],c=t[h+1];r=l<r?l:r,n=c<n?c:n,o=l>o?l:o,a=c>a?c:a}this.minX=r,this.minY=n,this.maxX=o,this.maxY=a}addVertices(t,e,s,r){this.addVerticesMatrix(t.worldTransform,e,s,r)}addVerticesMatrix(t,e,s,r,n=0,o=n){const a=t.a,h=t.b,l=t.c,c=t.d,u=t.tx,d=t.ty;let f=this.minX,p=this.minY,_=this.maxX,g=this.maxY;for(let v=s;v<r;v+=2){const T=e[v],y=e[v+1],x=a*T+l*y+u,b=c*y+h*T+d;f=Math.min(f,x-n),_=Math.max(_,x+n),p=Math.min(p,b-o),g=Math.max(g,b+o)}this.minX=f,this.minY=p,this.maxX=_,this.maxY=g}addBounds(t){const e=this.minX,s=this.minY,r=this.maxX,n=this.maxY;this.minX=t.minX<e?t.minX:e,this.minY=t.minY<s?t.minY:s,this.maxX=t.maxX>r?t.maxX:r,this.maxY=t.maxY>n?t.maxY:n}addBoundsMask(t,e){const s=t.minX>e.minX?t.minX:e.minX,r=t.minY>e.minY?t.minY:e.minY,n=t.maxX<e.maxX?t.maxX:e.maxX,o=t.maxY<e.maxY?t.maxY:e.maxY;if(s<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=s<a?s:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}addBoundsMatrix(t,e){this.addFrameMatrix(e,t.minX,t.minY,t.maxX,t.maxY)}addBoundsArea(t,e){const s=t.minX>e.x?t.minX:e.x,r=t.minY>e.y?t.minY:e.y,n=t.maxX<e.x+e.width?t.maxX:e.x+e.width,o=t.maxY<e.y+e.height?t.maxY:e.y+e.height;if(s<=n&&r<=o){const a=this.minX,h=this.minY,l=this.maxX,c=this.maxY;this.minX=s<a?s:a,this.minY=r<h?r:h,this.maxX=n>l?n:l,this.maxY=o>c?o:c}}pad(t=0,e=t){this.isEmpty()||(this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e)}addFramePad(t,e,s,r,n,o){t-=n,e-=o,s+=n,r+=o,this.minX=this.minX<t?this.minX:t,this.maxX=this.maxX>s?this.maxX:s,this.minY=this.minY<e?this.minY:e,this.maxY=this.maxY>r?this.maxY:r}}class it extends Pe{constructor(){super(),this.tempDisplayObjectParent=null,this.transform=new ze,this.alpha=1,this.visible=!0,this.renderable=!0,this.cullable=!1,this.cullArea=null,this.parent=null,this.worldAlpha=1,this._lastSortedIndex=0,this._zIndex=0,this.filterArea=null,this.filters=null,this._enabledFilters=null,this._bounds=new ri,this._localBounds=null,this._boundsID=0,this._boundsRect=null,this._localBoundsRect=null,this._mask=null,this._maskRefCount=0,this._destroyed=!1,this.isSprite=!1,this.isMask=!1}
|
||
|
${u}`)}});return await Promise.all(h),n?r[o[0].src]:r}async unload(t){const s=$t(t,r=>({src:r})).map(async r=>{var a,h;const n=ft.toAbsolute(r.src),o=this.promiseCache[n];if(o){const l=await o.promise;(h=(a=o.parser)==null?void 0:a.unload)==null||h.call(a,l,r,this),delete this.promiseCache[n]}});await Promise.all(s)}get parsers(){return this._parsers}}class df{constructor(){this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this._preferredOrder=[],this._resolverHash={},this._assetMap={},this._rootPath=null,this._basePath=null,this._manifest=null}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const s=[];Array.isArray(e)?e.forEach(r=>{typeof r.name=="string"?s.push(r.name):s.push(...r.name),this.add(r.name,r.srcs)}):Object.keys(e).forEach(r=>{s.push(r),this.add(r,e[r])}),this._bundles[t]=s}add(t,e,s){const r=$t(t);r.forEach(o=>{this._assetMap[o]}),Array.isArray(e)||(typeof e=="string"?e=zo(e):e=[e]);const n=e.map(o=>{var h;let a=o;if(typeof o=="string"){let l=!1;for(let c=0;c<this._parsers.length;c++){const u=this._parsers[c];if(u.test(o)){a=u.parse(o),l=!0;break}}l||(a={src:o})}return a.format||(a.format=a.src.split(".").pop()),a.alias||(a.alias=r),(this._basePath||this._rootPath)&&(a.src=ft.toAbsolute(a.src,this._basePath,this._rootPath)),a.data=(h=a.data)!=null?h:s,a});r.forEach(o=>{this._assetMap[o]=n})}resolveBundle(t){const e=ai(t);t=$t(t);const s={};return t.forEach(r=>{const n=this._bundles[r];n&&(s[r]=this.resolve(n))}),e?s[t[0]]:s}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const s={};for(const r in e)s[r]=e[r].src;return s}return e.src}resolve(t){const e=ai(t);t=$t(t);const s={};return t.forEach(r=>{var n;if(!this._resolverHash[r])if(this._assetMap[r]){let o=this._assetMap[r];const a=this._getPreferredOrder(o),h=o[0];a==null||a.priority.forEach(l=>{a.params[l].forEach(c=>{const u=o.filter(d=>d[l]?d[l]===c:!1);u.length&&(o=u)})}),this._resolverHash[r]=(n=o[0])!=null?n:h}else{let o=r;(this._basePath||this._rootPath)&&(o=ft.toAbsolute(o,this._basePath,this._rootPath)),this._resolverHash[r]={src:o}}s[r]=this._resolverHash[r]}),e?s[t[0]]:s}_getPreferredOrder(t){for(let e=0;e<t.length;e++){const s=t[0],r=this._preferredOrder.find(n=>n.params.format.includes(s.format));if(r)return r}return this._preferredOrder[0]}}class Wo{constructor(){this._detections=[],this._initialized=!1,this.resolver=new df,this.loader=new uf,this.cache=Ue,this._backgroundLoader=new lf(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var n,o,a,h;if(this._initialized)return;if(this._initialized=!0,t.basePath&&(this.resolver.basePath=t.basePath),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const e=(o=(n=t.texturePreference)==null?void 0:n.resolution)!=null?o:1,s=typeof e=="number"?[e]:e;let r=[];if((a=t.texturePreference)!=null&&a.format){const l=(h=t.texturePreference)==null?void 0:h.format;r=typeof l=="string"?[l]:l;for(const c of this._detections)await c.test()||(r=await c.remove(r))}else for(const l of this._detections)await l.test()&&(r=await l.add(r));this.resolver.prefer({params:{format:r,resolution:s}})}add(t,e,s){this.resolver.add(t,e,s)}async load(t,e){this._initialized||await this.init();const s=ai(t),r=$t(t).map(a=>typeof a!="string"?(this.resolver.add(a.src,a),a.src):a),n=this.resolver.resolve(r),o=await this._mapLoadToResolve(n,e);return s?o[r[0]]:o}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let s=!1;typeof t=="string"&&(s=!0,t=[t]);const r=this.resolver.resolveBundle(t),n={},o=Object.keys(r);let a=0,h=0;const l=()=>{e==null||e(++a/h)},c=o.map(u=>{const d=
|
||
|
async function checkImageBitmap()
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (typeof createImageBitmap !== 'function') return false;
|
||
|
|
||
|
const response = await fetch('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=');
|
||
|
const imageBlob = await response.blob();
|
||
|
const imageBitmap = await createImageBitmap(imageBlob);
|
||
|
|
||
|
return imageBitmap.width === 1 && imageBitmap.height === 1;
|
||
|
}
|
||
|
catch (e)
|
||
|
{
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
checkImageBitmap().then((result) => { self.postMessage(result); });
|
||
|
`},_f={id:"loadImageBitmap",code:`
|
||
|
async function loadImageBitmap(url)
|
||
|
{
|
||
|
const response = await fetch(url);
|
||
|
|
||
|
if (!response.ok)
|
||
|
{
|
||
|
throw new Error(\`[WorkerManager.loadImageBitmap] Failed to fetch \${url}: \`
|
||
|
+ \`\${response.status} \${response.statusText}\`);
|
||
|
}
|
||
|
|
||
|
const imageBlob = await response.blob();
|
||
|
const imageBitmap = await createImageBitmap(imageBlob);
|
||
|
|
||
|
return imageBitmap;
|
||
|
}
|
||
|
self.onmessage = async (event) =>
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
const imageBitmap = await loadImageBitmap(event.data.data[0]);
|
||
|
|
||
|
self.postMessage({
|
||
|
data: imageBitmap,
|
||
|
uuid: event.data.uuid,
|
||
|
id: event.data.id,
|
||
|
}, [imageBitmap]);
|
||
|
}
|
||
|
catch(e)
|
||
|
{
|
||
|
self.postMessage({
|
||
|
error: e,
|
||
|
uuid: event.data.uuid,
|
||
|
id: event.data.id,
|
||
|
});
|
||
|
}
|
||
|
};`};let jr;class gf{constructor(){this._initialized=!1,this._createdWorkers=0,this.workerPool=[],this.queue=[],this.resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const e=URL.createObjectURL(new Blob([mf.code],{type:"application/javascript"})),s=new Worker(e);s.addEventListener("message",r=>{s.terminate(),URL.revokeObjectURL(e),t(r.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t){return this._run("loadImageBitmap",[t])}async _initWorkers(){this._initialized||(this._initialized=!0)}getWorker(){Wr===void 0&&(Wr=navigator.hardwareConcurrency||4);let t=this.workerPool.pop();return!t&&this._createdWorkers<Wr&&(jr||(jr=URL.createObjectURL(new Blob([_f.code],{type:"application/javascript"}))),this._createdWorkers++,t=new Worker(jr),t.addEventListener("message",e=>{this.complete(e.data),this.returnWorker(e.target),this.next()})),t}returnWorker(t){this.workerPool.push(t)}complete(t){t.error!==void 0?this.resolveHash[t.uuid].reject(t.error):this.resolveHash[t.uuid].resolve(t.data),this.resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const s=new Promise((r,n)=>{this.queue.push({id:t,arguments:e,resolve:r,reject:n})});return this.next(),s}next(){if(!this.queue.length)return;const t=this.getWorker();if(!t)return;const e=this.queue.pop(),s=e.id;this.resolveHash[Qo]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Qo++,id:s})}}const Jo=new gf;function is(i,t){const e=i.split("?")[0],s=ft.extname(e).toLowerCase();return Array.isArray(t)?t.includes(s.toLowerCase()):s.toLowerCase()===t}function li(i,t,e){const s=new B(i);return s.baseTexture.on("dispose",()=>{delete t.promiseCache[e]}),s}const Yr=[".jpg",".png",".jpeg",".avif",".webp"];async function ta(i){const t=await R.ADAPTER.fetch(i);if(!t.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${i}: ${t.status} ${t.statusText}`);const e=await t.blob();return await createImageBitmap(e)}const ss={extension:{type:M.LoadParser,priority:kt.High},config:{preferWorkers:!0},test(i){let t=!1;for(let e=0;e<Yr.length;e++)if(i.startsWith(`data:image/${Yr[e].slice(1)}`)){t=!0;break}return t||is(i,Yr)},async load(i,t,e){let s=null;globalThis.createImageBitmap?this.config.preferWorkers&&await Jo.isImageBitmapSupported()?s=await Jo.loadImageBitmap(i):s=await ta(i):s=await new Promise(n=>{s=new Image,s.crossOrigin="anonymous",s.src=i,s.complete?n(s):s.onload=()=>{n(s)}});const r=new j(s,Zt({resolution:te(i)},t.data));return r.resource.src=i,li(r,e,i)},unload(i){i.destroy(!0)}};U.add(ss);const yf={extension:{type:M.LoadParser,priority:kt.High},test(i){return ft.extname(i).includes(".svg")},async testParse(i){return Ne.test(i)},async parse(i,t,e){var o,a,h;const s=new Ne(i,(o=t==null?void 0:t.data)==null?void 0:o.resourceOptions),r=new j(s,Zt({resolution:te(i)},t==null?void 0:t.data));r.resource.src=i;const n=li(r,e,i);return(h=(a=t==null?void 0:t.data)==null?void 0:a.resourceOptions)!=null&&h.autoLoad||await s.load(),n},async load(i,t){return(await R.ADAPTER.fetch(i)).text()},unload:ss.unload},ea={extension:M.ResolveParser,test:ss.test,parse:i=>{var t,e;return{resolution:parseFloat((e=(t=R.RETINA_PREFIX.exec(i))==null?void 0:t[1])!=null?e:"1"),format:i.split(".").pop(),src:i}}};U.add(ea);const ia={extension:{type:M.DetectionParser,priority:1},test:async()=>{if(!globalThis.createImageBitmap)return!1;const i="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A=",t=await R.ADAPTER.fetch(i).then(e=>e.blob());return createImageBitmap(t).then(()=>!0,()=>!1)},add:async i=>[...i,"avif"],remove:async i=>i.filter(t=>t!=="avif")};U.add(ia);const sa={extension:{type
|
||
|
uniform vec4 uColor;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_FragColor = texture2D(uSampler, vTextureCoord) * uColor;
|
||
|
}
|
||
|
`,jf=`attribute vec2 aVertexPosition;
|
||
|
attribute vec2 aTextureCoord;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
uniform mat3 translationMatrix;
|
||
|
uniform mat3 uTextureMatrix;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
|
||
|
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;
|
||
|
}
|
||
|
`;class Xe extends Gt{constructor(t,e){const s={uSampler:t,alpha:1,uTextureMatrix:tt.IDENTITY,uColor:new Float32Array([1,1,1,1])};e=Object.assign({tint:16777215,alpha:1,pluginName:"batch"},e),e.uniforms&&Object.assign(s,e.uniforms),super(e.program||jt.from(jf,Wf),s),this._colorDirty=!1,this.uvMatrix=new Yi(t),this.batchable=e.program===void 0,this.pluginName=e.pluginName,this.tint=e.tint,this.alpha=e.alpha}get texture(){return this.uniforms.uSampler}set texture(t){this.uniforms.uSampler!==t&&(!this.uniforms.uSampler.baseTexture.alphaMode!=!t.baseTexture.alphaMode&&(this._colorDirty=!0),this.uniforms.uSampler=t,this.uvMatrix.texture=t)}set alpha(t){t!==this._alpha&&(this._alpha=t,this._colorDirty=!0)}get alpha(){return this._alpha}set tint(t){t!==this._tint&&(this._tint=t,this._tintRGB=(t>>16)+(t&65280)+((t&255)<<16),this._colorDirty=!0)}get tint(){return this._tint}update(){if(this._colorDirty){this._colorDirty=!1;const t=this.texture.baseTexture;Hs(this._tint,this._alpha,this.uniforms.uColor,t.alphaMode)}this.uvMatrix.update()&&(this.uniforms.uTextureMatrix=this.uvMatrix.mapCoord)}}class mi extends se{constructor(t,e,s){super();const r=new nt(t),n=new nt(e,!0),o=new nt(s,!0,!0);this.addAttribute("aVertexPosition",r,2,!1,G.FLOAT).addAttribute("aTextureCoord",n,2,!1,G.FLOAT).addIndex(o),this._updateId=-1}get vertexDirtyId(){return this.buffers[0]._updateID}}class Ia extends mi{constructor(t=100,e=100,s=10,r=10){super(),this.segWidth=s,this.segHeight=r,this.width=t,this.height=e,this.build()}build(){const t=this.segWidth*this.segHeight,e=[],s=[],r=[],n=this.segWidth-1,o=this.segHeight-1,a=this.width/n,h=this.height/o;for(let c=0;c<t;c++){const u=c%this.segWidth,d=c/this.segWidth|0;e.push(u*a,d*h),s.push(u/n,d/o)}const l=n*o;for(let c=0;c<l;c++){const u=c%n,d=c/n|0,f=d*this.segWidth+u,p=d*this.segWidth+u+1,_=(d+1)*this.segWidth+u,g=(d+1)*this.segWidth+u+1;r.push(f,p,_,p,g,_)}this.buffers[0].data=new Float32Array(e),this.buffers[1].data=new Float32Array(s),this.indexBuffer.data=new Uint16Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}}class Pa extends mi{constructor(t=200,e,s=0){super(new Float32Array(e.length*4),new Float32Array(e.length*4),new Uint16Array((e.length-1)*6)),this.points=e,this._width=t,this.textureScale=s,this.build()}get width(){return this._width}build(){const t=this.points;if(!t)return;const e=this.getBuffer("aVertexPosition"),s=this.getBuffer("aTextureCoord"),r=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),s.data=new Float32Array(t.length*4),r.data=new Uint16Array((t.length-1)*6));const n=s.data,o=r.data;n[0]=0,n[1]=0,n[2]=0,n[3]=1;let a=0,h=t[0];const l=this._width*this.textureScale,c=t.length;for(let d=0;d<c;d++){const f=d*4;if(this.textureScale>0){const p=h.x-t[d].x,_=h.y-t[d].y,g=Math.sqrt(p*p+_*_);h=t[d],a+=g/l}else a=d/(c-1);n[f]=a,n[f+1]=0,n[f+2]=a,n[f+3]=1}let u=0;for(let d=0;d<c-1;d++){const f=d*2;o[u++]=f,o[u++]=f+1,o[u++]=f+2,o[u++]=f+2,o[u++]=f+1,o[u++]=f+3}s.update(),r.update(),this.updateVertices()}updateVertices(){const t=this.points;if(t.length<1)return;let e=t[0],s,r=0,n=0;const o=this.buffers[0].data,a=t.length;for(let h=0;h<a;h++){const l=t[h],c=h*4;h<t.length-1?s=t[h+1]:s=l,n=-(s.x-e.x),r=s.y-e.y;let u=(1-h/(a-1))*10;u>1&&(u=1);const d=Math.sqrt(r*r+n*n),f=this.textureScale>0?this.textureScale*this._width/2:this._width/2;r/=d,n/=d,r*=f,n*=f,o[c]=l.x+r,o[c+1]=l.y+n,o[c+2]=l.x-r,o[c+3]=l.y-n,e=l}this.buffers[0].update()}update(){this.textureScale>0?this.build():this.updateVertices()}}class Yf extends Ce{constructor(t,e,s=0){const r=new Pa(t.height,e,s),n=new Xe(t);s>0&&(t.baseTexture.wrapMode=zt.REPEAT),super(r,n),this.autoUpdate=!0}_render(t){const e=this.geometry;(this.autoUpdate||e._width!==this.shader.texture.height)&&(e._width=this.shader.texture.height,e.update()),super._render(t)}}class Ma extends Ce{constructor(t,e,s){const r=new Ia(t.width,t.height,e,s),n=new Xe(B.WHITE);super(r,n),this.texture=t,this.autoResize=!0}textureUpdated(){this._textureID=this.shader.texture._updateID;const t=
|
||
|
varying vec4 vColor;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
|
||
|
void main(void){
|
||
|
vec4 color = texture2D(uSampler, vTextureCoord) * vColor;
|
||
|
gl_FragColor = color;
|
||
|
}`,Qf=`attribute vec2 aVertexPosition;
|
||
|
attribute vec2 aTextureCoord;
|
||
|
attribute vec4 aColor;
|
||
|
|
||
|
attribute vec2 aPositionCoord;
|
||
|
attribute float aRotation;
|
||
|
|
||
|
uniform mat3 translationMatrix;
|
||
|
uniform vec4 uColor;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
varying vec4 vColor;
|
||
|
|
||
|
void main(void){
|
||
|
float x = (aVertexPosition.x) * cos(aRotation) - (aVertexPosition.y) * sin(aRotation);
|
||
|
float y = (aVertexPosition.x) * sin(aRotation) + (aVertexPosition.y) * cos(aRotation);
|
||
|
|
||
|
vec2 v = vec2(x, y);
|
||
|
v = v + aPositionCoord;
|
||
|
|
||
|
gl_Position = vec4((translationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);
|
||
|
|
||
|
vTextureCoord = aTextureCoord;
|
||
|
vColor = aColor * uColor;
|
||
|
}
|
||
|
`;class an extends ti{constructor(t){super(t),this.shader=null,this.properties=null,this.tempMatrix=new tt,this.properties=[{attributeName:"aVertexPosition",size:2,uploadFunction:this.uploadVertices,offset:0},{attributeName:"aPositionCoord",size:2,uploadFunction:this.uploadPosition,offset:0},{attributeName:"aRotation",size:1,uploadFunction:this.uploadRotation,offset:0},{attributeName:"aTextureCoord",size:2,uploadFunction:this.uploadUvs,offset:0},{attributeName:"aColor",size:1,type:G.UNSIGNED_BYTE,uploadFunction:this.uploadTint,offset:0}],this.shader=Gt.from(Qf,Zf,{}),this.state=Yt.for2d()}render(t){const e=t.children,s=t._maxSize,r=t._batchSize,n=this.renderer;let o=e.length;if(o===0)return;o>s&&!t.autoResize&&(o=s);let a=t._buffers;a||(a=t._buffers=this.generateBuffers(t));const h=e[0]._texture.baseTexture,l=h.alphaMode>0;this.state.blendMode=ks(t.blendMode,l),n.state.set(this.state);const c=n.gl,u=t.worldTransform.copyTo(this.tempMatrix);u.prepend(n.globalUniforms.uniforms.projectionMatrix),this.shader.uniforms.translationMatrix=u.toArray(!0),this.shader.uniforms.uColor=$n(t.tintRgb,t.worldAlpha,this.shader.uniforms.uColor,l),this.shader.uniforms.uSampler=h,this.renderer.shader.bind(this.shader);let d=!1;for(let f=0,p=0;f<o;f+=r,p+=1){let _=o-f;_>r&&(_=r),p>=a.length&&a.push(this._generateOneMoreBuffer(t));const g=a[p];g.uploadDynamic(e,f,_);const v=t._bufferUpdateIDs[p]||0;d=d||g._updateID<v,d&&(g._updateID=t._updateID,g.uploadStatic(e,f,_)),n.geometry.bind(g.geometry),c.drawElements(c.TRIANGLES,_*6,c.UNSIGNED_SHORT,0)}}generateBuffers(t){const e=[],s=t._maxSize,r=t._batchSize,n=t._properties;for(let o=0;o<s;o+=r)e.push(new Ba(this.properties,n,r));return e}_generateOneMoreBuffer(t){const e=t._batchSize,s=t._properties;return new Ba(this.properties,s,e)}uploadVertices(t,e,s,r,n,o){let a=0,h=0,l=0,c=0;for(let u=0;u<s;++u){const d=t[e+u],f=d._texture,p=d.scale.x,_=d.scale.y,g=f.trim,v=f.orig;g?(h=g.x-d.anchor.x*v.width,a=h+g.width,c=g.y-d.anchor.y*v.height,l=c+g.height):(a=v.width*(1-d.anchor.x),h=v.width*-d.anchor.x,l=v.height*(1-d.anchor.y),c=v.height*-d.anchor.y),r[o]=h*p,r[o+1]=c*_,r[o+n]=a*p,r[o+n+1]=c*_,r[o+n*2]=a*p,r[o+n*2+1]=l*_,r[o+n*3]=h*p,r[o+n*3+1]=l*_,o+=n*4}}uploadPosition(t,e,s,r,n,o){for(let a=0;a<s;a++){const h=t[e+a].position;r[o]=h.x,r[o+1]=h.y,r[o+n]=h.x,r[o+n+1]=h.y,r[o+n*2]=h.x,r[o+n*2+1]=h.y,r[o+n*3]=h.x,r[o+n*3+1]=h.y,o+=n*4}}uploadRotation(t,e,s,r,n,o){for(let a=0;a<s;a++){const h=t[e+a].rotation;r[o]=h,r[o+n]=h,r[o+n*2]=h,r[o+n*3]=h,o+=n*4}}uploadUvs(t,e,s,r,n,o){for(let a=0;a<s;++a){const h=t[e+a]._texture._uvs;h?(r[o]=h.x0,r[o+1]=h.y0,r[o+n]=h.x1,r[o+n+1]=h.y1,r[o+n*2]=h.x2,r[o+n*2+1]=h.y2,r[o+n*3]=h.x3,r[o+n*3+1]=h.y3,o+=n*4):(r[o]=0,r[o+1]=0,r[o+n]=0,r[o+n+1]=0,r[o+n*2]=0,r[o+n*2+1]=0,r[o+n*3]=0,r[o+n*3+1]=0,o+=n*4)}}uploadTint(t,e,s,r,n,o){for(let a=0;a<s;++a){const h=t[e+a],l=h._texture.baseTexture.alphaMode>0,c=h.alpha,u=c<1&&l?Ni(h._tintRGB,c):h._tintRGB+(c*255<<24);r[o]=u,r[o+n]=u,r[o+n*2]=u,r[o+n*3]=u,o+=n*4}}destroy(){super.destroy(),this.shader&&(this.shader.destroy(),this.shader=null),this.tempMatrix=null}}an.extension={name:"particle",type:M.RendererPlugin},U.add(an),R.UPLOADS_PER_FRAME=4;var _i=(i=>(i[i.LINEAR_VERTICAL=0]="LINEAR_VERTICAL",i[i.LINEAR_HORIZONTAL=1]="LINEAR_HORIZONTAL",i))(_i||{});const hn={align:"left",breakWords:!1,dropShadow:!1,dropShadowAlpha:1,dropShadowAngle:Math.PI/6,dropShadowBlur:0,dropShadowColor:"black",dropShadowDistance:5,fill:"black",fillGradientType:_i.LINEAR_VERTICAL,fillGradientStops:[],fontFamily:"Arial",fontSize:26,fontStyle:"normal",fontVariant:"normal",fontWeight:"normal",letterSpacing:0,lineHeight:0,lineJoin:"miter",miterLimit:10,padding:0,stroke:"black",strokeThickness:0,textBaseline:"alphabetic",trim:!1,whiteSpace:"pre",wordWrap:!1,wordWrapWidth:100,leading:0},Jf=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];class oe{constructor(t){this.styleID=0,this.reset(),cn(this,t,t)}clone(){const t={};return cn(t,this,hn),new oe(t)}reset(){cn(this,hn,hn)}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,t
|
||
|
`:t,t}static getFromCache(t,e,s,r){let n=s[t];if(typeof n!="number"){const o=t.length*e;n=r.measureText(t).width+o,s[t]=n}return n}static collapseSpaces(t){return t==="normal"||t==="pre-line"}static collapseNewlines(t){return t==="normal"}static trimRight(t){if(typeof t!="string")return"";for(let e=t.length-1;e>=0;e--){const s=t[e];if(!L.isBreakingSpace(s))break;t=t.slice(0,-1)}return t}static isNewline(t){return typeof t!="string"?!1:L._newlines.includes(t.charCodeAt(0))}static isBreakingSpace(t,e){return typeof t!="string"?!1:L._breakingSpaces.includes(t.charCodeAt(0))}static tokenize(t){const e=[];let s="";if(typeof t!="string")return e;for(let r=0;r<t.length;r++){const n=t[r],o=t[r+1];if(L.isBreakingSpace(n,o)||L.isNewline(n)){s!==""&&(e.push(s),s=""),e.push(n);continue}s+=n}return s!==""&&e.push(s),e}static canBreakWords(t,e){return e}static canBreakChars(t,e,s,r,n){return!0}static wordWrapSplit(t){return t.split("")}static measureFont(t){if(L._fonts[t])return L._fonts[t];const e={ascent:0,descent:0,fontSize:0},s=L._canvas,r=L._context;r.font=t;const n=L.METRICS_STRING+L.BASELINE_SYMBOL,o=Math.ceil(r.measureText(n).width);let a=Math.ceil(r.measureText(L.BASELINE_SYMBOL).width);const h=Math.ceil(L.HEIGHT_MULTIPLIER*a);a=a*L.BASELINE_MULTIPLIER|0,s.width=o,s.height=h,r.fillStyle="#f00",r.fillRect(0,0,o,h),r.font=t,r.textBaseline="alphabetic",r.fillStyle="#000",r.fillText(n,0,a);const l=r.getImageData(0,0,o,h).data,c=l.length,u=o*4;let d=0,f=0,p=!1;for(d=0;d<a;++d){for(let _=0;_<u;_+=4)if(l[f+_]!==255){p=!0;break}if(!p)f+=u;else break}for(e.ascent=a-d,f=c-u,p=!1,d=h;d>a;--d){for(let _=0;_<u;_+=4)if(l[f+_]!==255){p=!0;break}if(!p)f-=u;else break}return e.descent=d-a,e.fontSize=e.ascent+e.descent,L._fonts[t]=e,e}static clearMetrics(t=""){t?delete L._fonts[t]:L._fonts={}}static get _canvas(){if(!L.__canvas){let t;try{const e=new OffscreenCanvas(0,0),s=e.getContext("2d",ps);if(s!=null&&s.measureText)return L.__canvas=e,e;t=R.ADAPTER.createCanvas()}catch(e){t=R.ADAPTER.createCanvas()}t.width=t.height=10,L.__canvas=t}return L.__canvas}static get _context(){return L.__context||(L.__context=L._canvas.getContext("2d",ps)),L.__context}}L._fonts={},L.METRICS_STRING="|\xC9q\xC5",L.BASELINE_SYMBOL="M",L.BASELINE_MULTIPLIER=1.4,L.HEIGHT_MULTIPLIER=2,L._newlines=[10,13],L._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288];const ep={texture:!0,children:!1,baseTexture:!0},Fa=class extends le{constructor(i,t,e){let s=!1;e||(e=R.ADAPTER.createCanvas(),s=!0),e.width=3,e.height=3;const r=B.from(e);r.orig=new z,r.trim=new z,super(r),this._ownCanvas=s,this.canvas=e,this.context=e.getContext("2d",{willReadFrequently:!0}),this._resolution=R.RESOLUTION,this._autoResolution=!0,this._text=null,this._style=null,this._styleListener=null,this._font="",this.text=i,this.style=t,this.localStyleID=-1}updateText(i){const t=this._style;if(this.localStyleID!==t.styleID&&(this.dirty=!0,this.localStyleID=t.styleID),!this.dirty&&i)return;this._font=this._style.toFontString();const e=this.context,s=L.measureText(this._text||" ",this._style,this._style.wordWrap,this.canvas),r=s.width,n=s.height,o=s.lines,a=s.lineHeight,h=s.lineWidths,l=s.maxLineWidth,c=s.fontProperties;this.canvas.width=Math.ceil(Math.ceil(Math.max(1,r)+t.padding*2)*this._resolution),this.canvas.height=Math.ceil(Math.ceil(Math.max(1,n)+t.padding*2)*this._resolution),e.scale(this._resolution,this._resolution),e.clearRect(0,0,this.canvas.width,this.canvas.height),e.font=this._font,e.lineWidth=t.strokeThickness,e.textBaseline=t.textBaseline,e.lineJoin=t.lineJoin,e.miterLimit=t.miterLimit;let u,d;const f=t.dropShadow?2:1;for(let p=0;p<f;++p){const _=t.dropShadow&&p===0,g=_?Math.ceil(Math.max(1,n)+t.padding*2):0,v=g*this._resolution;if(_){e.fillStyle="black",e.strokeStyle="black";const y=t.dropShadowColor,x=ve(typeof y=="number"?y:Fi(y)),b=t.dropShadowBlur*this._resolution,D=t.dropShadowDistance*this._resolution;e.shadowColor=`rgba(${x[0]*255},${x[1]*255},${x[2]*255},${t.dropShadowAlpha})`,e.shadowBlur=b,e.shadowOffsetX=Math.cos(t.dropShadowAngle)*D,e.shadowOffsetY=
|
||
|
#define SHADER_NAME Tiling-Sprite-Simple-100
|
||
|
|
||
|
precision lowp float;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform vec4 uColor;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
vec4 texSample = texture2D(uSampler, vTextureCoord);
|
||
|
gl_FragColor = texSample * uColor;
|
||
|
}
|
||
|
`,ka=`#version 100
|
||
|
#define SHADER_NAME Tiling-Sprite-100
|
||
|
|
||
|
precision lowp float;
|
||
|
|
||
|
attribute vec2 aVertexPosition;
|
||
|
attribute vec2 aTextureCoord;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
uniform mat3 translationMatrix;
|
||
|
uniform mat3 uTransform;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
|
||
|
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
||
|
}
|
||
|
`,pp=`#version 100
|
||
|
#ifdef GL_EXT_shader_texture_lod
|
||
|
#extension GL_EXT_shader_texture_lod : enable
|
||
|
#endif
|
||
|
#define SHADER_NAME Tiling-Sprite-100
|
||
|
|
||
|
precision lowp float;
|
||
|
|
||
|
varying vec2 vTextureCoord;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform vec4 uColor;
|
||
|
uniform mat3 uMapCoord;
|
||
|
uniform vec4 uClampFrame;
|
||
|
uniform vec2 uClampOffset;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
||
|
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
||
|
vec2 unclamped = coord;
|
||
|
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
||
|
|
||
|
#ifdef GL_EXT_shader_texture_lod
|
||
|
vec4 texSample = unclamped == coord
|
||
|
? texture2D(uSampler, coord)
|
||
|
: texture2DLodEXT(uSampler, coord, 0);
|
||
|
#else
|
||
|
vec4 texSample = texture2D(uSampler, coord);
|
||
|
#endif
|
||
|
|
||
|
gl_FragColor = texSample * uColor;
|
||
|
}
|
||
|
`,mp=`#version 300 es
|
||
|
#define SHADER_NAME Tiling-Sprite-300
|
||
|
|
||
|
precision lowp float;
|
||
|
|
||
|
in vec2 aVertexPosition;
|
||
|
in vec2 aTextureCoord;
|
||
|
|
||
|
uniform mat3 projectionMatrix;
|
||
|
uniform mat3 translationMatrix;
|
||
|
uniform mat3 uTransform;
|
||
|
|
||
|
out vec2 vTextureCoord;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||
|
|
||
|
vTextureCoord = (uTransform * vec3(aTextureCoord, 1.0)).xy;
|
||
|
}
|
||
|
`,_p=`#version 300 es
|
||
|
#define SHADER_NAME Tiling-Sprite-100
|
||
|
|
||
|
precision lowp float;
|
||
|
|
||
|
in vec2 vTextureCoord;
|
||
|
|
||
|
out vec4 fragmentColor;
|
||
|
|
||
|
uniform sampler2D uSampler;
|
||
|
uniform vec4 uColor;
|
||
|
uniform mat3 uMapCoord;
|
||
|
uniform vec4 uClampFrame;
|
||
|
uniform vec2 uClampOffset;
|
||
|
|
||
|
void main(void)
|
||
|
{
|
||
|
vec2 coord = vTextureCoord + ceil(uClampOffset - vTextureCoord);
|
||
|
coord = (uMapCoord * vec3(coord, 1.0)).xy;
|
||
|
vec2 unclamped = coord;
|
||
|
coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);
|
||
|
|
||
|
vec4 texSample = texture(uSampler, coord, unclamped == coord ? 0.0f : -32.0f);// lod-bias very negative to force lod 0
|
||
|
|
||
|
fragmentColor = texSample * uColor;
|
||
|
}
|
||
|
`;const ys=new tt;class fn extends ti{constructor(t){super(t),t.runners.contextChange.add(this),this.quad=new tr,this.state=Yt.for2d()}contextChange(){const t=this.renderer,e={globals:t.globalUniforms};this.simpleShader=Gt.from(ka,fp,e),this.shader=t.context.webGLVersion>1?Gt.from(mp,_p,e):Gt.from(ka,pp,e)}render(t){const e=this.renderer,s=this.quad;let r=s.vertices;r[0]=r[6]=t._width*-t.anchor.x,r[1]=r[3]=t._height*-t.anchor.y,r[2]=r[4]=t._width*(1-t.anchor.x),r[5]=r[7]=t._height*(1-t.anchor.y);const n=t.uvRespectAnchor?t.anchor.x:0,o=t.uvRespectAnchor?t.anchor.y:0;r=s.uvs,r[0]=r[6]=-n,r[1]=r[3]=-o,r[2]=r[4]=1-n,r[5]=r[7]=1-o,s.invalidate();const a=t._texture,h=a.baseTexture,l=h.alphaMode>0,c=t.tileTransform.localTransform,u=t.uvMatrix;let d=h.isPowerOfTwo&&a.frame.width===h.width&&a.frame.height===h.height;d&&(h._glTextures[e.CONTEXT_UID]?d=h.wrapMode!==zt.CLAMP:h.wrapMode===zt.CLAMP&&(h.wrapMode=zt.REPEAT));const f=d?this.simpleShader:this.shader,p=a.width,_=a.height,g=t._width,v=t._height;ys.set(c.a*p/g,c.b*p/v,c.c*_/g,c.d*_/v,c.tx/g,c.ty/v),ys.invert(),d?ys.prepend(u.mapCoord):(f.uniforms.uMapCoord=u.mapCoord.toArray(!0),f.uniforms.uClampFrame=u.uClampFrame,f.uniforms.uClampOffset=u.uClampOffset),f.uniforms.uTransform=ys.toArray(!0),f.uniforms.uColor=Hs(t.tint,t.worldAlpha,f.uniforms.uColor,l),f.uniforms.translationMatrix=t.transform.worldTransform.toArray(!0),f.uniforms.uSampler=a,e.shader.bind(f),e.geometry.bind(s),this.state.blendMode=ks(t.blendMode,l),e.state.set(this.state),e.geometry.draw(this.renderer.gl.TRIANGLES,6,0)}}fn.extension={name:"tilingSprite",type:M.RendererPlugin},U.add(fn);class vi{constructor(){this.info=[],this.common=[],this.page=[],this.char=[],this.kerning=[],this.distanceField=[]}}class xi{static test(t){return typeof t=="string"&&t.startsWith("info face=")}static parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const n in e){const o=e[n].match(/^[a-z]+/gm)[0],a=e[n].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),h={};for(const l in a){const c=a[l].split("="),u=c[0],d=c[1].replace(/"/gm,""),f=parseFloat(d),p=isNaN(f)?d:f;h[u]=p}s[o].push(h)}const r=new vi;return s.info.forEach(n=>r.info.push({face:n.face,size:parseInt(n.size,10)})),s.common.forEach(n=>r.common.push({lineHeight:parseInt(n.lineHeight,10)})),s.page.forEach(n=>r.page.push({id:parseInt(n.id,10),file:n.file})),s.char.forEach(n=>r.char.push({id:parseInt(n.id,10),page:parseInt(n.page,10),x:parseInt(n.x,10),y:parseInt(n.y,10),width:parseInt(n.width,10),height:parseInt(n.height,10),xoffset:parseInt(n.xoffset,10),yoffset:parseInt(n.yoffset,10),xadvance:parseInt(n.xadvance,10)})),s.kerning.forEach(n=>r.kerning.push({first:parseInt(n.first,10),second:parseInt(n.second,10),amount:parseInt(n.amount,10)})),s.distanceField.forEach(n=>r.distanceField.push({distanceRange:parseInt(n.distanceRange,10),fieldType:n.fieldType})),r}}class vs{static test(t){return t instanceof XMLDocument&&t.getElementsByTagName("page").length&&t.getElementsByTagName("info")[0].getAttribute("face")!==null}static parse(t){const e=new vi,s=t.getElementsByTagName("info"),r=t.getElementsByTagName("common"),n=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning"),h=t.getElementsByTagName("distanceField");for(let l=0;l<s.length;l++)e.info.push({face:s[l].getAttribute("face"),size:parseInt(s[l].getAttribute("size"),10)});for(let l=0;l<r.length;l++)e.common.push({lineHeight:parseInt(r[l].getAttribute("lineHeight"),10)});for(let l=0;l<n.length;l++)e.page.push({id:parseInt(n[l].getAttribute("id"),10)||0,file:n[l].getAttribute("file")});for(let l=0;l<o.length;l++){const c=o[l];e.char.push({id:parseInt(c.getAttribute("id"),10),page:parseInt(c.getAttribute("page"),10)||0,x:parseInt(c.getAttribute("x"),10),y:parseInt(c.getAttribute("y"),10),width:parseInt(c.getAttribute("width"),10),height:parseInt(c.getAttribute("height"),10),xoffset:parseInt(c.getAttribute("xoffset"),10),yoffset:parseInt(c.getAttribute("yoffset"),10),xadvance:parseInt(c.getAttribute("xa
|
||
|
varying vec2 vTextureCoord;\r
|
||
|
uniform sampler2D uSampler;\r
|
||
|
\r
|
||
|
// Tint\r
|
||
|
uniform vec4 uColor;\r
|
||
|
\r
|
||
|
// on 2D applications fwidth is screenScale / glyphAtlasScale * distanceFieldRange\r
|
||
|
uniform float uFWidth;\r
|
||
|
\r
|
||
|
void main(void) {\r
|
||
|
\r
|
||
|
// To stack MSDF and SDF we need a non-pre-multiplied-alpha texture.\r
|
||
|
vec4 texColor = texture2D(uSampler, vTextureCoord);\r
|
||
|
\r
|
||
|
// MSDF\r
|
||
|
float median = texColor.r + texColor.g + texColor.b -\r
|
||
|
min(texColor.r, min(texColor.g, texColor.b)) -\r
|
||
|
max(texColor.r, max(texColor.g, texColor.b));\r
|
||
|
// SDF\r
|
||
|
median = min(median, texColor.a);\r
|
||
|
\r
|
||
|
float screenPxDistance = uFWidth * (median - 0.5);\r
|
||
|
float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\r
|
||
|
if (median < 0.01) {\r
|
||
|
alpha = 0.0;\r
|
||
|
} else if (median > 0.99) {\r
|
||
|
alpha = 1.0;\r
|
||
|
}\r
|
||
|
\r
|
||
|
// NPM Textures, NPM outputs\r
|
||
|
gl_FragColor = vec4(uColor.rgb, uColor.a * alpha);\r
|
||
|
\r
|
||
|
}\r
|
||
|
`,Tp=`// Mesh material default fragment\r
|
||
|
attribute vec2 aVertexPosition;\r
|
||
|
attribute vec2 aTextureCoord;\r
|
||
|
\r
|
||
|
uniform mat3 projectionMatrix;\r
|
||
|
uniform mat3 translationMatrix;\r
|
||
|
uniform mat3 uTextureMatrix;\r
|
||
|
\r
|
||
|
varying vec2 vTextureCoord;\r
|
||
|
\r
|
||
|
void main(void)\r
|
||
|
{\r
|
||
|
gl_Position = vec4((projectionMatrix * translationMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\r
|
||
|
\r
|
||
|
vTextureCoord = (uTextureMatrix * vec3(aTextureCoord, 1.0)).xy;\r
|
||
|
}\r
|
||
|
`;const Va=[],za=[],Wa=[],ja=class extends At{constructor(i,t={}){super(),this._tint=16777215;const{align:e,tint:s,maxWidth:r,letterSpacing:n,fontName:o,fontSize:a}=Object.assign({},ja.styleDefaults,t);if(!vt.available[o])throw new Error(`Missing BitmapFont "${o}"`);this._activePagesMeshData=[],this._textWidth=0,this._textHeight=0,this._align=e,this._tint=s,this._font=void 0,this._fontName=o,this._fontSize=a,this.text=i,this._maxWidth=r,this._maxLineHeight=0,this._letterSpacing=n,this._anchor=new Jt(()=>{this.dirty=!0},this,0,0),this._roundPixels=R.ROUND_PIXELS,this.dirty=!0,this._resolution=R.RESOLUTION,this._autoResolution=!0,this._textureCache={}}updateText(){var H;const i=vt.available[this._fontName],t=this.fontSize,e=t/i.size,s=new W,r=[],n=[],o=[],a=this._text.replace(/(?:\r\n|\r)/g,`
|
||
|
`)||" ",h=Xa(a),l=this._maxWidth*i.size/t,c=i.distanceFieldType==="none"?Va:za;let u=null,d=0,f=0,p=0,_=-1,g=0,v=0,T=0,y=0;for(let P=0;P<h.length;P++){const N=h[P],w=Ts(N);if(/(?:\s)/.test(N)&&(_=P,g=d,y++),N==="\r"||N===`
|
||
|
`){n.push(d),o.push(-1),f=Math.max(f,d),++p,++v,s.x=0,s.y+=i.lineHeight,u=null,y=0;continue}const E=i.chars[w];if(!E)continue;u&&E.kerning[u]&&(s.x+=E.kerning[u]);const V=Wa.pop()||{texture:B.EMPTY,line:0,charCode:0,prevSpaces:0,position:new W};V.texture=E.texture,V.line=p,V.charCode=w,V.position.x=s.x+E.xOffset+this._letterSpacing/2,V.position.y=s.y+E.yOffset,V.prevSpaces=y,r.push(V),d=V.position.x+Math.max(E.xAdvance-E.xOffset,E.texture.orig.width),s.x+=E.xAdvance+this._letterSpacing,T=Math.max(T,E.yOffset+E.texture.height),u=w,_!==-1&&l>0&&s.x>l&&(++v,xe(r,1+_-v,1+P-_),P=_,_=-1,n.push(g),o.push(r.length>0?r[r.length-1].prevSpaces:0),f=Math.max(f,g),p++,s.x=0,s.y+=i.lineHeight,u=null,y=0)}const x=h[h.length-1];x!=="\r"&&x!==`
|
||
|
`&&(/(?:\s)/.test(x)&&(d=g),n.push(d),f=Math.max(f,d),o.push(-1));const b=[];for(let P=0;P<=p;P++){let N=0;this._align==="right"?N=f-n[P]:this._align==="center"?N=(f-n[P])/2:this._align==="justify"&&(N=o[P]<0?0:(f-n[P])/o[P]),b.push(N)}const D=r.length,C={},S=[],O=this._activePagesMeshData;c.push(...O);for(let P=0;P<D;P++){const N=r[P].texture,w=N.baseTexture.uid;if(!C[w]){let E=c.pop();if(!E){const Y=new mi;let F,q;i.distanceFieldType==="none"?(F=new Xe(B.EMPTY),q=k.NORMAL):(F=new Xe(B.EMPTY,{program:jt.from(Tp,xp),uniforms:{uFWidth:0}}),q=k.NORMAL_NPM);const ot=new Ce(Y,F);ot.blendMode=q,E={index:0,indexCount:0,vertexCount:0,uvsCount:0,total:0,mesh:ot,vertices:null,uvs:null,indices:null}}E.index=0,E.indexCount=0,E.vertexCount=0,E.uvsCount=0,E.total=0;const{_textureCache:V}=this;V[w]=V[w]||new B(N.baseTexture),E.mesh.texture=V[w],E.mesh.tint=this._tint,S.push(E),C[w]=E}C[w].total++}for(let P=0;P<O.length;P++)S.includes(O[P])||this.removeChild(O[P].mesh);for(let P=0;P<S.length;P++)S[P].mesh.parent!==this&&this.addChild(S[P].mesh);this._activePagesMeshData=S;for(const P in C){const N=C[P],w=N.total;if(!(((H=N.indices)==null?void 0:H.length)>6*w)||N.vertices.length<Ce.BATCHABLE_SIZE*2)N.vertices=new Float32Array(4*2*w),N.uvs=new Float32Array(4*2*w),N.indices=new Uint16Array(6*w);else{const E=N.total,V=N.vertices;for(let Y=E*4*2;Y<V.length;Y++)V[Y]=0}N.mesh.size=6*w}for(let P=0;P<D;P++){const N=r[P];let w=N.position.x+b[N.line]*(this._align==="justify"?N.prevSpaces:1);this._roundPixels&&(w=Math.round(w));const E=w*e,V=N.position.y*e,Y=N.texture,F=C[Y.baseTexture.uid],q=Y.frame,ot=Y._uvs,A=F.index++;F.indices[A*6+0]=0+A*4,F.indices[A*6+1]=1+A*4,F.indices[A*6+2]=2+A*4,F.indices[A*6+3]=0+A*4,F.indices[A*6+4]=2+A*4,F.indices[A*6+5]=3+A*4,F.vertices[A*8+0]=E,F.vertices[A*8+1]=V,F.vertices[A*8+2]=E+q.width*e,F.vertices[A*8+3]=V,F.vertices[A*8+4]=E+q.width*e,F.vertices[A*8+5]=V+q.height*e,F.vertices[A*8+6]=E,F.vertices[A*8+7]=V+q.height*e,F.uvs[A*8+0]=ot.x0,F.uvs[A*8+1]=ot.y0,F.uvs[A*8+2]=ot.x1,F.uvs[A*8+3]=ot.y1,F.uvs[A*8+4]=ot.x2,F.uvs[A*8+5]=ot.y2,F.uvs[A*8+6]=ot.x3,F.uvs[A*8+7]=ot.y3}this._textWidth=f*e,this._textHeight=(s.y+i.lineHeight)*e;for(const P in C){const N=C[P];if(this.anchor.x!==0||this.anchor.y!==0){let Y=0;const F=this._textWidth*this.anchor.x,q=this._textHeight*this.anchor.y;for(let ot=0;ot<N.total;ot++)N.vertices[Y++]-=F,N.vertices[Y++]-=q,N.vertices[Y++]-=F,N.vertices[Y++]-=q,N.vertices[Y++]-=F,N.vertices[Y++]-=q,N.vertices[Y++]-=F,N.vertices[Y++]-=q}this._maxLineHeight=T*e;const w=N.mesh.geometry.getBuffer("aVertexPosition"),E=N.mesh.geometry.getBuffer("aTextureCoord"),V=N.mesh.geometry.getIndex();w.data=N.vertices,E.data=N.uvs,V.data=N.indices,w.update(),E.update(),V.update()}for(let P=0;P<r.length;P++)Wa.push(r[P]);this._font=i,this.dirty=!1}updateTransform(){this.validate(),this.containerUpdateTransform()}_render(i){this._autoResolution&&this._resolution!==i.resolution&&(this._resolution=i.resolution,this.dirty=!0);const{distanceFieldRange:t,distanceFieldType:e,size:s}=vt.available[this._fontName];if(e!=="none"){const{a:r,b:n,c:o,d:a}=this.worldTransform,h=Math.sqrt(r*r+n*n),l=Math.sqrt(o*o+a*a),c=(Math.abs(h)+Math.abs(l))/2,u=this.fontSize/s,d=i._view.resolution;for(const f of this._activePagesMeshData)f.mesh.shader.uniforms.uFWidth=c*t*u*d}super._render(i)}getLocalBounds(){return this.validate(),super.getLocalBounds()}validate(){const i=vt.available[this._fontName];if(!i)throw new Error(`Missing BitmapFont "${this._fontName}"`);this._font!==i&&(this.dirty=!0),this.dirty&&this.updateText()}get tint(){return this._tint}set tint(i){if(this._tint!==i){this._tint=i;for(let t=0;t<this._activePagesMeshData.length;t++)this._activePagesMeshData[t].mesh.tint=i}}get align(){return this._align}set align(i){this._align!==i&&(this._align=i,this.dirty=!0)}get fontName(){return this._fontName}set fontName(i){if(!vt.available[i])throw new Error(`Missing BitmapFont "${i}"`);this._fontName!==i&&(this._fontName=i,this.dirty=!0)}get fontSize(){var i;return(i=this._fontSize)!=null?i:vt.available[this._fontName].size}set fontS
|
||
|
//# sourceMappingURL=pixi.min.js.map
|