pixi.js 7.0.0 → 7.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pixi.min.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  var Za=Object.defineProperty,Qa=Object.defineProperties;var Ja=Object.getOwnPropertyDescriptors;var vi=Object.getOwnPropertySymbols;var _n=Object.prototype.hasOwnProperty,gn=Object.prototype.propertyIsEnumerable;var mn=(i,t,e)=>t in i?Za(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,Ht=(i,t)=>{for(var e in t||(t={}))_n.call(t,e)&&mn(i,e,t[e]);if(vi)for(var e of vi(t))gn.call(t,e)&&mn(i,e,t[e]);return i},Ts=(i,t)=>Qa(i,Ja(t));var bs=(i,t)=>{var e={};for(var s in i)_n.call(i,s)&&t.indexOf(s)<0&&(e[s]=i[s]);if(i!=null&&vi)for(var s of vi(i))t.indexOf(s)<0&&gn.call(i,s)&&(e[s]=i[s]);return e};/*!
2
- * pixi.js - v7.0.0
3
- * Compiled Fri, 28 Oct 2022 17:30:09 UTC
2
+ * pixi.js - v7.0.2
3
+ * Compiled Mon, 31 Oct 2022 15:20:53 UTC
4
4
  *
5
5
  * pixi.js is licensed under the MIT License.
6
6
  * http://www.opensource.org/licenses/mit-license
@@ -415,7 +415,7 @@ void main(void)
415
415
  `)}}return n.push(`
416
416
  renderer.buffer.update(buffer);
417
417
  `),{size:r,syncFunc:new Function("ud","uv","renderer","syncData","buffer",n.join(`
418
- `))}}class pd{}class Mo{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 md(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:xo(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function _d(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:po(h,n.size)}}return e}function Bo(i,t){var h;const e=uo(i,i.VERTEX_SHADER,t.vertexSrc),s=uo(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)||Ku(i,r,e,s),t.attributeData=md(r,i),t.uniformData=_d(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:po(c.type,c.size)}}return new Mo(r,o)}let gd=0;const Wi={textureCount:0,uboCount:0};class yr{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=gd++}systemCheck(){if(!rd())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||(Wi.textureCount=0,Wi.uboCount=0,this.syncUniformGroup(t.uniformGroup,Wi)),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]=ed(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,Wi,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]=Po(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.uniformGroups[t.id]}getSignature(t,e,s){const r=t.uniforms,n=[`${s}-`];for(const o in r)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,s=t.program,r=Bo(e,s);return s.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}yr.extension={type:P.RendererSystem,name:"shader"},U.add(yr);function xd(i,t=[]){return t[k.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD]=[i.ONE,i.ONE],t[k.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.NONE]=[0,0],t[k.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[k.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[k.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[k.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[k.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[k.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[k.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[k.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const vd=0,yd=1,Td=2,bd=3,Ed=4,wd=5,Tr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=k.NONE,this._blendEq=!1,this.map=[],this.map[vd]=this.setBlend,this.map[yd]=this.setOffset,this.map[Td]=this.setCullFace,this.map[bd]=this.setDepthTest,this.map[Ed]=this.setFrontFace,this.map[wd]=this.setDepthMask,this.checks=[],this.defaultState=new jt,this.defaultState.blend=!0}contextChange(i){this.gl=i,this.blendModes=xd(i),this.set(this.defaultState),this.reset()}set(i){if(i=i||this.defaultState,this.stateId!==i.data){let t=this.stateId^i.data,e=0;for(;t;)t&1&&this.map[e].call(this,!!(i.data&1<<e)),t=t>>1,e++;this.stateId=i.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,i)}forceState(i){i=i||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(i.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,i);this.stateId=i.data}setBlend(i){this.updateCheck(Tr.checkBlendMode,i),this.gl[i?"enable":"disable"](this.gl.BLEND)}setOffset(i){this.updateCheck(Tr.checkPolygonOffset,i),this.gl[i?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(i){this.gl[i?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(i){this.gl.depthMask(i)}setCullFace(i){this.gl[i?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(i){this.gl.frontFace(this.gl[i?"CW":"CCW"])}setBlendMode(i){if(i===this.blendMode)return;this.blendMode=i;const t=this.blendModes[i],e=this.gl;t.length===2?e.blendFunc(t[0],t[1]):e.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,e.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD))}setPolygonOffset(i,t){this.gl.polygonOffset(i,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(i,t){const e=this.checks.indexOf(i);t&&e===-1?this.checks.push(i):!t&&e!==-1&&this.checks.splice(e,1)}static checkBlendMode(i,t){i.setBlendMode(t.blendMode)}static checkPolygonOffset(i,t){i.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};let br=Tr;br.extension={type:P.RendererSystem,name:"state"},U.add(br);class Er{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=S.GC_MAX_IDLE,this.checkCountMax=S.GC_MAX_CHECK_COUNT,this.mode=S.GC_MODE}postrender(){!this.renderer.objectRenderer.renderingToScreen||(this.count++,this.mode!==bi.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let r=0;r<e.length;r++){const n=e[r];!n.framebuffer&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,s=!0)}if(s){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,s=t._texture;s&&!s.framebuffer&&e.destroyTexture(s);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}}Er.extension={type:P.RendererSystem,name:"textureGC"},U.add(Er);function Ad(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA8,[C.RGB]:i.RGB8,[C.RG]:i.RG8,[C.RED]:i.R8,[C.RGBA_INTEGER]:i.RGBA8UI,[C.RGB_INTEGER]:i.RGB8UI,[C.RG_INTEGER]:i.RG8UI,[C.RED_INTEGER]:i.R8UI,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.BYTE]:{[C.RGBA]:i.RGBA8_SNORM,[C.RGB]:i.RGB8_SNORM,[C.RG]:i.RG8_SNORM,[C.RED]:i.R8_SNORM,[C.RGBA_INTEGER]:i.RGBA8I,[C.RGB_INTEGER]:i.RGB8I,[C.RG_INTEGER]:i.RG8I,[C.RED_INTEGER]:i.R8I},[O.UNSIGNED_SHORT]:{[C.RGBA_INTEGER]:i.RGBA16UI,[C.RGB_INTEGER]:i.RGB16UI,[C.RG_INTEGER]:i.RG16UI,[C.RED_INTEGER]:i.R16UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[O.SHORT]:{[C.RGBA_INTEGER]:i.RGBA16I,[C.RGB_INTEGER]:i.RGB16I,[C.RG_INTEGER]:i.RG16I,[C.RED_INTEGER]:i.R16I},[O.UNSIGNED_INT]:{[C.RGBA_INTEGER]:i.RGBA32UI,[C.RGB_INTEGER]:i.RGB32UI,[C.RG_INTEGER]:i.RG32UI,[C.RED_INTEGER]:i.R32UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[O.INT]:{[C.RGBA_INTEGER]:i.RGBA32I,[C.RGB_INTEGER]:i.RGB32I,[C.RG_INTEGER]:i.RG32I,[C.RED_INTEGER]:i.R32I},[O.FLOAT]:{[C.RGBA]:i.RGBA32F,[C.RGB]:i.RGB32F,[C.RG]:i.RG32F,[C.RED]:i.R32F,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[O.HALF_FLOAT]:{[C.RGBA]:i.RGBA16F,[C.RGB]:i.RGB16F,[C.RG]:i.RG16F,[C.RED]:i.R16F},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB565},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA4},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGB5_A1},[O.UNSIGNED_INT_2_10_10_10_REV]:{[C.RGBA]:i.RGB10_A2,[C.RGBA_INTEGER]:i.RGB10_A2UI},[O.UNSIGNED_INT_10F_11F_11F_REV]:{[C.RGB]:i.R11F_G11F_B10F},[O.UNSIGNED_INT_5_9_9_9_REV]:{[C.RGB]:i.RGB9_E5},[O.UNSIGNED_INT_24_8]:{[C.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[O.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[C.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA,[C.RGB]:i.RGB,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGBA}},t}class ji{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=O.UNSIGNED_BYTE,this.internalFormat=C.RGBA,this.samplerType=0}}class wr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new W,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Ad(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const s=new ji(t.createTexture());t.bindTexture(t.TEXTURE_2D,s.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=s,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ji(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:s}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(s.TEXTURE_2D,this.emptyTextures[s.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:s}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<s.length;r++)s[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<s.length;r++)s[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),s[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:s,CONTEXT_UID:r}=this;if(!!s)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[r].samplerType!==Ti.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new ji(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var s,r;e.internalFormat=(r=(s=this.internalFormats[t.type])==null?void 0:s[t.format])!=null?r:t.format,this.webGLVersion===2&&t.type===O.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var r;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const s=this.renderer;if(this.initTextureType(t,e),(r=t.resource)!=null&&r.upload(s,t,e))e.samplerType!==Ti.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=s.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:s}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),s.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&_e(this.managedTextures,r,1)}}updateTextureStyle(t){var s;const e=t._glTextures[this.CONTEXT_UID];!e||((t.mipmap===Pt.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Vt.CLAMP:e.wrapMode=t.wrapMode,(s=t.resource)!=null&&s.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const s=this.gl;if(e.mipmap&&t.mipmap!==Pt.ON_MANUAL&&s.generateMipmap(t.target),s.texParameteri(t.target,s.TEXTURE_WRAP_S,e.wrapMode),s.texParameteri(t.target,s.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Xt.LINEAR){const n=Math.min(t.anisotropicLevel,s.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));s.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}wr.extension={type:P.RendererSystem,name:"texture"},U.add(wr);const Sd=new Xe;class Ar{constructor(t){this.renderer=t,this._tempMatrix=new et}generateTexture(t,e){const h=e||{},{region:s}=h,r=bs(h,["region"]),n=s||t.getLocalBounds(null,!0);n.width===0&&(n.width=1),n.height===0&&(n.height=1);const o=te.create(Ht({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const a=t.transform;return t.transform=Sd,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}Ar.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"textureGenerator"},U.add(Ar);class Sr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=0,this._backgroundColorRgba=[0,0,0,1],this._backgroundColorString="#000000",this.color=this._backgroundColor,this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender,t.color&&(this.color=typeof t.color=="string"?Pi(t.color):t.color),this.alpha=t.alpha}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this._backgroundColorString=Os(t),me(t,this._backgroundColorRgba)}get alpha(){return this._backgroundColorRgba[3]}set alpha(t){this._backgroundColorRgba[3]=t}get colorRgba(){return this._backgroundColorRgba}get colorString(){return this._backgroundColorString}destroy(){}}Sr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"background"},U.add(Sr);class Rr{constructor(t){this.renderer=t}init(t){this.screen=new V(0,0,t.width,t.height),this.element=t.view||S.ADAPTER.createCanvas(),this.resolution=t.resolution||S.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const s=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=s,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${s}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",s,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Rr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_view"},U.add(Rr);class Cr{constructor(t){this.renderer=t,this.plugins={}}init(t){for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Cr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_plugin"},U.add(Cr);class Do extends Re{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){var r;this.addRunners(...t.runners);const e=((r=t.priority)!=null?r:[]).filter(n=>t.systems[n]),s=[...e,...Object.keys(t.systems).filter(n=>!e.includes(n))];for(const n of s)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Tt(e)})}addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const r in this.runners)this.runners[r].add(s);return this}emitWithCustomOptions(t,e){const s=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=s.find(o=>this._systemsHash[o]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}class Ir{constructor(t){this.renderer=t}run(t){const e=this.renderer;e.emitWithCustomOptions(e.runners.init,t),t.hello&&console.log(`PixiJS 7.0.0 - ${e.rendererLogId} - https://pixijs.com`),e.resize(this.renderer.screen.width,this.renderer.screen.height)}destroy(){}}Ir.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"startup"},U.add(Ir);class Pr{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glTransformFeedbacks[s]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:s,renderer:r}=this;e&&r.shader.bind(e),s.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:s,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];!a||(s.buffer.update(a),a._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const s=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}!s||(e||r.deleteTransformFeedback(s),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Pr.extension={type:P.RendererSystem,name:"transformFeedback"},U.add(Pr);const No=[];U.handleByList(P.Renderer,No);function Fo(i){for(const t of No)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Rd=`attribute vec2 aVertexPosition;
418
+ `))}}class pd{}class Mo{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 md(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:xo(o),location:t.getAttribLocation(i,n.name)};e[n.name]=a}return e}function _d(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:po(h,n.size)}}return e}function Bo(i,t){var h;const e=uo(i,i.VERTEX_SHADER,t.vertexSrc),s=uo(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)||Ku(i,r,e,s),t.attributeData=md(r,i),t.uniformData=_d(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:po(c.type,c.size)}}return new Mo(r,o)}let gd=0;const Wi={textureCount:0,uboCount:0};class yr{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=gd++}systemCheck(){if(!rd())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||(Wi.textureCount=0,Wi.uboCount=0,this.syncUniformGroup(t.uniformGroup,Wi)),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]=ed(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,Wi,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]=Po(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.uniformGroups[t.id]}getSignature(t,e,s){const r=t.uniforms,n=[`${s}-`];for(const o in r)n.push(o),e[o]&&n.push(e[o].type);return n.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){const e=this.gl,s=t.program,r=Bo(e,s);return s.glPrograms[this.renderer.CONTEXT_UID]=r,r}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}}yr.extension={type:P.RendererSystem,name:"shader"},U.add(yr);function xd(i,t=[]){return t[k.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD]=[i.ONE,i.ONE],t[k.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.NONE]=[0,0],t[k.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[k.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[k.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[k.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[k.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[k.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[k.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[k.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[k.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[k.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}const vd=0,yd=1,Td=2,bd=3,Ed=4,wd=5,Tr=class{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=k.NONE,this._blendEq=!1,this.map=[],this.map[vd]=this.setBlend,this.map[yd]=this.setOffset,this.map[Td]=this.setCullFace,this.map[bd]=this.setDepthTest,this.map[Ed]=this.setFrontFace,this.map[wd]=this.setDepthMask,this.checks=[],this.defaultState=new jt,this.defaultState.blend=!0}contextChange(i){this.gl=i,this.blendModes=xd(i),this.set(this.defaultState),this.reset()}set(i){if(i=i||this.defaultState,this.stateId!==i.data){let t=this.stateId^i.data,e=0;for(;t;)t&1&&this.map[e].call(this,!!(i.data&1<<e)),t=t>>1,e++;this.stateId=i.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,i)}forceState(i){i=i||this.defaultState;for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(i.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,i);this.stateId=i.data}setBlend(i){this.updateCheck(Tr.checkBlendMode,i),this.gl[i?"enable":"disable"](this.gl.BLEND)}setOffset(i){this.updateCheck(Tr.checkPolygonOffset,i),this.gl[i?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(i){this.gl[i?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(i){this.gl.depthMask(i)}setCullFace(i){this.gl[i?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(i){this.gl.frontFace(this.gl[i?"CW":"CCW"])}setBlendMode(i){if(i===this.blendMode)return;this.blendMode=i;const t=this.blendModes[i],e=this.gl;t.length===2?e.blendFunc(t[0],t[1]):e.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,e.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD))}setPolygonOffset(i,t){this.gl.polygonOffset(i,t)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(i,t){const e=this.checks.indexOf(i);t&&e===-1?this.checks.push(i):!t&&e!==-1&&this.checks.splice(e,1)}static checkBlendMode(i,t){i.setBlendMode(t.blendMode)}static checkPolygonOffset(i,t){i.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null}};let br=Tr;br.extension={type:P.RendererSystem,name:"state"},U.add(br);class Er{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=S.GC_MAX_IDLE,this.checkCountMax=S.GC_MAX_CHECK_COUNT,this.mode=S.GC_MODE}postrender(){!this.renderer.objectRenderer.renderingToScreen||(this.count++,this.mode!==bi.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){const t=this.renderer.texture,e=t.managedTextures;let s=!1;for(let r=0;r<e.length;r++){const n=e[r];!n.framebuffer&&this.count-n.touched>this.maxIdle&&(t.destroyTexture(n,!0),e[r]=null,s=!0)}if(s){let r=0;for(let n=0;n<e.length;n++)e[n]!==null&&(e[r++]=e[n]);e.length=r}}unload(t){const e=this.renderer.texture,s=t._texture;s&&!s.framebuffer&&e.destroyTexture(s);for(let r=t.children.length-1;r>=0;r--)this.unload(t.children[r])}destroy(){this.renderer=null}}Er.extension={type:P.RendererSystem,name:"textureGC"},U.add(Er);function Ad(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA8,[C.RGB]:i.RGB8,[C.RG]:i.RG8,[C.RED]:i.R8,[C.RGBA_INTEGER]:i.RGBA8UI,[C.RGB_INTEGER]:i.RGB8UI,[C.RG_INTEGER]:i.RG8UI,[C.RED_INTEGER]:i.R8UI,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.BYTE]:{[C.RGBA]:i.RGBA8_SNORM,[C.RGB]:i.RGB8_SNORM,[C.RG]:i.RG8_SNORM,[C.RED]:i.R8_SNORM,[C.RGBA_INTEGER]:i.RGBA8I,[C.RGB_INTEGER]:i.RGB8I,[C.RG_INTEGER]:i.RG8I,[C.RED_INTEGER]:i.R8I},[O.UNSIGNED_SHORT]:{[C.RGBA_INTEGER]:i.RGBA16UI,[C.RGB_INTEGER]:i.RGB16UI,[C.RG_INTEGER]:i.RG16UI,[C.RED_INTEGER]:i.R16UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[O.SHORT]:{[C.RGBA_INTEGER]:i.RGBA16I,[C.RGB_INTEGER]:i.RGB16I,[C.RG_INTEGER]:i.RG16I,[C.RED_INTEGER]:i.R16I},[O.UNSIGNED_INT]:{[C.RGBA_INTEGER]:i.RGBA32UI,[C.RGB_INTEGER]:i.RGB32UI,[C.RG_INTEGER]:i.RG32UI,[C.RED_INTEGER]:i.R32UI,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[O.INT]:{[C.RGBA_INTEGER]:i.RGBA32I,[C.RGB_INTEGER]:i.RGB32I,[C.RG_INTEGER]:i.RG32I,[C.RED_INTEGER]:i.R32I},[O.FLOAT]:{[C.RGBA]:i.RGBA32F,[C.RGB]:i.RGB32F,[C.RG]:i.RG32F,[C.RED]:i.R32F,[C.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[O.HALF_FLOAT]:{[C.RGBA]:i.RGBA16F,[C.RGB]:i.RGB16F,[C.RG]:i.RG16F,[C.RED]:i.R16F},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB565},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA4},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGB5_A1},[O.UNSIGNED_INT_2_10_10_10_REV]:{[C.RGBA]:i.RGB10_A2,[C.RGBA_INTEGER]:i.RGB10_A2UI},[O.UNSIGNED_INT_10F_11F_11F_REV]:{[C.RGB]:i.R11F_G11F_B10F},[O.UNSIGNED_INT_5_9_9_9_REV]:{[C.RGB]:i.RGB9_E5},[O.UNSIGNED_INT_24_8]:{[C.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[O.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[C.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[O.UNSIGNED_BYTE]:{[C.RGBA]:i.RGBA,[C.RGB]:i.RGB,[C.ALPHA]:i.ALPHA,[C.LUMINANCE]:i.LUMINANCE,[C.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[O.UNSIGNED_SHORT_5_6_5]:{[C.RGB]:i.RGB},[O.UNSIGNED_SHORT_4_4_4_4]:{[C.RGBA]:i.RGBA},[O.UNSIGNED_SHORT_5_5_5_1]:{[C.RGBA]:i.RGBA}},t}class ji{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=O.UNSIGNED_BYTE,this.internalFormat=C.RGBA,this.samplerType=0}}class wr{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new W,this.hasIntegerTextures=!1}contextChange(){const t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=Ad(t);const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let r=0;r<e;r++)this.boundTextures[r]=null;this.emptyTextures={};const s=new ji(t.createTexture());t.bindTexture(t.TEXTURE_2D,s.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=s,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new ji(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let r=0;r<6;r++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+r,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let r=0;r<this.boundTextures.length;r++)this.bind(null,r)}bind(t,e=0){const{gl:s}=this;if(t=t==null?void 0:t.castToBaseTexture(),(t==null?void 0:t.valid)&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;const r=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(t.target,r.texture)),r.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),this.updateTexture(t)):r.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,s.activeTexture(s.TEXTURE0+e)),s.bindTexture(s.TEXTURE_2D,this.emptyTextures[s.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){const{gl:e,boundTextures:s}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let r=0;r<s.length;r++)s[r]===this.unknownTexture&&this.bind(null,r)}for(let r=0;r<s.length;r++)s[r]===t&&(this.currentLocation!==r&&(e.activeTexture(e.TEXTURE0+r),this.currentLocation=r),e.bindTexture(t.target,this.emptyTextures[t.target].texture),s[r]=null)}ensureSamplerType(t){const{boundTextures:e,hasIntegerTextures:s,CONTEXT_UID:r}=this;if(!!s)for(let n=t-1;n>=0;--n){const o=e[n];o&&o._glTextures[r].samplerType!==Ti.FLOAT&&this.renderer.texture.unbind(o)}}initTexture(t){const e=new ji(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){var s,r;e.internalFormat=(r=(s=this.internalFormats[t.type])==null?void 0:s[t.format])!=null?r:t.format,this.webGLVersion===2&&t.type===O.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){var r;const e=t._glTextures[this.CONTEXT_UID];if(!e)return;const s=this.renderer;if(this.initTextureType(t,e),(r=t.resource)!=null&&r.upload(s,t,e))e.samplerType!==Ti.FLOAT&&(this.hasIntegerTextures=!0);else{const n=t.realWidth,o=t.realHeight,a=s.gl;(e.width!==n||e.height!==o||e.dirtyId<0)&&(e.width=n,e.height=o,a.texImage2D(t.target,0,e.internalFormat,n,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){const{gl:s}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),s.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){const r=this.managedTextures.indexOf(t);r!==-1&&_e(this.managedTextures,r,1)}}updateTextureStyle(t){var s;const e=t._glTextures[this.CONTEXT_UID];!e||((t.mipmap===Pt.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Vt.CLAMP:e.wrapMode=t.wrapMode,(s=t.resource)!=null&&s.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){const s=this.gl;if(e.mipmap&&t.mipmap!==Pt.ON_MANUAL&&s.generateMipmap(t.target),s.texParameteri(t.target,s.TEXTURE_WRAP_S,e.wrapMode),s.texParameteri(t.target,s.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR_MIPMAP_LINEAR:s.NEAREST_MIPMAP_NEAREST);const r=this.renderer.context.extensions.anisotropicFiltering;if(r&&t.anisotropicLevel>0&&t.scaleMode===Xt.LINEAR){const n=Math.min(t.anisotropicLevel,s.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT));s.texParameterf(t.target,r.TEXTURE_MAX_ANISOTROPY_EXT,n)}}else s.texParameteri(t.target,s.TEXTURE_MIN_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST);s.texParameteri(t.target,s.TEXTURE_MAG_FILTER,t.scaleMode===Xt.LINEAR?s.LINEAR:s.NEAREST)}destroy(){this.renderer=null}}wr.extension={type:P.RendererSystem,name:"texture"},U.add(wr);const Sd=new Xe;class Ar{constructor(t){this.renderer=t,this._tempMatrix=new et}generateTexture(t,e){const h=e||{},{region:s}=h,r=bs(h,["region"]),n=s||t.getLocalBounds(null,!0);n.width===0&&(n.width=1),n.height===0&&(n.height=1);const o=te.create(Ht({width:n.width,height:n.height},r));this._tempMatrix.tx=-n.x,this._tempMatrix.ty=-n.y;const a=t.transform;return t.transform=Sd,this.renderer.render(t,{renderTexture:o,transform:this._tempMatrix,skipUpdateTransform:!!t.parent,blit:!0}),t.transform=a,o}destroy(){}}Ar.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"textureGenerator"},U.add(Ar);class Sr{constructor(){this.clearBeforeRender=!0,this._backgroundColor=0,this._backgroundColorRgba=[0,0,0,1],this._backgroundColorString="#000000",this.color=this._backgroundColor,this.alpha=1}init(t){this.clearBeforeRender=t.clearBeforeRender,t.color&&(this.color=typeof t.color=="string"?Pi(t.color):t.color),this.alpha=t.alpha}get color(){return this._backgroundColor}set color(t){this._backgroundColor=t,this._backgroundColorString=Os(t),me(t,this._backgroundColorRgba)}get alpha(){return this._backgroundColorRgba[3]}set alpha(t){this._backgroundColorRgba[3]=t}get colorRgba(){return this._backgroundColorRgba}get colorString(){return this._backgroundColorString}destroy(){}}Sr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"background"},U.add(Sr);class Rr{constructor(t){this.renderer=t}init(t){this.screen=new V(0,0,t.width,t.height),this.element=t.view||S.ADAPTER.createCanvas(),this.resolution=t.resolution||S.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);const s=this.element.width/this.resolution,r=this.element.height/this.resolution;this.screen.width=s,this.screen.height=r,this.autoDensity&&(this.element.style.width=`${s}px`,this.element.style.height=`${r}px`),this.renderer.emit("resize",s,r),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){var e;t&&((e=this.element.parentNode)==null||e.removeChild(this.element)),this.renderer=null,this.element=null,this.screen=null}}Rr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_view"},U.add(Rr);class Cr{constructor(t){this.renderer=t,this.plugins={}}init(t){for(const e in t)this.plugins[e]=new t[e](this.renderer)}destroy(){for(const t in this.plugins)this.plugins[t].destroy(),this.plugins[t]=null}}Cr.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"_plugin"},U.add(Cr);class Do extends Re{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){var r;this.addRunners(...t.runners);const e=((r=t.priority)!=null?r:[]).filter(n=>t.systems[n]),s=[...e,...Object.keys(t.systems).filter(n=>!e.includes(n))];for(const n of s)this.addSystem(t.systems[n],n)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Tt(e)})}addSystem(t,e){const s=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=s,this._systemsHash[e]=s;for(const r in this.runners)this.runners[r].add(s);return this}emitWithCustomOptions(t,e){const s=Object.keys(this._systemsHash);t.items.forEach(r=>{const n=s.find(o=>this._systemsHash[o]===r);r[t.name](e[n])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}}class Ir{constructor(t){this.renderer=t}run(t){const e=this.renderer;e.emitWithCustomOptions(e.runners.init,t),t.hello&&console.log(`PixiJS 7.0.2 - ${e.rendererLogId} - https://pixijs.com`),e.resize(this.renderer.screen.width,this.renderer.screen.height)}destroy(){}}Ir.extension={type:[P.RendererSystem,P.CanvasRendererSystem],name:"startup"},U.add(Ir);class Pr{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glTransformFeedbacks[s]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,r)}unbind(){const{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){const{gl:s,renderer:r}=this;e&&r.shader.bind(e),s.beginTransformFeedback(t)}endTransformFeedback(){const{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){const{gl:e,renderer:s,CONTEXT_UID:r}=this,n=e.createTransformFeedback();t._glTransformFeedbacks[r]=n,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,n);for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];!a||(s.buffer.update(a),a._glBuffers[r].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,o,a._glBuffers[r].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),n}disposeTransformFeedback(t,e){const s=t._glTransformFeedbacks[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this);const n=this.renderer.buffer;if(n)for(let o=0;o<t.buffers.length;o++){const a=t.buffers[o];if(!a)continue;const h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&n.dispose(a,e))}!s||(e||r.deleteTransformFeedback(s),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}}Pr.extension={type:P.RendererSystem,name:"transformFeedback"},U.add(Pr);const No=[];U.handleByList(P.Renderer,No);function Fo(i){for(const t of No)if(t.test(i))return new t(i);throw new Error("Unable to auto-detect a suitable renderer.")}var Rd=`attribute vec2 aVertexPosition;
419
419
  attribute vec2 aTextureCoord;
420
420
 
421
421
  uniform mat3 projectionMatrix;
@@ -491,7 +491,7 @@ void main(void){
491
491
  %forloop%
492
492
  gl_FragColor = color * vColor;
493
493
  }
494
- `;const Te=class extends Ze{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=jt.for2d(),this.size=S.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 Id}static get defaultFragmentTemplate(){return Pd}setShaderGenerator({vertex:i=Te.defaultVertexSrc,fragment:t=Te.defaultFragmentTemplate}={}){this.shaderGenerator=new Uo(i,t)}contextChange(){const i=this.renderer.gl;S.PREFER_ENV===se.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),S.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=To(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}=Te,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Yi);for(;t.length<s;)t.push(new $i);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=Te._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++W._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;W._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Te._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,m=ks[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==m&&(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=m}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;S.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=Te._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(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES),this.renderer.shader.bind(this._shader),S.CAN_UPLOAD_SAME_BUFFER&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let i=0;i<this._packedGeometryPoolSize;i++)this._packedGeometries[i]&&this._packedGeometries[i].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(i){const t=$e(Math.ceil(i/8)),e=Vs(t),s=t*8;this._aBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._aBuffers[s];return r||(this._aBuffers[s]=r=new qi(s*this.vertexSize*4)),r}getIndexBuffer(i){const t=$e(Math.ceil(i/12)),e=Vs(t),s=t*12;this._iBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._iBuffers[e];return r||(this._iBuffers[e]=r=new Uint16Array(s)),r}packInterleavedGeometry(i,t,e,s,r){const{uint32View:n,float32View:o}=t,a=s/this.vertexSize,h=i.uvs,l=i.indices,c=i.vertexData,u=i._texture.baseTexture._batchLocation,d=Math.min(i.worldAlpha,1),f=d<1&&i._texture.baseTexture.alphaMode?Mi(i._tintRGB,d):i._tintRGB+(d*255<<24);for(let p=0;p<c.length;p+=2)o[s++]=c[p],o[s++]=c[p+1],o[s++]=h[p],o[s++]=h[p+1],n[s++]=f,o[s++]=u;for(let p=0;p<l.length;p++)e[r++]=a+l[p]}};let ti=Te;ti.extension={name:"batch",type:P.RendererPlugin},ti._drawCallPool=[],ti._textureArrayPool=[],U.add(ti);class Md{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Tt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}class Bd{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Nr{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:s,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,s){const{gl:r,CONTEXT_UID:n}=this;s=s||0;const o=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,o.buffer,s*256,256)}update(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const s=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),s&&(e||r.deleteBuffer(s.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let s=0;s<e.length;s++)this.dispose(this.managedBuffers[e[s]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:s}=this;return t._glBuffers[e]=new Bd(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Nr.extension={type:P.RendererSystem,name:"buffer"},U.add(Nr);class Fr{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const s=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,s)}else{const s=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,s)}e>=nt.HIGH?this.multisample=nt.HIGH:e>=nt.MEDIUM?this.multisample=nt.MEDIUM:e>=nt.LOW?this.multisample=nt.LOW:this.multisample=nt.NONE}destroy(){}}Fr.extension={type:P.RendererSystem,name:"_multisample"},U.add(Fr);class Lr{constructor(t){this.renderer=t}render(t,e){const s=this.renderer;let r,n,o,a;if(e&&(r=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!r,s.runners.prerender.emit(),s.emit("prerender"),s.projection.transform=o,!s.context.isLost){if(r||(this.lastObjectRendered=t),!a){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}s.renderTexture.bind(r),s.batch.currentRenderer.start(),(n!=null?n:s.background.clearBeforeRender)&&s.renderTexture.clear(),t.render(s),s.batch.currentRenderer.flush(),r&&(e.blit&&s.framebuffer.blit(),r.baseTexture.update()),s.runners.postrender.emit(),s.projection.transform=null,s.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Lr.extension={type:P.RendererSystem,name:"objectRenderer"},U.add(Lr);const Dd="7.0.0";var Nd=`varying vec2 vTextureCoord;
494
+ `;const Te=class extends Ze{constructor(i){super(i),this.setShaderGenerator(),this.geometryClass=Dr,this.vertexSize=6,this.state=jt.for2d(),this.size=S.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 Id}static get defaultFragmentTemplate(){return Pd}setShaderGenerator({vertex:i=Te.defaultVertexSrc,fragment:t=Te.defaultFragmentTemplate}={}){this.shaderGenerator=new Uo(i,t)}contextChange(){const i=this.renderer.gl;S.PREFER_ENV===se.WEBGL_LEGACY?this.MAX_TEXTURES=1:(this.MAX_TEXTURES=Math.min(i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),S.SPRITE_MAX_TEXTURES),this.MAX_TEXTURES=To(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}=Te,e=this.size/4,s=Math.floor(e/this.MAX_TEXTURES)+1;for(;i.length<e;)i.push(new Yi);for(;t.length<s;)t.push(new $i);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=Te._textureArrayPool,s=this.renderer.batch,r=this._tempBoundTextures,n=this.renderer.textureGC.count;let o=++W._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;W._globalBatch=o}buildDrawCalls(i,t,e){const{_bufferedElements:s,_attributeBuffer:r,_indexBuffer:n,vertexSize:o}=this,a=Te._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,m=ks[p.alphaMode?1:0][f.blendMode];s[d]=null,t<d&&u.blend!==m&&(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=m}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;S.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=Te._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(this._indexCount),this._aIndex=0,this._iIndex=0,this._dcIndex=0,this.buildTexturesAndDrawCalls(),this.updateGeometry(),this.drawBatches(),this._bufferSize=0,this._vertexCount=0,this._indexCount=0)}start(){this.renderer.state.set(this.state),this.renderer.texture.ensureSamplerType(this.MAX_TEXTURES),this.renderer.shader.bind(this._shader),S.CAN_UPLOAD_SAME_BUFFER&&this.renderer.geometry.bind(this._packedGeometries[this._flushId])}stop(){this.flush()}destroy(){for(let i=0;i<this._packedGeometryPoolSize;i++)this._packedGeometries[i]&&this._packedGeometries[i].destroy();this.renderer.off("prerender",this.onPrerender,this),this._aBuffers=null,this._iBuffers=null,this._packedGeometries=null,this._attributeBuffer=null,this._indexBuffer=null,this._shader&&(this._shader.destroy(),this._shader=null),super.destroy()}getAttributeBuffer(i){const t=$e(Math.ceil(i/8)),e=Vs(t),s=t*8;this._aBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._aBuffers[s];return r||(this._aBuffers[s]=r=new qi(s*this.vertexSize*4)),r}getIndexBuffer(i){const t=$e(Math.ceil(i/12)),e=Vs(t),s=t*12;this._iBuffers.length<=e&&(this._iBuffers.length=e+1);let r=this._iBuffers[e];return r||(this._iBuffers[e]=r=new Uint16Array(s)),r}packInterleavedGeometry(i,t,e,s,r){const{uint32View:n,float32View:o}=t,a=s/this.vertexSize,h=i.uvs,l=i.indices,c=i.vertexData,u=i._texture.baseTexture._batchLocation,d=Math.min(i.worldAlpha,1),f=d<1&&i._texture.baseTexture.alphaMode?Mi(i._tintRGB,d):i._tintRGB+(d*255<<24);for(let p=0;p<c.length;p+=2)o[s++]=c[p],o[s++]=c[p+1],o[s++]=h[p],o[s++]=h[p+1],n[s++]=f,o[s++]=u;for(let p=0;p<l.length;p++)e[r++]=a+l[p]}};let ti=Te;ti.extension={name:"batch",type:P.RendererPlugin},ti._drawCallPool=[],ti._textureArrayPool=[],U.add(ti);class Md{constructor(){this._glTransformFeedbacks={},this.buffers=[],this.disposeRunner=new Tt("disposeTransformFeedback")}bindBuffer(t,e){this.buffers[t]=e}destroy(){this.disposeRunner.emit(this,!1)}}class Bd{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}}class Nr{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);e.bindBuffer(t.type,r.buffer)}unbind(t){const{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){const{gl:s,CONTEXT_UID:r}=this;if(this.boundBufferBases[e]!==t){const n=t._glBuffers[r]||this.createGLBuffer(t);this.boundBufferBases[e]=t,s.bindBufferBase(s.UNIFORM_BUFFER,e,n.buffer)}}bindBufferRange(t,e,s){const{gl:r,CONTEXT_UID:n}=this;s=s||0;const o=t._glBuffers[n]||this.createGLBuffer(t);r.bindBufferRange(r.UNIFORM_BUFFER,e||0,o.buffer,s*256,256)}update(t){const{gl:e,CONTEXT_UID:s}=this,r=t._glBuffers[s]||this.createGLBuffer(t);if(t._updateID!==r.updateID)if(r.updateID=t._updateID,e.bindBuffer(t.type,r.buffer),r.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{const n=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;r.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,n)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];const s=t._glBuffers[this.CONTEXT_UID],r=this.gl;t.disposeRunner.remove(this),s&&(e||r.deleteBuffer(s.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){const e=Object.keys(this.managedBuffers);for(let s=0;s<e.length;s++)this.dispose(this.managedBuffers[e[s]],t)}createGLBuffer(t){const{CONTEXT_UID:e,gl:s}=this;return t._glBuffers[e]=new Bd(s.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}}Nr.extension={type:P.RendererSystem,name:"buffer"},U.add(Nr);class Fr{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){const s=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,s)}else{const s=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,s)}e>=nt.HIGH?this.multisample=nt.HIGH:e>=nt.MEDIUM?this.multisample=nt.MEDIUM:e>=nt.LOW?this.multisample=nt.LOW:this.multisample=nt.NONE}destroy(){}}Fr.extension={type:P.RendererSystem,name:"_multisample"},U.add(Fr);class Lr{constructor(t){this.renderer=t}render(t,e){const s=this.renderer;let r,n,o,a;if(e&&(r=e.renderTexture,n=e.clear,o=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!r,s.runners.prerender.emit(),s.emit("prerender"),s.projection.transform=o,!s.context.isLost){if(r||(this.lastObjectRendered=t),!a){const h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}s.renderTexture.bind(r),s.batch.currentRenderer.start(),(n!=null?n:s.background.clearBeforeRender)&&s.renderTexture.clear(),t.render(s),s.batch.currentRenderer.flush(),r&&(e.blit&&s.framebuffer.blit(),r.baseTexture.update()),s.runners.postrender.emit(),s.projection.transform=null,s.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}}Lr.extension={type:P.RendererSystem,name:"objectRenderer"},U.add(Lr);const Dd="7.0.2";var Nd=`varying vec2 vTextureCoord;
495
495
 
496
496
  uniform sampler2D uSampler;
497
497
  uniform float uAlpha;