fancy-webgl-sparkles
Version:
PIXI.js library to add glitter particles with bokeh and special effects to your DOM elements
39 lines (37 loc) • 289 kB
JavaScript
!function t(e,r,i){function n(s,a){if(!r[s]){if(!e[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[s]={exports:{}};e[s][0].call(l.exports,(function(t){return n(e[s][1][t]||t)}),l,l.exports,t,e,r,i)}return r[s].exports}for(var o="function"==typeof require&&require,s=0;s<i.length;s++)n(i[s]);return n}({1:[function(t,e,r){
/*!
* @pixi/app - v5.3.8
* Compiled Sat, 20 Feb 2021 22:28:33 UTC
*
* @pixi/app is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("@pixi/display"),n=t("@pixi/core"),o=function(){function t(e){var r=this;e=Object.assign({forceCanvas:!1},e),this.renderer=n.autoDetectRenderer(e),this.stage=new i.Container,t._plugins.forEach((function(t){t.init.call(r,e)}))}return t.registerPlugin=function(e){t._plugins.push(e)},t.prototype.render=function(){this.renderer.render(this.stage)},Object.defineProperty(t.prototype,"view",{get:function(){return this.renderer.view},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screen",{get:function(){return this.renderer.screen},enumerable:!1,configurable:!0}),t.prototype.destroy=function(e,r){var i=this,n=t._plugins.slice(0);n.reverse(),n.forEach((function(t){t.destroy.call(i)})),this.stage.destroy(r),this.stage=null,this.renderer.destroy(e),this.renderer=null},t}();o._plugins=[];var s=function(){function t(){}return t.init=function(t){var e=this;Object.defineProperty(this,"resizeTo",{set:function(t){window.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(window.addEventListener("resize",this.queueResize),this.resize())},get:function(){return this._resizeTo}}),this.queueResize=function(){e._resizeTo&&(e.cancelResize(),e._resizeId=requestAnimationFrame((function(){return e.resize()})))},this.cancelResize=function(){e._resizeId&&(cancelAnimationFrame(e._resizeId),e._resizeId=null)},this.resize=function(){if(e._resizeTo){var t,r;if(e.cancelResize(),e._resizeTo===window)t=window.innerWidth,r=window.innerHeight;else{var i=e._resizeTo;t=i.clientWidth,r=i.clientHeight}e.renderer.resize(t,r)}},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null},t.destroy=function(){this.cancelResize(),this.cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null},t}();o.registerPlugin(s),r.Application=o},{"@pixi/core":3,"@pixi/display":4}],2:[function(t,e,r){
/*!
* @pixi/constants - v5.3.8
* Compiled Sat, 20 Feb 2021 22:28:33 UTC
*
* @pixi/constants is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";var i,n,o,s,a,h,u,l,c,d,f,p,m,y,v,_,g;Object.defineProperty(r,"__esModule",{value:!0}),(i=r.ENV||(r.ENV={}))[i.WEBGL_LEGACY=0]="WEBGL_LEGACY",i[i.WEBGL=1]="WEBGL",i[i.WEBGL2=2]="WEBGL2",(n=r.RENDERER_TYPE||(r.RENDERER_TYPE={}))[n.UNKNOWN=0]="UNKNOWN",n[n.WEBGL=1]="WEBGL",n[n.CANVAS=2]="CANVAS",(o=r.BUFFER_BITS||(r.BUFFER_BITS={}))[o.COLOR=16384]="COLOR",o[o.DEPTH=256]="DEPTH",o[o.STENCIL=1024]="STENCIL",(s=r.BLEND_MODES||(r.BLEND_MODES={}))[s.NORMAL=0]="NORMAL",s[s.ADD=1]="ADD",s[s.MULTIPLY=2]="MULTIPLY",s[s.SCREEN=3]="SCREEN",s[s.OVERLAY=4]="OVERLAY",s[s.DARKEN=5]="DARKEN",s[s.LIGHTEN=6]="LIGHTEN",s[s.COLOR_DODGE=7]="COLOR_DODGE",s[s.COLOR_BURN=8]="COLOR_BURN",s[s.HARD_LIGHT=9]="HARD_LIGHT",s[s.SOFT_LIGHT=10]="SOFT_LIGHT",s[s.DIFFERENCE=11]="DIFFERENCE",s[s.EXCLUSION=12]="EXCLUSION",s[s.HUE=13]="HUE",s[s.SATURATION=14]="SATURATION",s[s.COLOR=15]="COLOR",s[s.LUMINOSITY=16]="LUMINOSITY",s[s.NORMAL_NPM=17]="NORMAL_NPM",s[s.ADD_NPM=18]="ADD_NPM",s[s.SCREEN_NPM=19]="SCREEN_NPM",s[s.NONE=20]="NONE",s[s.SRC_OVER=0]="SRC_OVER",s[s.SRC_IN=21]="SRC_IN",s[s.SRC_OUT=22]="SRC_OUT",s[s.SRC_ATOP=23]="SRC_ATOP",s[s.DST_OVER=24]="DST_OVER",s[s.DST_IN=25]="DST_IN",s[s.DST_OUT=26]="DST_OUT",s[s.DST_ATOP=27]="DST_ATOP",s[s.ERASE=26]="ERASE",s[s.SUBTRACT=28]="SUBTRACT",s[s.XOR=29]="XOR",(a=r.DRAW_MODES||(r.DRAW_MODES={}))[a.POINTS=0]="POINTS",a[a.LINES=1]="LINES",a[a.LINE_LOOP=2]="LINE_LOOP",a[a.LINE_STRIP=3]="LINE_STRIP",a[a.TRIANGLES=4]="TRIANGLES",a[a.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",a[a.TRIANGLE_FAN=6]="TRIANGLE_FAN",(h=r.FORMATS||(r.FORMATS={}))[h.RGBA=6408]="RGBA",h[h.RGB=6407]="RGB",h[h.ALPHA=6406]="ALPHA",h[h.LUMINANCE=6409]="LUMINANCE",h[h.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",h[h.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",h[h.DEPTH_STENCIL=34041]="DEPTH_STENCIL",(u=r.TARGETS||(r.TARGETS={}))[u.TEXTURE_2D=3553]="TEXTURE_2D",u[u.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",u[u.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",u[u.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",u[u.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",u[u.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",u[u.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",u[u.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",u[u.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",(l=r.TYPES||(r.TYPES={}))[l.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",l[l.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",l[l.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",l[l.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",l[l.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",l[l.FLOAT=5126]="FLOAT",l[l.HALF_FLOAT=36193]="HALF_FLOAT",(c=r.SCALE_MODES||(r.SCALE_MODES={}))[c.NEAREST=0]="NEAREST",c[c.LINEAR=1]="LINEAR",(d=r.WRAP_MODES||(r.WRAP_MODES={}))[d.CLAMP=33071]="CLAMP",d[d.REPEAT=10497]="REPEAT",d[d.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",(f=r.MIPMAP_MODES||(r.MIPMAP_MODES={}))[f.OFF=0]="OFF",f[f.POW2=1]="POW2",f[f.ON=2]="ON",(p=r.ALPHA_MODES||(r.ALPHA_MODES={}))[p.NPM=0]="NPM",p[p.UNPACK=1]="UNPACK",p[p.PMA=2]="PMA",p[p.NO_PREMULTIPLIED_ALPHA=0]="NO_PREMULTIPLIED_ALPHA",p[p.PREMULTIPLY_ON_UPLOAD=1]="PREMULTIPLY_ON_UPLOAD",p[p.PREMULTIPLY_ALPHA=2]="PREMULTIPLY_ALPHA",(m=r.CLEAR_MODES||(r.CLEAR_MODES={}))[m.NO=0]="NO",m[m.YES=1]="YES",m[m.AUTO=2]="AUTO",m[m.BLEND=0]="BLEND",m[m.CLEAR=1]="CLEAR",m[m.BLIT=2]="BLIT",(y=r.GC_MODES||(r.GC_MODES={}))[y.AUTO=0]="AUTO",y[y.MANUAL=1]="MANUAL",(v=r.PRECISION||(r.PRECISION={})).LOW="lowp",v.MEDIUM="mediump",v.HIGH="highp",(_=r.MASK_TYPES||(r.MASK_TYPES={}))[_.NONE=0]="NONE",_[_.SCISSOR=1]="SCISSOR",_[_.STENCIL=2]="STENCIL",_[_.SPRITE=3]="SPRITE",(g=r.MSAA_QUALITY||(r.MSAA_QUALITY={}))[g.NONE=0]="NONE",g[g.LOW=2]="LOW",g[g.MEDIUM=4]="MEDIUM",g[g.HIGH=8]="HIGH"},{}],3:[function(t,e,r){
/*!
* @pixi/core - v5.3.8
* Compiled Sat, 20 Feb 2021 22:28:33 UTC
*
* @pixi/core is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
*/
"use strict";Object.defineProperty(r,"__esModule",{value:!0});var i=t("@pixi/settings"),n=t("@pixi/constants"),o=t("@pixi/utils"),s=t("@pixi/runner"),a=t("@pixi/ticker"),h=t("@pixi/math");i.settings.PREFER_ENV=o.isMobile.any?n.ENV.WEBGL:n.ENV.WEBGL2,i.settings.STRICT_TEXTURE_CACHE=!1;var u=[];function l(t,e){if(!t)return null;var r="";if("string"==typeof t){var i=/\.(\w{3,4})(?:$|\?|#)/i.exec(t);i&&(r=i[1].toLowerCase())}for(var n=u.length-1;n>=0;--n){var o=u[n];if(o.test&&o.test(t,r))return new o(t,e)}throw new Error("Unrecognized source type to auto-detect Resource")}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */var c=function(t,e){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function d(t,e){function r(){this.constructor=t}c(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var f=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this._width=t,this._height=e,this.destroyed=!1,this.internal=!1,this.onResize=new s.Runner("setRealSize"),this.onUpdate=new s.Runner("update"),this.onError=new s.Runner("onError")}return t.prototype.bind=function(t){this.onResize.add(t),this.onUpdate.add(t),this.onError.add(t),(this._width||this._height)&&this.onResize.emit(this._width,this._height)},t.prototype.unbind=function(t){this.onResize.remove(t),this.onUpdate.remove(t),this.onError.remove(t)},t.prototype.resize=function(t,e){t===this._width&&e===this._height||(this._width=t,this._height=e,this.onResize.emit(t,e))},Object.defineProperty(t.prototype,"valid",{get:function(){return!!this._width&&!!this._height},enumerable:!1,configurable:!0}),t.prototype.update=function(){this.destroyed||this.onUpdate.emit()},t.prototype.load=function(){return Promise.resolve(this)},Object.defineProperty(t.prototype,"width",{get:function(){return this._width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height},enumerable:!1,configurable:!0}),t.prototype.style=function(t,e,r){return!1},t.prototype.dispose=function(){},t.prototype.destroy=function(){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)},t.test=function(t,e){return!1},t}(),p=function(t){function e(e,r){var i=this,n=r||{},o=n.width,s=n.height;if(!o||!s)throw new Error("BufferResource width or height invalid");return(i=t.call(this,o,s)||this).data=e,i}return d(e,t),e.prototype.upload=function(t,e,r){var i=t.gl;return i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===n.ALPHA_MODES.UNPACK),r.width===e.width&&r.height===e.height?i.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.type,this.data):(r.width=e.width,r.height=e.height,i.texImage2D(e.target,0,r.internalFormat,e.width,e.height,0,e.format,r.type,this.data)),!0},e.prototype.dispose=function(){this.data=null},e.test=function(t){return t instanceof Float32Array||t instanceof Uint8Array||t instanceof Uint32Array},e}(f),m={scaleMode:n.SCALE_MODES.NEAREST,format:n.FORMATS.RGBA,alphaMode:n.ALPHA_MODES.NPM},y=function(t){function e(e,r){void 0===e&&(e=null),void 0===r&&(r=null);var s=t.call(this)||this,a=(r=r||{}).alphaMode,h=r.mipmap,u=r.anisotropicLevel,c=r.scaleMode,d=r.width,p=r.height,m=r.wrapMode,y=r.format,v=r.type,_=r.target,g=r.resolution,x=r.resourceOptions;return!e||e instanceof f||((e=l(e,x)).internal=!0),s.width=d||0,s.height=p||0,s.resolution=g||i.settings.RESOLUTION,s.mipmap=void 0!==h?h:i.settings.MIPMAP_TEXTURES,s.anisotropicLevel=void 0!==u?u:i.settings.ANISOTROPIC_LEVEL,s.wrapMode=m||i.settings.WRAP_MODE,s.scaleMode=void 0!==c?c:i.settings.SCALE_MODE,s.format=y||n.FORMATS.RGBA,s.type=v||n.TYPES.UNSIGNED_BYTE,s.target=_||n.TARGETS.TEXTURE_2D,s.alphaMode=void 0!==a?a:n.ALPHA_MODES.UNPACK,void 0!==r.premultiplyAlpha&&(s.premultiplyAlpha=r.premultiplyAlpha),s.uid=o.uid(),s.touched=0,s.isPowerOfTwo=!1,s._refreshPOT(),s._glTextures={},s.dirtyId=0,s.dirtyStyleId=0,s.cacheId=null,s.valid=d>0&&p>0,s.textureCacheIds=[],s.destroyed=!1,s.resource=null,s._batchEnabled=0,s._batchLocation=0,s.parentTextureArray=null,s.setResource(e),s}return d(e,t),Object.defineProperty(e.prototype,"realWidth",{get:function(){return Math.ceil(this.width*this.resolution-1e-4)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"realHeight",{get:function(){return Math.ceil(this.height*this.resolution-1e-4)},enumerable:!1,configurable:!0}),e.prototype.setStyle=function(t,e){var r;return void 0!==t&&t!==this.scaleMode&&(this.scaleMode=t,r=!0),void 0!==e&&e!==this.mipmap&&(this.mipmap=e,r=!0),r&&this.dirtyStyleId++,this},e.prototype.setSize=function(t,e,r){return this.resolution=r||this.resolution,this.width=t,this.height=e,this._refreshPOT(),this.update(),this},e.prototype.setRealSize=function(t,e,r){return this.resolution=r||this.resolution,this.width=t/this.resolution,this.height=e/this.resolution,this._refreshPOT(),this.update(),this},e.prototype._refreshPOT=function(){this.isPowerOfTwo=o.isPow2(this.realWidth)&&o.isPow2(this.realHeight)},e.prototype.setResolution=function(t){var e=this.resolution;return e===t||(this.resolution=t,this.valid&&(this.width=this.width*e/t,this.height=this.height*e/t,this.emit("update",this)),this._refreshPOT()),this},e.prototype.setResource=function(t){if(this.resource===t)return this;if(this.resource)throw new Error("Resource can be set only once");return t.bind(this),this.resource=t,this},e.prototype.update=function(){this.valid?(this.dirtyId++,this.dirtyStyleId++,this.emit("update",this)):this.width>0&&this.height>0&&(this.valid=!0,this.emit("loaded",this),this.emit("update",this))},e.prototype.onError=function(t){this.emit("error",this,t)},e.prototype.destroy=function(){this.resource&&(this.resource.unbind(this),this.resource.internal&&this.resource.destroy(),this.resource=null),this.cacheId&&(delete o.BaseTextureCache[this.cacheId],delete o.TextureCache[this.cacheId],this.cacheId=null),this.dispose(),e.removeFromCache(this),this.textureCacheIds=null,this.destroyed=!0},e.prototype.dispose=function(){this.emit("dispose",this)},e.prototype.castToBaseTexture=function(){return this},e.from=function(t,r,n){void 0===n&&(n=i.settings.STRICT_TEXTURE_CACHE);var s="string"==typeof t,a=null;s?a=t:(t._pixiId||(t._pixiId="pixiid_"+o.uid()),a=t._pixiId);var h=o.BaseTextureCache[a];if(s&&n&&!h)throw new Error('The cacheId "'+a+'" does not exist in BaseTextureCache.');return h||((h=new e(t,r)).cacheId=a,e.addToCache(h,a)),h},e.fromBuffer=function(t,r,i,o){t=t||new Float32Array(r*i*4);var s=new p(t,{width:r,height:i}),a=t instanceof Float32Array?n.TYPES.FLOAT:n.TYPES.UNSIGNED_BYTE;return new e(s,Object.assign(m,o||{width:r,height:i,type:a}))},e.addToCache=function(t,e){e&&(-1===t.textureCacheIds.indexOf(e)&&t.textureCacheIds.push(e),o.BaseTextureCache[e]&&console.warn("BaseTexture added to the cache with an id ["+e+"] that already had an entry"),o.BaseTextureCache[e]=t)},e.removeFromCache=function(t){if("string"==typeof t){var e=o.BaseTextureCache[t];if(e){var r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete o.BaseTextureCache[t],e}}else if(t&&t.textureCacheIds){for(var i=0;i<t.textureCacheIds.length;++i)delete o.BaseTextureCache[t.textureCacheIds[i]];return t.textureCacheIds.length=0,t}return null},e._globalBatch=0,e}(o.EventEmitter),v=function(t){function e(e,r){var i=this,n=r||{},o=n.width,s=n.height;(i=t.call(this,o,s)||this).items=[],i.itemDirtyIds=[];for(var a=0;a<e;a++){var h=new y;i.items.push(h),i.itemDirtyIds.push(-2)}return i.length=e,i._load=null,i.baseTexture=null,i}return d(e,t),e.prototype.initFromArray=function(t,e){for(var r=0;r<this.length;r++)t[r]&&(t[r].castToBaseTexture?this.addBaseTextureAt(t[r].castToBaseTexture(),r):t[r]instanceof f?this.addResourceAt(t[r],r):this.addResourceAt(l(t[r],e),r))},e.prototype.dispose=function(){for(var t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null},e.prototype.addResourceAt=function(t,e){if(!this.items[e])throw new Error("Index "+e+" is out of bounds");return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this},e.prototype.bind=function(e){if(null!==this.baseTexture)throw new Error("Only one base texture per TextureArray is allowed");t.prototype.bind.call(this,e);for(var r=0;r<this.length;r++)this.items[r].parentTextureArray=e,this.items[r].on("update",e.update,e)},e.prototype.unbind=function(e){t.prototype.unbind.call(this,e);for(var r=0;r<this.length;r++)this.items[r].parentTextureArray=null,this.items[r].off("update",e.update,e)},e.prototype.load=function(){var t=this;if(this._load)return this._load;var e=this.items.map((function(t){return t.resource})).filter((function(t){return t})).map((function(t){return t.load()}));return this._load=Promise.all(e).then((function(){var e=t.items[0],r=e.realWidth,i=e.realHeight;return t.resize(r,i),Promise.resolve(t)})),this._load},e}(f),_=function(t){function e(e,r){var i,n,o=this,s=r||{},a=s.width,h=s.height;return Array.isArray(e)?(i=e,n=e.length):n=e,o=t.call(this,n,{width:a,height:h})||this,i&&o.initFromArray(i,r),o}return d(e,t),e.prototype.addBaseTextureAt=function(t,e){if(!t.resource)throw new Error("ArrayResource does not support RenderTexture");return this.addResourceAt(t.resource,e),this},e.prototype.bind=function(e){t.prototype.bind.call(this,e),e.target=n.TARGETS.TEXTURE_2D_ARRAY},e.prototype.upload=function(t,e,r){var i=this,n=i.length,o=i.itemDirtyIds,s=i.items,a=t.gl;r.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,e.format,this._width,this._height,n,0,e.format,e.type,null);for(var h=0;h<n;h++){var u=s[h];o[h]<u.dirtyId&&(o[h]=u.dirtyId,u.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,u.resource.width,u.resource.height,1,e.format,e.type,u.resource.source))}return!0},e}(v),g=function(t){function e(e){var r=this,i=e,n=i.naturalWidth||i.videoWidth||i.width,o=i.naturalHeight||i.videoHeight||i.height;return(r=t.call(this,n,o)||this).source=e,r.noSubImage=!1,r}return d(e,t),e.crossOrigin=function(t,e,r){void 0===r&&0!==e.indexOf("data:")?t.crossOrigin=o.determineCrossOrigin(e):!1!==r&&(t.crossOrigin="string"==typeof r?r:"anonymous")},e.prototype.upload=function(t,e,r,i){var o=t.gl,s=e.realWidth,a=e.realHeight;return i=i||this.source,o.pixelStorei(o.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===n.ALPHA_MODES.UNPACK),this.noSubImage||e.target!==o.TEXTURE_2D||r.width!==s||r.height!==a?(r.width=s,r.height=a,o.texImage2D(e.target,0,e.format,e.format,e.type,i)):o.texSubImage2D(o.TEXTURE_2D,0,0,0,e.format,e.type,i),!0},e.prototype.update=function(){if(!this.destroyed){var e=this.source,r=e.naturalWidth||e.videoWidth||e.width,i=e.naturalHeight||e.videoHeight||e.height;this.resize(r,i),t.prototype.update.call(this)}},e.prototype.dispose=function(){this.source=null},e}(f),x=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return d(e,t),e.test=function(t){var e=window.OffscreenCanvas;return!!(e&&t instanceof e)||t instanceof HTMLCanvasElement},e}(g),b=function(t){function e(r,i){var o=this,s=i||{},a=s.width,h=s.height,u=s.autoLoad,l=s.linkBaseTexture;if(r&&r.length!==e.SIDES)throw new Error("Invalid length. Got "+r.length+", expected 6");o=t.call(this,6,{width:a,height:h})||this;for(var c=0;c<e.SIDES;c++)o.items[c].target=n.TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X+c;return o.linkBaseTexture=!1!==l,r&&o.initFromArray(r,i),!1!==u&&o.load(),o}return d(e,t),e.prototype.bind=function(e){t.prototype.bind.call(this,e),e.target=n.TARGETS.TEXTURE_CUBE_MAP},e.prototype.addBaseTextureAt=function(t,e,r){if(void 0===r&&(r=this.linkBaseTexture),!this.items[e])throw new Error("Index "+e+" is out of bounds");if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0){if(!t.resource)throw new Error("CubeResource does not support copying of renderTexture.");this.addResourceAt(t.resource,e)}else t.target=n.TARGETS.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this},e.prototype.upload=function(t,r,i){for(var n=this.itemDirtyIds,o=0;o<e.SIDES;o++){var s=this.items[o];n[o]<s.dirtyId&&(s.valid&&s.resource?(s.resource.upload(t,s,i),n[o]=s.dirtyId):n[o]<-1&&(t.gl.texImage2D(s.target,0,i.internalFormat,r.realWidth,r.realHeight,0,r.format,i.type,null),n[o]=-1))}return!0},e.test=function(t){return Array.isArray(t)&&t.length===e.SIDES},e.SIDES=6,e}(v),E=function(t){function e(e,r){var n=this;if(r=r||{},!(e instanceof HTMLImageElement)){var o=new Image;g.crossOrigin(o,e,r.crossorigin),o.src=e,e=o}return n=t.call(this,e)||this,!e.complete&&n._width&&n._height&&(n._width=0,n._height=0),n.url=e.src,n._process=null,n.preserveBitmap=!1,n.createBitmap=(void 0!==r.createBitmap?r.createBitmap:i.settings.CREATE_IMAGE_BITMAP)&&!!window.createImageBitmap,n.alphaMode="number"==typeof r.alphaMode?r.alphaMode:null,void 0!==r.premultiplyAlpha&&(n.premultiplyAlpha=r.premultiplyAlpha),n.bitmap=null,n._load=null,!1!==r.autoLoad&&n.load(),n}return d(e,t),e.prototype.load=function(t){var e=this;return this._load||(void 0!==t&&(this.createBitmap=t),this._load=new Promise((function(t,r){var i=e.source;e.url=i.src;var n=function(){e.destroyed||(i.onload=null,i.onerror=null,e.resize(i.width,i.height),e._load=null,e.createBitmap?t(e.process()):t(e))};i.complete&&i.src?n():(i.onload=n,i.onerror=function(t){r(t),e.onError.emit(t)})}))),this._load},e.prototype.process=function(){var t=this,e=this.source;return null!==this._process?this._process:null===this.bitmap&&window.createImageBitmap?(this._process=window.createImageBitmap(e,0,0,e.width,e.height,{premultiplyAlpha:this.alphaMode===n.ALPHA_MODES.UNPACK?"premultiply":"none"}).then((function(e){return t.destroyed?Promise.reject():(t.bitmap=e,t.update(),t._process=null,Promise.resolve(t))})),this._process):Promise.resolve(this)},e.prototype.upload=function(e,r,i){if("number"==typeof this.alphaMode&&(r.alphaMode=this.alphaMode),!this.createBitmap)return t.prototype.upload.call(this,e,r,i);if(!this.bitmap&&(this.process(),!this.bitmap))return!1;if(t.prototype.upload.call(this,e,r,i,this.bitmap),!this.preserveBitmap){var n=!0,o=r._glTextures;for(var s in o){var a=o[s];if(a!==i&&a.dirtyId!==r.dirtyId){n=!1;break}}n&&(this.bitmap.close&&this.bitmap.close(),this.bitmap=null)}return!0},e.prototype.dispose=function(){this.source.onload=null,this.source.onerror=null,t.prototype.dispose.call(this),this.bitmap&&(this.bitmap.close(),this.bitmap=null),this._process=null,this._load=null},e.test=function(t){return"string"==typeof t||t instanceof HTMLImageElement},e}(g),T=function(t){function e(e,r){var i=this;return r=r||{},(i=t.call(this,document.createElement("canvas"))||this)._width=0,i._height=0,i.svg=e,i.scale=r.scale||1,i._overrideWidth=r.width,i._overrideHeight=r.height,i._resolve=null,i._crossorigin=r.crossorigin,i._load=null,!1!==r.autoLoad&&i.load(),i}return d(e,t),e.prototype.load=function(){var t=this;return this._load||(this._load=new Promise((function(e){if(t._resolve=function(){t.resize(t.source.width,t.source.height),e(t)},/^\<svg/.test(t.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");t.svg="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(t.svg)))}t._loadSvg()}))),this._load},e.prototype._loadSvg=function(){var t=this,e=new Image;g.crossOrigin(e,this.svg,this._crossorigin),e.src=this.svg,e.onerror=function(r){t._resolve&&(e.onerror=null,t.onError.emit(r))},e.onload=function(){if(t._resolve){var r=e.width,i=e.height;if(!r||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");var n=r*t.scale,s=i*t.scale;(t._overrideWidth||t._overrideHeight)&&(n=t._overrideWidth||t._overrideHeight/i*r,s=t._overrideHeight||t._overrideWidth/r*i),n=Math.round(n),s=Math.round(s);var a=t.source;a.width=n,a.height=s,a._pixiId="canvas_"+o.uid(),a.getContext("2d").drawImage(e,0,0,r,i,0,0,n,s),t._resolve(),t._resolve=null}}},e.getSize=function(t){var r=e.SVG_SIZE.exec(t),i={};return r&&(i[r[1]]=Math.round(parseFloat(r[3])),i[r[5]]=Math.round(parseFloat(r[7]))),i},e.prototype.dispose=function(){t.prototype.dispose.call(this),this._resolve=null,this._crossorigin=null},e.test=function(t,e){return"svg"===e||"string"==typeof t&&/^data:image\/svg\+xml(;(charset=utf8|utf8))?;base64/.test(t)||"string"==typeof t&&0===t.indexOf("<svg")},e.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i,e}(g),w=function(t){function e(r,i){var n=this;if(i=i||{},!(r instanceof HTMLVideoElement)){var o=document.createElement("video");o.setAttribute("preload","auto"),o.setAttribute("webkit-playsinline",""),o.setAttribute("playsinline",""),"string"==typeof r&&(r=[r]);var s=r[0].src||r[0];g.crossOrigin(o,s,i.crossorigin);for(var a=0;a<r.length;++a){var h=document.createElement("source"),u=r[a],l=u.src,c=u.mime,d=(l=l||r[a]).split("?").shift().toLowerCase(),f=d.substr(d.lastIndexOf(".")+1);c=c||e.MIME_TYPES[f]||"video/"+f,h.src=l,h.type=c,o.appendChild(h)}r=o}return(n=t.call(this,r)||this).noSubImage=!0,n._autoUpdate=!0,n._isConnectedToTicker=!1,n._updateFPS=i.updateFPS||0,n._msToNextUpdate=0,n.autoPlay=!1!==i.autoPlay,n._load=null,n._resolve=null,n._onCanPlay=n._onCanPlay.bind(n),n._onError=n._onError.bind(n),!1!==i.autoLoad&&n.load(),n}return d(e,t),e.prototype.update=function(e){if(void 0===e&&(e=0),!this.destroyed){var r=a.Ticker.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-r),(!this._updateFPS||this._msToNextUpdate<=0)&&(t.prototype.update.call(this),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}},e.prototype.load=function(){var t=this;if(this._load)return this._load;var e=this.source;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart.bind(this)),e.addEventListener("pause",this._onPlayStop.bind(this)),this._isSourceReady()?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._load=new Promise((function(r){t.valid?r(t):(t._resolve=r,e.load())})),this._load},e.prototype._onError=function(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t)},e.prototype._isSourcePlaying=function(){var t=this.source;return t.currentTime>0&&!1===t.paused&&!1===t.ended&&t.readyState>2},e.prototype._isSourceReady=function(){var t=this.source;return 3===t.readyState||4===t.readyState},e.prototype._onPlayStart=function(){this.valid||this._onCanPlay(),this.autoUpdate&&!this._isConnectedToTicker&&(a.Ticker.shared.add(this.update,this),this._isConnectedToTicker=!0)},e.prototype._onPlayStop=function(){this._isConnectedToTicker&&(a.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1)},e.prototype._onCanPlay=function(){var t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);var e=this.valid;this.resize(t.videoWidth,t.videoHeight),!e&&this._resolve&&(this._resolve(this),this._resolve=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()},e.prototype.dispose=function(){this._isConnectedToTicker&&a.Ticker.shared.remove(this.update,this);var e=this.source;e&&(e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),t.prototype.dispose.call(this)},Object.defineProperty(e.prototype,"autoUpdate",{get:function(){return this._autoUpdate},set:function(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(a.Ticker.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._isSourcePlaying()&&(a.Ticker.shared.add(this.update,this),this._isConnectedToTicker=!0))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"updateFPS",{get:function(){return this._updateFPS},set:function(t){t!==this._updateFPS&&(this._updateFPS=t)},enumerable:!1,configurable:!0}),e.test=function(t,r){return t instanceof HTMLVideoElement||e.TYPES.indexOf(r)>-1},e.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],e.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"},e}(g),S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return d(e,t),e.test=function(t){return!!window.createImageBitmap&&t instanceof ImageBitmap},e}(g);u.push(E,S,x,w,T,p,b,_);var O={Resource:f,BaseImageResource:g,INSTALLED:u,autoDetectResource:l,AbstractMultiResource:v,ArrayResource:_,BufferResource:p,CanvasResource:x,CubeResource:b,ImageResource:E,SVGResource:T,VideoResource:w,ImageBitmapResource:S},A=function(){function t(t){this.renderer=t}return t.prototype.destroy=function(){this.renderer=null},t}(),P=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return d(e,t),e.prototype.upload=function(t,e,r){var i=t.gl;return i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.alphaMode===n.ALPHA_MODES.UNPACK),r.width===e.width&&r.height===e.height?i.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.type,this.data):(r.width=e.width,r.height=e.height,i.texImage2D(e.target,0,1===t.context.webGLVersion?i.DEPTH_COMPONENT:i.DEPTH_COMPONENT16,e.width,e.height,0,e.format,e.type,this.data)),!0},e}(p),C=function(){function t(t,e){this.width=Math.ceil(t||100),this.height=Math.ceil(e||100),this.stencil=!1,this.depth=!1,this.dirtyId=0,this.dirtyFormat=0,this.dirtySize=0,this.depthTexture=null,this.colorTextures=[],this.glFramebuffers={},this.disposeRunner=new s.Runner("disposeFramebuffer"),this.multisample=n.MSAA_QUALITY.NONE}return Object.defineProperty(t.prototype,"colorTexture",{get:function(){return this.colorTextures[0]},enumerable:!1,configurable:!0}),t.prototype.addColorTexture=function(t,e){return void 0===t&&(t=0),this.colorTextures[t]=e||new y(null,{scaleMode:n.SCALE_MODES.NEAREST,resolution:1,mipmap:n.MIPMAP_MODES.OFF,width:this.width,height:this.height}),this.dirtyId++,this.dirtyFormat++,this},t.prototype.addDepthTexture=function(t){return this.depthTexture=t||new y(new P(null,{width:this.width,height:this.height}),{scaleMode:n.SCALE_MODES.NEAREST,resolution:1,width:this.width,height:this.height,mipmap:n.MIPMAP_MODES.OFF,format:n.FORMATS.DEPTH_COMPONENT,type:n.TYPES.UNSIGNED_SHORT}),this.dirtyId++,this.dirtyFormat++,this},t.prototype.enableDepth=function(){return this.depth=!0,this.dirtyId++,this.dirtyFormat++,this},t.prototype.enableStencil=function(){return this.stencil=!0,this.dirtyId++,this.dirtyFormat++,this},t.prototype.resize=function(t,e){if(t=Math.ceil(t),e=Math.ceil(e),t!==this.width||e!==this.height){this.width=t,this.height=e,this.dirtyId++,this.dirtySize++;for(var r=0;r<this.colorTextures.length;r++){var i=this.colorTextures[r],n=i.resolution;i.setSize(t/n,e/n)}if(this.depthTexture){n=this.depthTexture.resolution;this.depthTexture.setSize(t/n,e/n)}}},t.prototype.dispose=function(){this.disposeRunner.emit(this,!1)},t.prototype.destroyDepthTexture=function(){this.depthTexture&&(this.depthTexture.destroy(),this.depthTexture=null,++this.dirtyId,++this.dirtyFormat)},t}(),M=function(t){function e(e){var r=this;if("number"==typeof e){var i=arguments[0],n=arguments[1],o=arguments[2],s=arguments[3];e={width:i,height:n,scaleMode:o,resolution:s}}r=t.call(this,null,e)||this;var a=e||{},h=a.width,u=a.height;return r.mipmap=0,r.width=Math.ceil(h)||100,r.height=Math.ceil(u)||100,r.valid=!0,r.clearColor=[0,0,0,0],r.framebuffer=new C(r.width*r.resolution,r.height*r.resolution).addColorTexture(0,r),r.maskStack=[],r.filterStack=[{}],r}return d(e,t),e.prototype.resize=function(t,e){t=Math.ceil(t),e=Math.ceil(e),this.framebuffer.resize(t*this.resolution,e*this.resolution)},e.prototype.dispose=function(){this.framebuffer.dispose(),t.prototype.dispose.call(this)},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.framebuffer.destroyDepthTexture(),this.framebuffer=null},e}(y),R=function(){function t(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}return t.prototype.set=function(t,e,r){var i=e.width,n=e.height;if(r){var o=t.width/2/i,s=t.height/2/n,a=t.x/i+o,u=t.y/n+s;r=h.groupD8.add(r,h.groupD8.NW),this.x0=a+o*h.groupD8.uX(r),this.y0=u+s*h.groupD8.uY(r),r=h.groupD8.add(r,2),this.x1=a+o*h.groupD8.uX(r),this.y1=u+s*h.groupD8.uY(r),r=h.groupD8.add(r,2),this.x2=a+o*h.groupD8.uX(r),this.y2=u+s*h.groupD8.uY(r),r=h.groupD8.add(r,2),this.x3=a+o*h.groupD8.uX(r),this.y3=u+s*h.groupD8.uY(r)}else this.x0=t.x/i,this.y0=t.y/n,this.x1=(t.x+t.width)/i,this.y1=t.y/n,this.x2=(t.x+t.width)/i,this.y2=(t.y+t.height)/n,this.x3=t.x/i,this.y3=(t.y+t.height)/n;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3},t}(),I=new R,D=function(t){function e(r,i,n,o,s,a){var u=t.call(this)||this;if(u.noFrame=!1,i||(u.noFrame=!0,i=new h.Rectangle(0,0,1,1)),r instanceof e&&(r=r.baseTexture),u.baseTexture=r,u._frame=i,u.trim=o,u.valid=!1,u._uvs=I,u.uvMatrix=null,u.orig=n||i,u._rotate=Number(s||0),!0===s)u._rotate=2;else if(u._rotate%2!=0)throw new Error("attempt to use diamond-shaped UVs. If you are sure, set rotation manually");return u.defaultAnchor=a?new h.Point(a.x,a.y):new h.Point(0,0),u._updateID=0,u.textureCacheIds=[],r.valid?u.noFrame?r.valid&&u.onBaseTextureUpdated(r):u.frame=i:r.once("loaded",u.onBaseTextureUpdated,u),u.noFrame&&r.on("update",u.onBaseTextureUpdated,u),u}return d(e,t),e.prototype.update=function(){this.baseTexture.resource&&this.baseTexture.resource.update()},e.prototype.onBaseTextureUpdated=function(t){if(this.noFrame){if(!this.baseTexture.valid)return;this._frame.width=t.width,this._frame.height=t.height,this.valid=!0,this.updateUvs()}else this.frame=this._frame;this.emit("update",this)},e.prototype.destroy=function(t){if(this.baseTexture){if(t){var r=this.baseTexture;r&&r.url&&o.TextureCache[r.url]&&e.removeFromCache(r.url),this.baseTexture.destroy()}this.baseTexture.off("loaded",this.onBaseTextureUpdated,this),this.baseTexture.off("update",this.onBaseTextureUpdated,this),this.baseTexture=null}this._frame=null,this._uvs=null,this.trim=null,this.orig=null,this.valid=!1,e.removeFromCache(this),this.textureCacheIds=null},e.prototype.clone=function(){return new e(this.baseTexture,this.frame.clone(),this.orig.clone(),this.trim&&this.trim.clone(),this.rotate,this.defaultAnchor)},e.prototype.updateUvs=function(){this._uvs===I&&(this._uvs=new R),this._uvs.set(this._frame,this.baseTexture,this.rotate),this._updateID++},e.from=function(t,r,n){void 0===r&&(r={}),void 0===n&&(n=i.settings.STRICT_TEXTURE_CACHE);var s="string"==typeof t,a=null;s?a=t:(t._pixiId||(t._pixiId="pixiid_"+o.uid()),a=t._pixiId);var h=o.TextureCache[a];if(s&&n&&!h)throw new Error('The cacheId "'+a+'" does not exist in TextureCache.');return h||(r.resolution||(r.resolution=o.getResolutionOfUrl(t)),(h=new e(new y(t,r))).baseTexture.cacheId=a,y.addToCache(h.baseTexture,a),e.addToCache(h,a)),h},e.fromURL=function(t,r){var i=Object.assign({autoLoad:!1},null==r?void 0:r.resourceOptions),n=e.from(t,Object.assign({resourceOptions:i},r),!1),o=n.baseTexture.resource;return n.baseTexture.valid?Promise.resolve(n):o.load().then((function(){return Promise.resolve(n)}))},e.fromBuffer=function(t,r,i,n){return new e(y.fromBuffer(t,r,i,n))},e.fromLoader=function(t,r,n){var s=new E(t);s.url=r;var a=new e(new y(s,{scaleMode:i.settings.SCALE_MODE,resolution:o.getResolutionOfUrl(r)}));return n||(n=r),y.addToCache(a.baseTexture,n),e.addToCache(a,n),n!==r&&(y.addToCache(a.baseTexture,r),e.addToCache(a,r)),a},e.addToCache=function(t,e){e&&(-1===t.textureCacheIds.indexOf(e)&&t.textureCacheIds.push(e),o.TextureCache[e]&&console.warn("Texture added to the cache with an id ["+e+"] that already had an entry"),o.TextureCache[e]=t)},e.removeFromCache=function(t){if("string"==typeof t){var e=o.TextureCache[t];if(e){var r=e.textureCacheIds.indexOf(t);return r>-1&&e.textureCacheIds.splice(r,1),delete o.TextureCache[t],e}}else if(t&&t.textureCacheIds){for(var i=0;i<t.textureCacheIds.length;++i)o.TextureCache[t.textureCacheIds[i]]===t&&delete o.TextureCache[t.textureCacheIds[i]];return t.textureCacheIds.length=0,t}return null},Object.defineProperty(e.prototype,"resolution",{get:function(){return this.baseTexture.resolution},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frame",{get:function(){return this._frame},set:function(t){this._frame=t,this.noFrame=!1;var e=t.x,r=t.y,i=t.width,n=t.height,o=e+i>this.baseTexture.width,s=r+n>this.baseTexture.height;if(o||s){var a=o&&s?"and":"or",h="X: "+e+" + "+i+" = "+(e+i)+" > "+this.baseTexture.width,u="Y: "+r+" + "+n+" = "+(r+n)+" > "+this.baseTexture.height;throw new Error("Texture Error: frame does not fit inside the base Texture dimensions: "+h+" "+a+" "+u)}this.valid=i&&n&&this.baseTexture.valid,this.trim||this.rotate||(this.orig=t),this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotate",{get:function(){return this._rotate},set:function(t){this._rotate=t,this.valid&&this.updateUvs()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this.orig.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this.orig.height},enumerable:!1,configurable:!0}),e.prototype.castToBaseTexture=function(){return this.baseTexture},e}(o.EventEmitter);function L(t){t.destroy=function(){},t.on=function(){},t.once=function(){},t.emit=function(){}}D.EMPTY=new D(new y),L(D.EMPTY),L(D.EMPTY.baseTexture),D.WHITE=function(){var t=document.createElement("canvas");t.width=16,t.height=16;var e=t.getContext("2d");return e.fillStyle="white",e.fillRect(0,0,16,16),new D(new y(new x(t)))}(),L(D.WHITE),L(D.WHITE.baseTexture);var N=function(t){function e(e,r){var i=this,n=null;if(!(e instanceof M)){var o=arguments[1],s=arguments[2],a=arguments[3],h=arguments[4];console.warn("Please use RenderTexture.create("+o+", "+s+") instead of the ctor directly."),n=arguments[0],r=null,e=new M({width:o,height:s,scaleMode:a,resolution:h})}return(i=t.call(this,e,r)||this).legacyRenderer=n,i.valid=!0,i.filterFrame=null,i.filterPoolKey=null,i.updateUvs(),i}return d(e,t),Object.defineProperty(e.prototype,"framebuffer",{get:function(){return this.baseTexture.framebuffer},enumerable:!1,configurable:!0}),e.prototype.resize=function(t,e,r){void 0===r&&(r=!0),t=Math.ceil(t),e=Math.ceil(e),this.valid=t>0&&e>0,this._frame.width=this.orig.width=t,this._frame.height=this.orig.height=e,r&&this.baseTexture.resize(t,e),this.updateUvs()},e.prototype.setResolution=function(t){var e=this.baseTexture;e.resolution!==t&&(e.setResolution(t),this.resize(e.width,e.height,!1))},e.create=function(t){return"number"==typeof t&&(t={width:t,height:arguments[1],scaleMode:arguments[2],resolution:arguments[3]}),new e(new M(t))},e}(D),F=function(){function t(t){this.texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this._pixelsWidth=0,this._pixelsHeight=0}return t.prototype.createTexture=function(t,e){var r=new M(Object.assign({width:t,height:e,resolution:1},this.textureOptions));return new N(r)},t.prototype.getOptimalTexture=function(e,r,i){void 0===i&&(i=1);var n=t.SCREEN_KEY;e*=i,r*=i,this.enableFullScreen&&e===this._pixelsWidth&&r===this._pixelsHeight||(n=(65535&(e=o.nextPow2(e)))<<16|65535&(r=o.nextPow2(r))),this.texturePool[n]||(this.texturePool[n]=[]);var s=this.texturePool[n].pop();return s||(s=this.createTexture(e,r)),s.filterPoolKey=n,s.setResolution(i),s},t.prototype.getFilterTexture=function(t,e){var r=this.getOptimalTexture(t.width,t.height,e||t.resolution);return r.filterFrame=t.filterFrame,r},t.prototype.returnTexture=function(t){var e=t.filterPoolKey;t.filterFrame=null,this.texturePool[e].push(t)},t.prototype.returnFilterTexture=function(t){this.returnTexture(t)},t.prototype.clear=function(t){if(t=!1!==t)for(var e in this.texturePool){var r=this.texturePool[e];if(r)for(var i=0;i<r.length;i++)r[i].destroy(!0)}this.texturePool={}},t.prototype.setScreenSize=function(e){if(e.width!==this._pixelsWidth||e.height!==this._pixelsHeight){var r=t.SCREEN_KEY,i=this.texturePool[r];if(this.enableFullScreen=e.width>0&&e.height>0,i)for(var n=0;n<i.length;n++)i[n].destroy(!0);this.texturePool[r]=[],this._pixelsWidth=e.width,this._pixelsHeight=e.height}},t.SCREEN_KEY="screen",t}(),U=function(){function t(t,e,r,i,n,o,s){void 0===e&&(e=0),void 0===r&&(r=!1),void 0===i&&(i=5126),this.buffer=t,this.size=e,this.normalized=r,this.type=i,this.stride=n,this.start=o,this.instance=s}return t.prototype.destroy=function(){this.buffer=null},t.from=function(e,r,i,n,o){return new t(e,r,i,n,o)},t}(),B=0,k=function(){function t(t,e,r){void 0===e&&(e=!0),void 0===r&&(r=!1),this.data=t||new Float32Array(1),this._glBuffers={},this._updateID=0,this.index=r,this.static=e,this.id=B++,this.disposeRunner=new s.Runner("disposeBuffer")}return t.prototype.update=function(t){this.data=t||this.data,this._updateID++},t.prototype.dispose=function(){this.disposeRunner.emit(this,!1)},t.prototype.destroy=function(){this.dispose(),this.data=null},t.from=function(e){return e instanceof Array&&(e=new Float32Array(e)),new t(e)},t}();function j(t){if(4===t.BYTES_PER_ELEMENT)return t instanceof Float32Array?"Float32Array":t instanceof Uint32Array?"Uint32Array":"Int32Array";if(2===t.BYTES_PER_ELEMENT){if(t instanceof Uint16Array)return"Uint16Array"}else if(1===t.BYTES_PER_ELEMENT&&t instanceof Uint8Array)return"Uint8Array";return null}var G={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array};var X={5126:4,5123:2,5121:1},z=0,Y={Float32Array:Float32Array,Uint32Array:Uint32Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array},H=function(){function t(t,e){void 0===t&&(t=[]),void 0===e&&(e={}),this.buffers=t,this.indexBuffer=null,this.attributes=e,this.glVertexArrayObjects={},this.id=z++,this.instanced=!1,this.instanceCount=1,this.disposeRunner=new s.Runner("disposeGeometry"),this.refCount=0}return t.prototype.addAttribute=function(t,e,r,i,n,o,s,a){if(void 0===r&&(r=0),void 0===i&&(i=!1),void 0===a&&(a=!1),!e)throw new Error("You must pass a buffer when creating an attribute");e instanceof k||(e instanceof Array&&(e=new Float32Array(e)),e=new k(e));var h=t.split("|");if(h.length>1){for(var u=0;u<h.length;u++)this.addAttribute(h[u],e,r,i,n);return this}var l=this.buffers.indexOf(e);return-1===l&&(this.buffers.push(e),l=this.buffers.length-1),this.attributes[t]=new U(l,r,i,n,o,s,a),this.instanced=this.instanced||a,this},t.prototype.getAttribute=function(t){return this.attributes[t]},t.prototype.getBuffer=function(t){return this.buffers[this.getAttribute(t).buffer]},t.prototype.addIndex=function(t){return t instanceof k||(t instanceof Array&&(t=new Uint16Array(t)),t=new k(t)),t.index=!0,this.indexBuffer=t,-1===this.buffers.indexOf(t)&&this.buffers.push(t),this},t.prototype.getIndex=function(){return this.indexBuffer},t.prototype.interleave=function(){if(1===this.buffers.length||2===this.buffers.length&&this.indexBuffer)return this;var t,e=[],r=[],i=new k;for(t in this.attributes){var n=this.attributes[t],o=this.buffers[n.buffer];e.push(o.data),r.push(n.size*X[n.type]/4),n.buffer=0}for(i.data=function(t,e){for(var r=0,i=0,n={},o=0;o<t.length;o++)i+=e[o],r+=t[o].length;var s=new ArrayBuffer(4*r),a=null,h=0;for(o=0;o<t.length;o++){var u=e[o],l=t[o],c=j(l);n[c]||(n[c]=new G[c](s)),a=n[c];for(var d=0;d<l.length;d++)a[(d/u|0)*i+h+d%u]=l[d];h+=u}return new Float32Array(s)}(e,r),t=0;t<this.buffers.length;t++)this.buffers[t]!==this.indexBuffer&&this.buffers[t].destroy();return this.buffers=[i],this.indexBuffer&&this.buffers.push(this.indexBuffer),this},t.prototype.getSize=function(){for(var t in this.attributes){var e=this.attributes[t];return this.buffers[e.buffer].data.length/(e.stride/4||e.size)}return 0},t.prototype.dispose=function(){this.disposeRunner.emit(this,!1)},t.prototype.destroy=function(){this.dispose(),this.buffers=null,this.indexBuffer=null,this.attributes=null},t.prototype.clone=function(){for(var e=new t,r=0;r<this.buffers.length;r++)e.buffers[r]=new k(this.buffers[r].data.slice(0));for(var r in this.attributes){var i=this.attributes[r];e.attributes[r]=new U(i.buffer,i.size,i.normalized,i.type,i.stride,i.start,i.instance)}return this.indexBuffer&&(e.indexBuffer=e.buffers[this.buffers.indexOf(this.indexBuffer)],e.indexBuffer.index=!0),e},t.merge=function(e){for(var r,i=new t,n=[],o=[],s=[],a=0;a<e.length;a++){r=e[a];for(var h=0;h<r.buffers.length;h++)o[h]=o[h]||0,o[h]+=r.buffers[h].data.length,s[h]=0}for(a=0;a<r.buffers.length;a++)n[a]=new(Y[j(r.buffers[a].data)])(o[a]),i.buffers[a]=new k(n[a]);for(a=0;a<e.length;a++){r=e[a];for(h=0;h<r.buffers.length;h++)n[h].set(r.buffers[h].data,s[h]),s[h]+=r.buffers[h].data.length}if(i.attributes=r.attributes,r.indexBuffer){i.indexBuffer=i.buffers[r.buffers.indexOf(r.indexBuffer)],i.indexBuffer.index=!0;var u=0,l=0,c=0,d=0;for(a=0;a<r.buffers.length;a++)if(r.buffers[a]!==r.indexBuffer){d=a;break}for(var a in r.attributes){var f=r.attributes[a];(0|f.buffer)===d&&(l+=f.size*X[f.type]/4)}for(a=0;a<e.length;a++){var p=e[a].indexBuffer.data;for(h=0;h<p.length;h++)i.indexBuffer.data[h+c]+=u;u+=r.buffers[d].data.length/l,c+=p.length}}return i},t}(),V=function(t){function e(){var e=t.call(this)||this;return e.addAttribute("aVertexPosition",new Float32Array([0,0,1,0,1,1,0,1])).addIndex([0,1,3,2]),e}return d(e,t),e}(H),W=function(t){function e(){var e=t.call(this)||this;return e.vertices=new Float32Array([-1,-1,1,-1,1,1,-1,1]),e.uvs=new Float32Array([0,0,1,0,1,1,0,1]),e.vertexBuffer=new k(e.vertices),e.uvBuffer=new k(e.uvs),e.addAttribute("aVertexPosition",e.vertexBuffer).addAttribute("aTextureCoord",e.uvBuffer).addIndex([0,1,2,0,2,3]),e}return d(e,t),e.prototype.map=function(t,e){var r=0,i=0;return this.uvs[0]=r,this.uvs[1]=i,this.uvs[2]=r+e.width/t.width,this.uvs[3]=i,this.uvs[4]=r+e.width/t.width,this.uvs[5]=i+e.height/t.height,this.uvs[6]=r,this.uvs[7]=i+e.height/t.height,r=e.x,i=e.y,this.vertices[0]=r,this.vertices[1]=i,this.vertices[2]=r+e.width,this.vertices[3]=i,this.vertices[4]=r+e.width,this.vertices[5]=i+e.height,this.vertices[6]=r,this.vertices[7]=i+e.height,this.invalidate(),this},e.prototype.invalidate=function(){return this.vertexBuffer._updateID++,this.uvBuffer._updateID++,this},e}(H),q=0,Z=function(){function t(t,e){this.uniforms=t,this.group=!0,this.syncUniforms={},this.dirtyId=0,this.id=q++,this.static=!!e}return t.prototype.update=function(){this.dirtyId++},t.prototype.add=function(e,r,i){this.uniforms[e]=new t(r,i)},t.from=function(e,r){return new t(e,r)},t}(),K=function(){function t(){this.renderTexture=null,this.target=null,this.legacy=!1,this.resolution=1,this.sourceFrame=new h.Rectangle,this.destinationFrame=new h.Rectangle,this.filters=[]}return t.prototype.clear=function(){this.target=null,this.filters=null,this.renderTexture=null},t}(),J=function(t){function e(e){var r=t.call(this,e)||this;return r.defaultFilterStack=[{}],r.texturePool=new F,r.texturePool.setScreenSize(e.view),r.statePool=[],r.quad=new V,r.quadUv=new W,r.tempRect=new h.Rectangle,r.activeState={},r.globalUniforms=new Z({outputFrame:r.tempRect,inputSize:new Float32Array(4),inputPixel:new Float32Array(4),inputClamp:new Float32Array(4),resolution:1,filterArea:new Float32Array(4),filterClamp:new Float32Array(4)},!0),r.forceClear=!1,r.useMaxPadding=!1,r}return d(e,t),e.prototype.push=function(t,e){for(var r=this.renderer,i=this.defaultFilterStack,n=this.statePool.pop()||new K,o=e[0].resolution,s=e[0].padding,a=e[0].autoFit,h=e[0].legacy,u=1;u<e.length;u++){var l=e[u];o=Math.min(o,l.resolution),s=this.useMaxPadding?Math.max(s,l.padding):s+l.padding,a=a&&l.autoFit,h=h||l.legacy}1===i.length&&(this.defaultFilterStack[0].renderTexture=r.renderTexture.current),i.push(n),n.resolution=o,n.legacy=h,n.target=t,n.sourceFrame.copyFrom(t.filterArea||t.getBounds(!0)),n.sourceFrame.pad(s),a&&n.sourceFrame.fit(this.renderer.renderTexture.sourceFrame),n.sourceFrame.ceil(o),n.renderTexture=this.getOptimalFilterTexture(n.sourceFrame.width,n.sourceFrame.height,o),n.filters=e,n.destinationFrame.width=n.renderTexture.width,n.destinationFrame.height=n.renderTexture.height;var c=this.tempRect;c.width=n.sourceFrame.width,c.height=n.sourceFrame.height,n.renderTexture.filterFrame=n.sourceFrame,r.renderTexture.bind(n.renderTexture,n.sourceFrame,c),r.renderTexture.clear()},e.prototype.pop=function(){var t=this.defaultFilterStack,e=t.pop(),r=e.filters;this.activeState=e;var i=this.globalUniforms.uniforms;i.outputFrame=e.sourceFrame,i.resolution=e.resolution;var o=i.inputSize,s=i.inputPixel,a=i.inputClamp;if(o[0]=e.destinationFrame.width,o[1]=e.destinationFrame.height,o[2]=1/o[0],o[3]=1/o[1],s[0]=o[0]*e.resolution,s[1]=o[1]*e.resolution,s[2]=1/s[0],s[3]=1/s[1],a[0]=.5*s[2],a[1]=.5*s[3],a[2]=e.sourceFrame.width*o[2]-.5*s[2],a[3]=e.sourceFrame.height*o[3]-.5*s[3],e.legacy){var h=i.filterArea;h[0]=e.destinationFrame.width,h[1]=e.destinationFrame.height,h[2]=e.sourceFrame.x,h[3]=e.sourceFrame.y,i.filterClamp=i.inputClamp}this.globalUniforms.update();var u=t[t.length-1];if(e.renderTexture.framebuffer.multisample>1&&this.renderer.framebuffer.blit(),1===r.length)r[0].apply(this,e.renderTexture,u.renderTexture,n.CLEAR_MODES.BLEND,e),this.returnFilterTexture(e.renderTexture);else{var l=e.renderTexture,c=this.getOptimalFilterTexture(l.width,l.height,e.resolution);c.filterFrame=l.filterFrame;var d=0;for(d=0;d<r.length-1;++d){r[d].apply(this,l,c,n.CLEAR_MODES.CLEAR,e);var f=l;l=c,c=f}r[d].apply(this,l,u.renderTexture,n.CLEAR_MODES.BLEND,e),this.returnFilterTexture(l),this.returnFilterTexture(c)}e.clear(),this.statePool.push(e)},e.prototype.bindAndClear=function(t,e){if(void 0===e&&(e=n.CLEAR_MODES.CLEAR),t&&t.filterFrame){var r=this.tempRect;r.width=t.filterFrame.width,r.height=t.filterFrame.height,this.renderer.renderTexture.bind(t,t.filterFrame,r)}else this.renderer.renderTexture.bind(t);"boolean"==typeof e&&(e=e?n.CLEAR_MODES.CLEAR:n.CLEAR_MODES.BLEND,o.deprecation("5.2.1","Use CLEAR_MODES when using clear applyFilter option")),(e===n.CLEAR_MODES